Compare commits

..

11 Commits

303 changed files with 9017 additions and 9047 deletions

View File

@ -766,11 +766,18 @@ 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());
@ -778,7 +785,8 @@ namespace DocFormatUtils
static inline std::string DoubleToString(double value)
{
std::stringstream src;
std::stringstream src;
src << value;
return std::string(src.str());
@ -805,16 +813,36 @@ 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();

View File

@ -72,8 +72,6 @@ namespace DocFileFormat
_isSectionPageBreak = 0;
_isTextBoxContent = false;
_embeddedObject = false;
_cacheListNum = -1;
}
DocumentMapping::~DocumentMapping()
@ -83,8 +81,12 @@ 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
@ -103,22 +105,6 @@ namespace DocFileFormat
return m_document->SectionPlex->CharacterPositions[current + 1];
}
int DocumentMapping::getListNumCache(int fc, int fc_end)
{
if ( !m_document->ListPlex ) return -1;
for (int i = 1; i < m_document->ListPlex->CharacterPositions.size(); i++)
{
if ((fc >= m_document->ListPlex->CharacterPositions[i-1]) && (fc_end <= m_document->ListPlex->CharacterPositions[i]))
{
ListNumCache* listNum = dynamic_cast<ListNumCache*> (m_document->ListPlex->Elements[i-1]);
return listNum->value;
}
}
return -1;
}
bool DocumentMapping::isSectionEnd(int cp)
{
bool result = false;
@ -194,8 +180,8 @@ namespace DocFileFormat
// get all CHPX between these boundaries to determine the count of runs
std::list<CharacterPropertyExceptions*>* chpxs = m_document->GetCharacterPropertyExceptions(fc, fcEnd);
std::vector<int>* chpxFcs = m_document->GetFileCharacterPositions(fc, fcEnd);
std::list<CharacterPropertyExceptions*>* chpxs = m_document->GetCharacterPropertyExceptions(fc, fcEnd);
std::vector<int>* chpxFcs = m_document->GetFileCharacterPositions(fc, fcEnd);
CharacterPropertyExceptions* paraEndChpx = NULL;
@ -212,7 +198,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
@ -222,8 +208,8 @@ namespace DocFileFormat
{
isBidi = currentSection->isBidi;
}
//-----------------------------------------------------------
//_cacheListNum = getListNumCache(fc, fcEnd);
_isSectionPageBreak = 0;
if (sectionEnd)
{
@ -353,7 +339,7 @@ namespace DocFileFormat
}
}
m_pXmlWriter->WriteNodeEnd(_T(""), true, false);
m_pXmlWriter->WriteNodeEnd(_T(""), TRUE, FALSE);
}
// Writes a run with the given characters and CHPX
@ -370,23 +356,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)
@ -410,7 +396,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);
@ -578,9 +564,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 );
@ -603,9 +589,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 );
@ -622,9 +608,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++;
@ -652,9 +638,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;
@ -685,38 +671,31 @@ namespace DocFileFormat
chpxObj->Convert(rPr);
RELEASEOBJECT(rPr);
}
XMLTools::CStringXmlWriter oleWriter;
XMLTools::CStringXmlWriter oleObjectWriter;
VMLPictureMapping oVmlMapper (m_context, &oleWriter, true, _caller);
if (!m_shapeIdOwner.empty()) //4571833.doc
oVmlMapper.m_shapeId = m_shapeIdOwner;
XMLTools::CStringXmlWriter OleWriter;
VMLPictureMapping oVmlMapper (m_context, &OleWriter, true, _caller);
if (m_document->bOlderVersion)
{
OleObject ole ( chpxObj, m_document->GetStorage(), m_document->bOlderVersion);
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.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 );
ole.pictureDesciptor.Convert(&oVmlMapper);
OleObjectMapping oleObjectMapping( &oleObjectWriter, m_context, &ole.pictureDesciptor, _caller, oVmlMapper.m_shapeId);
OleObjectMapping oleObjectMapping( &OleWriter, m_context, &ole.pictureDesciptor, _caller, oVmlMapper.GetShapeId() );
ole.Convert( &oleObjectMapping );
_lastOLEObject = oleObjectWriter.GetXmlString();
}
else
{
PictureDescriptor pic(chpxObj, m_document->DataStream, 0x7fffffff, m_document->bOlderVersion);
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.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 );
pic.Convert(&oVmlMapper);
RELEASEOBJECT(chpxs);
@ -730,7 +709,7 @@ namespace DocFileFormat
CharacterPropertyExceptions* chpxSep = chpxs->front();
OleObject ole ( chpxSep, m_document->GetStorage(), m_document->bOlderVersion);
OleObjectMapping oleObjectMapping( &oleObjectWriter, m_context, &pic, _caller, oVmlMapper.m_shapeId );
OleObjectMapping oleObjectMapping( &OleWriter, m_context, &pic, _caller, oVmlMapper.GetShapeId() );
if (oVmlMapper.m_isEmbedded)
{
@ -739,14 +718,11 @@ namespace DocFileFormat
ole.emeddedData = oVmlMapper.m_embeddedData;
}
ole.Convert( &oleObjectMapping );
_lastOLEObject = oleObjectWriter.GetXmlString();
RELEASEOBJECT( chpxs );
}
}
oleWriter.WriteString( _lastOLEObject );
oleWriter.WriteNodeEnd( _T( "w:object" ) );
OleWriter.WriteNodeEnd( _T( "w:object" ) );
if (!oVmlMapper.m_isEmbedded && oVmlMapper.m_isEquation)
{
@ -756,7 +732,7 @@ namespace DocFileFormat
}
else
{
m_pXmlWriter->WriteString(oleWriter.GetXmlString());
m_pXmlWriter->WriteString(OleWriter.GetXmlString());
}
}
@ -765,9 +741,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++;
@ -811,10 +787,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)
{
@ -831,23 +807,20 @@ namespace DocFileFormat
if (pSpa)
{
PictureDescriptor pictDiscr(chpx, m_document->WordDocumentStream, 0x7fffffff, m_document->bOlderVersion);
ShapeContainer* pShape = m_document->GetOfficeArt()->GetShapeContainer(pSpa->GetShapeID());
if (pShape)
{
VMLShapeMapping oVmlWriter (m_context, m_pXmlWriter, pSpa, &pictDiscr, _caller);
m_pXmlWriter->WriteNodeBegin (L"w:pict");
m_pXmlWriter->WriteNodeBegin (_T("w:pict"));
VMLShapeMapping oVmlWriter (m_context, m_pXmlWriter, pSpa, NULL, _caller);
pShape->Convert(&oVmlWriter);
m_pXmlWriter->WriteNodeEnd (L"w:pict");
m_pXmlWriter->WriteNodeEnd (_T("w:pict"));
}
if (!pSpa->primitives.empty())
{
m_pXmlWriter->WriteNodeBegin (_T("w:pict"));
VMLShapeMapping oVmlWriter (m_context, m_pXmlWriter, pSpa, &pictDiscr, _caller);
VMLShapeMapping oVmlWriter (m_context, m_pXmlWriter, pSpa, NULL, _caller);
pSpa->primitives.Convert(&oVmlWriter);
m_pXmlWriter->WriteNodeEnd (_T("w:pict"));
}
@ -892,7 +865,7 @@ namespace DocFileFormat
if (oVmlMapper.m_isEmbedded)
{
OleObject ole ( chpx, m_document->GetStorage(), m_document->bOlderVersion);
OleObjectMapping oleObjectMapping( &pictWriter, m_context, &oPicture, _caller, oVmlMapper.m_shapeId );
OleObjectMapping oleObjectMapping( &pictWriter, m_context, &oPicture, _caller, oVmlMapper.GetShapeId() );
ole.isEquation = oVmlMapper.m_isEquation;
ole.isEmbedded = oVmlMapper.m_isEmbedded;
@ -924,40 +897,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++;
@ -1003,12 +976,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)

View File

@ -70,70 +70,68 @@ namespace DocFileFormat
public:
DocumentMapping(ConversionContext* context, IMapping* caller);
DocumentMapping(ConversionContext* context, XMLTools::CStringXmlWriter* writer, IMapping* caller);
virtual ~DocumentMapping();
virtual void Apply( IVisitable* visited ) = 0;
//--------------------------------- 4571833.doc
std::wstring m_shapeIdOwner;
std::wstring getOLEObject() { return _lastOLEObject; }
protected:
int getListNumCache (int fc, int fc_end);
int getCurrentSection (int cp);
//---------------------------------
bool isSectionEnd ( int cp );
// Writes a Paragraph that starts at the given cp and
// ends at the next paragraph end mark or section end mark
/// Looks into the section table to find out if this CP is the current of a section
int getCurrentSection(int cp);
/// Looks into the section table to find out if this CP is the end of a section
bool isSectionEnd( int cp );
/// Writes a Paragraph that starts at the given cp and
/// ends at the next paragraph end mark or section end mark
int writeParagraph( int cp );
// Writes a Paragraph that starts at the given cpStart and
// ends at the given cpEnd
/// Writes a Paragraph that starts at the given cpStart and
/// ends at the given cpEnd
int writeParagraph( int initialCp, int cpEnd, bool sectionEnd, bool lastBad = false );
// Writes a Paragraph RSID
/// Writes a Paragraph RSID
void writeParagraphRsid( const ParagraphPropertyExceptions* papx );
// Writes a run with the given characters and CHPX
/// Writes a run with the given characters and CHPX
int writeRun( std::vector<wchar_t>* chars, CharacterPropertyExceptions* chpx, int initialCp );
// Writes the given text to the document
int writeText ( std::vector<wchar_t>* chars, int initialCp, CharacterPropertyExceptions* chpx, bool writeDeletedText );
void writeTextElement ( const std::wstring& text, const std::wstring& textType );
void writeTextStart ( const std::wstring& textType, bool preserve_space);
void writeTextEnd ( const std::wstring& textType );
/// Writes the given text to the document
// Searches for bookmarks in the list of characters.
int writeText( std::vector<wchar_t>* chars, int initialCp, CharacterPropertyExceptions* chpx, bool writeDeletedText );
void writeTextElement( const std::wstring& text, const std::wstring& textType );
void writeTextStart( const std::wstring& textType, bool preserve_space);
void writeTextEnd( const std::wstring& textType );
/// Searches for bookmarks in the list of characters.
std::vector<int> searchBookmarks( std::vector<wchar_t>* chars, int initialCp );
ParagraphPropertyExceptions* findValidPapx( int fc );
// Splits a list of characters into several lists
/// Splits a list of characters into several lists
std::list<std::vector<wchar_t> >* splitCharList( std::vector<wchar_t>* chars, std::vector<int>* splitIndices );
// Writes the table starts at the given cp value
int writeTable ( int initialCp, unsigned int nestingLevel );
// Builds a list that contains the width of the several columns of the table.
/// Writes the table starts at the given cp value
int writeTable( int initialCp, unsigned int nestingLevel );
/// Builds a list that contains the width of the several columns of the table.
std::vector<short>* buildTableGrid( int initialCp, unsigned int nestingLevel );
// Finds the FC of the next row end mark.
int findRowEndFc ( int initialCp, int& rowEndCp, unsigned int nestingLevel );
// Finds the FC of the next row end mark.
int findRowEndFc ( int initialCp, unsigned int nestingLevel );
// Writes the table row that starts at the given cp value and ends at the next row end mark
int writeTableRow ( int initialCp, std::vector<short>* grid, unsigned int nestingLevel );
// Writes the table cell that starts at the given cp value and ends at the next cell end mark
int writeTableCell ( int initialCp, TablePropertyExceptions* tapx, std::vector<short>* grid, int& gridIndex, int cellIndex, unsigned int nestingLevel );
int findCellEndCp ( int initialCp, unsigned int nestingLevel );
bool writeBookmarks ( int cp );
bool writeBookmarkStart ( short id );
bool writeBookmarkEnd ( short id );
// Checks if the CHPX is special
/// Finds the FC of the next row end mark.
int findRowEndFc( int initialCp, int& rowEndCp, unsigned int nestingLevel );
/// Finds the FC of the next row end mark.
int findRowEndFc( int initialCp, unsigned int nestingLevel );
/// Writes the table row that starts at the given cp value and ends at the next row end mark
int writeTableRow( int initialCp, std::vector<short>* grid, unsigned int nestingLevel );
/// Writes the table cell that starts at the given cp value and ends at the next cell end mark
int writeTableCell( int initialCp, TablePropertyExceptions* tapx, std::vector<short>* grid, int& gridIndex, int cellIndex, unsigned int nestingLevel );
int findCellEndCp( int initialCp, unsigned int nestingLevel );
bool writeBookmarks( int cp );
bool writeBookmarkStart( short id );
bool writeBookmarkEnd( short id );
/// Checks if the CHPX is special
bool isSpecial( CharacterPropertyExceptions* chpx );
// Finds the SEPX that is valid for the given CP.
/// Finds the SEPX that is valid for the given CP.
SectionPropertyExceptions* findValidSepx( int cp );
// Searches the given vector for the next FieldEnd character.
/// Searches the given vector for the next FieldEnd character.
int searchNextTextMark( std::vector<wchar_t>* chars, int initialCp, wchar_t mark );
Symbol getSymbol ( const CharacterPropertyExceptions* chpx );
//----------------------------------------------------------------------------------------------------------------------
private:
Symbol getSymbol( const CharacterPropertyExceptions* chpx );
bool m_bInternalXmlWriter;
protected:
WordDocument* m_document;
ConversionContext* m_context;
IMapping* _caller;
ParagraphPropertyExceptions* _lastValidPapx;
@ -151,7 +149,5 @@ namespace DocFileFormat
bool _writeWebHidden;
unsigned int _fldCharCounter;
std::wstring _writeAfterRun;
std::wstring _lastOLEObject;
int _cacheListNum;
};
}

View File

@ -43,8 +43,7 @@ namespace DocFileFormat
/*========================================================================================================*/
WordDocumentProperties::WordDocumentProperties(FileInformationBlock* fib, POLE::Stream* tableStream) :
doptypography(NULL), dogrid(NULL), asumyi(NULL), bDisplayBackgroundShape(false)
WordDocumentProperties::WordDocumentProperties(FileInformationBlock* fib, POLE::Stream* tableStream) : doptypography(NULL), dogrid(NULL), asumyi(NULL)
{
Initialize();
@ -227,7 +226,7 @@ namespace DocFileFormat
dywDispPag = FormatUtils::BytesToInt16( bytes, 498, size );
//WORD 2000, 2002, 2003 PART
if ( size > 500/* && fib->m_FibNew.nFibNew > Fib1997*/)
if ( size > 500 )
{
ilvlLastBulletMain = bytes[500];
ilvlLastNumberMain = bytes[501];
@ -267,158 +266,138 @@ namespace DocFileFormat
fDntULTrlSpc = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 14 );
fDntBlnSbDbWid = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 15 );
fSuppressTopSpacingMac5 = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 16 );
fTruncDxaExpand = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 17 );
fPrintBodyBeforeHdr = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 18 );
fNoLeading = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 19 );
fMakeSpaceForUL = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 20 );
fMWSmallCaps = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 21 );
f2ptExtLeadingOnly = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 22 );
fTruncFontHeight = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 23 );
fSubOnSize = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 24 );
fLineWrapLikeWord6 = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 25 );
fWW6BorderRules = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 26 );
fExactOnTop = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 27 );
fExtraAfter = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 28 );
fWPSpace = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 29 );
fWPJust = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 30 );
fPrintMet = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 31 );
fTruncDxaExpand = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 17 );
fPrintBodyBeforeHdr = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 18 );
fNoLeading = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 19 );
fMakeSpaceForUL = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 20 );
fMWSmallCaps = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 21 );
f2ptExtLeadingOnly = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 22 );
fTruncFontHeight = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 23 );
fSubOnSize = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 24 );
fLineWrapLikeWord6 = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 25 );
fWW6BorderRules = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 26 );
fExactOnTop = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 27 );
fExtraAfter = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 28 );
fWPSpace = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 29 );
fWPJust = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 30 );
fPrintMet = FormatUtils::GetBitFromBytes( ( bytes + 508 ), 4, 31 );
//split bytes 512,513,514,515 into bits
fSpLayoutLikeWW8 = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 0 );
fFtnLayoutLikeWW8 = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 1 );
fDontUseHTMLParagraphAutoSpacing = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 2 );
fDontAdjustLineHeightInTable = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 3 );
fForgetLastTabAlign = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 4 );
fUseAutoSpaceForFullWidthAlpha = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 5 );
fAlignTablesRowByRow = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 6 );
fLayoutRawTableWidth = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 7 );
fLayoutTableRowsApart = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 8 );
fUserWord97LineBreakingRules = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 9 );
fDontBreakWrappedTables = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 10 );
fDontSnapToGridInCell = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 11 );
fDontAllowFieldEndSelect = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 12 );
fApplyBreakingRules = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 13 );
fDontWrapTextWithPunct = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 14 );
fDontUseAsianBreakRules = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 15 );
fUseWord2002TableStyleRules = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 16 );
fGrowAutofit = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 17 );
fUseNormalStyleForList = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 18 );
fDontUseIndentAsNumberingTabStop = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 19 );
fFELineBreak11 = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 20 );
fAllowSpaceOfSameStyleInTable = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 21 );
fWW11IndentRules = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 22 );
fDontAutofitConstrainedTables = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 23 );
fAutofitLikeWW11 = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 24 );
fUnderlineTabInNumList = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 25 );
fHangulWidthLikeWW11 = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 26 );
fSplitPgBreakAndParaMark = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 27 );
fDontVertAlignCellWithSp = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 28 );
fDontBreakConstrainedForcedTables = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 29 );
fDontVertAlignInTxbx = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 30 );
fWord11KerningPairs = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 31 );
fCachedColBalance = FormatUtils::GetBitFromBytes( ( bytes + 516 ), 4, 0 );
//split bytes 512,513,514,515 into bits
fSpLayoutLikeWW8 = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 0 );
fFtnLayoutLikeWW8 = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 1 );
fDontUseHTMLParagraphAutoSpacing = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 2 );
fDontAdjustLineHeightInTable = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 3 );
fForgetLastTabAlign = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 4 );
fUseAutoSpaceForFullWidthAlpha = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 5 );
fAlignTablesRowByRow = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 6 );
fLayoutRawTableWidth = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 7 );
fLayoutTableRowsApart = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 8 );
fUserWord97LineBreakingRules = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 9 );
fDontBreakWrappedTables = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 10 );
fDontSnapToGridInCell = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 11 );
fDontAllowFieldEndSelect = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 12 );
fApplyBreakingRules = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 13 );
fDontWrapTextWithPunct = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 14 );
fDontUseAsianBreakRules = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 15 );
fUseWord2002TableStyleRules = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 16 );
fGrowAutofit = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 17 );
fUseNormalStyleForList = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 18 );
fDontUseIndentAsNumberingTabStop = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 19 );
fFELineBreak11 = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 20 );
fAllowSpaceOfSameStyleInTable = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 21 );
fWW11IndentRules = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 22 );
fDontAutofitConstrainedTables = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 23 );
fAutofitLikeWW11 = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 24 );
fUnderlineTabInNumList = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 25 );
fHangulWidthLikeWW11 = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 26 );
fSplitPgBreakAndParaMark = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 27 );
fDontVertAlignCellWithSp = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 28 );
fDontBreakConstrainedForcedTables = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 29 );
fDontVertAlignInTxbx = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 30 );
fWord11KerningPairs = FormatUtils::GetBitFromBytes( ( bytes + 512 ), 4, 31 );
fCachedColBalance = FormatUtils::GetBitFromBytes( ( bytes + 516 ), 4, 0 );
//bytes 517-539 are unused
//bytes 517-539 are unused
verCompatPreW10 = (unsigned short)FormatUtils::GetUIntFromBytesBits( ( bytes + 540 ), 4, 0, 16 );
fNoMargPgvwSaved = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 16 );
fNoMargPgvWPag = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 17 );
fWebViewPag = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 18 );
fSeeDrawingsPag = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 19 );
fBulletProofed = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 20 );
fCorrupted = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 21 );
fSaveUim = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 22 );
fFilterPrivacy = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 23 );
fInFReplaceNoRM = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 24 );
fSeenRepairs = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 25 );
fHasXML = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 26 );
fSeeScriptAnchorsPag = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 27 );
fValidateXML = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 28 );
fSaveIfInvalidXML = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 29 );
fShowXMLErrors = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 30 );
fAlwaysMergeEmptyNamespace = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 31 );
if ( size > 544/* && fib->m_FibNew.nFibNew > Fib2000*/)
{
cpMaxListCacheMainDoc = FormatUtils::BytesToInt32( bytes, 544, size ); //unused
verCompatPreW10 = (unsigned short)FormatUtils::GetUIntFromBytesBits( ( bytes + 540 ), 4, 0, 16 );
fNoMargPgvwSaved = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 16 );
fNoMargPgvWPag = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 17 );
fWebViewPag = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 18 );
fSeeDrawingsPag = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 19 );
fBulletProofed = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 20 );
fCorrupted = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 21 );
fSaveUim = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 22 );
fFilterPrivacy = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 23 );
fInFReplaceNoRM = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 24 );
fSeenRepairs = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 25 );
fHasXML = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 26 );
fSeeScriptAnchorsPag = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 27 );
fValidateXML = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 28 );
fSaveIfInvalidXML = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 29 );
fShowXMLErrors = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 30 );
fAlwaysMergeEmptyNamespace = FormatUtils::GetBitFromBytes( ( bytes + 540 ), 4, 31 );
//split bytes 548,549 into bits
fDoNotEmbedSystemFont = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 0 );
fWordCompact = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 1 );
fLiveRecover = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 2 );
fEmbedFactoids = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 3 );
fFactoidXML = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 4 );
fFactoidAllDone = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 5 );
fFolioPrint = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 6 );
fReverseFolio = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 7 );
iTextLineEnding = (short)FormatUtils::GetUIntFromBytesBits( ( bytes + 548 ), 2, 8, 3 );
fHideFcc = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 11 );
fAcetateShowMarkup = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 12 );
fAcetateShowAtn = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 13 );
fAcetateShowInsDel = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 14 );
fAcetateShowProps = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 15 );
cpMaxListCacheMainDoc = FormatUtils::BytesToInt32( bytes, 544, size );
istdTableDflt = FormatUtils::BytesToUInt16( bytes, 550, size );
verCompat = FormatUtils::BytesToUInt16( bytes, 552, size );
grfFmtFilter = FormatUtils::BytesToUInt16( bytes, 554, size );
iFolioPages = FormatUtils::BytesToInt16 ( bytes, 556, size );
cpgText = FormatUtils::BytesToUInt16( bytes, 558, size );
cpMinRMText = FormatUtils::BytesToInt32 ( bytes, 560, size );
cpMinRMFtn = FormatUtils::BytesToInt32 ( bytes, 564, size );
cpMinRMHdd = FormatUtils::BytesToInt32 ( bytes, 568, size );
cpMinRMAtn = FormatUtils::BytesToInt32 ( bytes, 572, size );
cpMinRMEdn = FormatUtils::BytesToInt32 ( bytes, 576, size );
cpMinRMTxbx = FormatUtils::BytesToInt32 ( bytes, 580, size );
cpMinRMHdrTxbx = FormatUtils::BytesToInt32 ( bytes, 584, size );
rsidRoot = FormatUtils::BytesToInt32 ( bytes, 588, size );
//unused 2
//split bytes 548,549 into bits
fDoNotEmbedSystemFont = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 0 );
fWordCompact = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 1 );
fLiveRecover = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 2 );
fEmbedFactoids = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 3 );
fFactoidXML = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 4 );
fFactoidAllDone = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 5 );
fFolioPrint = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 6 );
fReverseFolio = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 7 );
iTextLineEnding = (short)FormatUtils::GetUIntFromBytesBits( ( bytes + 548 ), 2, 8, 3 );
fHideFcc = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 11 );
fAcetateShowMarkup = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 12 );
fAcetateShowAtn = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 13 );
fAcetateShowInsDel = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 14 );
fAcetateShowProps = FormatUtils::GetBitFromBytes( ( bytes + 548 ), 2, 15 );
if ( size > 594/* && fib->m_FibNew.nFibNew > Fib2002*/)
{
//split bytes 592,593,594,595 into bits
fTreatLockAtnAsReadOnly = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 0 );
fStyleLock = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 1 );
fAutoFmtOverride = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 2 );
fRemoveWordML = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 3 );
fApplyCustomXForm = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 4 );
fStyeLockEnforced = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 5 );
fFakeLockAtn = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 6 );
fIgnoreMixedContent = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 7 );
fShowPlaceholderText = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 8 );
grf = FormatUtils::GetUIntFromBytesBits( ( bytes + 592 ), 4, 9, 23 );
istdTableDflt = FormatUtils::BytesToUInt16( bytes, 550, size );
verCompat = FormatUtils::BytesToUInt16( bytes, 552, size );
grfFmtFilter = FormatUtils::BytesToUInt16( bytes, 554, size );
iFolioPages = FormatUtils::BytesToInt16( bytes, 556, size );
cpgText = FormatUtils::BytesToUInt16( bytes, 558, size );
cpMinRMText = FormatUtils::BytesToInt32( bytes, 560, size );
cpMinRMFtn = FormatUtils::BytesToInt32( bytes, 564, size );
cpMinRMHdd = FormatUtils::BytesToInt32( bytes, 568, size );
cpMinRMAtn = FormatUtils::BytesToInt32( bytes, 572, size );
cpMinRMEdn = FormatUtils::BytesToInt32( bytes, 576, size );
cpMinRMTxbx = FormatUtils::BytesToInt32( bytes, 580, size );
cpMinRMHdrTxbx = FormatUtils::BytesToInt32( bytes, 584, size );
rsidRoot = FormatUtils::BytesToInt32( bytes, 588, size );
//split bytes 596 and 597 into bits
fReadingModeInkLockDown = FormatUtils::GetBitFromBytes( ( bytes + 596 ), 2, 0 );
fAcetateShowInkAtn = FormatUtils::GetBitFromBytes( ( bytes + 596 ), 2, 1 );
fFilterDttm = FormatUtils::GetBitFromBytes( ( bytes + 596 ), 2, 2 );
fEnforceDocProt = FormatUtils::GetBitFromBytes( ( bytes + 596 ), 2, 3 );
iDocProtCur = (unsigned short)FormatUtils::GetUIntFromBytesBits( ( bytes + 596 ), 2, 4, 3 );
fDispBkSpSaved = FormatUtils::GetBitFromBytes( ( bytes + 596 ), 2, 7 );
if ( size == 610 )
{
//split bytes 592,593,594,595 into bits
fTreatLockAtnAsReadOnly = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 0 );
fStyleLock = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 1 );
fAutoFmtOverride = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 2 );
fRemoveWordML = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 3 );
fApplyCustomXForm = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 4 );
fStyeLockEnforced = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 5 );
fFakeLockAtn = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 6 );
fIgnoreMixedContent = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 7 );
fShowPlaceholderText = FormatUtils::GetBitFromBytes( ( bytes + 592 ), 4, 8 );
grf = FormatUtils::GetUIntFromBytesBits( ( bytes + 592 ), 4, 9, 23 );
dxaPageLock = FormatUtils::BytesToInt16( bytes, 598, size );
dyaPageLock = FormatUtils::BytesToInt16( bytes, 600, size );
pctFontLock = FormatUtils::BytesToInt32( bytes, 602, size );
grfitbid = bytes[606];
//unsigned char 607 is unused
ilfoMacAtCleanup = FormatUtils::BytesToUInt16( bytes, 608, size );
if ( size > 616/* && fib->m_FibNew.nFibNew > Fib2003*/)
{
//4 bytes reserved
bool fRMTrackFormatting = FormatUtils::GetBitFromBytes( ( bytes + 620 ), 2, 0 );
bool fRMTrackMoves = FormatUtils::GetBitFromBytes( ( bytes + 620 ), 2, 1 );
//dopMth = 34 bytes from 624 = 658
if ( size > 674/* && fib->m_FibNew.nFibNew > Fib2007*/)
{
if ( size > 690/* && fib->m_FibNew.nFibNew > Fib2010*/)
{
}
}
}
}
}
//split bytes 596 and 597 into bits
fReadingModeInkLockDown = FormatUtils::GetBitFromBytes( ( bytes + 596 ), 2, 0 );
fAcetateShowInkAtn = FormatUtils::GetBitFromBytes( ( bytes + 596 ), 2, 1 );
fFilterDttm = FormatUtils::GetBitFromBytes( ( bytes + 596 ), 2, 2 );
fEnforceDocProt = FormatUtils::GetBitFromBytes( ( bytes + 596 ), 2, 3 );
iDocProtCur = (unsigned short)FormatUtils::GetUIntFromBytesBits( ( bytes + 596 ), 2, 4, 3 );
fDispBkSpSaved = FormatUtils::GetBitFromBytes( ( bytes + 596 ), 2, 7 );
dxaPageLock = FormatUtils::BytesToInt16( bytes, 598, size );
dyaPageLock = FormatUtils::BytesToInt16( bytes, 600, size );
pctFontLock = FormatUtils::BytesToInt32( bytes, 602, size );
grfitbid = bytes[606];
//unsigned char 607 is unused
ilfoMacAtCleanup = FormatUtils::BytesToUInt16( bytes, 608, size );
}
}
}
}

View File

@ -54,7 +54,6 @@ namespace DocFileFormat
friend class SettingsMapping;
bool bDisplayBackgroundShape;
private:
// True when facing pages should be printed
bool fFacingPages;

View File

@ -49,46 +49,39 @@ namespace DocFileFormat
unsigned char fNested:1;
unsigned char fHasSep:1;
};
public:
static const int STRUCTURE_SIZE = 2;
FieldCharacter() : fldch(0), grffld(0) {}
virtual ~FieldCharacter() {}
FieldCharacter():
fldch(0), grffld(0)
{
}
virtual ~FieldCharacter()
{
}
virtual ByteStructure* ConstructObject (VirtualStreamReader* pReader, int length)
{
FieldCharacter* pFldChar = new FieldCharacter();
FieldCharacter* pFldChar = new FieldCharacter();
if (pFldChar)
{
pFldChar->fldch = pReader->ReadByte();
pFldChar->grffld = pReader->ReadByte();
pFldChar->fldch = pReader->ReadByte();
pFldChar->grffld = pReader->ReadByte();
#ifdef _DEBUG
grffldEnd* __grffldEnd = (grffldEnd*)(&pFldChar->grffld);
int dbg = 0;
#endif
}
return static_cast<ByteStructure*>(pFldChar);
}
private:
unsigned char fldch;
unsigned char grffld;
};
class ListNumCache: public ByteStructure
{
public:
static const int STRUCTURE_SIZE = 4;
ListNumCache() : value(-1) {}
virtual ~ListNumCache() {}
virtual ByteStructure* ConstructObject (VirtualStreamReader* pReader, int length)
{
ListNumCache* pList = new ListNumCache();
if (pList)
{
pList->value = pReader->ReadInt32();
}
return static_cast<ByteStructure*>(pList);
}
int value;
};
}

View File

@ -1162,8 +1162,6 @@ namespace DocFileFormat
{
//Read the FibRgCswNew
m_FibNew.nFibNew = (FibVersion)reader.ReadUInt16();
if (m_FibNew.nFibNew == 0) m_FibNew.nFibNew = Fib1997;
m_FibNew.cQuickSavesNew = reader.ReadUInt16();
}
}

View File

@ -53,47 +53,33 @@ namespace DocFileFormat
m_context->_docx->RegisterDocument();
// Header
m_pXmlWriter->WriteNodeBegin(L"?xml version=\"1.0\" encoding=\"UTF-8\"?");
m_pXmlWriter->WriteNodeBegin(L"w:document", TRUE );
m_pXmlWriter->WriteNodeBegin(_T("?xml version=\"1.0\" encoding=\"UTF-8\"?"));
m_pXmlWriter->WriteNodeBegin(_T("w:document"), TRUE );
// Namespaces
m_pXmlWriter->WriteAttribute(L"xmlns:w", OpenXmlNamespaces::WordprocessingML );
m_pXmlWriter->WriteAttribute(L"xmlns:v", OpenXmlNamespaces::VectorML );
m_pXmlWriter->WriteAttribute(L"xmlns:o", OpenXmlNamespaces::Office );
m_pXmlWriter->WriteAttribute(L"xmlns:w10", OpenXmlNamespaces::OfficeWord );
m_pXmlWriter->WriteAttribute(L"xmlns:r", OpenXmlNamespaces::Relationships );
m_pXmlWriter->WriteAttribute(L"xmlns:m", L"http://schemas.openxmlformats.org/officeDocument/2006/math");
m_pXmlWriter->WriteAttribute(_T("xmlns:w"), OpenXmlNamespaces::WordprocessingML );
m_pXmlWriter->WriteAttribute(_T("xmlns:v"), OpenXmlNamespaces::VectorML );
m_pXmlWriter->WriteAttribute(_T("xmlns:o"), OpenXmlNamespaces::Office );
m_pXmlWriter->WriteAttribute(_T("xmlns:w10"), OpenXmlNamespaces::OfficeWord );
m_pXmlWriter->WriteAttribute(_T("xmlns:r"), OpenXmlNamespaces::Relationships );
m_pXmlWriter->WriteAttribute(_T("xmlns:m"), _T("http://schemas.openxmlformats.org/officeDocument/2006/math"));
//m_pXmlWriter->WriteAttribute(L"xmlns:wpc", L"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas");
//m_pXmlWriter->WriteAttribute(L"xmlns:mc", L"http://schemas.openxmlformats.org/markup-compatibility/2006");
//m_pXmlWriter->WriteAttribute(L"xmlns:wp14", L"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing");
//m_pXmlWriter->WriteAttribute(L"xmlns:wp", L"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing");
//m_pXmlWriter->WriteAttribute(L"xmlns:w14", L"http://schemas.microsoft.com/office/word/2010/wordml");
//m_pXmlWriter->WriteAttribute(L"xmlns:wpg", L"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup");
//m_pXmlWriter->WriteAttribute(L"xmlns:wpi", L"http://schemas.microsoft.com/office/word/2010/wordprocessingInk");
//m_pXmlWriter->WriteAttribute(L"xmlns:wne", L"http://schemas.microsoft.com/office/word/2006/wordml");
//m_pXmlWriter->WriteAttribute(L"xmlns:wps", L"http://schemas.microsoft.com/office/word/2010/wordprocessingShape");
//m_pXmlWriter->WriteAttribute(L"mc:Ignorable", L"w14 wp14");
//m_pXmlWriter->WriteAttribute(_T("xmlns:wpc"), _T("http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas"));
//m_pXmlWriter->WriteAttribute(_T("xmlns:mc"), _T("http://schemas.openxmlformats.org/markup-compatibility/2006"));
//m_pXmlWriter->WriteAttribute(_T("xmlns:wp14"),_T("http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing"));
//m_pXmlWriter->WriteAttribute(_T("xmlns:wp"), _T("http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"));
//m_pXmlWriter->WriteAttribute(_T("xmlns:w14"), _T("http://schemas.microsoft.com/office/word/2010/wordml"));
//m_pXmlWriter->WriteAttribute(_T("xmlns:wpg"), _T("http://schemas.microsoft.com/office/word/2010/wordprocessingGroup"));
//m_pXmlWriter->WriteAttribute(_T("xmlns:wpi"), _T("http://schemas.microsoft.com/office/word/2010/wordprocessingInk"));
//m_pXmlWriter->WriteAttribute(_T("xmlns:wne"), _T("http://schemas.microsoft.com/office/word/2006/wordml"));
//m_pXmlWriter->WriteAttribute(_T("xmlns:wps"), _T("http://schemas.microsoft.com/office/word/2010/wordprocessingShape"));
//m_pXmlWriter->WriteAttribute(_T("mc:Ignorable"), _T("w14 wp14"));
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
if ((m_document->GetOfficeArt()) && (m_document->GetOfficeArt()->GetShapeBackgound()))
{
m_document->DocProperties->bDisplayBackgroundShape = true;
ShapeContainer* pShape = m_document->GetOfficeArt()->GetShapeBackgound();
m_pXmlWriter->WriteNodeBegin( _T("w:body"), FALSE );
m_pXmlWriter->WriteNodeBegin ( L"w:background", TRUE);
m_pXmlWriter->WriteAttribute ( L"w:color", L"FFFFFF");
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
VMLShapeMapping oVmlWriter (m_context, m_pXmlWriter, NULL, NULL, _caller);
pShape->Convert(&oVmlWriter);
m_pXmlWriter->WriteNodeEnd (L"w:background");
}
m_pXmlWriter->WriteNodeBegin( L"w:body", FALSE );
// Convert the document
// Convert the document
_lastValidPapx = NULL;
if (m_document->AllPapxFkps->empty() == false)
{
@ -189,8 +175,8 @@ namespace DocFileFormat
}
}
m_pXmlWriter->WriteNodeEnd( L"w:body" );
m_pXmlWriter->WriteNodeEnd( L"w:document" );
m_pXmlWriter->WriteNodeEnd( _T( "w:body" ) );
m_pXmlWriter->WriteNodeEnd( _T( "w:document" ) );
m_context->_docx->DocumentXML = std::wstring(m_pXmlWriter->GetXmlString());
}

View File

@ -34,7 +34,6 @@
#include "OfficeDrawing/RecordFactory.h"
#include "OfficeDrawing/DrawingContainer.h"
#include "OfficeDrawing/DrawingRecord.h"
#include "OfficeDrawing/DrawingGroup.h"
#include "OfficeDrawing/GroupContainer.h"
#include "OfficeDrawing/Shape.h"
@ -58,7 +57,7 @@ namespace DocFileFormat
public:
OfficeArtContent (const FileInformationBlock* pFIB, POLE::Stream* pStream): m_pDrawingGroupData(NULL), m_pBackgroud(NULL)
OfficeArtContent (const FileInformationBlock* pFIB, POLE::Stream* pStream): m_pDrawingGroupData(NULL)
{
VirtualStreamReader oStearmReader(pStream, 0 , pFIB->m_bOlderVersion);
@ -88,23 +87,15 @@ namespace DocFileFormat
{
// the child is a subgroup
GroupContainer* group = static_cast<GroupContainer*>(groupChild);
if (group)
{
group->Index = i;
}
group->Index = i;
drawing.container->Children[i] = group;
}
else if (ShapeContainer::TYPE_CODE_0xF004 == groupChild->TypeCode)
{
// the child is a shape
ShapeContainer* shape = static_cast<ShapeContainer*>(groupChild);
if (shape)
{
shape->Index = i;
if (shape->isBackground())
{
m_pBackgroud = shape;
}
}
shape->Index = i;
drawing.container->Children[i] = shape;
}
}
}
@ -121,10 +112,7 @@ namespace DocFileFormat
for ( std::list<OfficeArtWordDrawing>::iterator iter = m_arrDrawings.begin(); iter != m_arrDrawings.end(); ++iter)
RELEASEOBJECT(iter->container);
}
inline ShapeContainer* GetShapeBackgound()
{
return m_pBackgroud;
}
inline ShapeContainer* GetShapeContainer (int spid)
{
ShapeContainer* ret = NULL;
@ -150,6 +138,7 @@ namespace DocFileFormat
if (shape->GetShapeID() == spid)
{
ret = container;
break;
}
}
@ -161,7 +150,7 @@ namespace DocFileFormat
if (shape->GetShapeID() == spid)
{
ret = container;
ret = container;
break;
}
}
@ -185,7 +174,7 @@ namespace DocFileFormat
}
private:
ShapeContainer* m_pBackgroud;
DrawingGroup* m_pDrawingGroupData;
std::list<OfficeArtWordDrawing> m_arrDrawings;
};

View File

@ -39,9 +39,11 @@ namespace DocFileFormat
{
public:
static const unsigned short TYPE_CODE_0xF008 = 0xF008;
unsigned int csp; // The number of shapes in this drawing
int spidCur; // The last MSOSPID given to an SP in this DG
/// The number of shapes in this drawing
unsigned int csp;
/// The last MSOSPID given to an SP in this DG
int spidCur;
DrawingRecord():
Record(), csp(0), spidCur(0)
@ -51,8 +53,8 @@ namespace DocFileFormat
DrawingRecord( IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance ):
Record( _reader, size, typeCode, version, instance )
{
csp = Reader->ReadUInt32();
spidCur = Reader->ReadInt32();
this->csp = this->Reader->ReadUInt32();
this->spidCur = this->Reader->ReadInt32();
}
virtual ~DrawingRecord()

View File

@ -93,23 +93,29 @@ namespace DocFileFormat
{
case ShapeContainer::TYPE_CODE_0xF004:
return new ShapeContainer();
break;
case Shape::TYPE_CODE_0xF00A:
return new Shape();
break;
case ShapeOptions::TYPE_CODE_0xF00B:
case ShapeOptions::TYPE_CODE_0xF121:
case ShapeOptions::TYPE_CODE_0xF122:
return new ShapeOptions();
break;
case ClientAnchor::TYPE_CODE_0xF010:
return new ClientAnchor();
break;
case ChildAnchor::TYPE_CODE_0xF00F:
return new ChildAnchor();
break;
case BlipStoreEntry::TYPE_CODE_0xF007:
return new BlipStoreEntry();
break;
case BitmapBlip::TYPE_CODE_0xF01D: //OfficeArtBlipJPEG
case BitmapBlip::TYPE_CODE_0xF01E: //OfficeArtBlipPNG
@ -119,25 +125,25 @@ namespace DocFileFormat
case BitmapBlip::TYPE_CODE_0xF029: //OfficeArtBlipTIFF
case BitmapBlip::TYPE_CODE_0xF02A: //OfficeArtBlipJPEG
return new BitmapBlip();
break;
case MetafilePictBlip::TYPE_CODE_0xF01A: //OfficeArtBlipEMF
case MetafilePictBlip::TYPE_CODE_0xF01B: //OfficeArtBlipWMF
case MetafilePictBlip::TYPE_CODE_0xF01C : //OfficeArtBlipPICT
return new MetafilePictBlip();
return new MetafilePictBlip(); break;
case DrawingGroup::TYPE_CODE_0xF000 : return new DrawingGroup();
case DrawingGroupRecord::TYPE_CODE_0xF006 : return new DrawingGroupRecord();
case BlipStoreContainer::TYPE_CODE_0xF001 : return new BlipStoreContainer();
case SplitMenuColorContainer::TYPE_CODE_0xF11E : return new SplitMenuColorContainer();
case ClientData::TYPE_CODE_0xF011 : return new ClientData();
case DrawingContainer::TYPE_CODE_0xF002 : return new DrawingContainer();
case DrawingRecord::TYPE_CODE_0xF008 : return new DrawingRecord();
case GroupContainer::TYPE_CODE_0xF003 : return new GroupContainer();
case GroupShapeRecord::TYPE_CODE_0xF009 : return new GroupShapeRecord ();
case OfficeArtClientTextbox::TYPE_CODE_0xF00D : return new OfficeArtClientTextbox ();
case DrawingGroup::TYPE_CODE_0xF000 : return new DrawingGroup(); break;
case DrawingGroupRecord::TYPE_CODE_0xF006 : return new DrawingGroupRecord(); break;
case BlipStoreContainer::TYPE_CODE_0xF001 : return new BlipStoreContainer(); break;
case SplitMenuColorContainer::TYPE_CODE_0xF11E : return new SplitMenuColorContainer(); break;
case ClientData::TYPE_CODE_0xF011 : return new ClientData(); break;
case DrawingContainer::TYPE_CODE_0xF002 : return new DrawingContainer(); break;
case DrawingRecord::TYPE_CODE_0xF008 : return new DrawingRecord(); break;
case GroupContainer::TYPE_CODE_0xF003 : return new GroupContainer(); break;
case GroupShapeRecord::TYPE_CODE_0xF009 : return new GroupShapeRecord (); break;
case OfficeArtClientTextbox::TYPE_CODE_0xF00D : return new OfficeArtClientTextbox (); break;
default:
return new UnknownRecord();
default: return new UnknownRecord(); break;
}
}
}

View File

@ -39,20 +39,33 @@ namespace DocFileFormat
class Shape: public Record
{
public:
int spid;
bool fGroup;
bool fChild;
bool fPatriarch; // This is the topmost group shape. Exactly one of these per drawing.
bool fDeleted; // The shape has been deleted
bool fOleShape; // The shape is an OLE object
bool fHaveMaster;
bool fFlipH;
bool fFlipV;
bool fConnector;
bool fHaveAnchor;
bool fBackground;
bool fHaveSpt;
int spid;
/// This shape is a group shape
bool fGroup;
/// Not a top-level shape
bool fChild;
/// This is the topmost group shape.
/// Exactly one of these per drawing.
bool fPatriarch;
/// The shape has been deleted
bool fDeleted;
/// The shape is an OLE object
bool fOleShape;
/// Shape has a hspMaster property
bool fHaveMaster;
/// Shape is flipped horizontally
bool fFlipH;
/// Shape is flipped vertically
bool fFlipV;
/// Connector type of shape
bool fConnector;
/// Shape has an anchor of some kind
bool fHaveAnchor;
/// Background shape
bool fBackground;
/// Shape has a shape type property
bool fHaveSpt;
/// The shape type of the shape
ShapeType* shapeType;
public:
@ -67,7 +80,7 @@ namespace DocFileFormat
virtual ~Shape()
{
RELEASEOBJECT( shapeType );
RELEASEOBJECT( this->shapeType );
}
Shape( IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance ):
@ -107,12 +120,12 @@ namespace DocFileFormat
inline int GetShapeID() const
{
return spid;
return this->spid;
}
inline ShapeType* GetShapeType() const
{
return shapeType;
return this->shapeType;
}
template<class T> bool is() const

View File

@ -69,34 +69,7 @@ namespace DocFileFormat
}
return 0;
}
bool isBackground()
{
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->fBackground;
}
}
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()
{
}
@ -106,6 +79,7 @@ namespace DocFileFormat
return new ShapeContainer( _reader, bodySize, typeCode, version, instance );
}
/// Searches all OptionEntry in the ShapeContainer and puts them into a list.
std::list<OptionEntry> ExtractOptions() const
{
std::list<OptionEntry> ret;

View File

@ -1,303 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2016
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#pragma once
#include "OleObject.h"
namespace DocFileFormat
{
OleObject::OleObject( const CharacterPropertyExceptions* chpx, StructuredStorageReader* docStorage, bool bOlderVersion_ )
: bLinked(false), updateMode(NoLink), bOlderVersion(bOlderVersion_), isEquation(false), isEmbedded (false)
{
if (!docStorage) return;
if (!chpx) return;
oleStorage = docStorage->GetStorage();
if (!oleStorage) return;
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;
}
}
void OleObject::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 OleObject::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 OleObject::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 OleObject::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 OleObject::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 = L"NoLink";
}
break;
case Always:
{
this->UpdateMode = L"Always";
}
break;
case OnCall:
{
this->UpdateMode = L"OnCall";
}
break;
}
delete pOleStream;
}
}
catch (...)
{
}
}
std::wstring OleObject::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 = ( L"_" + FormatUtils::IntToWideString( FormatUtils::BytesToUInt32( iter->Arguments, 0, iter->argumentsSize ) ) );
break;
}
}
}
return ret;
}
}

View File

@ -68,18 +68,276 @@ namespace DocFileFormat
PictureDescriptor pictureDesciptor;
OleObject( const CharacterPropertyExceptions* chpx, StructuredStorageReader* docStorage, bool bOlderVersion_ );
virtual ~OleObject() {}
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()
{
}
private:
POLE::Storage *oleStorage;
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 );
void processLinkInfoStream( const std::string& linkStream )
{
try
{
POLE::Stream* pLinkStream = NULL;
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;
}
};
}

View File

@ -67,6 +67,7 @@ namespace DocFileFormat
}
m_pXmlWriter->WriteNodeBegin( _T( "o:OLEObject" ), TRUE );
//type
if ( ole->bLinked )
{
int relID = m_context->_docx->RegisterExternalOLEObject(_caller, ole->ClipboardFormat, ole->Link);
@ -87,13 +88,22 @@ namespace DocFileFormat
m_pXmlWriter->WriteAttribute( _T( "r:id" ), ( std::wstring( _T( "rId" ) ) + FormatUtils::IntToWideString( relID ) ).c_str() );
m_pXmlWriter->WriteAttribute( _T( "Type" ), _T( "Embed" ) );
//copy the object
copyEmbeddedObject( ole );
}
//ProgID
m_pXmlWriter->WriteAttribute( _T( "ProgID" ), ole->Program.c_str() );
//ShapeId
m_pXmlWriter->WriteAttribute( _T( "ShapeID" ), _shapeId.c_str() );
//DrawAspect
m_pXmlWriter->WriteAttribute( _T( "DrawAspect" ), _T( "Content" ) );
//ObjectID
m_pXmlWriter->WriteAttribute( _T( "ObjectID" ), ole->ObjectId.c_str() );
m_pXmlWriter->WriteNodeEnd( _T( "" ), TRUE, FALSE );
m_pXmlWriter->WriteNodeEnd( _T( "o:OLEObject" ) );
@ -155,15 +165,20 @@ namespace DocFileFormat
}
private:
// Writes the embedded OLE object from the ObjectPool of the binary file to the OpenXml Package.
inline void copyEmbeddedObject( const OleObject* ole )
{
if ( ole != NULL )
{
//!!!TODO: There is issue with some Office OLE Objects. Word can't open *.xls object (Excel.Chart) with set CLSID and
//some Power Point Presentations, and Word Documents. Open Office CAN start this objects!!!
std::wstring clsid;
std::wstring exelChart = _T( "Excel.Chart" );
if ( std::search( ole->Program.begin(), ole->Program.end(), exelChart.begin(), exelChart.end() ) == ole->Program.end() )
{
{//??
clsid = ole->ClassId;
}
OleObjectFileStructure object_descr(OleObjectMapping::GetTargetExt( ole->ClipboardFormat ), ole->ObjectId, clsid);

View File

@ -73,7 +73,10 @@ namespace DocFileFormat
RELEASEOBJECT(_pPr);
RELEASEOBJECT(_framePr);
}
}
namespace DocFileFormat
{
int ParagraphPropertiesMapping::get_section_page_break()
{
return _isSectionPageBreak;
@ -145,12 +148,14 @@ namespace DocFileFormat
case sprmPFAutoSpaceDE:
{
appendFlagElement(_pPr, *iter, _T( "autoSpaceDE" ), true);
}break;
}
break;
case sprmPFAutoSpaceDN:
{
appendFlagElement( _pPr, *iter, _T( "autoSpaceDN" ), true );
}break;
}
break;
case sprmPFBiDi:
{
@ -243,7 +248,8 @@ namespace DocFileFormat
}
appendValueAttribute( &ind, flName.c_str(), flValue );
}break;
}
break;
case sprmPDxcLeft1:
appendValueAttribute( &ind, _T( "w:firstLineChars" ), FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) );
@ -299,9 +305,10 @@ namespace DocFileFormat
//no line rule means auto
spacing.AppendAttribute( lineRule );
}break;
}
break;
//justification code
//justification code
case sprmOldPJc:
case sprmPJc:
case sprmPJc80:
@ -311,14 +318,13 @@ namespace DocFileFormat
iter->Arguments[0] = (iter->Arguments[0] == 0 ? 2 : 0);
}
RELEASEOBJECT( jc );
jc = new XMLTools::XMLElement<wchar_t>( L"w:jc" );
if ( jc )
{
XMLTools::XMLAttribute<wchar_t> jcVal( L"w:val", FormatUtils::MapValueToWideString( iter->Arguments[0], &Global::JustificationCode[0][0], 10, 15 ).c_str() );
jc->AppendAttribute( jcVal );
}
}break;
//borders
jc = new XMLTools::XMLElement<wchar_t>( _T( "w:jc" ) );
XMLTools::XMLAttribute<wchar_t> jcVal( _T( "w:val" ), FormatUtils::MapValueToWideString( iter->Arguments[0], &Global::JustificationCode[0][0], 10, 15 ).c_str() );
jc->AppendAttribute( jcVal );
}
break;
//borders
//case 0x461C:
case sprmOldPBrcTop:
case sprmPBrcTop:
@ -332,7 +338,8 @@ namespace DocFileFormat
appendBorderAttributes( &bc, &topBorder );
addOrSetBorder( &pBdr, &topBorder );
}break;
}
break;
//case 0x461D:
case sprmOldPBrcLeft:
@ -347,7 +354,8 @@ namespace DocFileFormat
appendBorderAttributes( &bc, &leftBorder );
addOrSetBorder( &pBdr, &leftBorder );
}break;
}
break;
//case 0x461E:
case sprmOldPBrcBottom:
@ -362,8 +370,9 @@ namespace DocFileFormat
appendBorderAttributes( &bc, &bottomBorder );
addOrSetBorder( &pBdr, &bottomBorder );
}break;
}
break;
//case 0x461F:
case sprmOldPBrcRight:
case sprmPBrcRight:
@ -377,7 +386,8 @@ namespace DocFileFormat
appendBorderAttributes( &bc, &rightBorder );
addOrSetBorder( &pBdr, &rightBorder );
}break;
}
break;
//case 0x4620:
case sprmOldPBrcBetween:
@ -392,7 +402,8 @@ namespace DocFileFormat
appendBorderAttributes( &bc, &betweenBorder );
addOrSetBorder( &pBdr, &betweenBorder );
}break;
}
break;
//case 0x4621:
case sprmOldPBrcBar:
@ -407,17 +418,18 @@ namespace DocFileFormat
appendBorderAttributes( &bc, &barBorder );
addOrSetBorder( &pBdr, &barBorder );
}break;
}
break;
//shading
//shading
case sprmPShd80:
case sprmPShd:
{
ShadingDescriptor desc( iter->Arguments, iter->argumentsSize );
appendShading( _pPr, desc );
}break;
}
break;
//numbering
case sprmOldPAnld:
@ -455,10 +467,8 @@ namespace DocFileFormat
}break;
case sprmPIlfo:
{
//Если numbering.xml пустой, то не пищем свойство
{
//Если numbering.xml пустой, то не пищем свойство
if (NULL != m_document->listTable && false == m_document->listTable->listData.empty())
//Todo разобраться с закоментированным кодом
if(NULL != m_document->listTable && false == m_document->listTable->listData.empty())
appendValueElement( &numPr, _T( "numId" ), FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize ), true );
@ -475,8 +485,8 @@ namespace DocFileFormat
// appendValueElement(numPr, "ilvl", "0", true);
// }
//}
}
break;
}
break;
//tabs
case sprmOldPChgTabs:
@ -653,24 +663,28 @@ namespace DocFileFormat
//append indent
if ( ind.GetAttributeCount() > 0 )
{
_pPr->AppendChild( ind );
{
_pPr->AppendChild( ind );
}
//append spacing
if ( spacing.GetAttributeCount() > 0 )
{
_pPr->AppendChild( spacing );
{
_pPr->AppendChild( spacing );
}
//append justification
if ( jc != NULL )
{
_pPr->AppendChild( *jc );
RELEASEOBJECT( jc );
_pPr->AppendChild( *jc );
RELEASEOBJECT( jc );
}
//append numPr
if ( numPr.GetChildCount() > 0 )
{
_pPr->AppendChild( numPr );
{
_pPr->AppendChild( numPr );
}
//append borders
if ( pBdr.GetChildCount() > 0 )

View File

@ -46,25 +46,26 @@ namespace DocFileFormat
class ParagraphPropertiesMapping: public PropertiesMapping, public IMapping
{
public:
ParagraphPropertiesMapping ( XMLTools::CStringXmlWriter* writer, ConversionContext* ctx, WordDocument* document, CharacterPropertyExceptions* paraEndChpx, bool isBidi, bool isParagraphStyleNeeded = true );
ParagraphPropertiesMapping ( XMLTools::CStringXmlWriter* writer, ConversionContext* ctx, WordDocument* document, CharacterPropertyExceptions* paraEndChpx, bool isBidi, SectionPropertyExceptions* sepx, int sectionNr, bool isParagraphStyleNeeded = true );
ParagraphPropertiesMapping( XMLTools::CStringXmlWriter* writer, ConversionContext* ctx, WordDocument* document, CharacterPropertyExceptions* paraEndChpx, bool isBidi, bool isParagraphStyleNeeded = true );
ParagraphPropertiesMapping( XMLTools::CStringXmlWriter* writer, ConversionContext* ctx, WordDocument* document, CharacterPropertyExceptions* paraEndChpx, bool isBidi, SectionPropertyExceptions* sepx, int sectionNr, bool isParagraphStyleNeeded = true );
virtual ~ParagraphPropertiesMapping();
void Apply(IVisitable* visited);
int get_section_page_break();
private:
WordDocument* m_document;
ConversionContext* m_context;
WordDocument* m_document;
ConversionContext* m_context;
XMLTools::XMLElement<wchar_t>* _pPr;
XMLTools::XMLElement<wchar_t>* _framePr;
SectionPropertyExceptions* _sepx;
CharacterPropertyExceptions* _paraEndChpx;
int _sectionNr;
XMLTools::XMLElement<wchar_t>* _pPr;
XMLTools::XMLElement<wchar_t>* _framePr;
SectionPropertyExceptions* _sepx;
CharacterPropertyExceptions* _paraEndChpx;
int _sectionNr;
bool _isParagraphStyleNeeded;
bool _isBidi;
int _isSectionPageBreak;
bool _isParagraphStyleNeeded;
bool _isBidi;
int _isSectionPageBreak;
};
}

View File

@ -79,8 +79,8 @@ namespace DocFileFormat
//rgbColor6.Format( _T( "%02x%02x%02x" ), /*R*/this->Red, /*G*/this->Green, /*B*/this->Blue );
//rgbColor8.Format( _T( "%02x%02x%02x%02x" ), /*R*/this->Red, /*G*/this->Green, /*B*/this->Blue, /*A*/this->Alpha );
//SixDigitHexCode = rgbColor6;
//EightDigitHexCode = rgbColor8;
//SixDigitHexCode = string2std_string( rgbColor6 );
//EightDigitHexCode = string2std_string( rgbColor8 );
rgbColor6 << boost::wformat( L"%02x%02x%02x" ) % /*R*/this->Red % /*G*/this->Green % /*B*/this->Blue;
rgbColor8 << boost::wformat( L"%02x%02x%02x%02x" ) % /*R*/this->Red % /*G*/this->Green % /*B*/this->Blue % /*A*/this->Alpha;
@ -101,8 +101,8 @@ namespace DocFileFormat
//rgbColor6.Format( _T( "%02x%02x%02x" ), /*R*/this->Red, /*G*/this->Green, /*B*/this->Blue );
//rgbColor8.Format( _T( "%02x%02x%02x%02x" ), /*R*/this->Red, /*G*/this->Green, /*B*/this->Blue, /*A*/this->Alpha );
//SixDigitHexCode = rgbColor6;
//EightDigitHexCode = rgbColor8;
//SixDigitHexCode = string2std_string( rgbColor6 );
//EightDigitHexCode = string2std_string( rgbColor8 );
rgbColor6 << boost::wformat( L"%02x%02x%02x" ) % /*R*/this->Red % /*G*/this->Green % /*B*/this->Blue;
rgbColor8 << boost::wformat( L"%02x%02x%02x%02x" ) % /*R*/this->Red % /*G*/this->Green % /*B*/this->Blue % /*A*/this->Alpha;

View File

@ -35,6 +35,7 @@
namespace DocFileFormat
{
// Creates a new SectionPropertiesMapping which writes the properties to the given writer
SectionPropertiesMapping::SectionPropertiesMapping (XMLTools::CStringXmlWriter* pWriter, ConversionContext* pContext, int nSelectProperties) : PropertiesMapping (pWriter)
{
m_bDeleteNode = TRUE;
@ -53,6 +54,7 @@ namespace DocFileFormat
_type = std::wstring (_T("nextPage"));
}
// Creates a new SectionPropertiesMapping which appends the properties to a given node.
SectionPropertiesMapping::SectionPropertiesMapping (XMLTools::XMLElement<wchar_t>* pBaseNode, ConversionContext* pContext, int nSelectProperties) : PropertiesMapping(NULL)
{
m_bDeleteNode = FALSE;
@ -83,6 +85,7 @@ namespace DocFileFormat
namespace DocFileFormat
{
// Converts the given SectionPropertyExceptions
void SectionPropertiesMapping::Apply (IVisitable* visited)
{
SectionPropertyExceptions* sepx = static_cast<SectionPropertyExceptions*>(visited);
@ -153,56 +156,60 @@ namespace DocFileFormat
{
switch (iter->OpCode)
{
//page margins
case sprmOldSDxaLeft:
case sprmSDxaLeft:
{
_marLeft = FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize );
appendValueAttribute( &pgMar, _T( "w:left" ), FormatUtils::IntToWideString( _marLeft ).c_str() );
}
break;
{
//left margin
_marLeft = FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize );
appendValueAttribute( &pgMar, _T( "w:left" ), FormatUtils::IntToWideString( _marLeft ).c_str() );
}
break;
case sprmOldSDxaRight:
case sprmSDxaRight:
{
_marRight = FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize );
appendValueAttribute( &pgMar, _T( "w:right" ), FormatUtils::IntToWideString( _marRight ).c_str() );
}
break;
{
//right margin
_marRight = FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize );
appendValueAttribute( &pgMar, _T( "w:right" ), FormatUtils::IntToWideString( _marRight ).c_str() );
}
break;
case sprmOldSDyaTop:
case sprmSDyaTop:
//top margin
//top margin
appendValueAttribute( &pgMar, _T( "w:top" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str() );
break;
case sprmOldSDyaBottom:
case sprmSDyaBottom:
//bottom margin
//bottom margin
appendValueAttribute( &pgMar, _T( "w:bottom" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str() );
break;
case sprmOldSDzaGutter:
case sprmSDzaGutter:
//gutter margin
//gutter margin
appendValueAttribute( &pgMar, _T( "w:gutter" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str() );
break;
case sprmOldSDyaHdrTop:
case sprmSDyaHdrTop:
//header margin
//header margin
appendValueAttribute( &pgMar, _T( "w:header"), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str() );
break;
case sprmOldSDyaHdrBottom:
case sprmSDyaHdrBottom:
//footer margin
//footer margin
appendValueAttribute( &pgMar, _T( "w:footer" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str() );
break;
//page size and orientation
//page size and orientation
case sprmOldSXaPage:
case sprmSXaPage:
{
//width
_pgWidth = FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize );
appendValueAttribute( &pgSz, _T( "w:w" ), FormatUtils::IntToWideString( _pgWidth ).c_str() );
}
@ -210,6 +217,7 @@ namespace DocFileFormat
case sprmOldSYaPage:
case sprmSYaPage:
//height
appendValueAttribute( &pgSz, _T( "w:h" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str() );
break;
@ -219,7 +227,7 @@ namespace DocFileFormat
appendValueAttribute( &pgSz, _T( "w:orient" ), FormatUtils::MapValueToWideString( iter->Arguments[0], &PageOrientationMap[0][0], 3, 10 ).c_str() );
break;
//paper source
//paper source
case sprmOldSDmBinFirst:
case sprmSDmBinFirst:
appendValueAttribute( &paperSrc, _T( "w:first" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str() );
@ -230,85 +238,91 @@ namespace DocFileFormat
appendValueAttribute( &paperSrc, _T( "w:other" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str() );
break;
//page borders
//page borders
case sprmSBrcTop80:
case sprmSBrcTop:
{
//top
XMLTools::XMLElement<wchar_t> topBorder( _T( "w:top" ) );
BorderCode bc( iter->Arguments, iter->argumentsSize );
appendBorderAttributes( &bc, &topBorder );
addOrSetBorder( &pgBorders, &topBorder);
}
break;
{
//top
XMLTools::XMLElement<wchar_t> topBorder( _T( "w:top" ) );
BorderCode bc( iter->Arguments, iter->argumentsSize );
appendBorderAttributes( &bc, &topBorder );
addOrSetBorder( &pgBorders, &topBorder);
}
break;
case sprmSBrcLeft80:
case sprmSBrcLeft:
{
XMLTools::XMLElement<wchar_t> leftBorder( _T( "w:left" ) );
BorderCode bc( iter->Arguments, iter->argumentsSize );
appendBorderAttributes( &bc, &leftBorder);
addOrSetBorder( &pgBorders, &leftBorder);
}
break;
{
//left
XMLTools::XMLElement<wchar_t> leftBorder( _T( "w:left" ) );
BorderCode bc( iter->Arguments, iter->argumentsSize );
appendBorderAttributes( &bc, &leftBorder);
addOrSetBorder( &pgBorders, &leftBorder);
}
break;
case sprmSBrcBottom80:
case sprmSBrcBottom:
{
//left
XMLTools::XMLElement<wchar_t> bottomBorder( _T( "w:bottom" ) );
BorderCode bc( iter->Arguments, iter->argumentsSize );
appendBorderAttributes( &bc, &bottomBorder );
addOrSetBorder( &pgBorders, &bottomBorder);
}
break;
{
//left
XMLTools::XMLElement<wchar_t> bottomBorder( _T( "w:bottom" ) );
BorderCode bc( iter->Arguments, iter->argumentsSize );
appendBorderAttributes( &bc, &bottomBorder );
addOrSetBorder( &pgBorders, &bottomBorder);
}
break;
case sprmSBrcRight80:
case sprmSBrcRight:
{
//left
XMLTools::XMLElement<wchar_t> rightBorder( _T( "w:right" ) );
BorderCode bc( iter->Arguments, iter->argumentsSize );
appendBorderAttributes( &bc, &rightBorder);
addOrSetBorder( &pgBorders, &rightBorder);
}
break;
{
//left
XMLTools::XMLElement<wchar_t> rightBorder( _T( "w:right" ) );
BorderCode bc( iter->Arguments, iter->argumentsSize );
appendBorderAttributes( &bc, &rightBorder);
addOrSetBorder( &pgBorders, &rightBorder);
}
break;
//footnote properties
case sprmSRncFtn:
//restart code
appendValueElement( &footnotePr, _T( "numRestart" ), FormatUtils::MapValueToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ), &FootnoteRestartCodeMap[0][0], 3, 11 ).c_str(), true );
break;
//endnote properties
case sprmSRncEdn:
//restart code
appendValueElement( &endnotePr, _T( "numRestart" ), FormatUtils::MapValueToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ), &EndnoteRestartCodeMap[0][0], 3, 11 ).c_str(), true );
break;
case sprmSFpc:
{
//position code
short fpc = 0;
{
//position code
short fpc = 0;
if ( iter->argumentsSize == 2 )
{
fpc = FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize );
}
else
{
fpc = (short)iter->Arguments[0];
}
if ( iter->argumentsSize == 2 )
{
fpc = FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize );
}
else
{
fpc = (short)iter->Arguments[0];
}
if ( fpc == 2 )
{
appendValueElement( &footnotePr, _T( "pos" ), _T( "beneathText" ), true );
if ( fpc == 2 )
{
appendValueElement( &footnotePr, _T( "pos" ), _T( "beneathText" ), true );
}
}
}break;
break;
case sprmSNfcFtnRef:
//number format
appendValueElement( &footnotePr, _T( "numFmt" ), NumberingMapping::GetNumberFormatWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str(), true );
break;
case sprmSNfcEdnRef:
//number format
appendValueElement( &endnotePr, _T( "numFmt" ), NumberingMapping::GetNumberFormatWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str(), true );
break;
@ -320,6 +334,7 @@ namespace DocFileFormat
appendValueElement( &endnotePr, _T( "numStart" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str(), true );
break;
//doc grid
case sprmSDyaLinePitch:
appendValueAttribute( &docGrid, _T( "w:linePitch" ), FormatUtils::IntToWideString( FormatUtils::BytesToInt16( iter->Arguments, 0, iter->argumentsSize ) ).c_str() );
break;
@ -332,17 +347,18 @@ namespace DocFileFormat
appendValueAttribute( &docGrid, _T( "w:type" ), FormatUtils::MapValueToWideString( FormatUtils::BytesToUInt16( iter->Arguments, 0, iter->argumentsSize ), &DocGridTypeMap[0][0], 4, 14 ).c_str() );
break;
// Columns
case sprmOldSCcolumns:
case sprmSCcolumns:
{
m_nColumns = static_cast<int> (FormatUtils::BytesToInt16 (iter->Arguments, 0, iter->argumentsSize) + 1);
{
m_nColumns = static_cast<int> (FormatUtils::BytesToInt16 (iter->Arguments, 0, iter->argumentsSize) + 1);
RELEASEARRAYOBJECTS (m_arrSpace);
m_arrSpace = new short [m_nColumns];
RELEASEARRAYOBJECTS (m_arrSpace);
m_arrSpace = new short [m_nColumns];
appendValueAttribute (&cols, _T( "w:num" ), FormatUtils::IntToWideString (m_nColumns).c_str());
}
break;
appendValueAttribute (&cols, _T( "w:num" ), FormatUtils::IntToWideString (m_nColumns).c_str());
}
break;
case sprmOldSDxaColumns:
case sprmSDxaColumns:
@ -352,60 +368,65 @@ namespace DocFileFormat
case sprmOldSDxaColWidth:
case sprmSDxaColWidth:
{
if (m_nColumns) // there is at least one width set, so create the array
{
if (NULL == m_arrWidth)
m_arrWidth = new short [m_nColumns];
// there is at least one width set, so create the array
if (m_nColumns)
{
if (NULL == m_arrWidth)
m_arrWidth = new short [m_nColumns];
unsigned char nInd = iter->Arguments[0];
m_arrWidth[nInd] = FormatUtils::BytesToInt16 (iter->Arguments, 1, iter->argumentsSize);
unsigned char nInd = iter->Arguments[0];
m_arrWidth[nInd] = FormatUtils::BytesToInt16 (iter->Arguments, 1, iter->argumentsSize);
}
}
}
break;
break;
case sprmOldSDxaColSpacing:
case sprmSDxaColSpacing:
{
// there is at least one space set, so create the array
if (m_nColumns)
{
if (NULL == m_arrSpace)
m_arrSpace = new short[m_nColumns];
// there is at least one space set, so create the array
if (m_nColumns)
{
if (NULL == m_arrSpace)
m_arrSpace = new short[m_nColumns];
unsigned char nInd = iter->Arguments[0];
m_arrSpace [nInd] = FormatUtils::BytesToInt16 (iter->Arguments, 1, iter->argumentsSize);
unsigned char nInd = iter->Arguments[0];
m_arrSpace [nInd] = FormatUtils::BytesToInt16 (iter->Arguments, 1, iter->argumentsSize);
}
}
}break;
break;
//bidi
case sprmSFBiDi:
{
appendFlagElement (m_pXmlNode, *iter, _T( "bidi" ), iter->argumentsSize > 0 ? iter->Arguments[0] : true );
}break;
appendFlagElement (m_pXmlNode, *iter, _T( "bidi" ), true );
break;
//title page
case sprmOldSFTitlePage:
case sprmSFTitlePage:
{
appendFlagElement (m_pXmlNode, *iter, _T( "titlePg" ), iter->argumentsSize > 0 ? iter->Arguments[0] : true );
}break;
appendFlagElement (m_pXmlNode, *iter, _T( "titlePg" ), true );
break;
//RTL gutter
case sprmSFRTLGutter:
{
appendFlagElement (m_pXmlNode, *iter, _T( "rtlGutter" ), iter->argumentsSize > 0 ? iter->Arguments[0] : true );
}break;
appendFlagElement (m_pXmlNode, *iter, _T( "rtlGutter" ), true );
break;
//type
case sprmOldSBkc:
case sprmSBkc:
{
_type = FormatUtils::MapValueToWideString( iter->Arguments[0], &SectionTypeMap[0][0], 5, 11 );
}
break;
{
_type = FormatUtils::MapValueToWideString( iter->Arguments[0], &SectionTypeMap[0][0], 5, 11 );
}
break;
//align
case sprmOldSVjc:
case sprmSVjc:
appendValueElement (m_pXmlNode, _T( "vAlign" ), FormatUtils::MapValueToWideString( iter->Arguments[0], &TextVerticalAlignment[0][0], 4, 7 ).c_str(), true );
break;
//pgNumType
case sprmOldSNfcPgn:
case sprmSNfcPgn:
appendValueAttribute( &pgNumType, _T( "w:fmt" ), FormatUtils::MapValueToWideString( iter->Arguments[0], &PageNumberFormatCodeMap[0][0], 42, 29 ).c_str() );
@ -421,7 +442,7 @@ namespace DocFileFormat
bWasSprmSFPgnRestart = true;
break;
// <w:lnNumType> - Line Numbering Settings
// <w:lnNumType> - Line Numbering Settings
case sprmOldSLnnMin :
case sprmSLnnMin :
@ -455,7 +476,6 @@ namespace DocFileFormat
default:
{
int sz = iter->argumentsSize;
}break;
}
}
@ -466,6 +486,7 @@ namespace DocFileFormat
// build the columns
if (m_arrWidth)
{
//set to unequal width
XMLTools::XMLAttribute<wchar_t> equalWidth( _T( "w:equalWidth" ), _T( "0" ) );
cols.AppendAttribute( equalWidth );
@ -484,6 +505,7 @@ namespace DocFileFormat
m_arrWidth [m_nColumns - 1] = lastColWidth;
}
// append the xml elements
for (int i = 0; i < m_nColumns; ++i)
{
XMLTools::XMLElement<wchar_t> col (_T( "w:col" ));
@ -496,35 +518,46 @@ namespace DocFileFormat
}
}
//append the section type
appendValueElement (m_pXmlNode, _T( "type" ), _type.c_str(), true );
// Document-Wide Footnote Properties
if (footnotePr.GetChildCount())
m_pXmlNode->AppendChild (footnotePr);
// Document-Wide Endnote Properties
if (endnotePr.GetChildCount())
m_pXmlNode->AppendChild (endnotePr);
// Page Size
if (pgSz.GetAttributeCount())
m_pXmlNode->AppendChild (pgSz);
// Page Borders
if (pgBorders.GetChildCount())
m_pXmlNode->AppendChild (pgBorders);
// Page Margins
if (pgMar.GetAttributeCount())
m_pXmlNode->AppendChild (pgMar);
// Line Numbering Settings
if (lnNumType.GetAttributeCount())
m_pXmlNode->AppendChild (lnNumType);
// Paper Source Information
if (paperSrc.GetAttributeCount())
m_pXmlNode->AppendChild (paperSrc);
// Single Column Definition)
if (cols.GetAttributeCount() || cols.GetChildCount())
m_pXmlNode->AppendChild (cols);
// Document Grid
if (docGrid.GetAttributeCount())
m_pXmlNode->AppendChild (docGrid);
// Page Numbering Settings
if (pgNumType.GetAttributeCount())
m_pXmlNode->AppendChild (pgNumType);

View File

@ -42,11 +42,11 @@ namespace DocFileFormat
SectionPropertyExceptions( unsigned char* bytes, int size, bool oldVersion ):
PropertyExceptions( bytes, size, oldVersion ), isBidi(false)
{
for ( std::list<SinglePropertyModifier>::iterator iter = grpprl->begin(); iter != grpprl->end(); iter++ )
for ( std::list<SinglePropertyModifier>::iterator iter = this->grpprl->begin(); iter != this->grpprl->end(); iter++ )
{
SinglePropertyModifier sprm( *iter );
if( sprm.OpCode == sprmSFBiDi && sprm.Arguments[0] != 0)
if( sprm.OpCode == sprmSFBiDi )
{
isBidi = true;
}

View File

@ -44,31 +44,27 @@ namespace DocFileFormat
{
WordDocumentProperties* dop = static_cast<WordDocumentProperties*>( visited );
_ctx->_docx->RegisterSettings();
this->_ctx->_docx->RegisterSettings();
//start w:settings
m_oXmlWriter.WriteNodeBegin( L"?xml version=\"1.0\" encoding=\"UTF-8\"?" );
m_oXmlWriter.WriteNodeBegin( L"w:settings", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "?xml version=\"1.0\" encoding=\"UTF-8\"?" ) );
m_oXmlWriter.WriteNodeBegin( _T( "w:settings" ), TRUE );
//write namespaces
m_oXmlWriter.WriteAttribute( L"xmlns:w", OpenXmlNamespaces::WordprocessingML );
m_oXmlWriter.WriteNodeEnd( L"", TRUE, FALSE );
m_oXmlWriter.WriteAttribute( _T( "xmlns:w" ), OpenXmlNamespaces::WordprocessingML );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE, FALSE );
//zoom
m_oXmlWriter.WriteNodeBegin ( L"w:zoom", TRUE );
m_oXmlWriter.WriteAttribute ( L"w:percent", FormatUtils::IntToWideString( dop->wScaleSaved ).c_str() );
m_oXmlWriter.WriteNodeBegin( _T( "w:zoom" ), TRUE );
m_oXmlWriter.WriteAttribute( _T( "w:percent" ), FormatUtils::IntToWideString( dop->wScaleSaved ).c_str() );
if ( dop->zkSaved != 0 )
{
m_oXmlWriter.WriteAttribute( L"w:val", FormatUtils::MapValueToWideString( dop->zkSaved, &ZoomTypeMap[0][0], 3, 9 ).c_str() );
m_oXmlWriter.WriteAttribute( _T( "w:val" ), FormatUtils::MapValueToWideString( dop->zkSaved, &ZoomTypeMap[0][0], 3, 9 ).c_str() );
}
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
if (dop->bDisplayBackgroundShape)
{
m_oXmlWriter.WriteNodeBegin ( L"w:displayBackgroundShape", TRUE );
m_oXmlWriter.WriteNodeEnd ( L"", TRUE );
}
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
//doc protection
//<w:documentProtection w:edit="forms" w:enforcement="1"/>
@ -76,30 +72,30 @@ namespace DocFileFormat
//embed system fonts
if( !dop->fDoNotEmbedSystemFont )
{
m_oXmlWriter.WriteNodeBegin( L"w:embedSystemFonts", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:embedSystemFonts" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
//mirror margins
if ( dop->fMirrorMargins )
{
m_oXmlWriter.WriteNodeBegin( L"w:mirrorMargins", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:mirrorMargins" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
//evenAndOddHeaders
if ( dop->fFacingPages )
{
m_oXmlWriter.WriteNodeBegin( L"w:evenAndOddHeaders", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:evenAndOddHeaders" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
//proof state
XMLTools::XMLElement<wchar_t> proofState( L"w:proofState" );
XMLTools::XMLElement<wchar_t> proofState( _T( "w:proofState" ) );
if ( dop->fGramAllClean )
{
appendValueAttribute( &proofState, L"w:grammar", L"clean" );
appendValueAttribute( &proofState, _T( "w:grammar" ), _T( "clean" ) );
}
if ( proofState.GetAttributeCount() > 0 )
@ -110,31 +106,31 @@ namespace DocFileFormat
//stylePaneFormatFilter
if ( dop->grfFmtFilter != 0 )
{
m_oXmlWriter.WriteNodeBegin( L"w:stylePaneFormatFilter", TRUE );
m_oXmlWriter.WriteAttribute( L"w:val", FormatUtils::IntToFormattedWideString( dop->grfFmtFilter, L"%04x" ).c_str() );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:stylePaneFormatFilter" ), TRUE );
m_oXmlWriter.WriteAttribute( _T( "w:val" ), FormatUtils::IntToFormattedWideString( dop->grfFmtFilter, _T( "%04x" ) ).c_str() );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
//default tab stop
m_oXmlWriter.WriteNodeBegin( L"w:defaultTabStop", TRUE );
m_oXmlWriter.WriteAttribute( L"w:val", FormatUtils::IntToWideString( dop->dxaTab ).c_str() );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:defaultTabStop" ), TRUE );
m_oXmlWriter.WriteAttribute( _T( "w:val" ), FormatUtils::IntToWideString( dop->dxaTab ).c_str() );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
//drawing grid
if( dop->dogrid != NULL )
{
m_oXmlWriter.WriteNodeBegin( L"w:displayHorizontalDrawingGridEvery", TRUE );
m_oXmlWriter.WriteAttribute( L"w:val", FormatUtils::IntToWideString( dop->dogrid->dxGridDisplay ).c_str() );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:displayHorizontalDrawingGridEvery" ), TRUE );
m_oXmlWriter.WriteAttribute( _T( "w:val" ), FormatUtils::IntToWideString( dop->dogrid->dxGridDisplay ).c_str() );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
m_oXmlWriter.WriteNodeBegin( L"w:displayVerticalDrawingGridEvery", TRUE );
m_oXmlWriter.WriteAttribute( L"w:val", FormatUtils::IntToWideString( dop->dogrid->dyGridDisplay ).c_str() );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:displayVerticalDrawingGridEvery" ), TRUE );
m_oXmlWriter.WriteAttribute( _T( "w:val" ), FormatUtils::IntToWideString( dop->dogrid->dyGridDisplay ).c_str() );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
if ( dop->dogrid->fFollowMargins == false )
{
m_oXmlWriter.WriteNodeBegin( L"w:doNotUseMarginsForDrawingGridOrigin", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:doNotUseMarginsForDrawingGridOrigin" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
}
@ -143,27 +139,27 @@ namespace DocFileFormat
{
if ( dop->doptypography->fKerningPunct == false )
{
m_oXmlWriter.WriteNodeBegin( L"w:noPunctuationKerning", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:noPunctuationKerning" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
}
//footnote properties
XMLTools::XMLElement<wchar_t> footnotePr( L"w:footnotePr" );
XMLTools::XMLElement<wchar_t> footnotePr( _T( "w:footnotePr" ) );
if ( dop->nFtn != 0 )
{
appendValueAttribute( &footnotePr, L"w:numStart", FormatUtils::IntToWideString( dop->nFtn ).c_str() );
appendValueAttribute( &footnotePr, _T( "w:numStart" ), FormatUtils::IntToWideString( dop->nFtn ).c_str() );
}
if ( dop->rncFtn != 0 )
{
appendValueAttribute( &footnotePr, L"w:numRestart", FormatUtils::IntToWideString( dop->rncFtn ).c_str() );
appendValueAttribute( &footnotePr, _T( "w:numRestart" ), FormatUtils::IntToWideString( dop->rncFtn ).c_str() );
}
if ( dop->Fpc != 0 )
{
appendValueAttribute( &footnotePr, L"w:pos", FormatUtils::MapValueToWideString( dop->Fpc, &FootnotePositionMap[0][0], 4, 12 ).c_str() );
appendValueAttribute( &footnotePr, _T( "w:pos" ), FormatUtils::MapValueToWideString( dop->Fpc, &FootnotePositionMap[0][0], 4, 12 ).c_str() );
}
if ( footnotePr.GetAttributeCount() > 0 )
@ -177,7 +173,7 @@ namespace DocFileFormat
writeRsidList();
//close w:settings
m_oXmlWriter.WriteNodeEnd( L"w:settings" );
m_oXmlWriter.WriteNodeEnd( _T( "w:settings" ) );
this->_ctx->_docx->SettingsXML = std::wstring( m_oXmlWriter.GetXmlString() );
}
@ -185,368 +181,368 @@ namespace DocFileFormat
void SettingsMapping::writeRsidList()
{
//convert the rsid list
m_oXmlWriter.WriteNodeBegin( L"w:rsids" );
m_oXmlWriter.WriteNodeBegin( _T( "w:rsids" ) );
for ( std::set<std::wstring>::iterator iter = this->_ctx->AllRsids.begin(); iter != this->_ctx->AllRsids.end(); iter++ )
{
m_oXmlWriter.WriteNodeBegin( L"w:rsid", TRUE );
m_oXmlWriter.WriteAttribute( L"w:val", iter->c_str() );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:rsid" ), TRUE );
m_oXmlWriter.WriteAttribute( _T( "w:val" ), iter->c_str() );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
m_oXmlWriter.WriteNodeEnd( L"w:rsids" );
m_oXmlWriter.WriteNodeEnd( _T( "w:rsids" ) );
}
void SettingsMapping::writeCompatibilitySettings(const WordDocumentProperties* dop)
{
//compatibility settings
m_oXmlWriter.WriteNodeBegin( L"w:compat" );
m_oXmlWriter.WriteNodeBegin( _T( "w:compat" ) );
//some settings must always be written
if ( dop->fUseNormalStyleForList )
{
m_oXmlWriter.WriteNodeBegin( L"w:useNormalStyleForList", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:useNormalStyleForList" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fDontUseIndentAsNumberingTabStop )
{
m_oXmlWriter.WriteNodeBegin( L"w:doNotUseIndentAsNumberingTabStop", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:doNotUseIndentAsNumberingTabStop" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fFELineBreak11 )
{
m_oXmlWriter.WriteNodeBegin( L"w:useAltKinsokuLineBreakRules", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:useAltKinsokuLineBreakRules" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fAllowSpaceOfSameStyleInTable )
{
m_oXmlWriter.WriteNodeBegin( L"w:allowSpaceOfSameStyleInTable", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:allowSpaceOfSameStyleInTable" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fWW11IndentRules )
{
m_oXmlWriter.WriteNodeBegin( L"w:doNotSuppressIndentation", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:doNotSuppressIndentation" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fDontAutofitConstrainedTables )
{
m_oXmlWriter.WriteNodeBegin( L"w:doNotAutofitConstrainedTables", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:doNotAutofitConstrainedTables" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fAutofitLikeWW11 )
{
m_oXmlWriter.WriteNodeBegin( L"w:autofitToFirstFixedWidthCell", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:autofitToFirstFixedWidthCell" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fUnderlineTabInNumList )
{
m_oXmlWriter.WriteNodeBegin( L"w:underlineTabInNumList", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:underlineTabInNumList" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fHangulWidthLikeWW11 )
{
m_oXmlWriter.WriteNodeBegin( L"w:displayHangulFixedWidth", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:displayHangulFixedWidth" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fSplitPgBreakAndParaMark )
{
m_oXmlWriter.WriteNodeBegin( L"w:splitPgBreakAndParaMark", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:splitPgBreakAndParaMark" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fDontVertAlignCellWithSp )
{
m_oXmlWriter.WriteNodeBegin( L"w:doNotVertAlignCellWithSp", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:doNotVertAlignCellWithSp" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fDontBreakConstrainedForcedTables )
{
m_oXmlWriter.WriteNodeBegin( L"w:doNotBreakConstrainedForcedTable", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:doNotBreakConstrainedForcedTable" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fDontVertAlignInTxbx )
{
m_oXmlWriter.WriteNodeBegin( L"w:doNotVertAlignInTxbx", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:doNotVertAlignInTxbx" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fWord11KerningPairs )
{
m_oXmlWriter.WriteNodeBegin( L"w:useAnsiKerningPairs", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:useAnsiKerningPairs" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fCachedColBalance )
{
m_oXmlWriter.WriteNodeBegin( L"w:cachedColBalance", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:cachedColBalance" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
//others are saved in the file
if ( !dop->fDontAdjustLineHeightInTable )
{
m_oXmlWriter.WriteNodeBegin( L"w:adjustLineHeightInTable", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:adjustLineHeightInTable" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fAlignTablesRowByRow )
{
m_oXmlWriter.WriteNodeBegin( L"w:alignTablesRowByRow", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:alignTablesRowByRow" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fApplyBreakingRules )
{
m_oXmlWriter.WriteNodeBegin( L"w:applyBreakingRules", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:applyBreakingRules" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fUseAutoSpaceForFullWidthAlpha )
{
m_oXmlWriter.WriteNodeBegin( L"w:autoSpaceLikeWord95", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:autoSpaceLikeWord95" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( !dop->fDntBlnSbDbWid )
{
m_oXmlWriter.WriteNodeBegin( L"w:balanceSingleByteDoubleByteWidth", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:balanceSingleByteDoubleByteWidth" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fConvMailMergeEsc )
{
m_oXmlWriter.WriteNodeBegin( L"w:convMailMergeEsc", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:convMailMergeEsc" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fDontBreakWrappedTables )
{
m_oXmlWriter.WriteNodeBegin( L"w:doNotBreakWrappedTables", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:doNotBreakWrappedTables" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( !dop->fExpShRtn )
{
m_oXmlWriter.WriteNodeBegin( L"w:doNotExpandShiftReturn", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:doNotExpandShiftReturn" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( !dop->fLeaveBackslashAlone )
{
m_oXmlWriter.WriteNodeBegin( L"w:doNotLeaveBackslashAlone", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:doNotLeaveBackslashAlone" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fDontSnapToGridInCell )
{
m_oXmlWriter.WriteNodeBegin( L"w:doNotSnapToGridInCell", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:doNotSnapToGridInCell" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fDontUseAsianBreakRules )
{
m_oXmlWriter.WriteNodeBegin( L"w:doNotUseEastAsianBreakRules", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:doNotUseEastAsianBreakRules" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fDontUseHTMLParagraphAutoSpacing )
{
m_oXmlWriter.WriteNodeBegin( L"w:doNotUseHTMLParagraphAutoSpacing", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:doNotUseHTMLParagraphAutoSpacing" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fDontWrapTextWithPunct )
{
m_oXmlWriter.WriteNodeBegin( L"w:doNotWrapTextWithPunct", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:doNotWrapTextWithPunct" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fFtnLayoutLikeWW8 )
{
m_oXmlWriter.WriteNodeBegin( L"w:footnoteLayoutLikeWW8", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:footnoteLayoutLikeWW8" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fForgetLastTabAlign )
{
m_oXmlWriter.WriteNodeBegin( L"w:forgetLastTabAlignment", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:forgetLastTabAlignment" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fGrowAutofit )
{
m_oXmlWriter.WriteNodeBegin( L"w:growAutofit", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:growAutofit" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fLayoutRawTableWidth )
{
m_oXmlWriter.WriteNodeBegin( L"w:layoutRawTableWidth", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:layoutRawTableWidth" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fLayoutTableRowsApart )
{
m_oXmlWriter.WriteNodeBegin( L"w:layoutTableRowsApart", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:layoutTableRowsApart" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fLineWrapLikeWord6 )
{
m_oXmlWriter.WriteNodeBegin( L"w:lineWrapLikeWord6", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:lineWrapLikeWord6" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fMWSmallCaps )
{
m_oXmlWriter.WriteNodeBegin( L"w:mwSmallCaps", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:mwSmallCaps" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fNoColumnBalance )
{
m_oXmlWriter.WriteNodeBegin( L"w:noColumnBalance", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:noColumnBalance" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fNoLeading )
{
m_oXmlWriter.WriteNodeBegin( L"w:noLeading", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:noLeading" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fNoSpaceRaiseLower )
{
m_oXmlWriter.WriteNodeBegin( L"w:noSpaceRaiseLower", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:noSpaceRaiseLower" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fNoTabForInd )
{
m_oXmlWriter.WriteNodeBegin( L"w:noTabHangInd", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:noTabHangInd" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fPrintBodyBeforeHdr )
{
m_oXmlWriter.WriteNodeBegin( L"w:printBodyTextBeforeHeader", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:printBodyTextBeforeHeader" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fMapPrintTextColor )
{
m_oXmlWriter.WriteNodeBegin( L"w:printColBlack", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:printColBlack" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fDontAllowFieldEndSelect )
{
m_oXmlWriter.WriteNodeBegin( L"w:selectFldWithFirstOrLastChar", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:selectFldWithFirstOrLastChar" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fSpLayoutLikeWW8 )
{
m_oXmlWriter.WriteNodeBegin( L"w:shapeLayoutLikeWW8", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:shapeLayoutLikeWW8" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fShowBreaksInFrames )
{
m_oXmlWriter.WriteNodeBegin( L"w:showBreaksInFrames", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:showBreaksInFrames" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fMakeSpaceForUL )
{
m_oXmlWriter.WriteNodeBegin( L"w:spaceForUL", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:spaceForUL" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fTruncDxaExpand )
{
m_oXmlWriter.WriteNodeBegin( L"w:spacingInWholePoints", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:spacingInWholePoints" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fSubOnSize )
{
m_oXmlWriter.WriteNodeBegin( L"w:subFontBySize", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:subFontBySize" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fSuppressSpbfAfterPageBreak )
{
m_oXmlWriter.WriteNodeBegin( L"w:suppressSpBfAfterPgBrk", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:suppressSpBfAfterPgBrk" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fSuppressTopSpacing )
{
m_oXmlWriter.WriteNodeBegin( L"w:suppressTopSpacing", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:suppressTopSpacing" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fSwapBordersFacingPgs )
{
m_oXmlWriter.WriteNodeBegin( L"w:swapBordersFacingPages", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:swapBordersFacingPages" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( !dop->fDntULTrlSpc )
{
m_oXmlWriter.WriteNodeBegin( L"w:ulTrailSpace", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:ulTrailSpace" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fPrintMet )
{
m_oXmlWriter.WriteNodeBegin( L"w:usePrinterMetrics", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:usePrinterMetrics" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fUseWord2002TableStyleRules )
{
m_oXmlWriter.WriteNodeBegin( L"w:useWord2002TableStyleRules", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:useWord2002TableStyleRules" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fUserWord97LineBreakingRules )
{
m_oXmlWriter.WriteNodeBegin( L"w:useWord97LineBreakRules", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:useWord97LineBreakRules" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fWPJust )
{
m_oXmlWriter.WriteNodeBegin( L"w:wpJustification", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:wpJustification" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fWPSpace )
{
m_oXmlWriter.WriteNodeBegin( L"w:wpSpaceWidth", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:wpSpaceWidth" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
if ( dop->fWrapTrailSpaces )
{
m_oXmlWriter.WriteNodeBegin( L"w:wrapTrailSpaces", TRUE );
m_oXmlWriter.WriteNodeEnd( L"", TRUE );
m_oXmlWriter.WriteNodeBegin( _T( "w:wrapTrailSpaces" ), TRUE );
m_oXmlWriter.WriteNodeEnd( _T( "" ), TRUE );
}
m_oXmlWriter.WriteNodeEnd( L"w:compat" );
m_oXmlWriter.WriteNodeEnd( _T( "w:compat" ) );
}
}

View File

@ -112,14 +112,23 @@ namespace DocFileFormat
friend class PropertiesMapping;
private:
unsigned int cvFore; // 24-bit foreground color
bool cvForeAuto;
int icoFore; // Foreground color.
unsigned int cvBack;
bool cvBackAuto;
int icoBack;
ShadingPattern ipat;
ShadingType shadingType;
/// 24-bit foreground color
unsigned int cvFore;
bool cvForeAuto;
/// Foreground color.
/// Only used if cvFore is not set
int icoFore;
/// 24-bit background color
unsigned int cvBack;
bool cvBackAuto;
/// Background color.
/// Only used if cvBack is not set.
int icoBack;
/// Shading pattern
ShadingPattern ipat;
/// Shading type
ShadingType shadingType;
/// Shading special vale
ShadingSpecialValue shadingSpecialValue;
public:
@ -227,7 +236,7 @@ namespace DocFileFormat
else if (0x0F == icoBack) { cvBack = RGB2 (0x80, 0x80, 0x80); }
else if (0x10 == icoBack) { cvBack = RGB2 (0xC0, 0xC0, 0xC0); }
// .... если будут документы с такими цветовыми палитрами
// TODO : если будут документы с такими цветовыми палитрами
//if ((cvFore == 0) && (icoFore == 0x0) && (cvBack == 0) && (icoBack == 0x0) && (ipat == Automatic))
//{
@ -241,6 +250,7 @@ namespace DocFileFormat
}
else
{
//throw new ByteParseException("Cannot parse the struct SHD, the length of the struct doesn't match");
}
}
}

View File

@ -96,8 +96,6 @@ namespace DocFileFormat
{
friend class TextboxMapping;
public:
static const int STRUCTURE_SIZE = 22;
struct FTXBXSReusable
{
int iNextReuse;
@ -110,6 +108,8 @@ namespace DocFileFormat
int cTxbxEdit; // This value MUST be zero and MUST be ignored.
};
static const int STRUCTURE_SIZE = 22;
FTXBXS ()
{

View File

@ -50,8 +50,9 @@ namespace DocFileFormat
void SetTextboxStyle(const std::wstring & style);
private:
static int TextboxCount;
static int TextboxCount;
int m_nTBIndex;
double m_dxTextLeft;

View File

@ -189,6 +189,7 @@ namespace DocFileFormat
return res;
}
//---------------------------------------------------------------
static int count_vml_objects = 0;
void VMLPictureMapping::appendStyleProperty(std::wstring* b, const std::wstring& propName, const std::wstring& propValue) const
{
if ( b != NULL )
@ -214,6 +215,8 @@ namespace DocFileFormat
m_isEmbedded = false;
m_imageData = new XMLTools::XMLElement<wchar_t>( _T( "v:imagedata" ) );
m_ShapeId = std::wstring(L"_x0000_i") + FormatUtils::IntToWideString(1024 + (count_vml_objects++));
}
VMLPictureMapping::~VMLPictureMapping()
@ -260,12 +263,7 @@ namespace DocFileFormat
m_pXmlWriter->WriteAttribute( _T( "type" ), std::wstring( _T( "#" ) + VMLShapeTypeMapping::GenerateTypeId(&type)).c_str());
count_vml_objects++;
if (m_shapeId.empty())
m_shapeId = std::wstring(L"_x0000_s") + FormatUtils::IntToWideString(1024 + count_vml_objects);
m_pXmlWriter->WriteAttribute( _T( "id" ), m_shapeId.c_str() );
m_pXmlWriter->WriteAttribute( _T( "id" ), m_ShapeId.c_str() );
if (m_isOlePreview)
{
@ -428,6 +426,11 @@ namespace DocFileFormat
m_pXmlWriter->WriteNodeEnd( _T( "v:shape" ) );
}
std::wstring VMLPictureMapping::GetShapeId () const
{
return m_ShapeId;
}
void VMLPictureMapping::writePictureBorder( const std::wstring & name, const BorderCode* brc )
{
if (!brc || name.empty()) return;

View File

@ -54,6 +54,8 @@ namespace DocFileFormat
VMLPictureMapping( ConversionContext* ctx, XMLTools::CStringXmlWriter* writer, bool olePreview, IMapping* caller, bool isInlinePicture = false );
virtual ~VMLPictureMapping();
virtual void Apply( IVisitable* visited );
std::wstring GetShapeId() const;
private:
/// Writes a border element
void writePictureBorder (const std::wstring & name, const BorderCode* brc);
@ -73,13 +75,12 @@ namespace DocFileFormat
bool m_isEmbedded;
std::string m_embeddedData;
std::wstring m_equationXml;
std::wstring m_shapeId;
private:
ConversionContext* m_ctx;
IMapping* m_caller;
int m_nImageId;
std::wstring m_ShapeId;
bool m_isOlePreview;
bool m_isInlinePicture;

File diff suppressed because it is too large Load Diff

View File

@ -68,8 +68,7 @@ namespace DocFileFormat
static std::wstring mapHorizontalPosition (PositionHorizontal hPos );
static std::wstring mapHorizontalPositionRelative(int hRel );
bool m_isBullete;
std::wstring m_shapeId;
bool m_isBullete;
private:
void ApplyPrimitives (DrawingPrimitives * primitives );
@ -130,7 +129,7 @@ namespace DocFileFormat
BlipStoreContainer* m_pBlipStore;
int m_nImageId;
std::wstring m_textPathStyle;
ConversionContext* m_context;
ConversionContext* m_ctx;
PictureDescriptor* m_pict;
XMLTools::XMLElement<wchar_t> m_fill;

View File

@ -37,8 +37,6 @@
namespace DocFileFormat
{
static int count_vml_objects = 0;
class VMLShapeTypeMapping: public PropertiesMapping, public IMapping
{
private:

View File

@ -49,7 +49,7 @@ namespace DocFileFormat
EndnoteReferenceCharactersPlex(NULL), FieldsPlex(NULL), FootnoteDocumentFieldsPlex(NULL),
EndnoteDocumentFieldsPlex(NULL), HeadersAndFootersDocumentFieldsPlex(NULL), HeaderStoriesPlex(NULL),
AnnotationsReferencePlex(NULL), IndividualCommentsPlex(NULL), TextboxBreakPlex(NULL), TextboxBreakPlexHeader(NULL),
TextboxIndividualPlex(NULL),AssocNames(NULL), BookmarkAnnotNames(NULL), Captions(NULL), AutoCaptions(NULL), ListPlex(NULL),
TextboxIndividualPlex(NULL),
OfficeDrawingPlex(NULL), OfficeDrawingPlexHeader(NULL), SectionPlex(NULL), BookmarkStartPlex(NULL), BookmarkEndPlex(NULL),
AutoTextPlex(NULL), AllPapxFkps(NULL), AllChpxFkps(NULL), AllPapx(NULL), AllPapxVector(NULL), AllSepx(NULL), Styles(NULL), listTable(NULL),
AnnotationOwners(NULL), DocProperties(NULL), listFormatOverrideTable(NULL), headerAndFooterTable(NULL), encryptionHeader(NULL)
@ -218,14 +218,10 @@ namespace DocFileFormat
m_pStorage->GetStream ("WordDocument", &TableStream);
}
RevisionAuthorTable = new StringTable<WideString> (TableStream, FIB->m_FibWord97.fcSttbfRMark, FIB->m_FibWord97.lcbSttbfRMark, bOlderVersion);
FontTable = new StringTable<FontFamilyName> (TableStream, FIB->m_FibWord97.fcSttbfFfn, FIB->m_FibWord97.lcbSttbfFfn, bOlderVersion);
BookmarkNames = new StringTable<WideString> (TableStream, FIB->m_FibWord97.fcSttbfBkmk, FIB->m_FibWord97.lcbSttbfBkmk, bOlderVersion);
AutoTextNames = new StringTable<WideString> (TableStream, FIB->m_FibWord97.fcSttbfGlsy, FIB->m_FibWord97.lcbSttbfGlsy, bOlderVersion);
AssocNames = new StringTable<WideString> (TableStream, FIB->m_FibWord97.fcSttbfAssoc, FIB->m_FibWord97.lcbSttbfAssoc, bOlderVersion);
BookmarkAnnotNames = new StringTable<WideString> (TableStream, FIB->m_FibWord97.fcSttbfAtnBkmk, FIB->m_FibWord97.lcbSttbfAtnBkmk, bOlderVersion);
Captions = new StringTable<WideString> (TableStream, FIB->m_FibWord97.fcSttbfCaption, FIB->m_FibWord97.lcbSttbfCaption, bOlderVersion);
AutoCaptions = new StringTable<WideString> (TableStream, FIB->m_FibWord97.fcSttbfAutoCaption, FIB->m_FibWord97.lcbSttbfAutoCaption, bOlderVersion);
RevisionAuthorTable = new StringTable<WideString> (TableStream, FIB->m_FibWord97.fcSttbfRMark, FIB->m_FibWord97.lcbSttbfRMark, bOlderVersion);
FontTable = new StringTable<FontFamilyName> (TableStream, FIB->m_FibWord97.fcSttbfFfn, FIB->m_FibWord97.lcbSttbfFfn, bOlderVersion);
BookmarkNames = new StringTable<WideString> (TableStream, FIB->m_FibWord97.fcSttbfBkmk, FIB->m_FibWord97.lcbSttbfBkmk, bOlderVersion);
AutoTextNames = new StringTable<WideString> (TableStream, FIB->m_FibWord97.fcSttbfGlsy, FIB->m_FibWord97.lcbSttbfGlsy, bOlderVersion);
if (m_pCallFunc)
{
@ -272,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<FTXBXS> (FTXBXS::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcftxbxTxt, FIB->m_FibWord97.lcbPlcftxbxTxt, bOlderVersion);
TextboxIndividualPlex = new Plex<EmptyStructure> (EmptyStructure::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);
@ -290,13 +286,12 @@ namespace DocFileFormat
}
}
AutoTextPlex = new Plex<EmptyStructure>(EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfGlsy, FIB->m_FibWord97.lcbPlcfGlsy, bOlderVersion);
FieldsPlex = new Plex<FieldCharacter>(FieldCharacter::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfFldMom, FIB->m_FibWord97.lcbPlcfFldMom, bOlderVersion);
FootnoteDocumentFieldsPlex = new Plex<FieldCharacter>(FieldCharacter::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfFldFtn, FIB->m_FibWord97.lcbPlcfFldFtn, bOlderVersion);
EndnoteDocumentFieldsPlex = new Plex<FieldCharacter>(FieldCharacter::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfFldEdn, FIB->m_FibWord97.lcbPlcfFldEdn, bOlderVersion);
HeadersAndFootersDocumentFieldsPlex = new Plex<FieldCharacter>(FieldCharacter::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfFldHdr, FIB->m_FibWord97.lcbPlcfFldHdr, bOlderVersion);
ListPlex = new Plex<ListNumCache> (ListNumCache::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfBteLvc, FIB->m_FibWord97.lcbPlcfBteLvc, bOlderVersion);
AutoTextPlex = new Plex<EmptyStructure> (EmptyStructure::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfGlsy, FIB->m_FibWord97.lcbPlcfGlsy, bOlderVersion);
FieldsPlex = new Plex<FieldCharacter> (FieldCharacter::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfFldMom, FIB->m_FibWord97.lcbPlcfFldMom, bOlderVersion);
FootnoteDocumentFieldsPlex = new Plex<FieldCharacter> (FieldCharacter::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfFldFtn, FIB->m_FibWord97.lcbPlcfFldFtn, bOlderVersion);
EndnoteDocumentFieldsPlex = new Plex<FieldCharacter> (FieldCharacter::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfFldEdn, FIB->m_FibWord97.lcbPlcfFldEdn, bOlderVersion);
HeadersAndFootersDocumentFieldsPlex = new Plex<FieldCharacter> (FieldCharacter::STRUCTURE_SIZE, TableStream, FIB->m_FibWord97.fcPlcfFldHdr, FIB->m_FibWord97.lcbPlcfFldHdr, bOlderVersion);
if (m_pCallFunc)
{
m_pCallFunc->OnProgress(m_pCallFunc->caller, DOC_ONPROGRESSEVENT_ID, 200000 );
@ -597,11 +592,6 @@ namespace DocFileFormat
RELEASEOBJECT(FontTable);
RELEASEOBJECT(BookmarkNames);
RELEASEOBJECT(AutoTextNames);
RELEASEOBJECT(AutoCaptions);
RELEASEOBJECT(Captions);
RELEASEOBJECT(BookmarkAnnotNames);
RELEASEOBJECT(AssocNames);
RELEASEOBJECT(IndividualFootnotesPlex);
RELEASEOBJECT(FootnoteReferenceCharactersPlex);
RELEASEOBJECT(IndividualEndnotesPlex);
@ -623,7 +613,6 @@ namespace DocFileFormat
RELEASEOBJECT(BookmarkStartPlex);
RELEASEOBJECT(BookmarkEndPlex);
RELEASEOBJECT(AutoTextPlex);
RELEASEOBJECT(ListPlex);
RELEASEOBJECT(Styles);
RELEASEOBJECT(listTable);
RELEASEOBJECT(AllPapx);
@ -710,7 +699,8 @@ namespace DocFileFormat
{
FormattedDiskPageCHPX *fkp = (*iter);
// get the CHPX
// get the CHPX
for (unsigned int j = 0; j < fkp->grpchpxSize; ++j)
{
if ( ( fkp->rgfc[j] < fcMin ) && ( fkp->rgfc[j + 1] > fcMin ) )

View File

@ -177,10 +177,6 @@ namespace DocFileFormat
StringTable<FontFamilyName> *FontTable; // A list of all font names, used in the doucument
StringTable<WideString> *BookmarkNames;
StringTable<WideString> *AutoTextNames;
StringTable<WideString> *AssocNames;
StringTable<WideString> *BookmarkAnnotNames;
StringTable<WideString> *Captions;
StringTable<WideString> *AutoCaptions;
Plex<EmptyStructure> *IndividualFootnotesPlex; //A plex of locations of individual footnotes
Plex<FootnoteDescriptor> *FootnoteReferenceCharactersPlex; //A plex of footnote reference characters
@ -191,7 +187,7 @@ namespace DocFileFormat
Plex<EmptyStructure> *HeaderStoriesPlex; //A plex of the header document
Plex<EmptyStructure> *IndividualCommentsPlex; // A plex with all ATRDPre10 structs
Plex<FTXBXS> *TextboxIndividualPlex;
Plex<EmptyStructure> *TextboxIndividualPlex;
Plex<Tbkd> *TextboxBreakPlex; // Describes the breaks inside the textbox subdocument
Plex<Tbkd> *TextboxBreakPlexHeader; // Describes the breaks inside the header textbox subdocument
@ -204,14 +200,13 @@ namespace DocFileFormat
Plex<BookmarkFirst> *BookmarkStartPlex;
Plex<EmptyStructure> *BookmarkEndPlex;
Plex<ListNumCache> *ListPlex;
Plex<FieldCharacter> *FieldsPlex;
Plex<FieldCharacter> *FootnoteDocumentFieldsPlex;
Plex<FieldCharacter> *EndnoteDocumentFieldsPlex;
Plex<FieldCharacter> *HeadersAndFootersDocumentFieldsPlex;
Plex<AnnotationReferenceDescriptor> *AnnotationsReferencePlex;
Plex<EmptyStructure> *AutoTextPlex;
// Each character position specifies the beginning of a range of text that constitutes the contents of an AutoText item
Plex<EmptyStructure> *AutoTextPlex; // Each character position specifies the beginning of\
a range of text that constitutes the contents of an AutoText item
};
}

View File

@ -40,8 +40,7 @@ SOURCES += \
../../../Common/3dParty/pole/pole.cpp \
../../DocDocxConverter/EncryptionHeader.cpp \
../../DocDocxConverter/DrawingPrimitives.cpp \
../../DocDocxConverter/Spa.cpp \
../../DocDocxConverter/OleObject.cpp
../../DocDocxConverter/Spa.cpp
build_fast {
SOURCES += \

View File

@ -555,10 +555,6 @@
RelativePath="..\..\DocDocxConverter\OfficeArtContent.h"
>
</File>
<File
RelativePath="..\..\DocDocxConverter\OleObject.cpp"
>
</File>
<File
RelativePath="..\..\DocDocxConverter\OleObject.h"
>

View File

@ -50,10 +50,8 @@
int _tmain(int argc, _TCHAR* argv[])
{
if (argc < 2) return 1;
std::wstring sSrcDoc = argv[1];
std::wstring sDstDocx = argc > 2 ? argv[2] : sSrcDoc + L"-my.docx";
std::wstring sDstDocx = argv[2];
std::wstring outputDir = FileSystem::Directory::GetFolderPath(sDstDocx);
std::wstring dstTempPath = FileSystem::Directory::CreateDirectoryWithUniqueName(outputDir);

View File

@ -71,7 +71,7 @@ namespace Writers
if(false == IsEmpty())
{
OOX::CPath pathChartDir = m_sDir + FILE_SEPARATOR_STR + _T("word") + FILE_SEPARATOR_STR + _T("charts");
FileSystem::Directory::CreateDirectory(pathChartDir.GetPath());
FileSystem::Directory::CreateDirectory(string2std_string(pathChartDir.GetPath()));
for(int i = 0, length = m_aCharts.size(); i < length; ++i)
{
@ -80,7 +80,7 @@ namespace Writers
OOX::CPath filePath = pathChartDir + FILE_SEPARATOR_STR + elem->filename;
NSFile::CFileBinary oFile;
oFile.CreateFileW(filePath.GetPath());
oFile.CreateFileW(string2std_string(filePath.GetPath()));
oFile.WriteStringUTF8(L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\r\n");
oFile.WriteStringUTF8(elem->content);
oFile.CloseFile();
@ -91,15 +91,14 @@ namespace Writers
}
}
}
void AddChart(std::wstring& content, std::wstring& sRelsName, std::wstring& sFileName, int& index)
void AddChart(std::wstring& content, CString& sRelsName, CString& sFileName, int& index)
{
ChartElem* pChartElem = new ChartElem();
pChartElem->content = content;
pChartElem->index = nChartCount + 1;
nChartCount++;
pChartElem->filename.Format(L"chart%d.xml", pChartElem->index);
sRelsName = L"charts/" + pChartElem->filename;
pChartElem->filename.Format(_T("chart%d.xml"), pChartElem->index);
sRelsName = _T("charts/") + pChartElem->filename;
sFileName = pChartElem->filename;
index = pChartElem->index;

View File

@ -53,22 +53,13 @@ namespace Writers
CFile oFile;
oFile.CreateFile(filePath.GetPath());
oFile.WriteStringUTF8(CString(_T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>")));
oFile.WriteStringUTF8(CString(_T("<w:document xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" mc:Ignorable=\"w14 wp14\">")));
oFile.WriteStringUTF8(m_oBackground.GetData());
oFile.WriteStringUTF8(CString(_T("<w:body>")));
oFile.WriteStringUTF8(m_oContent.GetData());
oFile.WriteStringUTF8(CString(_T("<w:sectPr >")));
oFile.WriteStringUTF8(WriteSectPrHdrFtr());
oFile.WriteStringUTF8(m_oSecPr.GetData());
oFile.WriteStringUTF8(CString(_T("</w:sectPr>")));
oFile.WriteStringUTF8(CString(_T("</w:body>")));
oFile.WriteStringUTF8(CString(_T("</w:document>")));
oFile.WriteStringUTF8(CString(_T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:document xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" mc:Ignorable=\"w14 wp14\"><w:body>")));
oFile.WriteStringUTF8(m_oContent.GetData());
oFile.WriteStringUTF8(CString(_T("<w:sectPr >")));
oFile.WriteStringUTF8(WriteSectPrHdrFtr());
oFile.WriteStringUTF8(m_oSecPr.GetData());
oFile.WriteStringUTF8(CString(_T("</w:sectPr>")));
oFile.WriteStringUTF8(CString(_T("</w:body></w:document>")));
oFile.CloseFile();
}
CString WriteSectPrHdrFtr()

View File

@ -39,8 +39,7 @@ namespace Writers
class ContentWriter
{
public:
XmlUtils::CStringWriter m_oBackground;
XmlUtils::CStringWriter m_oContent;
XmlUtils::CStringWriter m_oContent;
XmlUtils::CStringWriter m_oSecPr;
};
class HdrFtrItem

View File

@ -74,10 +74,10 @@ namespace Writers
{
CString sNewImagePath = AddImageGetNewPath();
NSFile::CFileBinary oFile;
oFile.CreateFileW(sNewImagePath);
oFile.CreateFileW(string2std_string(sNewImagePath));
oFile.WriteFile(pData, dwSizeRead);
oFile.CloseFile();
CString sFilename = NSSystemPath::GetFileName(sNewImagePath);
CString sFilename = NSSystemPath::GetFileName(string2std_string(sNewImagePath)).c_str();
m_aImageNames.push_back(sFilename);
}
RELEASEARRAYOBJECTS(pData);
@ -87,8 +87,8 @@ namespace Writers
{
OOX::CPath pathNewImg = AddImageGetNewPath();
NSFile::CFileBinary::Copy(sImg, pathNewImg.GetPath());
CString sFilename = NSSystemPath::GetFileName(pathNewImg.GetPath()).c_str();
NSFile::CFileBinary::Copy(string2std_string(sImg), string2std_string(pathNewImg.GetPath()));
CString sFilename = NSSystemPath::GetFileName(string2std_string(pathNewImg.GetPath())).c_str();
m_aImageNames.push_back(sFilename);
}
};

View File

@ -265,64 +265,19 @@ public:
bBeforeAuto = false;
}
};
class Background
{
public:
docRGB Color;
CThemeColor ThemeColor;
CString sObject;
bool bColor;
bool bThemeColor;
Background() : bColor (false), bThemeColor(false) {}
CString Write()
{
CString sBackground = L"<w:background";
if(bColor)
{
sBackground += L" w:color=\"" + Color.ToString() + L"\"";
}
if(bThemeColor && ThemeColor.IsNoEmpty())
{
if(ThemeColor.bColor)
sBackground += L" w:themeColor=\"" + ThemeColor.ToStringColor() + L"\"";
if(ThemeColor.bTint)
sBackground += L" w:themeColorTint=\"" + ThemeColor.ToStringTint() + L"\"";
if(ThemeColor.bShade)
sBackground += L" w:themeColorShade=\"" + ThemeColor.ToStringShade() + L"\"";
}
if (!bColor && !bThemeColor)
{
sBackground += L" w:color=\"ffffff\"";
}
sBackground += L">";
sBackground += sObject;
sBackground += L"</w:background>";
return sBackground;
}
};
class Shd
{
public:
BYTE Value;
docRGB Color;
BYTE Value;
docRGB Color;
CThemeColor ThemeColor;
bool bColor;
bool bThemeColor;
Shd()
{
Value = shd_Nil;
bColor = false;
Value = shd_Nil;
bColor = false;
bThemeColor = false;
}
CString ToString()
@ -1846,7 +1801,87 @@ public:
return sRes;
}
};
//class CComment
//{
//public:
// int Id;
// CString Initials;
// CString UserName;
// CString Date;
// CString Text;
// CAtlArray<CComment*> replies;
//
// bool bId;
//public:
// CComment()
// {
// bId = false;
// }
// ~CComment()
// {
// for(int i = 0, length = replies.GetCount(); i < length; ++i)
// {
// delete replies[i];
// }
// replies.RemoveAll();
// }
// CString Write()
// {
// CString sRes;
// if(bId)
// {
// sRes.AppendFormat(_T("<w:comment w:id=\"%d\""), Id);
// if(false == UserName.IsEmpty())
// {
// CString sUserName = XmlUtils::EncodeXmlString(UserName);
// sRes.AppendFormat(_T(" w:author=\"%ls\""), sUserName);
// }
// if(false == Date.IsEmpty())
// {
// CString sDate = XmlUtils::EncodeXmlString(Date);
// sRes.AppendFormat(_T(" w:date=\"%ls\""), sDate);
// }
// if(false == Initials.IsEmpty())
// {
// CString sInitials = XmlUtils::EncodeXmlString(Initials);
// sRes.AppendFormat(_T(" w:initials=\"%ls\""), sInitials);
// }
// sRes.Append(_T(">"));
//
// sRes.Append(WriteCommentContent(this, true));
//
// sRes.Append(_T("</w:comment>"));
// }
// return sRes;
// }
//private:
// CString WriteCommentContent(CComment* pComment, bool bCheckLast)
// {
// CString sRes;
// CString sFormat = _T("<w:p><w:pPr><w:spacing w:line=\"240\" w:after=\"0\" w:lineRule=\"auto\" w:before=\"0\"/><w:ind w:firstLine=\"0\" w:left=\"0\" w:right=\"0\"/><w:jc w:val=\"left\"/></w:pPr><w:r><w:rPr><w:rFonts w:eastAsia=\"Arial\" w:ascii=\"Arial\" w:hAnsi=\"Arial\" w:cs=\"Arial\"/><w:sz w:val=\"22\"/></w:rPr><w:t xml:space=\"preserve\">%ls</w:t></w:r></w:p>");
// CString sName = XmlUtils::EncodeXmlString(pComment->UserName + _T(":"));
// sRes.AppendFormat(sFormat, sName);
// if(false == pComment->Text.IsEmpty())
// {
// CString sText = XmlUtils::EncodeXmlString(pComment->Text);
// sRes.AppendFormat(sFormat, sText);
// }
// if(false == bCheckLast || pComment->replies.GetCount() > 0)
// sRes.Append(_T("<w:p><w:pPr><w:pBdr><w:top w:space=\"1\" w:sz=\"4\" w:color=\"auto\" w:val=\"single\"/></w:pBdr></w:pPr></w:p>"));
//
// if(pComment->replies.GetCount() > 0)
// {
// for(int i = 0, length = pComment->replies.GetCount(); i < length; ++i)
// {
// if(i != length - 1)
// sRes += WriteCommentContent(pComment->replies[i], false);
// else
// sRes += WriteCommentContent(pComment->replies[i], bCheckLast);
// }
// }
// return sRes;
// }
//};
class CDrawingPropertyWrapPoint
{
public:
@ -1889,42 +1924,41 @@ public:
class CDrawingProperty
{
public:
long DataPos;
long DataLength;
BYTE Type;
bool BehindDoc;
double DistL;
double DistT;
double DistR;
double DistB;
bool LayoutInCell;
long DataPos;
long DataLength;
BYTE Type;
bool BehindDoc;
double DistL;
double DistT;
double DistR;
double DistB;
bool LayoutInCell;
unsigned long RelativeHeight;
bool BSimplePos;
double EffectExtentL;
double EffectExtentT;
double EffectExtentR;
double EffectExtentB;
double Width;
double Height;
BYTE PositionHRelativeFrom;
BYTE PositionHAlign;
double PositionHPosOffset;
double PositionHPctOffset;
BYTE PositionVRelativeFrom;
BYTE PositionVAlign;
double PositionVPosOffset;
double PositionVPctOffset;
double SimplePosX;
double SimplePosY;
CString sChartRels;
CString sSizeRelH;
CString sSizeRelV;
int m_nDocPr;
CString sGraphicFramePr;
bool BSimplePos;
double EffectExtentL;
double EffectExtentT;
double EffectExtentR;
double EffectExtentB;
double Width;
double Height;
BYTE PositionHRelativeFrom;
BYTE PositionHAlign;
double PositionHPosOffset;
double PositionHPctOffset;
BYTE PositionVRelativeFrom;
BYTE PositionVAlign;
double PositionVPosOffset;
double PositionVPctOffset;
double SimplePosX;
double SimplePosY;
CDrawingPropertyWrap DrawingPropertyWrap;
CString sChartRels;
CString sSizeRelH;
CString sSizeRelV;
int m_nDocPr;
CString sGraphicFramePr;
CDrawingPropertyWrap DrawingPropertyWrap;
bool bDataPos;
bool bDataPos;
bool bDataLength;
bool bType;
bool bBehindDoc;
@ -1952,37 +1986,36 @@ public:
bool bSimplePosX;
bool bSimplePosY;
bool bDrawingPropertyWrap;
CDrawingProperty(int nDocPr)
CDrawingProperty(int nDocPr)
{
m_nDocPr = nDocPr;
bDataPos = false;
m_nDocPr = nDocPr;
bDataPos = false;
bDataLength = false;
bType = false;
bBehindDoc = false;
bDistL = false;
bDistT = false;
bDistR = false;
bDistB = false;
bLayoutInCell = false;
bType = false;
bBehindDoc = false;
bDistL = false;
bDistT = false;
bDistR = false;
bDistB = false;
bLayoutInCell = false;
bRelativeHeight = false;
bBSimplePos = false;
bEffectExtentL = false;
bEffectExtentT = false;
bEffectExtentR = false;
bEffectExtentB = false;
bWidth = false;
bHeight = false;
bBSimplePos = false;
bEffectExtentL = false;
bEffectExtentT = false;
bEffectExtentR = false;
bEffectExtentB = false;
bWidth = false;
bHeight = false;
bPositionHRelativeFrom = false;
bPositionHAlign = false;
bPositionHAlign = false;
bPositionHPosOffset = false;
bPositionHPctOffset = false;
bPositionVRelativeFrom = false;
bPositionVAlign = false;
bPositionVAlign = false;
bPositionVPosOffset = false;
bPositionVPctOffset = false;
bSimplePosX = false;
bSimplePosY = false;
bSimplePosX = false;
bSimplePosY = false;
bDrawingPropertyWrap = false;
}
bool IsChart()
@ -1991,284 +2024,284 @@ public:
}
CString Write()
{
if(!bType) return L"";
CString sXml;
if(bType)
{
bool bChart = IsChart();
if(c_oAscWrapStyle::Inline == Type)
{
if(bWidth && bHeight)
{
__int64 emuWidth = (__int64)(g_dKoef_mm_to_emu * Width);
__int64 emuHeight = (__int64)(g_dKoef_mm_to_emu * Height);
if(false == bChart)
sXml.AppendFormat(_T("<wp:inline xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" distT=\"0\" distB=\"0\" distL=\"0\" distR=\"0\"><wp:extent cx=\"%lld\" cy=\"%lld\"/>"), emuWidth, emuHeight);
else
sXml.AppendFormat(_T("<w:drawing><wp:inline distT=\"0\" distB=\"0\" distL=\"0\" distR=\"0\"><wp:extent cx=\"%lld\" cy=\"%lld\"/>"), emuWidth, emuHeight);
if(bEffectExtentL && bEffectExtentT && bEffectExtentR && bEffectExtentB)
{
__int64 emuEffectExtentL = (__int64)(g_dKoef_mm_to_emu * EffectExtentL);
__int64 emuEffectExtentT = (__int64)(g_dKoef_mm_to_emu * EffectExtentT);
__int64 emuEffectExtentR = (__int64)(g_dKoef_mm_to_emu * EffectExtentR);
__int64 emuEffectExtentB = (__int64)(g_dKoef_mm_to_emu * EffectExtentB);
sXml.AppendFormat(_T("<wp:effectExtent l=\"%lld\" t=\"%lld\" r=\"%lld\" b=\"%lld\"/>"), emuEffectExtentL, emuEffectExtentT, emuEffectExtentR, emuEffectExtentB);
}
CString sXml;
if(bChart)
{
sXml.AppendFormat(_T("<wp:docPr id=\"%d\" name=\"Chart %d\"/>"), m_nDocPr, m_nDocPr);
}
else
{
sXml.AppendFormat(_T("<wp:docPr id=\"%d\" name=\"\"/>"), m_nDocPr);
}
if(!sGraphicFramePr.IsEmpty())
{
sXml.Append(sGraphicFramePr);
}
else
{
sXml.Append(_T("<wp:cNvGraphicFramePr/>"));
}
if(bChart)
{
sXml.AppendFormat(_T("<a:graphic xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\"><a:graphicData uri=\"http://schemas.openxmlformats.org/drawingml/2006/chart\"><c:chart xmlns:c=\"http://schemas.openxmlformats.org/drawingml/2006/chart\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" r:id=\"%ls\"/></a:graphicData></a:graphic></wp:inline></w:drawing>"), (const TCHAR *) sChartRels);
}
else
{
sXml.Append(_T("</wp:inline>"));
}
}
}
else
{
if(bWidth && bHeight && ((bPositionHRelativeFrom && (bPositionHAlign || bPositionHPosOffset || bPositionHPctOffset)
&& bPositionVRelativeFrom && (bPositionVAlign || bPositionVPosOffset || bPositionVPctOffset))
|| (bBSimplePos && bSimplePosX && bSimplePosY)))
{
__int64 emuDistL = 0;
__int64 emuDistT = 0;
__int64 emuDistR = 0;
__int64 emuDistB = 0;
bool bChart = IsChart();
if(c_oAscWrapStyle::Inline == Type)
{
if(bWidth && bHeight)
{
__int64 emuWidth = (__int64)(g_dKoef_mm_to_emu * Width);
__int64 emuHeight = (__int64)(g_dKoef_mm_to_emu * Height);
if(false == bChart)
sXml.AppendFormat(_T("<wp:inline xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" distT=\"0\" distB=\"0\" distL=\"0\" distR=\"0\"><wp:extent cx=\"%lld\" cy=\"%lld\"/>"), emuWidth, emuHeight);
else
sXml.AppendFormat(_T("<w:drawing><wp:inline distT=\"0\" distB=\"0\" distL=\"0\" distR=\"0\"><wp:extent cx=\"%lld\" cy=\"%lld\"/>"), emuWidth, emuHeight);
if(bEffectExtentL && bEffectExtentT && bEffectExtentR && bEffectExtentB)
{
__int64 emuEffectExtentL = (__int64)(g_dKoef_mm_to_emu * EffectExtentL);
__int64 emuEffectExtentT = (__int64)(g_dKoef_mm_to_emu * EffectExtentT);
__int64 emuEffectExtentR = (__int64)(g_dKoef_mm_to_emu * EffectExtentR);
__int64 emuEffectExtentB = (__int64)(g_dKoef_mm_to_emu * EffectExtentB);
sXml.AppendFormat(_T("<wp:effectExtent l=\"%lld\" t=\"%lld\" r=\"%lld\" b=\"%lld\"/>"), emuEffectExtentL, emuEffectExtentT, emuEffectExtentR, emuEffectExtentB);
}
if(bDistL)
emuDistL = (__int64)(g_dKoef_mm_to_emu * DistL);
if(bDistT)
emuDistT = (__int64)(g_dKoef_mm_to_emu * DistT);
if(bDistR)
emuDistR = (__int64)(g_dKoef_mm_to_emu * DistR);
if(bDistB)
emuDistB = (__int64)(g_dKoef_mm_to_emu * DistB);
int nSimplePos = 0;
if(bBSimplePos && BSimplePos)
nSimplePos = 1;
int nRelativeHeight = 0;
if(bRelativeHeight)
nRelativeHeight = RelativeHeight;
int nBehindDoc = 0;
if(bBehindDoc && BehindDoc)
nBehindDoc = 1;
int nLayoutInCell = 1;
if(bLayoutInCell && false == LayoutInCell)
nLayoutInCell = 0;
if(bChart)
{
sXml.AppendFormat(_T("<wp:docPr id=\"%d\" name=\"Chart %d\"/>"), m_nDocPr, m_nDocPr);
}
else
{
sXml.AppendFormat(_T("<wp:docPr id=\"%d\" name=\"\"/>"), m_nDocPr);
}
if(!sGraphicFramePr.IsEmpty())
{
sXml.Append(sGraphicFramePr);
}
else
{
sXml.Append(_T("<wp:cNvGraphicFramePr/>"));
}
if(bChart)
{
sXml.AppendFormat(_T("<a:graphic xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\"><a:graphicData uri=\"http://schemas.openxmlformats.org/drawingml/2006/chart\"><c:chart xmlns:c=\"http://schemas.openxmlformats.org/drawingml/2006/chart\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" r:id=\"%ls\"/></a:graphicData></a:graphic></wp:inline></w:drawing>"), (const TCHAR *) sChartRels);
}
else
{
sXml.Append(_T("</wp:inline>"));
}
}
}
else
{
if(bWidth && bHeight && ((bPositionHRelativeFrom && (bPositionHAlign || bPositionHPosOffset || bPositionHPctOffset)
&& bPositionVRelativeFrom && (bPositionVAlign || bPositionVPosOffset || bPositionVPctOffset))
|| (bBSimplePos && bSimplePosX && bSimplePosY)))
{
__int64 emuDistL = 0;
__int64 emuDistT = 0;
__int64 emuDistR = 0;
__int64 emuDistB = 0;
if(bChart)
sXml.Append(_T("<w:drawing>"));
if(bDistL)
emuDistL = (__int64)(g_dKoef_mm_to_emu * DistL);
if(bDistT)
emuDistT = (__int64)(g_dKoef_mm_to_emu * DistT);
if(bDistR)
emuDistR = (__int64)(g_dKoef_mm_to_emu * DistR);
if(bDistB)
emuDistB = (__int64)(g_dKoef_mm_to_emu * DistB);
int nSimplePos = 0;
if(bBSimplePos && BSimplePos)
nSimplePos = 1;
int nRelativeHeight = 0;
if(bRelativeHeight)
nRelativeHeight = RelativeHeight;
int nBehindDoc = 0;
if(bBehindDoc && BehindDoc)
nBehindDoc = 1;
int nLayoutInCell = 1;
if(bLayoutInCell && false == LayoutInCell)
nLayoutInCell = 0;
sXml.AppendFormat(_T("<wp:anchor xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" distT=\"%lld\" distB=\"%lld\" distL=\"%lld\" distR=\"%lld\" simplePos=\"%d\" relativeHeight=\"%u\" behindDoc=\"%d\" locked=\"0\" layoutInCell=\"%d\" allowOverlap=\"1\">"), emuDistT, emuDistB, emuDistL, emuDistR, nSimplePos, nRelativeHeight, nBehindDoc, nLayoutInCell);
__int64 emuX = 0;
if(bSimplePosX)
emuX = (__int64)(g_dKoef_mm_to_emu * SimplePosX);
__int64 emuY = 0;
if(bSimplePosY)
emuY = (__int64)(g_dKoef_mm_to_emu * SimplePosY);
sXml.AppendFormat(_T("<wp:simplePos x=\"%lld\" y=\"%lld\"/>"), emuX, emuY);
if(bChart)
sXml.Append(_T("<w:drawing>"));
if(bPositionHRelativeFrom && (bPositionHAlign || bPositionHPosOffset || bPositionHPctOffset))
{
CString sRelativeFrom;
switch(PositionHRelativeFrom)
{
case 0: sRelativeFrom = _T("character");break;
case 1: sRelativeFrom = _T("column");break;
case 2: sRelativeFrom = _T("insideMargin");break;
case 3: sRelativeFrom = _T("leftMargin");break;
case 4: sRelativeFrom = _T("margin");break;
case 5: sRelativeFrom = _T("outsideMargin");break;
case 6: sRelativeFrom = _T("page");break;
case 7: sRelativeFrom = _T("rightMargin");break;
}
CString sContent;
if(bPositionHAlign)
{
switch(PositionHAlign)
{
case 0: sContent = _T("<wp:align>center</wp:align>");break;
case 1: sContent = _T("<wp:align>inside</wp:align>");break;
case 2: sContent = _T("<wp:align>left</wp:align>");break;
case 3: sContent = _T("<wp:align>outside</wp:align>");break;
case 4: sContent = _T("<wp:align>right</wp:align>");break;
}
}
else if(bPositionHPosOffset)
{
__int64 emuPosOffset = (__int64)(g_dKoef_mm_to_emu * PositionHPosOffset);
sContent.Format(_T("<wp:posOffset>%lld</wp:posOffset>"), emuPosOffset);
}
else if(bPositionHPctOffset)
{
long pctOffset = (long)(1000 * PositionHPctOffset);
sContent.Format(_T("<wp14:pctPosHOffset>%d</wp14:pctPosHOffset>"), pctOffset);
}
sXml.AppendFormat(_T("<wp:positionH relativeFrom=\"%ls\">%ls</wp:positionH>"), (const TCHAR *) sRelativeFrom, (const TCHAR *) sContent);
}
if(bPositionVRelativeFrom && (bPositionVAlign || bPositionVPosOffset || bPositionVPctOffset))
{
CString sRelativeFrom;
switch(PositionVRelativeFrom)
{
case 0: sRelativeFrom = _T("bottomMargin");break;
case 1: sRelativeFrom = _T("insideMargin");break;
case 2: sRelativeFrom = _T("line");break;
case 3: sRelativeFrom = _T("margin");break;
case 4: sRelativeFrom = _T("outsideMargin");break;
case 5: sRelativeFrom = _T("page");break;
case 6: sRelativeFrom = _T("paragraph");break;
case 7: sRelativeFrom = _T("topMargin");break;
}
CString sContent;
if(bPositionVAlign)
{
switch(PositionVAlign)
{
case 0: sContent = _T("<wp:align>bottom</wp:align>");break;
case 1: sContent = _T("<wp:align>center</wp:align>");break;
case 2: sContent = _T("<wp:align>inside</wp:align>");break;
case 3: sContent = _T("<wp:align>outside</wp:align>");break;
case 4: sContent = _T("<wp:align>top</wp:align>");break;
}
}
else if(bPositionVPosOffset)
{
__int64 emuPosOffset = (__int64)(g_dKoef_mm_to_emu * PositionVPosOffset);
sContent.Format(_T("<wp:posOffset>%lld</wp:posOffset>"), emuPosOffset);
}
else if(bPositionVPctOffset)
{
long pctOffset = (long)(1000 * PositionVPctOffset);
sContent.Format(_T("<wp14:pctPosVOffset>%d</wp14:pctPosVOffset>"), pctOffset);
}
sXml.AppendFormat(_T("<wp:positionV relativeFrom=\"%ls\">%ls</wp:positionV>"), (const TCHAR *) sRelativeFrom, (const TCHAR *) sContent);
}
__int64 emuWidth = (__int64)(g_dKoef_mm_to_emu * Width);
__int64 emuHeight = (__int64)(g_dKoef_mm_to_emu * Height);
sXml.AppendFormat(_T("<wp:extent cx=\"%lld\" cy=\"%lld\"/>"), emuWidth, emuHeight);
if(bEffectExtentL && bEffectExtentT && bEffectExtentR && bEffectExtentB)
{
__int64 emuEffectExtentL = (__int64)(g_dKoef_mm_to_emu * EffectExtentL);
__int64 emuEffectExtentT = (__int64)(g_dKoef_mm_to_emu * EffectExtentT);
__int64 emuEffectExtentR = (__int64)(g_dKoef_mm_to_emu * EffectExtentR);
__int64 emuEffectExtentB = (__int64)(g_dKoef_mm_to_emu * EffectExtentB);
sXml.AppendFormat(_T("<wp:effectExtent l=\"%lld\" t=\"%lld\" r=\"%lld\" b=\"%lld\"/>"), emuEffectExtentL, emuEffectExtentT, emuEffectExtentR, emuEffectExtentB);
}
if(bDrawingPropertyWrap && DrawingPropertyWrap.bWrappingType)
{
CString sTagName;
switch(DrawingPropertyWrap.WrappingType)
{
case c_oSerImageType2::WrapNone:sTagName = _T("wrapNone");break;
case c_oSerImageType2::WrapSquare:sTagName = _T("wrapSquare");break;
case c_oSerImageType2::WrapThrough:sTagName = _T("wrapThrough");break;
case c_oSerImageType2::WrapTight:sTagName = _T("wrapTight");break;
case c_oSerImageType2::WrapTopAndBottom:sTagName = _T("wrapTopAndBottom");break;
}
if(DrawingPropertyWrap.bStart || DrawingPropertyWrap.Points.size() > 0)
{
if( c_oSerImageType2::WrapSquare == DrawingPropertyWrap.WrappingType ||
c_oSerImageType2::WrapThrough == DrawingPropertyWrap.WrappingType ||
c_oSerImageType2::WrapTight == DrawingPropertyWrap.WrappingType)
{
sXml.AppendFormat(_T("<wp:%ls wrapText=\"bothSides\">"), (const TCHAR *) sTagName);
}
else
sXml.AppendFormat(_T("<wp:%ls>"), (const TCHAR *) sTagName);
sXml.AppendFormat(_T("<wp:anchor xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" distT=\"%lld\" distB=\"%lld\" distL=\"%lld\" distR=\"%lld\" simplePos=\"%d\" relativeHeight=\"%u\" behindDoc=\"%d\" locked=\"0\" layoutInCell=\"%d\" allowOverlap=\"1\">"), emuDistT, emuDistB, emuDistL, emuDistR, nSimplePos, nRelativeHeight, nBehindDoc, nLayoutInCell);
__int64 emuX = 0;
if(bSimplePosX)
emuX = (__int64)(g_dKoef_mm_to_emu * SimplePosX);
__int64 emuY = 0;
if(bSimplePosY)
emuY = (__int64)(g_dKoef_mm_to_emu * SimplePosY);
sXml.AppendFormat(_T("<wp:simplePos x=\"%lld\" y=\"%lld\"/>"), emuX, emuY);
int nEdited = 0;
if(DrawingPropertyWrap.bEdited && DrawingPropertyWrap.Edited)
nEdited = 1;
sXml.AppendFormat(_T("<wp:wrapPolygon edited=\"%d\">"), nEdited);
if(DrawingPropertyWrap.bStart && DrawingPropertyWrap.Start.bX && DrawingPropertyWrap.Start.bY)
{
__int64 emuX = (__int64)(g_dKoef_mm_to_emu * DrawingPropertyWrap.Start.X);
__int64 emuY = (__int64)(g_dKoef_mm_to_emu * DrawingPropertyWrap.Start.Y);
sXml.AppendFormat(_T("<wp:start x=\"%lld\" y=\"%lld\"/>"), emuX, emuY);
}
for(int i = 0, length = DrawingPropertyWrap.Points.size(); i < length; ++i)
{
CDrawingPropertyWrapPoint* pWrapPoint = DrawingPropertyWrap.Points[i];
if(pWrapPoint->bX && pWrapPoint->bY)
{
__int64 emuX = (__int64)(g_dKoef_mm_to_emu * pWrapPoint->X);
__int64 emuY = (__int64)(g_dKoef_mm_to_emu * pWrapPoint->Y);
sXml.AppendFormat(_T("<wp:lineTo x=\"%lld\" y=\"%lld\"/>"), emuX, emuY);
}
}
sXml.Append(_T("</wp:wrapPolygon>"));
sXml.AppendFormat(_T("</wp:%ls>"), (const TCHAR *) sTagName);
}
else
{
//для wrapThrough и wrapTight wrapPolygon обязательное поле, если его нет - меняем тип.
if( c_oSerImageType2::WrapSquare == DrawingPropertyWrap.WrappingType ||
c_oSerImageType2::WrapThrough == DrawingPropertyWrap.WrappingType ||
c_oSerImageType2::WrapTight == DrawingPropertyWrap.WrappingType)
{
sXml.Append(_T("<wp:wrapSquare wrapText=\"bothSides\"/>"));
}
else
sXml.AppendFormat(_T("<wp:%ls/>"), (const TCHAR *) sTagName);
}
}
else
sXml.Append(_T("<wp:wrapNone/>"));
if(bPositionHRelativeFrom && (bPositionHAlign || bPositionHPosOffset || bPositionHPctOffset))
{
CString sRelativeFrom;
switch(PositionHRelativeFrom)
{
case 0: sRelativeFrom = _T("character");break;
case 1: sRelativeFrom = _T("column");break;
case 2: sRelativeFrom = _T("insideMargin");break;
case 3: sRelativeFrom = _T("leftMargin");break;
case 4: sRelativeFrom = _T("margin");break;
case 5: sRelativeFrom = _T("outsideMargin");break;
case 6: sRelativeFrom = _T("page");break;
case 7: sRelativeFrom = _T("rightMargin");break;
}
CString sContent;
if(bPositionHAlign)
{
switch(PositionHAlign)
{
case 0: sContent = _T("<wp:align>center</wp:align>");break;
case 1: sContent = _T("<wp:align>inside</wp:align>");break;
case 2: sContent = _T("<wp:align>left</wp:align>");break;
case 3: sContent = _T("<wp:align>outside</wp:align>");break;
case 4: sContent = _T("<wp:align>right</wp:align>");break;
}
}
else if(bPositionHPosOffset)
{
__int64 emuPosOffset = (__int64)(g_dKoef_mm_to_emu * PositionHPosOffset);
sContent.Format(_T("<wp:posOffset>%lld</wp:posOffset>"), emuPosOffset);
}
else if(bPositionHPctOffset)
{
long pctOffset = (long)(1000 * PositionHPctOffset);
sContent.Format(_T("<wp14:pctPosHOffset>%d</wp14:pctPosHOffset>"), pctOffset);
}
sXml.AppendFormat(_T("<wp:positionH relativeFrom=\"%ls\">%ls</wp:positionH>"), (const TCHAR *) sRelativeFrom, (const TCHAR *) sContent);
}
if(bPositionVRelativeFrom && (bPositionVAlign || bPositionVPosOffset || bPositionVPctOffset))
{
CString sRelativeFrom;
switch(PositionVRelativeFrom)
{
case 0: sRelativeFrom = _T("bottomMargin");break;
case 1: sRelativeFrom = _T("insideMargin");break;
case 2: sRelativeFrom = _T("line");break;
case 3: sRelativeFrom = _T("margin");break;
case 4: sRelativeFrom = _T("outsideMargin");break;
case 5: sRelativeFrom = _T("page");break;
case 6: sRelativeFrom = _T("paragraph");break;
case 7: sRelativeFrom = _T("topMargin");break;
}
CString sContent;
if(bPositionVAlign)
{
switch(PositionVAlign)
{
case 0: sContent = _T("<wp:align>bottom</wp:align>");break;
case 1: sContent = _T("<wp:align>center</wp:align>");break;
case 2: sContent = _T("<wp:align>inside</wp:align>");break;
case 3: sContent = _T("<wp:align>outside</wp:align>");break;
case 4: sContent = _T("<wp:align>top</wp:align>");break;
}
}
else if(bPositionVPosOffset)
{
__int64 emuPosOffset = (__int64)(g_dKoef_mm_to_emu * PositionVPosOffset);
sContent.Format(_T("<wp:posOffset>%lld</wp:posOffset>"), emuPosOffset);
}
else if(bPositionVPctOffset)
{
long pctOffset = (long)(1000 * PositionVPctOffset);
sContent.Format(_T("<wp14:pctPosVOffset>%d</wp14:pctPosVOffset>"), pctOffset);
}
sXml.AppendFormat(_T("<wp:positionV relativeFrom=\"%ls\">%ls</wp:positionV>"), (const TCHAR *) sRelativeFrom, (const TCHAR *) sContent);
}
__int64 emuWidth = (__int64)(g_dKoef_mm_to_emu * Width);
__int64 emuHeight = (__int64)(g_dKoef_mm_to_emu * Height);
sXml.AppendFormat(_T("<wp:extent cx=\"%lld\" cy=\"%lld\"/>"), emuWidth, emuHeight);
if(bEffectExtentL && bEffectExtentT && bEffectExtentR && bEffectExtentB)
{
__int64 emuEffectExtentL = (__int64)(g_dKoef_mm_to_emu * EffectExtentL);
__int64 emuEffectExtentT = (__int64)(g_dKoef_mm_to_emu * EffectExtentT);
__int64 emuEffectExtentR = (__int64)(g_dKoef_mm_to_emu * EffectExtentR);
__int64 emuEffectExtentB = (__int64)(g_dKoef_mm_to_emu * EffectExtentB);
sXml.AppendFormat(_T("<wp:effectExtent l=\"%lld\" t=\"%lld\" r=\"%lld\" b=\"%lld\"/>"), emuEffectExtentL, emuEffectExtentT, emuEffectExtentR, emuEffectExtentB);
}
if(bDrawingPropertyWrap && DrawingPropertyWrap.bWrappingType)
{
CString sTagName;
switch(DrawingPropertyWrap.WrappingType)
{
case c_oSerImageType2::WrapNone:sTagName = _T("wrapNone");break;
case c_oSerImageType2::WrapSquare:sTagName = _T("wrapSquare");break;
case c_oSerImageType2::WrapThrough:sTagName = _T("wrapThrough");break;
case c_oSerImageType2::WrapTight:sTagName = _T("wrapTight");break;
case c_oSerImageType2::WrapTopAndBottom:sTagName = _T("wrapTopAndBottom");break;
}
if(DrawingPropertyWrap.bStart || DrawingPropertyWrap.Points.size() > 0)
{
if( c_oSerImageType2::WrapSquare == DrawingPropertyWrap.WrappingType ||
c_oSerImageType2::WrapThrough == DrawingPropertyWrap.WrappingType ||
c_oSerImageType2::WrapTight == DrawingPropertyWrap.WrappingType)
{
sXml.AppendFormat(_T("<wp:%ls wrapText=\"bothSides\">"), (const TCHAR *) sTagName);
}
else
sXml.AppendFormat(_T("<wp:%ls>"), (const TCHAR *) sTagName);
if(bChart)
{
sXml.AppendFormat(_T("<wp:docPr id=\"%d\" name=\"Chart %d\"/>"), m_nDocPr, m_nDocPr);
}
else
{
sXml.AppendFormat(_T("<wp:docPr id=\"%d\" name=\"\"/>"), m_nDocPr);
}
if(!sGraphicFramePr.IsEmpty())
{
sXml.Append(sGraphicFramePr);
}
else
{
sXml.Append(_T("<wp:cNvGraphicFramePr/>"));
}
if(bChart)
{
sXml.AppendFormat(_T("<a:graphic xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\"><a:graphicData uri=\"http://schemas.openxmlformats.org/drawingml/2006/chart\"><c:chart xmlns:c=\"http://schemas.openxmlformats.org/drawingml/2006/chart\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" r:id=\"%ls\"/></a:graphicData></a:graphic>"), (const TCHAR *) sChartRels);
}
int nEdited = 0;
if(DrawingPropertyWrap.bEdited && DrawingPropertyWrap.Edited)
nEdited = 1;
sXml.AppendFormat(_T("<wp:wrapPolygon edited=\"%d\">"), nEdited);
if(DrawingPropertyWrap.bStart && DrawingPropertyWrap.Start.bX && DrawingPropertyWrap.Start.bY)
{
__int64 emuX = (__int64)(g_dKoef_mm_to_emu * DrawingPropertyWrap.Start.X);
__int64 emuY = (__int64)(g_dKoef_mm_to_emu * DrawingPropertyWrap.Start.Y);
sXml.AppendFormat(_T("<wp:start x=\"%lld\" y=\"%lld\"/>"), emuX, emuY);
}
for(int i = 0, length = DrawingPropertyWrap.Points.size(); i < length; ++i)
{
CDrawingPropertyWrapPoint* pWrapPoint = DrawingPropertyWrap.Points[i];
if(pWrapPoint->bX && pWrapPoint->bY)
{
__int64 emuX = (__int64)(g_dKoef_mm_to_emu * pWrapPoint->X);
__int64 emuY = (__int64)(g_dKoef_mm_to_emu * pWrapPoint->Y);
sXml.AppendFormat(_T("<wp:lineTo x=\"%lld\" y=\"%lld\"/>"), emuX, emuY);
}
}
sXml.Append(_T("</wp:wrapPolygon>"));
sXml.AppendFormat(_T("</wp:%ls>"), (const TCHAR *) sTagName);
}
else
{
//для wrapThrough и wrapTight wrapPolygon обязательное поле, если его нет - меняем тип.
if( c_oSerImageType2::WrapSquare == DrawingPropertyWrap.WrappingType ||
c_oSerImageType2::WrapThrough == DrawingPropertyWrap.WrappingType ||
c_oSerImageType2::WrapTight == DrawingPropertyWrap.WrappingType)
{
sXml.Append(_T("<wp:wrapSquare wrapText=\"bothSides\"/>"));
}
else
sXml.AppendFormat(_T("<wp:%ls/>"), (const TCHAR *) sTagName);
}
}
else
sXml.Append(_T("<wp:wrapNone/>"));
if(!sSizeRelH.IsEmpty())
{
sXml.Append(sSizeRelH);
}
if(!sSizeRelV.IsEmpty())
{
sXml.Append(sSizeRelV);
}
if(bChart)
{
sXml.AppendFormat(_T("<wp:docPr id=\"%d\" name=\"Chart %d\"/>"), m_nDocPr, m_nDocPr);
}
else
{
sXml.AppendFormat(_T("<wp:docPr id=\"%d\" name=\"\"/>"), m_nDocPr);
}
if(!sGraphicFramePr.IsEmpty())
{
sXml.Append(sGraphicFramePr);
}
else
{
sXml.Append(_T("<wp:cNvGraphicFramePr/>"));
}
if(bChart)
{
sXml.AppendFormat(_T("<a:graphic xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\"><a:graphicData uri=\"http://schemas.openxmlformats.org/drawingml/2006/chart\"><c:chart xmlns:c=\"http://schemas.openxmlformats.org/drawingml/2006/chart\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" r:id=\"%ls\"/></a:graphicData></a:graphic>"), (const TCHAR *) sChartRels);
}
sXml.Append(_T("</wp:anchor>"));
if(!sSizeRelH.IsEmpty())
{
sXml.Append(sSizeRelH);
}
if(!sSizeRelV.IsEmpty())
{
sXml.Append(sSizeRelV);
}
sXml.Append(_T("</wp:anchor>"));
if(bChart)
sXml.Append(_T("</w:drawing>"));
}
}
if(bChart)
sXml.Append(_T("</w:drawing>"));
}
}
}
return sXml;
}
};

View File

@ -613,8 +613,9 @@ public:
if(0 != contextualSpacing)
pCStringWriter->WriteString(CString(_T("<w:contextualSpacing w:val=\"true\"/>")));
else if(false == bDoNotWriteNullProp)
pCStringWriter->WriteString(CString(_T("<w:contextualSpacing w:val=\"false\"/>")));
}break;
pCStringWriter->WriteString(CString(_T("<w:contextualSpacing w:val=\"false\"/>")));
break;
}
case c_oSerProp_pPrType::Ind:
{
XmlUtils::CStringWriter oTempWriter;
@ -636,24 +637,27 @@ public:
case align_Left: pCStringWriter->WriteString(CString(_T("<w:jc w:val=\"left\" />")));break;
case align_Center: pCStringWriter->WriteString(CString(_T("<w:jc w:val=\"center\" />")));break;
case align_Justify: pCStringWriter->WriteString(CString(_T("<w:jc w:val=\"both\" />")));break;
}
}break;
}
break;
}
case c_oSerProp_pPrType::KeepLines:
{
BYTE KeepLines = m_oBufferedStream.GetUChar();
if(0 != KeepLines)
pCStringWriter->WriteString(CString(_T("<w:keepLines/>")));
else if(false == bDoNotWriteNullProp)
pCStringWriter->WriteString(CString(_T("<w:keepLines w:val=\"false\"/>")));
}break;
pCStringWriter->WriteString(CString(_T("<w:keepLines w:val=\"false\"/>")));
break;
}
case c_oSerProp_pPrType::KeepNext:
{
BYTE KeepNext = m_oBufferedStream.GetUChar();
if(0 != KeepNext)
pCStringWriter->WriteString(CString(_T("<w:keepNext/>")));
else if(false == bDoNotWriteNullProp)
pCStringWriter->WriteString(CString(_T("<w:keepNext w:val=\"false\"/>")));
}break;
pCStringWriter->WriteString(CString(_T("<w:keepNext w:val=\"false\"/>")));
break;
}
case c_oSerProp_pPrType::PageBreakBefore:
{
BYTE pageBreakBefore = m_oBufferedStream.GetUChar();
@ -784,8 +788,9 @@ public:
pCStringWriter->WriteString(sTab);
}
pCStringWriter->WriteString(CString(_T("</w:tabs>")));
}
}break;
}
break;
}
case c_oSerProp_pPrType::ParaStyle:
{
CString sStyleName(m_oBufferedStream.GetString3(length));
@ -794,23 +799,23 @@ public:
sStyle.Append(_T("<w:pStyle w:val=\""));
sStyle.Append(sStyleName);
sStyle.Append(_T("\" />"));
pCStringWriter->WriteString(sStyle);
}break;
pCStringWriter->WriteString(sStyle);
break;
}
case c_oSerProp_pPrType::numPr:
{
pCStringWriter->WriteString(CString(_T("<w:numPr>")));
res = Read2(length, &Binary_pPrReader::ReadNumPr, this, poResult);
pCStringWriter->WriteString(CString(_T("</w:numPr>")));
}break;
pCStringWriter->WriteString(CString(_T("<w:numPr>")));
res = Read2(length, &Binary_pPrReader::ReadNumPr, this, poResult);
pCStringWriter->WriteString(CString(_T("</w:numPr>")));
break;
case c_oSerProp_pPrType::pPr_rPr:
{
rPr orPr(m_oFontTableWriter.m_mapFonts);
res = oBinary_rPrReader.Read(length, &orPr);
//Read2(length, &Binary_pPrReader::ReadNumPr, this, &orPr);
if(orPr.IsNoEmpty())
orPr.Write(pCStringWriter);
}break;
orPr.Write(pCStringWriter);
break;
}
case c_oSerProp_pPrType::pBdr:
{
docBorders odocBorders;
@ -820,29 +825,33 @@ public:
pCStringWriter->WriteString(CString(_T("<w:pBdr>")));
odocBorders.Write(pCStringWriter, false);
pCStringWriter->WriteString(CString(_T("</w:pBdr>")));
}
}break;
}
break;
}
case c_oSerProp_pPrType::FramePr:
{
CFramePr oFramePr;
res = Read2(length, &Binary_pPrReader::ReadFramePr, this, &oFramePr);
if(false == oFramePr.IsEmpty())
oFramePr.Write(*pCStringWriter);
}break;
oFramePr.Write(*pCStringWriter);
break;
}
case c_oSerProp_pPrType::pPrChange:
{
TrackRevision oPPrChange;
res = Read1(length, &Binary_pPrReader::ReadPPrChange, this, &oPPrChange);
oPPrChange.Write(pCStringWriter, _T("w:pPrChange"));
}break;
case c_oSerProp_pPrType::SectPr:
oPPrChange.Write(pCStringWriter, _T("w:pPrChange"));
break;
}
case c_oSerProp_pPrType::SectPr:
{
SectPr oSectPr;
res = Read1(length, &Binary_pPrReader::Read_SecPr, this, &oSectPr);
pCStringWriter->WriteString(CString(_T("<w:sectPr>")));
pCStringWriter->WriteString(oSectPr.Write());
pCStringWriter->WriteString(CString(_T("</w:sectPr>")));
}break;
pCStringWriter->WriteString(CString(_T("</w:sectPr>")));
break;
}
default:
res = c_oSerConstants::ReadUnknown;
break;
@ -862,7 +871,7 @@ public:
else
res = c_oSerConstants::ReadUnknown;
return res;
}
};
int ReadInd(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
@ -904,7 +913,7 @@ public:
break;
}
return res;
}
};
int ReadSpacing(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
@ -940,7 +949,7 @@ public:
break;
}
return res;
}
};
int ReadTabs(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
@ -966,7 +975,7 @@ public:
else
res = c_oSerConstants::ReadUnknown;
return res;
}
};
int ReadNumPr(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
@ -1041,7 +1050,7 @@ public:
else
res = c_oSerConstants::ReadUnknown;
return res;
}
};
int ReadBorder(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
@ -1074,7 +1083,7 @@ public:
else
res = c_oSerConstants::ReadUnknown;
return res;
}
};
int ReadFramePr(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
@ -1152,9 +1161,9 @@ public:
else
res = c_oSerConstants::ReadUnknown;
return res;
}
int Read_SecPr(BYTE type, long length, void* poResult)
{
};
int Read_SecPr(BYTE type, long length, void* poResult)
{
SectPr* pSectPr = static_cast<SectPr*>(poResult);
int res = c_oSerConstants::ReadOk;
if( c_oSerProp_secPrType::pgSz == type )
@ -2936,11 +2945,11 @@ public:
{
m_oFileWriter.m_oMediaWriter.AddImage2(pFileNative);
}
else if(NSFile::CFileBinary::Exists(sFilePath))
else if(NSFile::CFileBinary::Exists(string2std_string(sFilePath)))
{
m_oFileWriter.m_oMediaWriter.AddImage(sFilePath);
if(bDeleteFile)
NSFile::CFileBinary::Remove(sFilePath);
NSFile::CFileBinary::Remove(string2std_string(sFilePath));
}
}
else
@ -3570,37 +3579,22 @@ public:
};
class Binary_DocumentTableReader : public Binary_CommonReader<Binary_DocumentTableReader>
{
private:
Binary_CommonReader2 oBinary_CommonReader2;
Writers::FileWriter& m_oFileWriter;
Writers::FontTableWriter& m_oFontTableWriter;
Binary_pPrReader oBinary_pPrReader;
Binary_rPrReader oBinary_rPrReader;
Binary_tblPrReader oBinary_tblPrReader;
XmlUtils::CStringWriter* m_pCurWriter;
rPr m_oCur_rPr;
rPr m_oMath_rPr;
XmlUtils::CStringWriter m_oCur_pPr;
BYTE m_byteLastElemType;
CComments* m_pComments;
Writers::FileWriter& m_oFileWriter;
Writers::FontTableWriter& m_oFontTableWriter;
Binary_pPrReader oBinary_pPrReader;
Binary_rPrReader oBinary_rPrReader;
Binary_tblPrReader oBinary_tblPrReader;
XmlUtils::CStringWriter* m_pCurWriter;
rPr m_oCur_rPr;
rPr m_oMath_rPr;
XmlUtils::CStringWriter m_oCur_pPr;
BYTE m_byteLastElemType;
CComments* m_pComments;
public:
Writers::ContentWriter& m_oDocumentWriter;
Writers::MediaWriter& m_oMediaWriter;
Binary_DocumentTableReader(NSBinPptxRW::CBinaryFileReader& poBufferedStream, Writers::FileWriter& oFileWriter, Writers::ContentWriter& oDocumentWriter, CComments* pComments)
: Binary_CommonReader(poBufferedStream)
, m_oDocumentWriter(oDocumentWriter)
, m_oFileWriter(oFileWriter)
, m_oMediaWriter(oFileWriter.m_oMediaWriter)
, m_oFontTableWriter(oFileWriter.m_oFontTableWriter)
, oBinary_CommonReader2(poBufferedStream)
, oBinary_pPrReader(poBufferedStream, oFileWriter)
, oBinary_rPrReader(poBufferedStream, oFileWriter)
, oBinary_tblPrReader(poBufferedStream, oFileWriter)
, m_oCur_rPr(m_oFontTableWriter.m_mapFonts)
, m_oMath_rPr(m_oFontTableWriter.m_mapFonts)
, m_pComments(pComments)
Writers::ContentWriter& m_oDocumentWriter;
Writers::MediaWriter& m_oMediaWriter;
public:
Binary_DocumentTableReader(NSBinPptxRW::CBinaryFileReader& poBufferedStream, Writers::FileWriter& oFileWriter, Writers::ContentWriter& oDocumentWriter, CComments* pComments) :Binary_CommonReader(poBufferedStream), m_oDocumentWriter(oDocumentWriter), m_oFileWriter(oFileWriter), m_oMediaWriter(oFileWriter.m_oMediaWriter), m_oFontTableWriter(oFileWriter.m_oFontTableWriter), oBinary_pPrReader(poBufferedStream, oFileWriter), oBinary_rPrReader(poBufferedStream, oFileWriter), oBinary_tblPrReader(poBufferedStream, oFileWriter), m_oCur_rPr(m_oFontTableWriter.m_mapFonts), m_oMath_rPr(m_oFontTableWriter.m_mapFonts), m_pComments(pComments)
{
m_byteLastElemType = c_oSerParType::Content;
m_pCurWriter = NULL;
@ -3611,7 +3605,7 @@ public:
int Read()
{
return ReadTable(&Binary_DocumentTableReader::ReadDocumentContent, this);
}
};
XmlUtils::CStringWriter& GetRunStringWriter()
{
if(NULL != m_pCurWriter)
@ -3634,12 +3628,12 @@ public:
else if(c_oSerParType::Table == type)
{
m_byteLastElemType = c_oSerParType::Table;
//сбрасываем Shd
//сбрасываем Shd
oBinary_tblPrReader.m_sCurTableShd.Empty();
m_oDocumentWriter.m_oContent.WriteString(CString(_T("<w:tbl>")));
res = Read1(length, &Binary_DocumentTableReader::ReadDocTable, this, &m_oDocumentWriter.m_oContent);
m_oDocumentWriter.m_oContent.WriteString(CString(_T("</w:tbl>")));
//сбрасываем Shd
//сбрасываем Shd
oBinary_tblPrReader.m_sCurTableShd.Empty();
}
else if ( c_oSerParType::sectPr == type )
@ -3650,16 +3644,10 @@ public:
if(oSectPr.bEvenAndOddHeaders && oSectPr.EvenAndOddHeaders)
m_oFileWriter.m_oSettingWriter.AddSetting(_T("<w:evenAndOddHeaders/>"));
}
else if ( c_oSerParType::Background == type )
{
Background oBackground;
res = Read2(length, &Binary_DocumentTableReader::Read_Background, this, &oBackground);
m_oDocumentWriter.m_oBackground.WriteString(oBackground.Write());
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
};
int ReadParagraph(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
@ -3680,7 +3668,7 @@ public:
else
res = c_oSerConstants::ReadUnknown;
return res;
}
};
int ReadParagraphContent(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
@ -6274,7 +6262,7 @@ public:
else
res = c_oSerConstants::ReadUnknown;
return res;
}
};
int ReadFootnoteRef(BYTE type, long length, void* poResult)
{
OOX::Logic::CFootnoteReference* pFootnoteRef = static_cast<OOX::Logic::CFootnoteReference*>(poResult);
@ -6351,11 +6339,8 @@ public:
{
CDrawingProperty oCDrawingProperty(m_oFileWriter.getNextDocPr());
res = Read2(length, &Binary_DocumentTableReader::ReadPptxDrawing, this, &oCDrawingProperty);
if(oCDrawingProperty.bDataPos && oCDrawingProperty.bDataLength)
{
if(oCDrawingProperty.bDataPos && oCDrawingProperty.bDataLength)
ReadDrawing(oCDrawingProperty);
}
}
else
res = c_oSerConstants::ReadUnknown;
@ -6395,7 +6380,7 @@ public:
else
res = c_oSerConstants::ReadUnknown;
return res;
};
};
int Read_tblGrid(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
@ -6560,53 +6545,6 @@ public:
res = c_oSerConstants::ReadUnknown;
return res;
}
int Read_Background(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
Background* pBackground = static_cast<Background*>(poResult);
if( c_oSerBackgroundType::Color == type )
{
pBackground->bColor = true;
pBackground->Color = oBinary_CommonReader2.ReadColor();
}
else if( c_oSerBackgroundType::ColorTheme == type )
{
pBackground->bThemeColor = true;
oBinary_CommonReader2.ReadThemeColor(length, pBackground->ThemeColor);
}
else if( c_oSerBackgroundType::pptxDrawing == type )
{
CDrawingProperty oCDrawingProperty(m_oFileWriter.getNextDocPr());
oCDrawingProperty.bType = oCDrawingProperty.bHeight = oCDrawingProperty.bWidth = true;
oCDrawingProperty.Type = c_oAscWrapStyle::Inline;
CString sDrawingProperty = oCDrawingProperty.Write();
BYTE type = m_oBufferedStream.GetUChar();
long lenType = m_oBufferedStream.GetUChar();
int nRealLen = m_oBufferedStream.GetLong();
CString* bstrDrawingXml = NULL;
long nCurPos = m_oBufferedStream.GetPos();
m_oFileWriter.m_pDrawingConverter->SaveObjectEx(nCurPos, nRealLen, sDrawingProperty, XMLWRITER_DOC_TYPE_DOCX, &bstrDrawingXml);
if(NULL != bstrDrawingXml && false == bstrDrawingXml->IsEmpty())
{
pBackground->sObject = *bstrDrawingXml;
}
RELEASEOBJECT(bstrDrawingXml);
m_oBufferedStream.Seek(nCurPos + nRealLen);
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
int ReadPptxDrawing(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
@ -6653,14 +6591,14 @@ public:
//save xlsx
std::wstring sXlsxFilename = L"Microsoft_Excel_Worksheet" + std::to_wstring(m_oFileWriter.m_oChartWriter.getChartCount() + 1) + L".xlsx";
std::wstring sXlsxPath = pathChartsWorksheetDir.GetPath() + FILE_SEPARATOR_STR + sXlsxFilename;
std::wstring sXlsxPath = string2std_string(pathChartsWorksheetDir.GetPath() + FILE_SEPARATOR_STR) + sXlsxFilename;
BinXlsxRW::CXlsxSerializer oXlsxSerializer;
oXlsxSerializer.writeChartXlsx(sXlsxPath, *pChartSpace);
std::wstring sChartsWorksheetRelsName = L"../embeddings/" + sXlsxFilename;
long rIdXlsx;
CString bstrChartsWorksheetRelType = OOX::Spreadsheet::FileTypes::ChartsWorksheet.RelationType();
m_oFileWriter.m_pDrawingConverter->WriteRels(bstrChartsWorksheetRelType, sChartsWorksheetRelsName, CString(), &rIdXlsx);
m_oFileWriter.m_pDrawingConverter->WriteRels(bstrChartsWorksheetRelType, std_string2string(sChartsWorksheetRelsName), CString(), &rIdXlsx);
pChartSpace->m_oChartSpace.m_externalData = new OOX::Spreadsheet::CT_ExternalData();
pChartSpace->m_oChartSpace.m_externalData->m_id = new std::wstring();
@ -6673,15 +6611,14 @@ public:
NSStringUtils::CStringBuilder sw;
pChartSpace->toXML(sw);
std::wstring sFilename;
std::wstring sRelsName;
CString sFilename;
CString sRelsName;
int nChartIndex;
std::wstring sContent = sw.GetData();
m_oFileWriter.m_oChartWriter.AddChart(sContent, sRelsName, sFilename, nChartIndex);
m_oFileWriter.m_oChartWriter.AddChart(sContent, sRelsName, sFilename, nChartIndex);
m_oFileWriter.m_oContentTypesWriter.AddOverrideRaw(oSaveParams.sAdditionalContentTypes);
OOX::CPath pathChartsRels = pathChartsRelsDir.GetPath() + FILE_SEPARATOR_STR + sFilename + L".rels";
OOX::CPath pathChartsRels = pathChartsRelsDir.GetPath() + FILE_SEPARATOR_STR + sFilename + _T(".rels");
m_oFileWriter.m_pDrawingConverter->SaveDstContentRels(pathChartsRels.GetPath());
long rIdChart;
@ -7098,7 +7035,7 @@ Binary_HdrFtrTableReader::Binary_HdrFtrTableReader(NSBinPptxRW::CBinaryFileReade
int Binary_HdrFtrTableReader::Read()
{
return ReadTable(&Binary_HdrFtrTableReader::ReadHdrFtrContent, this);
}
};
int Binary_HdrFtrTableReader::ReadHdrFtrContent(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;

View File

@ -57,7 +57,7 @@ namespace Writers
if(sFontDir.IsEmpty())
m_oApplicationFonts.Initialize();
else
m_oApplicationFonts.InitializeFromFolder(sFontDir);
m_oApplicationFonts.InitializeFromFolder(string2std_string(sFontDir));
CFontList* pFontList = m_oApplicationFonts.GetList();
if(NULL != pFontList)
{

View File

@ -152,8 +152,7 @@ extern int g_nCurFormatVersion;
Comments = 8,
Settings = 9,
Footnotes = 10,
Endnotes = 11,
Background
Endnotes = 11
};}
namespace c_oSerSigTypes{enum c_oSerSigTypes
{
@ -447,21 +446,20 @@ extern int g_nCurFormatVersion;
};}
namespace c_oSerParType{enum c_oSerParType
{
Par = 0,
pPr = 1,
Content = 2,
Table = 3,
sectPr = 4,
Run = 5,
CommentStart = 6,
CommentEnd = 7,
OMathPara = 8,
OMath = 9,
Hyperlink = 10,
FldSimple = 11,
Del = 12,
Ins = 13,
Background = 14
Par = 0,
pPr = 1,
Content = 2,
Table = 3,
sectPr = 4,
Run = 5,
CommentStart = 6,
CommentEnd = 7,
OMathPara = 8,
OMath = 9,
Hyperlink = 10,
FldSimple = 11,
Del = 12,
Ins = 13
};}
namespace c_oSerDocTableType{enum c_oSerDocTableType
{
@ -508,12 +506,6 @@ extern int g_nCurFormatVersion;
endnoteReference = 27,
arPr = 28
};}
namespace c_oSerBackgroundType{enum c_oSerBackgroundType
{
Color = 0,
ColorTheme = 1,
pptxDrawing = 2
};}
namespace c_oSerImageType{enum c_oSerImageType
{
MediaId = 0,

File diff suppressed because it is too large Load Diff

View File

@ -248,7 +248,7 @@ namespace BinXlsxRW{
pTable->m_oTable->m_oDisplayName.Init();
pTable->m_oTable->m_oDisplayName->append(L"Table1");
pTable->m_oTable->m_oRef.Init();
pTable->m_oTable->m_oRef->SetValue(OOX::Spreadsheet::CCell::combineRef(m_nRow1 - 1, m_nCol1 - 1) + L":" + OOX::Spreadsheet::CCell::combineRef(m_nRow2 - 1, m_nCol2 - 1));
pTable->m_oTable->m_oRef->SetValue(std_string2string(OOX::Spreadsheet::CCell::combineRef(m_nRow1 - 1, m_nCol1 - 1) + L":" + OOX::Spreadsheet::CCell::combineRef(m_nRow2 - 1, m_nCol2 - 1)));
pTable->m_oTable->m_oTotalsRowCount.Init();
pTable->m_oTable->m_oTotalsRowCount->SetValue(0);
pTable->m_oTable->m_oTableBorderDxfId.Init();

View File

@ -32,7 +32,12 @@
#ifndef CHART_WRITER
#define CHART_WRITER
#include "../../Common/DocxFormat/Source/Base/ASCString.h"
#if defined(_WIN32) || defined (_WIN64)
#include <atlbase.h>
#include <atlstr.h>
#else
#include "../../Common/DocxFormat/Source/Base/ASCString.h"
#endif
#include <string>
#include <map>

View File

@ -50,45 +50,48 @@ BinDocxRW::CDocxSerializer::CDocxSerializer()
}
bool BinDocxRW::CDocxSerializer::ConvertDocxToDoct(const CString& sSrcFileName, const CString& sDstFileName, const CString& sTmpDir, const CString& sXMLOptions)
{
std::wstring strDirSrc = NSSystemPath::Combine(sTmpDir, L"from");
std::wstring strDirDst = NSSystemPath::Combine(sTmpDir, L"to");
std::wstring strEditorBin = NSSystemPath::Combine(strDirDst, L"Editor.bin");
std::wstring strDirSrc = NSSystemPath::Combine(string2std_string(sTmpDir), _T("from"));
std::wstring strDirDst = NSSystemPath::Combine(string2std_string(sTmpDir), _T("to"));
std::wstring strEditorBin = NSSystemPath::Combine(strDirDst, _T("Editor.bin"));
NSDirectory::CreateDirectory(strDirSrc);
NSDirectory::CreateDirectory(strDirDst);
CString sDirSrc = std_string2string(strDirSrc);
CString sEditorBin = std_string2string(strEditorBin);
COfficeUtils oCOfficeUtils(NULL);
if(S_OK == oCOfficeUtils.ExtractToDirectory(sSrcFileName, strDirSrc, NULL, 0))
if(saveToFile(strEditorBin, strDirSrc, sXMLOptions))
if(S_OK == oCOfficeUtils.CompressFileOrDirectory(strDirDst, sDstFileName, -1))
if(S_OK == oCOfficeUtils.ExtractToDirectory(string2std_string(sSrcFileName), strDirSrc, NULL, 0))
if(saveToFile(sEditorBin, sDirSrc, sXMLOptions))
if(S_OK == oCOfficeUtils.CompressFileOrDirectory(strDirDst, string2std_string(sDstFileName), -1))
return true;
return false;
}
bool BinDocxRW::CDocxSerializer::ConvertDoctToDocx(const CString& sSrcFileName, const CString& sDstFileName, const CString& sTmpDir, const CString& sXMLOptions)
{
std::wstring strDirSrc = NSSystemPath::Combine(sTmpDir, L"from");
std::wstring strEditorBin = NSSystemPath::Combine(strDirSrc, L"Editor.bin");
std::wstring strDirDst = NSSystemPath::Combine(sTmpDir, L"to");
std::wstring strDirSrc = NSSystemPath::Combine(string2std_string(sTmpDir), _T("from"));
std::wstring strEditorBin = NSSystemPath::Combine(strDirSrc, _T("Editor.bin"));
std::wstring strDirDst = NSSystemPath::Combine(string2std_string(sTmpDir), _T("to"));
NSDirectory::CreateDirectory(strDirSrc);
NSDirectory::CreateDirectory(strDirDst);
CString sEditorBin = strEditorBin;
CString sEditorBin = std_string2string(strEditorBin);
COfficeUtils oCOfficeUtils(NULL);
if(S_OK == oCOfficeUtils.ExtractToDirectory(sSrcFileName, strDirSrc, NULL, 0))
if(S_OK == oCOfficeUtils.ExtractToDirectory(string2std_string(sSrcFileName), strDirSrc, NULL, 0))
{
CString sMediaPath;
CString sThemePath;
CString sEmbedPath;
CreateDocxFolders(strDirDst, sThemePath, sMediaPath, sEmbedPath);
CreateDocxFolders(std_string2string(strDirDst), sThemePath, sMediaPath, sEmbedPath);
if(loadFromFile(sEditorBin, strDirDst, sXMLOptions, sThemePath, sMediaPath, sEmbedPath))
if(loadFromFile(sEditorBin, std_string2string(strDirDst), sXMLOptions, sThemePath, sMediaPath, sEmbedPath))
{
if(S_OK == oCOfficeUtils.CompressFileOrDirectory(strDirDst, sDstFileName, -1))
if(S_OK == oCOfficeUtils.CompressFileOrDirectory(strDirDst, string2std_string(sDstFileName), -1))
return true;
}
}
@ -99,7 +102,7 @@ bool BinDocxRW::CDocxSerializer::saveToFile(const CString& sSrcFileName, const C
OOX::CPath pathMain(sSrcFileName);
OOX::CPath pathMedia = pathMain.GetDirectory() + FILE_SEPARATOR_STR + _T("media");
NSDirectory::CreateDirectory(pathMedia.GetPath());
NSDirectory::CreateDirectory(string2std_string(pathMedia.GetPath()));
COfficeFontPicker* pFontPicker = new COfficeFontPicker();
pFontPicker->Init(m_sFontDir);
@ -113,7 +116,7 @@ bool BinDocxRW::CDocxSerializer::saveToFile(const CString& sSrcFileName, const C
NSFontCutter::CEmbeddedFontsManager* pEmbeddedFontsManager = NULL;
if(false == m_sEmbeddedFontsDir.IsEmpty())
{
NSDirectory::CreateDirectory(m_sEmbeddedFontsDir);
NSDirectory::CreateDirectory(string2std_string(m_sEmbeddedFontsDir));
pFontPicker->SetEmbeddedFontsDirectory(m_sEmbeddedFontsDir);
@ -143,7 +146,7 @@ bool BinDocxRW::CDocxSerializer::saveToFile(const CString& sSrcFileName, const C
if (m_bIsNoBase64Save)
{
NSFile::CFileBinary oFile;
oFile.CreateFileW(sSrcFileName);
oFile.CreateFileW(string2std_string(sSrcFileName));
oFile.WriteFile(pbBinBuffer, nBinBufferLen);
oFile.CloseFile();
}
@ -155,8 +158,8 @@ bool BinDocxRW::CDocxSerializer::saveToFile(const CString& sSrcFileName, const C
if(true == Base64_1::Base64Encode(pbBinBuffer, nBinBufferLen, pbBase64Buffer, &nBase64BufferLen))
{
NSFile::CFileBinary oFile;
oFile.CreateFileW(sSrcFileName);
oFile.WriteStringUTF8(oBinaryFileWriter.WriteFileHeader(nBinBufferLen));
oFile.CreateFileW(string2std_string(sSrcFileName));
oFile.WriteStringUTF8(string2std_string(oBinaryFileWriter.WriteFileHeader(nBinBufferLen)));
oFile.WriteFile(pbBase64Buffer, nBase64BufferLen);
oFile.CloseFile();
}
@ -172,32 +175,32 @@ bool BinDocxRW::CDocxSerializer::CreateDocxFolders(CString strDirectory, CString
bool res = true;
// rels
OOX::CPath pathRels = strDirectory + FILE_SEPARATOR_STR + _T("_rels");
if (!NSDirectory::CreateDirectory(pathRels.GetPath())) res = false;
if (!NSDirectory::CreateDirectory(pathRels.GetPath().GetBuffer())) res = false;
// word
OOX::CPath pathWord = strDirectory + FILE_SEPARATOR_STR + _T("word");
if (!NSDirectory::CreateDirectory(pathWord.GetPath())) res = false;
if (!NSDirectory::CreateDirectory(pathWord.GetPath().GetBuffer())) res = false;
// documentRels
OOX::CPath pathWordRels = pathWord + FILE_SEPARATOR_STR + _T("_rels");
if (!NSDirectory::CreateDirectory(pathWordRels.GetPath()))res = false;
if (!NSDirectory::CreateDirectory(pathWordRels.GetPath().GetBuffer()))res = false;
//media
OOX::CPath pathMedia = pathWord + FILE_SEPARATOR_STR + _T("media");
if (!NSDirectory::CreateDirectory(pathMedia.GetPath())) res = false;
if (!NSDirectory::CreateDirectory(pathMedia.GetPath().GetBuffer())) res = false;
sMediaPath = pathMedia.GetPath();
//embeddings
OOX::CPath pathEmbeddings = pathWord + FILE_SEPARATOR_STR + _T("embeddings");
if (!NSDirectory::CreateDirectory(pathEmbeddings.GetPath()))res = false;
if (!NSDirectory::CreateDirectory(pathEmbeddings.GetPath().GetBuffer()))res = false;
sEmbedPath = pathEmbeddings.GetPath();
// theme
OOX::CPath pathTheme = pathWord + FILE_SEPARATOR_STR + _T("theme");
if (!NSDirectory::CreateDirectory(pathTheme.GetPath())) res = false;
if (!NSDirectory::CreateDirectory(pathTheme.GetPath().GetBuffer())) res = false;
OOX::CPath pathThemeRels = pathTheme + FILE_SEPARATOR_STR + _T("_rels");
if (!NSDirectory::CreateDirectory(pathThemeRels.GetPath())) res = false;
if (!NSDirectory::CreateDirectory(pathThemeRels.GetPath().GetBuffer())) res = false;
pathTheme = pathTheme + FILE_SEPARATOR_STR + _T("theme1.xml");
sThemePath = pathTheme.GetPath();
@ -209,7 +212,7 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(const CString& sSrcFileName, const
bool bResultOk = false;
NSFile::CFileBinary oFile;
if(oFile.OpenFile(sSrcFileName))
if(oFile.OpenFile(string2std_string(sSrcFileName)))
{
DWORD nBase64DataSize = 0;
BYTE* pBase64Data = new BYTE[oFile.GetFileSize()];
@ -283,7 +286,7 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(const CString& sSrcFileName, const
m_pCurFileWriter = new Writers::FileWriter(sDstPath, m_sFontDir, false, nVersion, m_bSaveChartAsImg, &oDrawingConverter, sThemePath);
//папка с картинками
std::wstring strFileInDir = NSSystemPath::GetDirectoryName(sSrcFileName);
std::wstring strFileInDir = NSSystemPath::GetDirectoryName(string2std_string(sSrcFileName));
CString sFileInDir = strFileInDir.c_str();
VARIANT var;

View File

@ -32,7 +32,12 @@
#ifndef DOCX_SERIALIZER
#define DOCX_SERIALIZER
#include "../../Common/DocxFormat/Source/Base/ASCString.h"
#if defined(_WIN32) || defined (_WIN64)
#include <atlbase.h>
#include <atlstr.h>
#else
#include "../../Common/DocxFormat/Source/Base/ASCString.h"
#endif
#include "../../Common/DocxFormat/Source/DocxFormat/WritingElement.h"
namespace Writers

View File

@ -95,14 +95,13 @@ namespace DocWrapper {
sFontName = pTheme->GetMinorFont();
}
if(sFontName.IsEmpty() && oRFont.IsInit() && oRFont->m_sVal.IsInit())
sFontName = oRFont->ToString2();
sFontName = std_string2string(oRFont->ToString2());
if(sFontName.IsEmpty())
sFontName = CString(gc_sNoNameFont);
//подбор перенесен в js
return sFontName;
oFontSelectFormat.wsName = new std::wstring(sFontName);
oFontSelectFormat.wsName = new std::wstring;
*oFontSelectFormat.wsName = string2std_string(sFontName);
if(oCharset.IsInit() && oCharset->m_oCharset.IsInit())
{
SimpleTypes::Spreadsheet::EFontCharset eCharset = oCharset->m_oCharset->GetValue();
@ -122,7 +121,7 @@ namespace DocWrapper {
CString sRes;
CFontInfo* pFontInfo = m_pFontManager->GetFontInfoByParams(oFontSelectFormat);
if(NULL != pFontInfo)
sRes = pFontInfo->m_wsFontName;
sRes = std_string2string(pFontInfo->m_wsFontName);
else
sRes = gc_sDefaultFontName;
fontMap[sFontName] = sRes;
@ -136,12 +135,12 @@ namespace DocWrapper {
sFontName = CString(gc_sNoNameFont);
else
sFontName = font.m_sName;
oFontSelectFormat.wsName = new std::wstring(sFontName);
oFontSelectFormat.wsName = new std::wstring;
*oFontSelectFormat.wsName = string2std_string(sFontName);
if (font.m_oAltName.IsInit() && font.m_oAltName->GetLength() > 0)
{
oFontSelectFormat.wsAltName = new std::wstring(*font.m_oAltName);
oFontSelectFormat.wsAltName = new std::wstring;
*oFontSelectFormat.wsAltName = string2std_string(*font.m_oAltName);
}
if(font.m_oCharset.IsInit())
{
@ -217,7 +216,7 @@ namespace DocWrapper {
CFontInfo* pFontInfo = m_pFontManager->GetFontInfoByParams(oFontSelectFormat);
if(NULL != pFontInfo)
fontMap[sFontName] = pFontInfo->m_wsFontName;
fontMap[sFontName] = std_string2string(pFontInfo->m_wsFontName);
else
fontMap[sFontName] = gc_sDefaultFontName;
}

View File

@ -34,9 +34,14 @@
#include <map>
#include "../../Common/DocxFormat/Source/Base/ASCString.h"
#include "../../DesktopEditor/fontengine/ApplicationFonts.h"
#if defined(_WIN32) || defined (_WIN64)
#include <atlbase.h>
#include <atlstr.h>
#else
#include "../../Common/DocxFormat/Source/Base/ASCString.h"
#endif
#include "../../DesktopEditor/fontengine/ApplicationFonts.h"
//#include "DocWrapper/Base.h"
namespace NSCommon{
template<class Type> class nullable;

View File

@ -68,11 +68,11 @@ namespace BinXlsxRW{
OOX::CPath pathThemeThemeRelsDir = pathThemeDir + FILE_SEPARATOR_STR + _T("_rels");
NSDirectory::CreateDirectory(pathXlDir.GetPath());
NSDirectory::CreateDirectory(pathThemeDir.GetPath());
NSDirectory::CreateDirectory(pathThemeThemeRelsDir.GetPath());
NSDirectory::CreateDirectory(pathMediaDir.GetPath());
NSDirectory::CreateDirectory(pathEmbedDir.GetPath());
NSDirectory::CreateDirectory(string2std_string(pathXlDir.GetPath()));
NSDirectory::CreateDirectory(string2std_string(pathThemeDir.GetPath()));
NSDirectory::CreateDirectory(string2std_string(pathThemeThemeRelsDir.GetPath()));
NSDirectory::CreateDirectory(string2std_string(pathMediaDir.GetPath()));
NSDirectory::CreateDirectory(string2std_string(pathEmbedDir.GetPath()));
//Create Default Theme
{
@ -90,7 +90,7 @@ namespace BinXlsxRW{
oOfficeDrawingConverter.SetEmbedDstPath(sEmbedDir);
//папка с бинарников
std::wstring strFileInDir = NSSystemPath::GetDirectoryName(sSrcFileName);
std::wstring strFileInDir = NSSystemPath::GetDirectoryName(string2std_string(sSrcFileName));
CString sFileInDir = strFileInDir.c_str();
VARIANT var;
@ -119,7 +119,7 @@ namespace BinXlsxRW{
NSFontCutter::CEmbeddedFontsManager* pEmbeddedFontsManager = NULL;
if(false == m_sEmbeddedFontsDir.IsEmpty())
{
NSDirectory::CreateDirectory(m_sEmbeddedFontsDir);
NSDirectory::CreateDirectory(string2std_string(m_sEmbeddedFontsDir));
pFontPicker->SetEmbeddedFontsDirectory(m_sEmbeddedFontsDir);
pEmbeddedFontsManager = pFontPicker->GetNativeCutter();
@ -182,42 +182,40 @@ namespace BinXlsxRW{
{
m_pExternalDrawingConverter->SetDstContentRels();
//получаем sThemePath из bsFilename предполагая что папка theme находится на уровень выше bsFilename
std::wstring sThemePath;
std::wstring sEmbedingPath;
CString sFilenameReverse = sFilepath; sFilenameReverse.MakeReverse();
//получаем sThemePath из bsFilename предполагая что папка theme находится на уровень выше bsFilename
CString sThemePath;
CString sEmbedingPath;
CString sFilenameReverse = sFilepath;sFilenameReverse.MakeReverse();
int nIndex = sFilenameReverse.Find(FILE_SEPARATOR_CHAR);
nIndex = sFilenameReverse.Find(FILE_SEPARATOR_CHAR, nIndex + 1);
if(-1 != nIndex)
{
CString sFilepathLeft = sFilepath.Left(sFilepath.GetLength() - nIndex);
sThemePath = sFilepathLeft + L"theme";
sEmbedingPath = sFilepathLeft + L"embeddings";
sThemePath = sFilepathLeft + _T("theme");
sEmbedingPath = sFilepathLeft + _T("embeddings");
}
//todo theme path
BinXlsxRW::SaveParams oSaveParams(sThemePath);
OOX::Spreadsheet::CChartSpace oChartSpace;
BinXlsxRW::BinaryChartReader oBinaryChartReader(oBufferedStream, oSaveParams, m_pExternalDrawingConverter);
//todo theme path
BinXlsxRW::SaveParams oSaveParams(sThemePath);
OOX::Spreadsheet::CChartSpace oChartSpace;
BinXlsxRW::BinaryChartReader oBinaryChartReader(oBufferedStream, oSaveParams, m_pExternalDrawingConverter);
oBinaryChartReader.ReadCT_ChartSpace(lLength, &oChartSpace.m_oChartSpace);
if(oChartSpace.isValid())
{
//todo не делать embeddings, если пишем xlsx
//save xlsx
if(!sEmbedingPath.empty())
if(!sEmbedingPath.IsEmpty())
{
std::wstring sXlsxFilename = L"Microsoft_Excel_Worksheet" + std::to_wstring(lChartNumber) + L".xlsx";
std::wstring sXlsxPath = sEmbedingPath + FILE_SEPARATOR_STR + sXlsxFilename;
std::wstring sXlsxPath = string2std_string(sEmbedingPath + FILE_SEPARATOR_STR) + sXlsxFilename;
writeChartXlsx(sXlsxPath, oChartSpace);
std::wstring sChartsWorksheetRelsName = L"../embeddings/" + sXlsxFilename;
long rId;
CString bstrChartsWorksheetRelType = OOX::Spreadsheet::FileTypes::ChartsWorksheet.RelationType();
m_pExternalDrawingConverter->WriteRels(bstrChartsWorksheetRelType, sChartsWorksheetRelsName, CString(), &rId);
m_pExternalDrawingConverter->WriteRels(bstrChartsWorksheetRelType, std_string2string(sChartsWorksheetRelsName), CString(), &rId);
oChartSpace.m_oChartSpace.m_externalData = new OOX::Spreadsheet::CT_ExternalData();
oChartSpace.m_oChartSpace.m_externalData->m_id = new std::wstring();
@ -227,9 +225,9 @@ namespace BinXlsxRW{
oChartSpace.m_oChartSpace.m_externalData->m_autoUpdate->m_val = new bool(false);
}
std::wstring strFilepath = sFilepath;
CString strDir = NSSystemPath::GetDirectoryName(strFilepath);
CString strFilename = NSSystemPath::GetFileName(strFilepath);
std::wstring strFilepath = string2std_string(sFilepath);
CString strDir = std_string2string(NSSystemPath::GetDirectoryName(strFilepath));
CString strFilename = std_string2string(NSSystemPath::GetFileName(strFilepath));
OOX::CPath pathRelsDir = strDir + FILE_SEPARATOR_STR + _T("_rels");
@ -252,11 +250,11 @@ namespace BinXlsxRW{
}
return bRes;
}
void CXlsxSerializer::setFontDir(std::wstring& sFontDir)
void CXlsxSerializer::setFontDir(CString& sFontDir)
{
m_sFontDir = sFontDir;
}
void CXlsxSerializer::setEmbeddedFontsDir(std::wstring& sEmbeddedFontsDir)
void CXlsxSerializer::setEmbeddedFontsDir(CString& sEmbeddedFontsDir)
{
m_sEmbeddedFontsDir = sEmbeddedFontsDir;
}
@ -277,7 +275,7 @@ namespace BinXlsxRW{
CString sXmlOptions = _T("");
CString sMediaPath;// will be filled by 'CreateXlsxFolders' method
CString sEmbedPath; // will be filled by 'CreateXlsxFolders' method
CreateXlsxFolders (sXmlOptions, sTempDir, sMediaPath, sEmbedPath);
CreateXlsxFolders (sXmlOptions, std_string2string(sTempDir), sMediaPath, sEmbedPath);
//заполняем Xlsx
OOX::Spreadsheet::CXlsx oXlsx;
helper.toXlsx(oXlsx);

View File

@ -32,7 +32,13 @@
#ifndef XLSX_SERIALIZER
#define XLSX_SERIALIZER
#include "../../Common/DocxFormat/Source/Base/ASCString.h"
#if defined(_WIN32) || defined (_WIN64)
#include <atlbase.h>
#include <atlstr.h>
#else
#include "../../Common/DocxFormat/Source/Base/ASCString.h"
#endif
#include <string>
namespace OOX
@ -68,8 +74,8 @@ namespace BinXlsxRW {
bool loadChart(CString& sChartPath, NSBinPptxRW::CBinaryFileWriter& oBufferedStream, long& lDataSize);
bool saveChart(NSBinPptxRW::CBinaryFileReader& oBufferedStream, long lLength, CString& sFilename, CString& sContentTypePath, CString** sContentTypeElement, const long& lChartNumber);
void setFontDir (std::wstring& sFontDir);
void setEmbeddedFontsDir(std::wstring& sEmbeddedFontsDir);
void setFontDir(CString& sFontDir);
void setEmbeddedFontsDir(CString& sEmbeddedFontsDir);
void setDrawingConverter(NSBinPptxRW::CDrawingConverter* pDrawingConverter);
void writeChartXlsx(const std::wstring& sDstFile ,const OOX::Spreadsheet::CChartSpace& oChart);

View File

@ -37,21 +37,12 @@
#include "../../src/ConvertOO2OOX.h"
#if defined(_WIN64)
#pragma comment(lib, "../../../build/bin/icu/win_64/icuuc.lib")
#elif defined (_WIN32)
#pragma comment(lib, "../../../build/bin/icu/win_32/icuuc.lib")
#endif
int _tmain(int argc, _TCHAR* argv[])
{
if (argc < 2) return 1;
HRESULT hr = S_OK;
//////////////////////////////////////////////////////////////////////////
std::wstring srcFileName = argv[1];
std::wstring dstPath = argc > 2 ? argv[2] : sSrcDoc + L"-my.docx"; //xlsx pptx
std::wstring dstPath = argv[2];
std::wstring outputDir = FileSystem::Directory::GetFolderPath(dstPath);
std::wstring srcTempPath = FileSystem::Directory::CreateDirectoryWithUniqueName(outputDir);

View File

@ -345,30 +345,6 @@
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\..\Common\3dParty\pole\pole.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\..\UnicodeConverter\UnicodeConverter.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
</Filter>
</Files>
<Globals>

View File

@ -213,6 +213,7 @@ SOURCES += \
../src/docx/hyperlinks.cpp \
../src/docx/measuredigits.cpp \
../src/docx/mediaitems.cpp \
../src/docx/mediaitems_utils.cpp \
../src/docx/namespaces.cpp \
../src/docx/oox_chart_axis.cpp \
../src/docx/oox_chart_context.cpp \
@ -461,6 +462,7 @@ HEADERS += \
../src/docx/hyperlinks.h \
../src/docx/measuredigits.h \
../src/docx/mediaitems.h \
../src/docx/mediaitems_utils.h \
../src/docx/namespaces.h \
../src/docx/oox_chart_axis.h \
../src/docx/oox_chart_context.h \

View File

@ -76,7 +76,7 @@ public:
{}
std::wostream & xml_to_stream(std::wostream & _Wostream) const;
const std::wstring & part_name() const { return part_name_; }
const std::wstring & part_name() const { return part_name_; }
const std::wstring & content_type() const { return content_type_; }
public:

View File

@ -82,8 +82,6 @@ void text_tracked_context::start_changes_content()
void text_tracked_context::end_changes_content()
{
docx_context_.finish_run(); //0106GS-GettingStartedWithWriter_el.odt - удаленный заголовок
current_state_.content.push_back(changes_stream_.str());
docx_context_.set_delete_text_state (false);
@ -132,8 +130,8 @@ text_tracked_context::_state & text_tracked_context::get_tracked_change(std::wst
//----------------------------------------------------------------------------------------------------------------
docx_conversion_context::docx_conversion_context(odf_reader::odf_document * OdfDocument) :
mediaitems_ (OdfDocument->get_folder() ),
next_dump_page_properties_ (false),
page_break_ (false),
page_break_after_ (false),
page_break_before_ (false),
in_run_ (false),
@ -152,8 +150,7 @@ docx_conversion_context::docx_conversion_context(odf_reader::odf_document * OdfD
delayed_converting_ (false),
process_headers_footers_ (false),
process_comment_ (false),
mediaitems_ (OdfDocument->get_folder() ),
math_context_ (OdfDocument->odf_context().fontContainer(), false),
math_context_ (false),
odf_document_ (OdfDocument)
{
streams_man_ = streams_man::create(temp_stream_);
@ -835,20 +832,13 @@ void docx_conversion_context::docx_serialize_paragraph_style(std::wostream & str
//in_styles = true -> styles.xml
//почему то конструкция <pPr><rPr/></pPr><rPr/> "не работает" в части в rPr в ms2010 )
{
bool in_drawing = false;
if (get_drawing_context().get_current_shape() || get_drawing_context().get_current_frame())
{
in_drawing = true;
}
std::wstringstream & paragraph_style = get_styles_context().paragraph_nodes();
std::wstringstream & run_style = get_styles_context().text_style();
CP_XML_WRITER(strm)
{
//Tutor_Charlotte_Tutor_the_Entire_World_.odt
if (get_section_context().dump_.empty() == false && (!ParentId.empty() || get_section_context().get().is_dump_ || in_header_)
&& !get_table_context().in_table() && !in_drawing)
&& !get_table_context().in_table())
{//две подряд секции или если стиль определен и в заголовки нельзя пихать !!!
CP_XML_NODE(L"w:pPr")
{
@ -863,7 +853,7 @@ void docx_conversion_context::docx_serialize_paragraph_style(std::wostream & str
{
CP_XML_NODE(L"w:pPr")
{
if ( !get_table_context().in_table() && !in_drawing)
if ( !get_table_context().in_table() )
{
CP_XML_STREAM() << get_section_context().dump_;
get_section_context().dump_.clear();

View File

@ -187,10 +187,12 @@ void serialize_wrap(std::wostream & strm, _docx_drawing const & val)
}
}
void _docx_drawing::serialize_text(std::wostream & strm)
void docx_serialize_text(std::wostream & strm, _docx_drawing & val)
{
const std::vector<odf_reader::_property> & properties = val.additional;
_CP_OPT(std::wstring) strTextContent;
odf_reader::GetProperty(additional, L"text-content", strTextContent);
odf_reader::GetProperty(properties,L"text-content",strTextContent);
CP_XML_WRITER(strm)
{
@ -207,7 +209,7 @@ void _docx_drawing::serialize_text(std::wostream & strm)
}
}
serialize_bodyPr(strm, L"wps");
oox_serialize_bodyPr(strm, val, L"wps");
}
//--------------------------------------------------------------------
@ -238,11 +240,11 @@ void docx_serialize_image_child(std::wostream & strm, _docx_drawing & val)
CP_XML_NODE(L"pic:spPr")
{
val.serialize_xfrm(CP_XML_STREAM());
oox_serialize_xfrm(CP_XML_STREAM(), val);
CP_XML_NODE(L"a:prstGeom")
{
CP_XML_ATTR(L"prst", L"rect");
CP_XML_ATTR(L"prst",L"rect");
CP_XML_NODE(L"a:avLst");
}
@ -278,12 +280,13 @@ void docx_serialize_shape_child(std::wostream & strm, _docx_drawing & val)
}
CP_XML_NODE(L"wps:spPr")
{
val.serialize_xfrm (CP_XML_STREAM());
val.serialize_shape (CP_XML_STREAM());
oox_serialize_xfrm(CP_XML_STREAM(),val);
oox_serialize_shape(CP_XML_STREAM(),val);
oox_serialize_ln(CP_XML_STREAM(), val.additional);
}
val.serialize_text(CP_XML_STREAM());
docx_serialize_text(CP_XML_STREAM(),val);
}
}
}
@ -303,14 +306,13 @@ void docx_serialize_group_child(std::wostream & strm, _docx_drawing & val)
CP_XML_NODE(L"wpg:grpSpPr")
{
val.serialize_xfrm(CP_XML_STREAM());
oox_serialize_xfrm(CP_XML_STREAM(),val);
}
CP_XML_STREAM() << val.content_group_;
}
}
}
void docx_serialize_chart_child(std::wostream & strm, _docx_drawing & val)
{
CP_XML_WRITER(strm)
@ -319,7 +321,7 @@ void docx_serialize_chart_child(std::wostream & strm, _docx_drawing & val)
{
CP_XML_ATTR(L"xmlns:c", L"http://schemas.openxmlformats.org/drawingml/2006/chart");
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
CP_XML_ATTR(L"r:id", val.objectId);
CP_XML_ATTR(L"r:id", val.chartId);
}
}
}
@ -330,9 +332,9 @@ void docx_serialize_common(std::wostream & strm, _docx_drawing & val)
{
CP_XML_NODE(L"wp:docPr")
{
CP_XML_ATTR(L"name", val.name);
CP_XML_ATTR(L"id", val.id + 1);
oox_serialize_hlink(CP_XML_STREAM(), val.hlinks);
CP_XML_ATTR(L"name",val.name);
CP_XML_ATTR(L"id", val.id + 1);
oox_serialize_hlink(CP_XML_STREAM(),val.hlinks);
}
CP_XML_NODE(L"wp:cNvGraphicFramePr")
@ -353,11 +355,6 @@ void docx_serialize_common(std::wostream & strm, _docx_drawing & val)
CP_XML_ATTR(L"uri",L"http://schemas.microsoft.com/office/word/2010/wordprocessingShape");
docx_serialize_shape_child(CP_XML_STREAM(), val);
}
else if (val.type == typeGroupShape)
{
CP_XML_ATTR(L"uri", L"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup");
docx_serialize_group_child(CP_XML_STREAM(), val);
}
else if (val.type == typeImage)
{
CP_XML_ATTR(L"uri",L"http://schemas.openxmlformats.org/drawingml/2006/picture");
@ -368,6 +365,11 @@ void docx_serialize_common(std::wostream & strm, _docx_drawing & val)
CP_XML_ATTR(L"uri", L"http://schemas.openxmlformats.org/drawingml/2006/chart");
docx_serialize_chart_child(CP_XML_STREAM(), val);
}
else if (val.type == typeGroupShape)
{
CP_XML_ATTR(L"uri", L"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup");
docx_serialize_group_child(CP_XML_STREAM(), val);
}
}
}
}
@ -438,6 +440,8 @@ void docx_serialize_wps(std::wostream & strm, _docx_drawing & val)
std::wstring relativeFrom = L"margin";
if (val.styleHorizontalRel) relativeFrom =val.styleHorizontalRel->get_type_str();
if (relativeFrom == L"column") relativeFrom = L"margin";
CP_XML_ATTR(L"relativeFrom", relativeFrom);
if (val.styleHorizontalPos &&
@ -455,10 +459,10 @@ void docx_serialize_wps(std::wostream & strm, _docx_drawing & val)
CP_XML_NODE(L"wp:positionV")
{
std::wstring relativeFrom = L"margin";
if (val.styleVerticalRel)relativeFrom = val.styleVerticalRel->get_type_str();
CP_XML_ATTR(L"relativeFrom", relativeFrom);
std::wstring relativeFrom = L"paragraph";
if (val.styleVerticalRel)relativeFrom = val.styleVerticalRel->get_type_str();
CP_XML_ATTR(L"relativeFrom",relativeFrom);
if (val.styleVerticalPos &&
val.styleVerticalPos->get_type() != odf_types::vertical_pos::FromTop &&
@ -479,8 +483,8 @@ void docx_serialize_wps(std::wostream & strm, _docx_drawing & val)
}
CP_XML_NODE(L"wp:extent")
{
CP_XML_ATTR(L"cx", val.cx);
CP_XML_ATTR(L"cy", val.cy);
CP_XML_ATTR(L"cx",val.cx);
CP_XML_ATTR(L"cy",val.cy);
}
serialize_wrap(CP_XML_STREAM(), val);
@ -509,8 +513,6 @@ void docx_serialize_wps(std::wostream & strm, _docx_drawing & val)
std::wstring relativeFrom = L"paragraph";
if (val.styleVerticalRel)relativeFrom = val.styleVerticalRel->get_type_str();
if (relativeFrom == L"paragraph") relativeFrom = L"margin";
CP_XML_NODE(L"wp14:sizeRelV")
{
CP_XML_ATTR(L"relativeFrom", relativeFrom);
@ -575,65 +577,16 @@ void docx_serialize_alt_content(std::wostream & strm, _docx_drawing & val)
}
}
}
void docx_serialize_object(std::wostream & strm, _docx_drawing & val)
void docx_serialize(std::wostream & strm, _docx_drawing & val, bool insideOtherDrawing)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"w:object")
{
CP_XML_NODE(L"v:shape")
{
CP_XML_ATTR(L"id", L"ole_" + val.objectId);
CP_XML_ATTR(L"o:ole", "");
std::wstring style_str; // = L"width:730.6pt; height:261.8pt";
style_str += L"width:" + std::to_wstring(val.cx / 12700.) + L"pt;";
style_str += L"height:" + std::to_wstring(val.cy / 12700.) + L"pt;";
CP_XML_ATTR(L"style", style_str);
if (val.fill.bitmap)
{
CP_XML_NODE(L"v:imagedata")
{
CP_XML_ATTR(L"o:title", val.name);
CP_XML_ATTR(L"r:id", val.fill.bitmap->rId);
}
}
}
CP_XML_NODE(L"o:OLEObject")
{
CP_XML_ATTR(L"Type", L"Embed");
CP_XML_ATTR(L"ProgID", val.objectProgId);
CP_XML_ATTR(L"ShapeID", L"ole_" + val.objectId);
CP_XML_ATTR(L"DrawAspect", L"Content" );
CP_XML_ATTR(L"ObjectID", 0x583A3000 + val.id );
CP_XML_ATTR(L"r:id", val.objectId);
}
}
}
}
void _docx_drawing::serialize(std::wostream & strm/*, bool insideOtherDrawing*/)
{
if (type == typeUnknown) return;
if (inGroup)
return docx_serialize_child(strm, *this);
if (val.inGroup)
return docx_serialize_child(strm, val);
if (type == typeMsObject ||
type == typeOleObject)
{
docx_serialize_object(strm, *this);
}
else
{
//if (insideOtherDrawing)
docx_serialize_wps(strm, *this);
//else
// docx_serialize_alt_content(strm, val);
}
//if (insideOtherDrawing)
docx_serialize_wps(strm, val);
//else
// docx_serialize_alt_content(strm, val);
}

View File

@ -44,10 +44,9 @@
namespace cpdoccore {
namespace oox {
class _docx_drawing : public _oox_drawing
struct _docx_drawing : _oox_drawing
{
public:
_docx_drawing() : _oox_drawing(), parallel(0), isInline(false), number_wrapped_paragraphs(0), posOffsetV(0), posOffsetH(0)
_docx_drawing():_oox_drawing(), parallel(0), isInline(false), number_wrapped_paragraphs(0), posOffsetV(0), posOffsetH(0)
{
}
bool isInline;
@ -73,12 +72,15 @@ public:
_CP_OPT(int) pctWidth;
_CP_OPT(int) pctHeight;
int margin_rect[4]; //0-left, 1 -top, 2- right, 3 - bottom
int margin_rect[4];//0-left, 1 -top, 2- right, 3 - bottom
//std::wstring distB;
// std::wstring distT;
// std::wstring distL;
// std::wstring distR;
std::wstring content_group_;
void serialize_text (std::wostream & strm);
void serialize (std::wostream & strm/*, bool insideOtherDrawing*/);
friend void docx_serialize(std::wostream & _Wostream, _docx_drawing & val, bool insideOtherDrawing);
};
}
}

View File

@ -96,13 +96,8 @@ void word_files::write(const std::wstring & RootPath)
{
media_->write( path );
}
if (embeddings_)
{
embeddings_->write( path );
}
if (headers_footers_)
if (headers_footers_)
{
headers_footers_->write( path );
}
@ -141,15 +136,7 @@ void word_files::update_rels(docx_conversion_context & Context)
void word_files::set_media(mediaitems & _Mediaitems, CApplicationFonts *pAppFonts)
{
if (_Mediaitems.count_image + _Mediaitems.count_media > 0)
{
media_ = element_ptr( new media(_Mediaitems, pAppFonts) );
}
if (_Mediaitems.count_object > 0)
{
embeddings_ = element_ptr( new embeddings(_Mediaitems) );
embeddings_->set_main_document( get_main_document() );
}
media_ = element_ptr( new media(_Mediaitems, pAppFonts) );
}
void word_files::set_styles(element_ptr Element)
@ -210,7 +197,6 @@ void docx_charts_files::add_chart(chart_content_ptr chart)
{
charts_.push_back(chart);
}
void docx_charts_files::write(const std::wstring & RootPath)
{
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"charts";

View File

@ -148,7 +148,6 @@ private:
element_ptr fontTable_;
element_ptr numbering_;
element_ptr media_;
element_ptr embeddings_;
element_ptr headers_footers_;
element_ptr notes_;
element_ptr settings_;

View File

@ -52,8 +52,6 @@ struct drawing_object_description
oox::RelsType type_;
std::wstring name_;
std::wstring descriptor_;
_CP_OPT(_rect) svg_rect_;
std::wstring anchor_;
@ -68,6 +66,7 @@ struct drawing_object_description
_oox_fill fill_;
bool use_image_replace_;
bool in_group_;
int shape_type_; //default - frame

View File

@ -97,12 +97,9 @@ void headers_footers::dump_rels(rels & Rels) const//внешние релсы
}
}
bool headers_footers::write_sectPr(const std::wstring & StyleName, bool next_page/*not used*/, std::wostream & _Wostream)
bool headers_footers::write_sectPr(const std::wstring & StyleName, std::wostream & _Wostream) const
{
if (!instances_.count(StyleName)) return false;
if (last_write_style_ == StyleName) return true;
last_write_style_ = StyleName;
if (!instances_.count(StyleName))return false;
bool first = false, left = false;
bool res = false;

View File

@ -49,8 +49,7 @@ namespace oox {
class headers_footers
{
public:
headers_footers() : size_(0) {}
headers_footers() : size_(0),enable_write_(false){}
enum Type { header, footer, headerLeft, footerLeft, headerFirst, footerFirst, none };
std::wstring add(const std::wstring & StyleName, const std::wstring & Content, Type type,rels &_rels);
@ -67,17 +66,18 @@ public:
};
void dump_rels(rels & Rels) const;
bool write_sectPr(const std::wstring & StyleName, bool next_page, std::wostream & _Wostream);
bool write_sectPr(const std::wstring & StyleName, std::wostream & _Wostream) const;
typedef boost::shared_ptr<instance> instance_ptr;
typedef std::vector<instance_ptr> instances_array;
typedef boost::unordered_map<std::wstring, instances_array> instances_map;
const instances_map & instances() const { return instances_; }
const instances_map & instances() const { return instances_; }
bool get_enable_write(){return enable_write_;}
void set_enable_write(bool val){enable_write_ = val;}
private:
std::wstring last_write_style_;
bool enable_write_;
static std::wstring create_id(size_t i);
static std::wstring create_name(size_t i, Type _Type);
instances_map instances_;

View File

@ -39,27 +39,15 @@
#include <cpdoccore/xml/utils.h>
#include "mediaitems_utils.h"
#include "../../Common/DocxFormat/Source/Base/Base.h"
#include "../../Common/DocxFormat/Source/SystemUtility/File.h"
#include "../../Common/DocxFormat/Source/SystemUtility/FileSystem/Directory.h"
#include "../../DesktopEditor/raster/ImageFileFormatChecker.h"
namespace cpdoccore {
namespace oox {
bool is_internal(const std::wstring & uri, const std::wstring & packetRoot)
{
if (uri.empty())return false;
std::wstring mediaPath = boost::regex_search(uri.begin(), uri.end(), boost::wregex(L"^/[A-Za-z]:"))
? std::wstring(uri.begin() + 1, uri.end())
: uri;
std::wstring resultPath = packetRoot + FILE_SEPARATOR_STR + mediaPath;
return FileSystem::Directory::IsExist(resultPath) || FileSystem::Directory::IsExist(mediaPath);
}
mediaitems::item::item( std::wstring const & _href,
RelsType _type,
@ -67,12 +55,12 @@ mediaitems::item::item( std::wstring const & _href,
bool _mediaInternal,
std::wstring const & _Id
)
: href(_href),
type(_type),
outputName(_outputName),
mediaInternal(_mediaInternal),
Id(_Id),
valid(true) //вообще говоря даже если файл покоцанный то мы все равно обязаны перенести "объект"
: href(_href),
type(_type),
outputName(_outputName),
mediaInternal(_mediaInternal),
Id(_Id),
valid(true) //вообще говоря даже если файл покоцанный то мы все равно обязаны перенести "объект"
{
count_add = 1;
count_used = 0;
@ -94,10 +82,6 @@ std::wstring static get_default_file_name(RelsType type)
return L"chart";
case typeMedia:
return L"media";
case typeMsObject:
return L"msObject";
case typeOleObject:
return L"oleObject";
default:
return L"";
}
@ -136,9 +120,6 @@ std::wstring mediaitems::create_file_name(const std::wstring & uri, RelsType typ
sExt = uri.substr(n);
}
}
if (type == typeOleObject && sExt.empty())
sExt = L".bin";
return get_default_file_name(type) + std::to_wstring(Num) + sExt;
}
@ -148,7 +129,7 @@ std::wstring mediaitems::detectImageFileExtension(std::wstring &fileName)
CFile file;
std::wstring sExt;
if (file.OpenFile(fileName) == S_OK)
if (file.OpenFile(std_string2string(fileName)) == S_OK)
{
BYTE buffer[128];
int buffer_size = 128;
@ -166,7 +147,7 @@ std::wstring mediaitems::detectImageFileExtension(std::wstring &fileName)
std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, bool & isInternal, std::wstring & ref)
{
bool isMediaInternal = is_internal(href, odf_packet_);
bool isMediaInternal = utils::media::is_internal(href, odf_packet_);
std::wstring sub_path = L"media/";
@ -175,27 +156,21 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b
{
sub_path = L"charts/";
}
if ( type == typeMsObject || type == typeOleObject)
{
sub_path = L"embeddings/";
}
int number=0;
if ( type == typeChart) number = count_charts + 1;
else if ( type == typeImage) number = count_image + 1;
else if ( type == typeShape) number = count_shape + 1;
else if ( type == typeMedia) number = count_media + 1;
else if ( type == typeMsObject ||
type == typeOleObject) number = count_object + 1;
if ( type == typeChart) number = count_charts + 1;
else if ( type == typeImage) number = count_image + 1;
else if ( type == typeShape) number = count_shape + 1;
else if ( type == typeMedia) number = count_media + 1;
else
number = items_.size() + 1;
number = items_.size()+1;
inputFileName = create_file_name(href, type, isMediaInternal, number);
std::wstring inputPath = isMediaInternal ? odf_packet_ + FILE_SEPARATOR_STR + href : href;
std::wstring outputPath = isMediaInternal ? ( sub_path + inputFileName) : href;
if ( type == typeChart) outputPath = outputPath + L".xml";
if ( type == typeChart) outputPath= outputPath + L".xml";
std::wstring id;
for (int i = 0 ; i < items_.size(); i++)
@ -217,7 +192,7 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b
{
if ( type == typeChart)
{
id = std::wstring(L"chId") + std::to_wstring(count_charts + 1);
id = std::wstring(L"chId") + std::to_wstring(count_charts+1);
count_charts++;
}
else if ( type == typeImage)
@ -230,17 +205,12 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b
//------------------------------------------------
if (inputFileName.empty()) return L"";
id = std::wstring(L"picId") + std::to_wstring(count_image + 1);
id = std::wstring(L"picId") + std::to_wstring(count_image+1);
count_image++;
}
else if ( type == typeMsObject || type == typeOleObject)
{
id = std::wstring(L"objId") + std::to_wstring(count_object + 1);
count_object++;
}
else
{
id = std::wstring(L"rId") + std::to_wstring(count_shape + 1);
id = std::wstring(L"rId") + std::to_wstring(count_shape+1);
count_shape++;
}
@ -255,17 +225,16 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b
void mediaitems::dump_rels(rels & Rels)
{
size_t i = 0;
for (int i = 0; i < items_.size(); i++)
BOOST_FOREACH(item & elm, items_)
{
if (items_[i].count_used > items_[i].count_add) continue; // уже использовали этот релс выше(колонтитул ....)
Rels.add( relationship(
items_[i].Id,
get_rel_type (items_[i].type),
items_[i].valid ? items_[i].outputName : L"NULL",
items_[i].mediaInternal ? L"" : L"External" )
if (elm.count_used > elm.count_add)continue; // уже использовали этот релс выше(колонтитул ....)
Rels.add( relationship(
elm.Id,
utils::media::get_rel_type(elm.type),
elm.valid ? elm.outputName : L"NULL",
elm.mediaInternal ? L"" : L"External" )
);
items_[i].count_used++;
elm.count_used++;
}
}

View File

@ -39,6 +39,7 @@
namespace cpdoccore {
namespace oox {
class mediaitems
{
public:
@ -49,7 +50,7 @@ public:
count_image = 0;
count_tables = 0;
count_media = 0;
count_object = 0;
}
struct item
@ -76,7 +77,6 @@ public:
size_t count_media;
size_t count_shape;
size_t count_tables;
size_t count_object;
std::wstring add_or_find(const std::wstring & href, RelsType type, bool & isInternal);//возможны ссылки на один и тот же объект
std::wstring add_or_find(const std::wstring & href, RelsType type, bool & isInternal, std::wstring & ref);
@ -84,20 +84,6 @@ public:
void dump_rels(rels & Rels);
items_array & items() { return items_; }
static std::wstring get_rel_type(RelsType type)
{
switch (type)
{
case typeImage: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image";
case typeChart: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart";
case typeMsObject: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/package";
case typeOleObject: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject";
case typeHyperlink: return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink";
default:
return L"";
}
}
private:
std::wstring create_file_name (const std::wstring & uri, RelsType type, bool & isInternal, size_t Num);
std::wstring detectImageFileExtension (std::wstring &fileName);

View File

@ -0,0 +1,91 @@
/*
* (c) Copyright Ascensio System SIA 2010-2016
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "mediaitems_utils.h"
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/regex.hpp>
#include "../../Common/DocxFormat/Source/Base/Base.h"
#include "../../Common/DocxFormat/Source/SystemUtility/FileSystem/Directory.h"
namespace cpdoccore {
namespace oox {
namespace utils {
namespace media {
bool is_internal(const std::wstring & uri, const std::wstring & packetRoot)
{
if (uri.empty())return false;
std::wstring mediaPath = boost::regex_search(uri.begin(), uri.end(), boost::wregex(L"^/[A-Za-z]:"))
? std::wstring(uri.begin() + 1, uri.end())
: uri;
std::wstring resultPath = packetRoot + FILE_SEPARATOR_STR + mediaPath;
return FileSystem::Directory::IsExist(resultPath);
}
std::wstring get_rel_type(RelsType type)
{
switch (type)
{
case typeImage:
return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image";
case typeChart:
return L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart";
default:
return L"";
}
}
std::wstring replace_extension(const std::wstring & ext)
{
// TODO
if (ext == L"jpg")
return L"jpeg";
else
return ext;
}
}
}
}
}

View File

@ -0,0 +1,52 @@
/*
* (c) Copyright Ascensio System SIA 2010-2016
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#ifndef CPDOCCORE_MEDIAITEMS_UTILS_H_
#define CPDOCCORE_MEDIAITEMS_UTILS_H_
#include <string>
#include "mediaitems.h"
namespace cpdoccore {
namespace oox {
namespace utils {
namespace media {
bool is_internal(const std::wstring & uri, const std::wstring & packetRoot);
std::wstring get_rel_type(RelsType type);
}
}
}
}
#endif

View File

@ -31,12 +31,13 @@
*/
#include <boost/foreach.hpp>
#include <vector>
#include <cpdoccore/xml/simple_xml_writer.h>
#include "mediaitems_utils.h"
#include "oox_rels.h"
#include "oox_chart_context.h"
#include "mediaitems.h"
namespace cpdoccore {
namespace oox {
@ -86,7 +87,7 @@ void oox_chart_context::dump_rels(rels & Rels)
{
Rels.add(relationship(
r.rid,
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
utils::media::get_rel_type(r.type),
r.is_internal ? std::wstring(L"../") + r.ref : r.ref,
(r.is_internal ? L"" : L"External")
)

View File

@ -144,7 +144,7 @@ void styles_context::docx_serialize_table_style(std::wostream & strm, std::wstri
}
namespace oox
{
math_context::math_context(odf_reader::fonts_container & fonts, bool graphic) : base_font_size_(12), fonts_container_(fonts)
math_context::math_context(bool graphic) : base_font_size_(12)
{
graphRPR_ = graphic;

View File

@ -44,7 +44,6 @@ namespace odf_reader
{
class style_instance;
class style_text_properties;
class fonts_container;
typedef boost::shared_ptr<style_text_properties> style_text_properties_ptr;
};
@ -91,7 +90,7 @@ namespace oox {
class math_context : boost::noncopyable
{
public:
math_context(odf_reader::fonts_container & fonts, bool graphic = false);
math_context(bool graphic = false);
void start();
std::wstring end();
@ -100,7 +99,6 @@ namespace oox {
std::wstringstream & math_style_stream() { return math_style_stream_; }
odf_reader::fonts_container & fonts_container_;
int base_font_size_;
odf_reader::style_text_properties_ptr text_properties_;

View File

@ -37,19 +37,6 @@
namespace cpdoccore {
static const std::wstring _ooxShapeType[]=
{
L"rect", //frame
L"rect", //text box
L"rect", //shape
L"ellipse",
L"ellipse",
L"line",
L"path",
L"custGeom",//uses sub-sub type,
L"polygon",
};
void svg_path::oox_serialize(std::wostream & strm, std::vector<svg_path::_polyline> & path)
{
CP_XML_WRITER(strm)
@ -68,7 +55,7 @@ void svg_path::oox_serialize(std::wostream & strm, svg_path::_polyline const & v
{
BOOST_FOREACH(svg_path::_point const & p, val.points)
{
oox_serialize(CP_XML_STREAM(), p);
oox_serialize(CP_XML_STREAM() ,p);
}
}
}
@ -248,9 +235,9 @@ void oox_serialize_aLst(std::wostream & strm, const std::vector<odf_reader::_pro
}
}
}
void _oox_drawing::serialize_bodyPr(std::wostream & strm, const std::wstring & namespace_)
void oox_serialize_bodyPr(std::wostream & strm, _oox_drawing & val, const std::wstring & namespace_)
{
const std::vector<odf_reader::_property> & prop = additional;
const std::vector<odf_reader::_property> & prop = val.additional;
_CP_OPT(bool) bWordArt;
odf_reader::GetProperty(prop,L"wordArt", bWordArt);
@ -270,11 +257,11 @@ void _oox_drawing::serialize_bodyPr(std::wostream & strm, const std::wstring & n
if (dPaddingTop) CP_XML_ATTR(L"tIns", (int)(*dPaddingTop));
if (dPaddingBottom) CP_XML_ATTR(L"bIns", (int)(*dPaddingBottom));
if (inGroup == false)
if (val.inGroup == false)
{
_CP_OPT(int) iWrap;
odf_reader::GetProperty(prop, L"text-wrap" , iWrap);
if ((iWrap) && (*iWrap == 0)) CP_XML_ATTR(L"wrap", L"none");
odf_reader::GetProperty(prop,L"text-wrap" , iWrap);
if ((iWrap) && (*iWrap == 0))CP_XML_ATTR(L"wrap", L"none");
}
_CP_OPT(int) iAlign;
@ -332,7 +319,7 @@ void _oox_drawing::serialize_bodyPr(std::wostream & strm, const std::wstring & n
}
}
void _oox_drawing::serialize_shape(std::wostream & strm)
void oox_serialize_shape(std::wostream & strm, _oox_drawing & val)
{
_CP_OPT(std::wstring) strVal;
_CP_OPT(double) dVal;
@ -340,61 +327,60 @@ void _oox_drawing::serialize_shape(std::wostream & strm)
std::wstring shapeType;
_CP_OPT(bool) bWordArt;
odf_reader::GetProperty(additional,L"wordArt", bWordArt);
odf_reader::GetProperty(val.additional,L"wordArt", bWordArt);
if (sub_type == 7)//custom
if (val.sub_type == 7)//custom
{
_CP_OPT(int) iVal;
odf_reader::GetProperty(additional, L"odf-custom-draw-index",iVal);
odf_reader::GetProperty(val.additional, L"odf-custom-draw-index",iVal);
if (iVal)
shapeType = _OO_OOX_custom_shapes[*iVal].oox;
else
sub_type = 6; //path
val.sub_type = 6; //path
if (shapeType == L"textBox")
{
sub_type = 1;
val.sub_type = 1;
shapeType = L"rect";
}
}
else if (sub_type < 9 && sub_type >= 0)
else if (val.sub_type < 9 && val.sub_type >= 0)
{
shapeType = _ooxShapeType[sub_type];
shapeType = _ooxShapeType[val.sub_type];
}
if (bWordArt) sub_type = 1;
if (bWordArt) val.sub_type = 1;
CP_XML_WRITER(strm)
{
if (sub_type == 6 || sub_type == 8)
if (val.sub_type == 6 || val.sub_type == 8)
{
CP_XML_NODE(L"a:custGeom")
{
oox_serialize_aLst(CP_XML_STREAM(), additional);
oox_serialize_aLst(CP_XML_STREAM(), val.additional);
CP_XML_NODE(L"a:ahLst");
CP_XML_NODE(L"a:gdLst");
CP_XML_NODE(L"a:rect")
{
CP_XML_ATTR(L"b", L"b");
CP_XML_ATTR(L"l", 0);
CP_XML_ATTR(L"r", L"r");
CP_XML_ATTR(L"t", 0);
CP_XML_ATTR(L"b",L"b");
CP_XML_ATTR(L"l",0);
CP_XML_ATTR(L"r",L"r");
CP_XML_ATTR(L"t",0);
}
//<a:rect b="b" l="0" r="r" t="0"/>
if (odf_reader::GetProperty(additional, L"custom_path", strVal))
if (odf_reader::GetProperty(val.additional, L"custom_path", strVal))
{
_CP_OPT(int) w, h;
odf_reader::GetProperty(additional, L"custom_path_w", w);
odf_reader::GetProperty(additional, L"custom_path_h", h);
odf_reader::GetProperty(val.additional, L"custom_path_w", w);
odf_reader::GetProperty(val.additional, L"custom_path_h", h);
CP_XML_NODE(L"a:pathLst")
{
CP_XML_NODE(L"a:path")
{
CP_XML_ATTR(L"w", w ? *w : cx);
CP_XML_ATTR(L"h", h ? *h : cy);
CP_XML_ATTR(L"w", w ? *w : val.cx);
CP_XML_ATTR(L"h", h ? *h : val.cy);
CP_XML_STREAM() << strVal.get();
}
@ -407,12 +393,12 @@ void _oox_drawing::serialize_shape(std::wostream & strm)
if (shapeType.length() < 1)
{
shapeType = L"rect";
sub_type = 2;
val.sub_type = 2;
}
CP_XML_NODE(L"a:prstGeom")//автофигура
{
CP_XML_ATTR(L"prst", shapeType);
if (!bWordArt) oox_serialize_aLst(CP_XML_STREAM(), additional);
if (!bWordArt) oox_serialize_aLst(CP_XML_STREAM(), val.additional);
}
}
if (bWordArt)
@ -421,25 +407,25 @@ void _oox_drawing::serialize_shape(std::wostream & strm)
oox_serialize_fill(strm, no_fill);
}
else
oox_serialize_fill(strm, fill);
oox_serialize_fill(strm, val.fill);
}
}
void _oox_drawing::serialize_xfrm(std::wostream & strm, const std::wstring & name_space, bool always_position)
void oox_serialize_xfrm(std::wostream & strm, _oox_drawing & val, const std::wstring name_space)
{
CP_XML_WRITER(strm)
{
std::wstring xfrm = name_space + L":xfrm";
_CP_OPT(double) dRotate;
odf_reader::GetProperty(additional, L"svg:rotate", dRotate);
odf_reader::GetProperty(val.additional,L"svg:rotate",dRotate);
_CP_OPT(double) dSkewX;
odf_reader::GetProperty(additional, L"svg:skewX", dSkewX);
odf_reader::GetProperty(val.additional,L"svg:skewX",dSkewX);
_CP_OPT(double) dSkewY;
odf_reader::GetProperty(additional, L"svg:skewY", dSkewY);
odf_reader::GetProperty(val.additional,L"svg:skewY",dSkewY);
_CP_OPT(double) dRotateAngle;
@ -457,44 +443,36 @@ void _oox_drawing::serialize_xfrm(std::wostream & strm, const std::wstring & nam
{
if (dRotateAngle)
{
double d =360 - dRotateAngle.get() * 180. / 3.14159265358979323846;
double d =360-dRotateAngle.get()*180./3.14159265358979323846;
d *= 60000; //60 000 per 1 gr - 19.5.5 oox
CP_XML_ATTR(L"rot", (int)d);
}
_CP_OPT(bool)bVal;
if (odf_reader::GetProperty(additional,L"flipH", bVal))
if (odf_reader::GetProperty(val.additional,L"flipH",bVal))
CP_XML_ATTR(L"flipH", bVal.get());
if (odf_reader::GetProperty(additional,L"flipV", bVal))
if (odf_reader::GetProperty(val.additional,L"flipV",bVal))
CP_XML_ATTR(L"flipV", bVal.get());
CP_XML_NODE(L"a:off")
{
if (inGroup || always_position)
{
CP_XML_ATTR(L"x", x);
CP_XML_ATTR(L"y", y);
}
else
{
CP_XML_ATTR(L"x", 0);
CP_XML_ATTR(L"y", 0);
}
CP_XML_ATTR(L"x", val.x);
CP_XML_ATTR(L"y", val.y);
}
if (cx > 0 || cy > 0)
if (val.cx >0 || val.cy >0)
{
CP_XML_NODE(L"a:ext")
{
CP_XML_ATTR(L"cx", cx);
CP_XML_ATTR(L"cy", cy);
CP_XML_ATTR(L"cx", val.cx);
CP_XML_ATTR(L"cy", val.cy);
}
}else
{
_CP_LOG << L"[error!!!] not set size object\n";
}
if (type == typeGroupShape)
if (val.type == typeGroupShape)
{
CP_XML_NODE(L"a:chOff")
{
@ -503,8 +481,8 @@ void _oox_drawing::serialize_xfrm(std::wostream & strm, const std::wstring & nam
}
CP_XML_NODE(L"a:chExt")
{
CP_XML_ATTR(L"cx", cx);
CP_XML_ATTR(L"cy", cy);
CP_XML_ATTR(L"cx", val.cx);
CP_XML_ATTR(L"cy", val.cy);
}
}
}
@ -516,7 +494,7 @@ void oox_serialize_hlink(std::wostream & strm, std::vector<_hlink_desc> const &
{
BOOST_FOREACH(const _hlink_desc & h, val)
{
if (h.in_object == true)
if (h.object == true)
{
CP_XML_NODE(L"a:hlinkClick")
{

View File

@ -42,6 +42,22 @@
#include "../../../Common/DocxFormat/Source/Base/Types_32.h"
static const int _odf_to_oox_ShapeType[]=
{ 4,4,4,34,};
static const std::wstring _ooxShapeType[]=
{
L"rect", //frame
L"rect", //text box
L"rect", //shape
L"ellipse",
L"ellipse",
L"line",
L"path",
L"custGeom",//uses sub-sub type,
L"polygon",
};
namespace cpdoccore {
namespace oox {
@ -49,47 +65,38 @@ namespace oox {
{
std::wstring hId;
std::wstring hRef;
bool in_object;
bool object;
};
class _oox_drawing
struct _oox_drawing
{
public:
_oox_drawing() : type(typeUnknown), id(0), x(0), y(0), cx(0), cy(0), sub_type(0), inGroup(false), name(L"object")
{
}
RelsType type;
RelsType type;
bool inGroup;
size_t id;
bool inGroup;
size_t id;
std::wstring name;
int sub_type; //odf
std::wstring name;
_INT32 x, y;
_INT32 cx, cy;
_INT32 x, y;
_INT32 cx, cy;
_oox_fill fill;
_oox_fill fill;
std::wstring objectId;
std::wstring objectProgId;
int sub_type; //odf
std::wstring chartId;
std::vector<_hlink_desc> hlinks;
std::vector<odf_reader::_property> additional;
std::vector<_hlink_desc> hlinks;
virtual void serialize (std::wostream & strm) = 0;
std::vector<odf_reader::_property> additional;
void serialize_shape (std::wostream & strm);
void serialize_xfrm (std::wostream & strm, const std::wstring & namespace_ = L"a", bool always_position = false);
void serialize_bodyPr (std::wostream & strm, const std::wstring & namespace_ = L"a");
};
typedef _CP_PTR(_oox_drawing) oox_drawing_ptr;
void oox_serialize_ln (std::wostream & strm, const std::vector<odf_reader::_property> & val, bool always_draw = false);
void oox_serialize_aLst (std::wostream & strm, const std::vector<odf_reader::_property> & val);
void oox_serialize_xfrm (std::wostream & strm, _oox_drawing & val, const std::wstring namespace_ = L"a");
void oox_serialize_shape (std::wostream & strm, _oox_drawing & val);
void oox_serialize_ln (std::wostream & strm, const std::vector<odf_reader::_property> & val, bool always_draw = false);
void oox_serialize_hlink (std::wostream & strm, const std::vector<_hlink_desc> & val);
void oox_serialize_bodyPr (std::wostream & strm, _oox_drawing & val, const std::wstring & namespace_ = L"a");
void oox_serialize_aLst (std::wostream & strm, const std::vector<odf_reader::_property> & val);
}
}

View File

@ -74,8 +74,6 @@ static std::wstring get_mime_type(const std::wstring & extension)
else if (L"wav" == extension) return L"audio/wav";
else if (L"bin" == extension) return L"application/vnd.openxmlformats-officedocument.oleObject";
else if (L"xlsx" == extension) return L"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
else if (L"docx" == extension) return L"application/vnd.openxmlformats-officedocument.wordprocessingml.document";
else if (L"doc" == extension) return L"application/msword";
else return L"application/octet-stream";
@ -114,48 +112,14 @@ content_type_content * content_types_file::content()
bool content_types_file::add_or_find_default(const std::wstring & extension)
{
std::vector<default_content_type> & defaults = content_type_content_.get_default();
for (int i = 0 ; i < defaults.size(); i++)
for (int i = 0 ; i < content_type_content_.get_default().size(); i++)
{
if (defaults[i].extension() == extension)
if (content_type_content_.get_default()[i].extension() == extension)
return true;
}
content_type_content_.add_default(extension, get_mime_type(extension));
return true;
}
bool content_types_file::add_or_find_override(const std::wstring & fileName)
{
std::vector<override_content_type> & override_ = content_type_content_.get_override();
for (int i = 0 ; i < override_.size(); i++)
{
if (override_[i].part_name() == fileName)
return true;
}
std::wstring content_type;
int pos = fileName.rfind(L".");
std::wstring extension = pos >= 0 ? fileName.substr(pos + 1) : L"";
if (extension == L"xlsx")
{
content_type = L"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
content_type_content_.add_override(fileName, content_type);
}
if (extension == L"bin")
{
//content_type = L"application/vnd.openxmlformats-officedocument.oleObject";
add_or_find_default(extension);
}
return true;
}
void content_types_file::set_media(mediaitems & _Mediaitems)
{
BOOST_FOREACH( mediaitems::item & item, _Mediaitems.items() )
@ -319,13 +283,12 @@ void media::write(const std::wstring & RootPath)
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"media";
FileSystem::Directory::CreateDirectory(path.c_str());
mediaitems::items_array & items = mediaitems_.items();
for (int i = 0; i < items.size(); i++ )
BOOST_FOREACH( mediaitems::item & item, mediaitems_.items() )
{
if (items[i].mediaInternal && items[i].valid && (items[i].type == typeImage || items[i].type == typeMedia))
if (item.mediaInternal && item.valid && item.type == typeImage )
{
std::wstring & file_name = items[i].href;
std::wstring file_name_out = RootPath + FILE_SEPARATOR_STR + items[i].outputName;
std::wstring & file_name = item.href;
std::wstring file_name_out = RootPath + FILE_SEPARATOR_STR + item.outputName;
CImageFileFormatChecker svmFileChecker;
if (svmFileChecker.isSvmFile(file_name))
@ -333,12 +296,14 @@ void media::write(const std::wstring & RootPath)
ConvertSvmToImage(file_name, file_name_out, appFonts_);
}
else
NSFile::CFileBinary::Copy(items[i].href, file_name_out);
NSFile::CFileBinary::Copy(item.href, file_name_out);
}
}
}
//------------------------------------------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////////
charts::charts(mediaitems & _ChartsItems) : chartsitems_(_ChartsItems)
{
}
@ -347,35 +312,6 @@ void charts::write(const std::wstring & RootPath)
{
}
//--------------------------------------------------------------------------------------------------------------
embeddings::embeddings(mediaitems & _EmbeddingsItems) : embeddingsitems_(_EmbeddingsItems)
{
}
void embeddings::write(const std::wstring & RootPath)
{
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"embeddings";
FileSystem::Directory::CreateDirectory(path.c_str());
content_types_file & content_types = get_main_document()->get_content_types_file();
mediaitems::items_array & items = embeddingsitems_.items();
for (int i = 0; i < items.size(); i++ )
{
if ( items[i].mediaInternal && items[i].valid &&
(items[i].type == typeMsObject || items[i].type == typeOleObject))
{
int pos = items[i].outputName.rfind(L".");
std::wstring extension = pos >= 0 ? items[i].outputName.substr(pos + 1) : L"";
content_types.add_or_find_default(extension);
std::wstring file_name_out = RootPath + FILE_SEPARATOR_STR + items[i].outputName;
NSFile::CFileBinary::Copy(items[i].href, file_name_out);
}
}
}
}
}
}

View File

@ -81,7 +81,6 @@ public:
content_types_file ();
void write (const std::wstring & RootPath);
bool add_or_find_default (const std::wstring & extension);
bool add_or_find_override(const std::wstring & fileName);
void set_media (mediaitems & _Mediaitems);
content_type_content * content ();
@ -225,18 +224,7 @@ private:
mediaitems & chartsitems_;
};
class embeddings : public element
{
public:
embeddings(mediaitems & _EmbeddingsItems);
public:
virtual void write(const std::wstring & RootPath);
private:
mediaitems & embeddingsitems_;
};
} // namespace package
} // namespace oox
} // namespace cpdoccore

View File

@ -40,20 +40,7 @@
namespace cpdoccore {
namespace oox {
enum RelsType
{
typeUnknown = 0,
typeImage,
typeChart,
typeShape,
typeTable,
typeHyperlink,
typeComment,
typeMedia,
typeGroupShape,
typeMsObject,
typeOleObject
};
enum RelsType { typeUnknown = 0, typeImage, typeChart, typeShape, typeTable, typeHyperlink, typeComment, typeMedia, typeGroupShape};
struct _rel
{

View File

@ -61,16 +61,16 @@ namespace package
class pptx_document;
}
pptx_conversion_context::pptx_conversion_context( odf_reader::odf_document * odfDocument)
:output_document_ (NULL)
,odf_document_ (odfDocument)
,pptx_text_context_ (odf_document_->odf_context(), *this)
,pptx_table_context_ (*this)
,pptx_comments_context_ (comments_context_handle_)
,pptx_slide_context_ (*this/*, pptx_text_context_*/)
,math_context_ (odf_document_->odf_context().fontContainer(), true)
,last_idx_placeHolder (1)
,last_uniq_big_id (1)
pptx_conversion_context::pptx_conversion_context( odf_reader::odf_document * odfDocument):
output_document_(NULL)
,odf_document_(odfDocument)
,pptx_text_context_(odf_document_->odf_context(),*this)
,pptx_table_context_(*this)
,pptx_comments_context_(comments_context_handle_)
,pptx_slide_context_(*this/*, pptx_text_context_*/)
,math_context_(true)
,last_idx_placeHolder(1)
,last_uniq_big_id(1)
{
applicationFonts_ = new CApplicationFonts();
}
@ -514,7 +514,7 @@ void pptx_conversion_context::end_page()
}
get_slide_context().serialize_background(current_slide().Background());
get_slide_context().serialize_objects (current_slide().Data());
get_slide_context().serialize_objects(current_slide().Data());
get_slide_context().serialize_animations(current_slide().Timing());
get_slide_context().dump_rels(current_slide().Rels());//hyperlinks, mediaitems, ...
@ -543,9 +543,9 @@ std::pair<int,int> pptx_conversion_context::add_author_comments(std::wstring aut
void pptx_conversion_context::end_master()
{
get_slide_context().serialize_background (current_master().Background(),true);
get_slide_context().serialize_objects (current_master().Data());
get_slide_context().serialize_HeaderFooter (current_master().DataExtra());
get_slide_context().serialize_background(current_master().Background(),true);
get_slide_context().serialize_objects(current_master().Data());
get_slide_context().serialize_HeaderFooter(current_master().DataExtra());
get_slide_context().dump_rels(current_master().Rels());//hyperlinks, mediaitems, ...

View File

@ -61,8 +61,7 @@ void pptx_serialize_text(std::wostream & strm, _pptx_drawing & val)
{
CP_XML_NODE(L"p:txBody")
{
val.serialize_bodyPr(CP_XML_STREAM());
oox_serialize_bodyPr(CP_XML_STREAM(), val);
if (strTextContent)
{
CP_XML_STREAM() << strTextContent.get();
@ -87,10 +86,10 @@ void pptx_serialize_image(std::wostream & strm, _pptx_drawing & val)
{
CP_XML_NODE(L"p:cNvPr")
{
CP_XML_ATTR(L"id", val.id);
CP_XML_ATTR(L"name", val.name);
CP_XML_ATTR(L"id", val.id);
CP_XML_ATTR(L"name", val.name);
oox_serialize_hlink(CP_XML_STREAM(), val.hlinks);
oox_serialize_hlink(CP_XML_STREAM(),val.hlinks);
}
CP_XML_NODE(L"p:cNvPicPr")
@ -107,14 +106,14 @@ void pptx_serialize_image(std::wostream & strm, _pptx_drawing & val)
CP_XML_NODE(L"p:spPr")
{
val.serialize_xfrm(CP_XML_STREAM(), L"a", true);
oox_serialize_xfrm(CP_XML_STREAM(),val);
CP_XML_NODE(L"a:prstGeom")
{
CP_XML_ATTR(L"prst", L"rect");
CP_XML_NODE(L"a:avLst");
}
oox_serialize_ln(CP_XML_STREAM(), val.additional);
oox_serialize_ln(CP_XML_STREAM(),val.additional);
}
//_CP_OPT(std::wstring) strTextContent;
//odf::GetProperty(properties,L"text-content",strTextContent);
@ -170,13 +169,13 @@ void pptx_serialize_shape(std::wostream & strm, _pptx_drawing & val)
if (!bNoRect)
{
val.serialize_xfrm(CP_XML_STREAM(), L"a", true);
val.serialize_shape(CP_XML_STREAM());
oox_serialize_xfrm(CP_XML_STREAM(),val);
oox_serialize_shape(CP_XML_STREAM(),val);
oox_serialize_ln(CP_XML_STREAM(), val.additional);
}
}
pptx_serialize_text(CP_XML_STREAM(), val);
pptx_serialize_text(CP_XML_STREAM(), val);
}
} // CP_XML_WRITER
}
@ -198,7 +197,7 @@ void pptx_serialize_chart(std::wostream & strm, _pptx_drawing & val)
CP_XML_NODE(L"p:cNvGraphicFramePr");
CP_XML_NODE(L"p:nvPr");
}
val.serialize_xfrm(CP_XML_STREAM(), L"p", true);
oox_serialize_xfrm(CP_XML_STREAM(),val,L"p");
//oox_serialize_ln(CP_XML_STREAM(),val.additional);
@ -211,13 +210,14 @@ void pptx_serialize_chart(std::wostream & strm, _pptx_drawing & val)
{
CP_XML_ATTR(L"xmlns:c", L"http://schemas.openxmlformats.org/drawingml/2006/chart");
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
CP_XML_ATTR(L"r:id", val.objectId);
CP_XML_ATTR(L"r:id", val.chartId);
}
}
}
} // p:graphicFrame
} // CP_XML_WRITER
}
void pptx_serialize_table(std::wostream & strm, _pptx_drawing & val)
{
CP_XML_WRITER(strm)
@ -235,7 +235,7 @@ void pptx_serialize_table(std::wostream & strm, _pptx_drawing & val)
CP_XML_NODE(L"p:cNvGraphicFramePr");
CP_XML_NODE(L"p:nvPr");
}
val.serialize_xfrm(CP_XML_STREAM(), L"p", true);
oox_serialize_xfrm(CP_XML_STREAM(),val,L"p");
//oox_serialize_ln(CP_XML_STREAM(),val.additional);
@ -258,73 +258,23 @@ void pptx_serialize_table(std::wostream & strm, _pptx_drawing & val)
} // CP_XML_WRITER
}
void pptx_serialize_object(std::wostream & strm, _pptx_drawing & val)
void pptx_serialize(std::wostream & strm, _pptx_drawing & val)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"p:graphicFrame")
{
CP_XML_NODE(L"p:nvGraphicFramePr")
{
CP_XML_NODE(L"p:cNvPr")
{
CP_XML_ATTR(L"id", val.id);
CP_XML_ATTR(L"name", val.name);
}
CP_XML_NODE(L"p:cNvGraphicFramePr");
CP_XML_NODE(L"p:nvPr");
}
val.serialize_xfrm(CP_XML_STREAM(), L"p", true);
//oox_serialize_ln(CP_XML_STREAM(),val.additional);
CP_XML_NODE(L"a:graphic")
{
CP_XML_NODE(L"a:graphicData")
{
CP_XML_ATTR(L"uri", L"http://schemas.openxmlformats.org/presentationml/2006/ole");
CP_XML_NODE(L"p:oleObj")
{
CP_XML_ATTR(L"r:id", val.objectId);
CP_XML_ATTR(L"progId", val.objectProgId);
CP_XML_ATTR(L"imgW", val.cx );
CP_XML_ATTR(L"imgH", val.cy );
CP_XML_NODE(L"p:embed");
val.id = 0;
pptx_serialize_image(CP_XML_STREAM(), val);
}
}
}
} // p:graphicFrame
} // CP_XML_WRITER
}
void _pptx_drawing::serialize(std::wostream & strm)
{
if (type == typeShape)
if (val.type == typeShape)
{
pptx_serialize_shape(strm, *this);
pptx_serialize_shape(strm,val);
}
else if (type == typeImage)
else if (val.type == typeImage)
{
pptx_serialize_image(strm, *this);
pptx_serialize_image(strm,val);
}
else if (type == typeChart)
else if (val.type == typeChart)
{
pptx_serialize_chart(strm, *this);
pptx_serialize_chart(strm,val);
}
else if (type == typeTable)
else if (val.type == typeTable)
{
pptx_serialize_table(strm, *this);
}
else if (type == typeMsObject ||
type == typeOleObject)
{
pptx_serialize_object(strm, *this);
pptx_serialize_table(strm,val);
}
}

View File

@ -43,15 +43,13 @@
namespace cpdoccore {
namespace oox {
class _pptx_drawing : public _oox_drawing
struct _pptx_drawing : _oox_drawing
{
public:
_pptx_drawing(): _oox_drawing(), place_holder_idx_(-1) {}
std::wstring place_holder_type_;
int place_holder_idx_;
_pptx_drawing(): place_holder_idx_(-1){}
std::wstring place_holder_type_;
int place_holder_idx_;
void serialize (std::wostream & _Wostream);
friend void pptx_serialize(std::wostream & _Wostream, _pptx_drawing & val);
};
}

View File

@ -34,6 +34,7 @@
#include <vector>
#include <cpdoccore/xml/simple_xml_writer.h>
#include "mediaitems_utils.h"
#include "oox_rels.h"
#include "pptx_drawings.h"
@ -56,18 +57,18 @@ public:
pptx_drawings_.push_back(d);
bool present = false;
for (int i = 0; i < pptx_drawing_rels_.size(); i++)
BOOST_FOREACH(_rel const & r, pptx_drawing_rels_)
{
if (pptx_drawing_rels_[i].rid == rid && pptx_drawing_rels_[i].ref == ref)
if (r.rid == rid && r.ref == ref)
present = true;
}
if (!present)
{
pptx_drawing_rels_.push_back(_rel(isInternal, rid, ref, type));
}
for (int i = 0; i < d.hlinks.size(); i++)
BOOST_FOREACH(_hlink_desc h, d.hlinks)
{
pptx_drawing_rels_.push_back(_rel(false, d.hlinks[i].hId, d.hlinks[i].hRef, typeHyperlink));
pptx_drawing_rels_.push_back(_rel(false, h.hId, h.hRef, typeHyperlink));
}
}
@ -79,22 +80,21 @@ public:
{
bool present = false;
for (int i = 0; i < pptx_drawing_rels_.size(); i++)
BOOST_FOREACH(_rel const & r, pptx_drawing_rels_)
{
if (pptx_drawing_rels_[i].rid == rid && pptx_drawing_rels_[i].ref == ref)
if (r.rid == rid && r.ref == ref)
present = true;
}
if (!present)
{
if (type == typeHyperlink) isInternal = false;
pptx_drawing_rels_.push_back(_rel(isInternal, rid, ref, type));
}
}
void serialize(std::wostream & strm)
{
for (int i = 0; i < pptx_drawings_.size(); i++)
BOOST_FOREACH(_pptx_drawing & d, pptx_drawings_)
{
pptx_drawings_[i].serialize(strm);
pptx_serialize(strm,d);
}
}
@ -105,28 +105,47 @@ public:
void dump_rels(rels & Rels)
{
for (int i = 0; i < pptx_drawing_rels_.size(); i++)
BOOST_FOREACH(_rel const & r, pptx_drawing_rels_)
{
if (pptx_drawing_rels_[i].type == typeUnknown ||
pptx_drawing_rels_[i].type == typeTable ||
pptx_drawing_rels_[i].type == typeShape ||
pptx_drawing_rels_[i].type == typeGroupShape) continue;
if (pptx_drawing_rels_[i].type == typeComment)
if (r.type == typeChart)//временно - нужно потом все загнать в релс
{
Rels.add(relationship( pptx_drawing_rels_[i].rid,
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments",
pptx_drawing_rels_[i].ref) );
Rels.add(relationship(
r.rid,
utils::media::get_rel_type(r.type),
(r.is_internal ? std::wstring(L"../") + r.ref : r.ref),
(r.is_internal ? L"" : L"External")
)
);
}
else
else if (r.type == typeImage)
{
Rels.add(relationship( pptx_drawing_rels_[i].rid,
mediaitems::get_rel_type(pptx_drawing_rels_[i].type),
(pptx_drawing_rels_[i].is_internal ? std::wstring(L"../") + pptx_drawing_rels_[i].ref : pptx_drawing_rels_[i].ref),
(pptx_drawing_rels_[i].is_internal ? L"" : L"External")) );
Rels.add(relationship(
r.rid,
utils::media::get_rel_type(r.type),
r.is_internal ? std::wstring(L"../") + r.ref : r.ref,
(r.is_internal ? L"" : L"External")
)
);
}
else if (r.type == typeHyperlink)
{
Rels.add(relationship(
r.rid,
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
r.ref,
L"External")
);
}
else if (r.type == typeComment)
{
Rels.add(relationship(
r.rid,
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments",
r.ref)
);
}
}
}
}
private:

View File

@ -40,7 +40,8 @@
namespace cpdoccore {
namespace oox {
class _pptx_drawing;
struct _pptx_drawing;
class rels;
class pptx_drawings;

View File

@ -33,6 +33,10 @@
#include "pptx_package.h"
#include "pptx_output_xml.h"
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/ref.hpp>
#include <cpdoccore/utf8cpp/utf8.h>
namespace cpdoccore {
@ -95,13 +99,11 @@ void slide_content::add_rel(relationship const & r)
rels_->get_rels().add(r);
}
void slide_content::add_rels(rels & _r)
void slide_content::add_rels(rels & r)
{
std::vector<relationship> & r = _r.relationships();
for (int i = 0; i < r.size(); i++)
BOOST_FOREACH(relationship & item, r.relationships())
{
rels_->get_rels().add(r[i]);
rels_->get_rels().add(item);
}
}
////////////
@ -122,29 +124,33 @@ void slides_files::write(const std::wstring & RootPath)
content_type_content * contentTypes = this->get_main_document()->get_content_types_file().content();
static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.presentationml.slide+xml";
for (int i = 0; i < slides_.size(); i++)
size_t count = 0;
BOOST_FOREACH(const slide_content_ptr & item, slides_)
{
if (!slides_[i]) continue;
const std::wstring fileName = std::wstring(L"slide") + std::to_wstring( i + 1 ) + L".xml";
contentTypes->add_override(std::wstring(L"/ppt/slides/") + fileName, kWSConType);
if (rels_)
if (item)
{
const std::wstring id = std::wstring(L"sId") + std::to_wstring( i + 1);
static const std::wstring kWSRel = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide";
const std::wstring fileRef = std::wstring(L"slides/") + fileName;
rels_->add(id, kWSRel, fileRef);
count++;
const std::wstring fileName = std::wstring(L"slide") + boost::lexical_cast<std::wstring>(count) + L".xml";
contentTypes->add_override(std::wstring(L"/ppt/slides/") + fileName, kWSConType);
if (rels_)
{
const std::wstring id = std::wstring(L"sId") + boost::lexical_cast<std::wstring>(count);
static const std::wstring kWSRel = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide";
const std::wstring fileRef = std::wstring(L"slides/") + fileName;
rels_->add(id, kWSRel, fileRef);
}
item->get_rel_file()->set_file_name(fileName + L".rels");//внитренние релсы
rels_files relFiles;
relFiles.add_rel_file(item->get_rel_file());
relFiles.write(path);
package::simple_element(fileName, item->str()).write(path);
}
slides_[i]->get_rel_file()->set_file_name(fileName + L".rels");//внитренние релсы
rels_files relFiles;
relFiles.add_rel_file(slides_[i]->get_rel_file());
relFiles.write(path);
package::simple_element(fileName, slides_[i]->str()).write(path);
}
}
@ -165,28 +171,32 @@ void slideMasters_files::write(const std::wstring & RootPath)
content_type_content * contentTypes = this->get_main_document()->get_content_types_file().content();
static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml";
for (int i = 0; i < slides_.size(); i++)
size_t count = 0;
BOOST_FOREACH(const slide_content_ptr & item, slides_)
{
if (!slides_[i]) continue;
const std::wstring fileName = std::wstring(L"slideMaster") + std::to_wstring( i + 1 ) + L".xml";
contentTypes->add_override(std::wstring(L"/ppt/slideMasters/") + fileName, kWSConType);
if (rels_)
if (item)
{
const std::wstring id = std::wstring(L"smId") + std::to_wstring( i + 1);
static const std::wstring kWSRel = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster";
const std::wstring fileRef = std::wstring(L"slideMasters/") + fileName;
rels_->add(id, kWSRel, fileRef);
count++;
const std::wstring fileName = std::wstring(L"slideMaster") + boost::lexical_cast<std::wstring>(count) + L".xml";
contentTypes->add_override(std::wstring(L"/ppt/slideMasters/") + fileName, kWSConType);
if (rels_)
{
const std::wstring id = std::wstring(L"smId") + boost::lexical_cast<std::wstring>(count);
static const std::wstring kWSRel = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster";
const std::wstring fileRef = std::wstring(L"slideMasters/") + fileName;
rels_->add(id, kWSRel, fileRef);
}
item->get_rel_file()->set_file_name(fileName + L".rels");//внитренние релсы
rels_files relFiles;
relFiles.add_rel_file(item->get_rel_file());
relFiles.write(path);
package::simple_element(fileName, item->str()).write(path);
}
slides_[i]->get_rel_file()->set_file_name(fileName + L".rels");//внитренние релсы
rels_files relFiles;
relFiles.add_rel_file(slides_[i]->get_rel_file());
relFiles.write(path);
package::simple_element(fileName, slides_[i]->str()).write(path);
}
}
@ -204,23 +214,27 @@ void slideLayouts_files::write(const std::wstring & RootPath)
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"slideLayouts" ;
FileSystem::Directory::CreateDirectory(path.c_str());
for (int i = 0; i < slides_.size(); i++)
size_t count = 0;
BOOST_FOREACH(const slide_content_ptr & item, slides_)
{
if (!slides_[i]) continue;
if (item)
{
count++;
const std::wstring fileName = std::wstring(L"slideLayout") + boost::lexical_cast<std::wstring>(count) + L".xml";
const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml";
content_type_content * contentTypes = get_main_document()->get_content_types_file().content();
contentTypes->add_override(std::wstring(L"/ppt/slideLayouts/") + fileName, kWSConType);
const std::wstring fileName = std::wstring(L"slideLayout") + std::to_wstring( i + 1 ) + L".xml";
const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml";
content_type_content * contentTypes = get_main_document()->get_content_types_file().content();
contentTypes->add_override(std::wstring(L"/ppt/slideLayouts/") + fileName, kWSConType);
item->get_rel_file()->set_file_name(fileName + L".rels");//внитренние релсы
rels_files relFiles;
relFiles.add_rel_file(item->get_rel_file());
relFiles.write(path);
slides_[i]->get_rel_file()->set_file_name(fileName + L".rels");//внитренние релсы
rels_files relFiles;
relFiles.add_rel_file(slides_[i]->get_rel_file());
relFiles.write(path);
package::simple_element(fileName, slides_[i]->str()).write(path);
package::simple_element(fileName, item->str()).write(path);
}
}
}
@ -256,24 +270,28 @@ void ppt_charts_files::write(const std::wstring & RootPath)
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"charts";
FileSystem::Directory::CreateDirectory(path.c_str());
for (int i = 0; i < charts_.size(); i++)
size_t count = 0;
BOOST_FOREACH(const chart_content_ptr & item, charts_)
{
if (!charts_[i]) continue;
const std::wstring fileName = std::wstring(L"chart") + std::to_wstring( i + 1 ) + L".xml";
content_type_content * contentTypes = get_main_document()->get_content_types_file().content();
static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.drawingml.chart+xml";
contentTypes->add_override(std::wstring(L"/ppt/charts/") + fileName, kWSConType);
if (item)
{
count++;
const std::wstring fileName = std::wstring(L"chart") + boost::lexical_cast<std::wstring>(count) + L".xml";
content_type_content * contentTypes = get_main_document()->get_content_types_file().content();
static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.drawingml.chart+xml";
contentTypes->add_override(std::wstring(L"/ppt/charts/") + fileName, kWSConType);
package::simple_element(fileName, charts_[i]->str()).write(path);
rels_files relFiles;
package::simple_element(fileName, item->str()).write(path);
rels_files relFiles;
charts_[i]->get_rel_file()->set_file_name(fileName + L".rels");
relFiles.add_rel_file(charts_[i]->get_rel_file());
relFiles.write(path);
item->get_rel_file()->set_file_name(fileName + L".rels");
relFiles.add_rel_file(item->get_rel_file());
relFiles.write(path);
}
}
}
///////////////////////////////////
@ -286,19 +304,24 @@ void ppt_themes_files::write(const std::wstring & RootPath)
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"theme" ;
FileSystem::Directory::CreateDirectory(path.c_str());
for (int i = 0; i < themes_.size(); i++)
{
if (!themes_[i]) continue;
const std::wstring fileName = std::wstring(L"theme") + std::to_wstring( i + 1) + L".xml";
const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.theme+xml";
content_type_content * contentTypes = get_main_document()->get_content_types_file().content();
contentTypes->add_override(std::wstring(L"/ppt/theme/") + fileName, kWSConType);
size_t count = 0;
std::wstringstream content;
themes_[i]->write_to(content);
package::simple_element(fileName, content.str()).write(path);
BOOST_FOREACH(const pptx_xml_theme_ptr & item, themes_)
{
if (item)
{
count++;
const std::wstring fileName = std::wstring(L"theme") + boost::lexical_cast<std::wstring>(count) + L".xml";
const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.theme+xml";
content_type_content * contentTypes = get_main_document()->get_content_types_file().content();
contentTypes->add_override(std::wstring(L"/ppt/theme/") + fileName, kWSConType);
std::wstringstream content;
item->write_to(content);
package::simple_element(fileName, content.str()).write(path);
}
}
}
//////////////////////////////
@ -312,14 +335,14 @@ void ppt_comments_files::write(const std::wstring & RootPath)
std::wstring comm_path = RootPath + FILE_SEPARATOR_STR + L"comments";
FileSystem::Directory::CreateDirectory(comm_path.c_str());
for (int i = 0; i < comments_.size(); i++)
BOOST_FOREACH(pptx_comment_elm const & e, comments_)
{
content_type_content * contentTypes = get_main_document()->get_content_types_file().content();
static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.presentationml.comments+xml";
contentTypes->add_override(std::wstring(L"/ppt/comments/") + comments_[i].filename, kWSConType);
contentTypes->add_override(std::wstring(L"/ppt/comments/") + e.filename, kWSConType);
package::simple_element(comments_[i].filename, comments_[i].content).write( comm_path);
package::simple_element(e.filename, e.content).write( comm_path);
}
}
////////////////////////////////////////////
@ -363,12 +386,7 @@ void ppt_files::write(const std::wstring & RootPath)
media_->set_main_document(get_main_document());
media_->write(path);
}
if (embeddings_)
{
embeddings_->set_main_document(get_main_document());
embeddings_->write(path);
}
{
charts_files_.set_main_document(get_main_document());
charts_files_.write(path);
}
@ -422,14 +440,7 @@ void ppt_files::add_slideMaster(slide_content_ptr slide)
void ppt_files::set_media(mediaitems & _Mediaitems, CApplicationFonts *pAppFonts)
{
if (_Mediaitems.count_image + _Mediaitems.count_media > 0)
{
media_ = element_ptr( new media(_Mediaitems, pAppFonts) );
}
if (_Mediaitems.count_object > 0)
{
embeddings_ = element_ptr( new embeddings(_Mediaitems) );
}
media_ = element_ptr( new media(_Mediaitems, pAppFonts) );
}
void ppt_files::set_authors_comments(pptx_xml_authors_comments_ptr & authors_comments)
{

View File

@ -238,7 +238,6 @@ private:
element_ptr comments_;
element_ptr media_;
element_ptr embeddings_;
};
// xlsx_document

View File

@ -36,6 +36,8 @@
#include <cpdoccore/xml/utils.h>
#include <cpdoccore/odf/odf_document.h>
#include "mediaitems_utils.h"
#include "pptx_drawing.h"
#include "pptx_drawings.h"
#include "pptx_slide_context.h"
@ -71,12 +73,16 @@ public:
clear();
}
drawing_object_description object_description_;
std::vector<drawing_object_description> objects_;
drawing_object_description object_description_;
_CP_OPT(_oox_fill) background_fill_;
_transition transition_;
bool use_image_replacement_;
std::vector<drawing_object_description> images_;
std::vector<drawing_object_description> charts_;
std::vector<drawing_object_description> shapes_;
std::vector<drawing_object_description> tables_;
_CP_OPT(_oox_fill) background_fill_;
_transition transition_;
bool header, footer, date_time, slideNum;
@ -105,7 +111,10 @@ public:
void clear()
{
objects_.clear();
images_.clear();
charts_.clear();
shapes_.clear();
tables_.clear();
background_fill_ = boost::none;
@ -133,46 +142,14 @@ public:
return pptx_drawings_;
}
std::wstring odfPacket_;
void process_drawings();
private:
void process_common_properties(drawing_object_description& obj,_pptx_drawing & drawing);
void process_shape (drawing_object_description& obj, _pptx_drawing & drawing);
void process_image (drawing_object_description& obj, _pptx_drawing & drawing);
void process_chart (drawing_object_description& obj, _pptx_drawing & drawing);
void process_table (drawing_object_description& obj, _pptx_drawing & drawing);
void process_object (drawing_object_description& obj, _pptx_drawing & drawing);
size_t rId_;
mediaitems mediaitems_;
pptx_drawings_ptr pptx_drawings_;
};
void pptx_slide_context::Impl::process_drawings()
{
for (int i = 0; i < objects_.size(); i++)
{
_pptx_drawing drawing =_pptx_drawing();
drawing.type = objects_[i].type_;
drawing.name = objects_[i].name_;
drawing.id = next_rId();
process_common_properties(objects_[i], drawing);
switch(objects_[i].type_)
{
case typeImage: process_image(objects_[i], drawing); break;
case typeChart: process_chart(objects_[i], drawing); break;
case typeShape: process_shape(objects_[i], drawing); break;
case typeTable: process_table(objects_[i], drawing); break;
case typeMsObject:
case typeOleObject: process_object(objects_[i], drawing); break;
}
}
}
pptx_slide_context::pptx_slide_context(pptx_conversion_context & Context)
: impl_(new pptx_slide_context::Impl(Context.root()->get_folder()))
@ -223,11 +200,12 @@ void pptx_slide_context::set_transitionSpeed(std::wstring val)
/////////////////////////////////////////////////////////////////////////////////////////////////
void pptx_slide_context::default_set()
{
impl_->object_description_.xlink_href_ = L"";
impl_->object_description_.name_ = L"";
impl_->object_description_.descriptor_ = L"";
impl_->object_description_.anchor_ = L"";
impl_->object_description_.xlink_href_ = L"";
impl_->object_description_.name_ = L"";
impl_->object_description_.additional_.clear();
impl_->object_description_.anchor_ =L"";
impl_->object_description_.clipping_string_= L"";
impl_->object_description_.svg_rect_ = boost::none;
@ -237,12 +215,7 @@ void pptx_slide_context::default_set()
impl_->object_description_.fill_.clear();
impl_->use_image_replacement_ = false;
}
void pptx_slide_context::set_use_image_replacement()
{
impl_->use_image_replacement_ = true;
impl_->object_description_.use_image_replace_ = false;
}
void pptx_slide_context::set_placeHolder_type(std::wstring typeHolder)
@ -368,72 +341,54 @@ void pptx_slide_context::start_shape(int type)
impl_->object_description_.shape_type_ = type; //2,3...
}
void pptx_slide_context::start_image(std::wstring const & path)
{
impl_->object_description_.type_ = typeImage;
impl_->object_description_.xlink_href_ = path;
}
void pptx_slide_context::start_table()
{
impl_->object_description_.type_ = typeTable;
impl_->object_description_.type_ = typeTable;
}
void pptx_slide_context::set_text_box()
void pptx_slide_context::set_use_image_replacement()
{
impl_->object_description_.type_ = typeShape;
impl_->object_description_.shape_type_ = 2; //2,3...
}
void pptx_slide_context::set_ms_object(const std::wstring & path, const std::wstring & progId)
{
impl_->object_description_.type_ = typeMsObject;
impl_->object_description_.xlink_href_ = path;
impl_->object_description_.descriptor_ = progId;
}
void pptx_slide_context::set_ole_object(const std::wstring & path, const std::wstring & progId)
{
impl_->object_description_.type_ = typeOleObject;
impl_->object_description_.xlink_href_ = path;
impl_->object_description_.descriptor_ = progId;
impl_->object_description_.use_image_replace_ = true;
}
void pptx_slide_context::set_image(const std::wstring & path)
void pptx_slide_context::start_object_ole()
{
if (impl_->object_description_.type_ == typeUnknown)
{
impl_->object_description_.type_ = typeImage;
impl_->object_description_.xlink_href_ = path;
}
else if (impl_->use_image_replacement_)
{
impl_->object_description_.fill_.type = 2;
impl_->object_description_.fill_.bitmap = oox::oox_bitmap_fill::create();
impl_->object_description_.fill_.bitmap->xlink_href_ = path;
impl_->object_description_.fill_.bitmap->bStretch = true;
}
}
void pptx_slide_context::start_frame()
{
impl_->object_description_.type_ = typeUnknown;
}
void pptx_slide_context::set_chart(const std::wstring & path)
void pptx_slide_context::start_chart(std::wstring const & path)
{
impl_->object_description_.type_ = typeChart;
impl_->object_description_.xlink_href_ = path;
}
void pptx_slide_context::end_frame()
void pptx_slide_context::end_object_ole()
{
impl_->objects_.push_back(impl_->object_description_);
}
void pptx_slide_context::end_shape()
{
impl_->shapes_.push_back(impl_->object_description_);
default_set();
}
void pptx_slide_context::end_shape()
void pptx_slide_context::end_image()
{
impl_->objects_.push_back(impl_->object_description_);
impl_->images_.push_back(impl_->object_description_);
default_set();
}
void pptx_slide_context::end_chart()
{
impl_->charts_.push_back(impl_->object_description_);
default_set();
}
void pptx_slide_context::end_table()
{
impl_->objects_.push_back(impl_->object_description_);
impl_->tables_.push_back(impl_->object_description_);
default_set();
}
@ -444,115 +399,112 @@ bool pptx_slide_context::empty() const
void pptx_slide_context::process_drawings()
{
return impl_->process_drawings();
process_shapes();
process_images();
process_tables();
process_charts();
}
void pptx_slide_context::Impl::process_image(drawing_object_description& pic, _pptx_drawing & drawing)
void pptx_slide_context::process_images()
{
int pos_replaicement = 0, pos_preview = 0;
int pos_replaicement=0, pos_preview=0;
drawing.fill.bitmap = oox_bitmap_fill::create();
drawing.fill.type = 2;
_CP_OPT(std::wstring) sTextContent;
GetProperty(pic.additional_, L"text-content", sTextContent);
if (sTextContent)//в ms office на картинке нельзя сделать надпись - меняем тип на рект с заливкой картинкой
{
drawing.type = typeShape;
drawing.sub_type = 2;//rect
}
BOOST_FOREACH(drawing_object_description & pic, impl_->images_)
{
pos_replaicement = pic.xlink_href_.find(L"ObjectReplacements");
pos_preview = pic.xlink_href_.find(L"TablePreview");
if ((pos_replaicement <0 && pos_preview <0) || pic.use_image_replace_)//оригинал, а не заменяемый объект (при наличии объекта)
{
_pptx_drawing drawing =_pptx_drawing();
drawing.type = pic.type_;
drawing.name = pic.name_;
drawing.id = impl_->next_rId();
process_common_properties(pic,drawing);
drawing.fill.bitmap = oox_bitmap_fill::create();
drawing.fill.type = 2;
_CP_OPT(std::wstring) sTextContent;
GetProperty(pic.additional_,L"text-content",sTextContent);
if (sTextContent)//в ms office на картинке нельзя сделать надпись - меняем тип на рект с заливкой картинкой
{
drawing.type = typeShape;
drawing.sub_type = 2;//rect
}
std::wstring fileName = odfPacket_ + FILE_SEPARATOR_STR + pic.xlink_href_;
drawing.fill.bitmap->bCrop = odf_reader::parse_clipping(pic.clipping_string_,fileName,drawing.fill.bitmap->cropRect, NULL);
drawing.fill.bitmap->bStretch = true;
std::wstring fileName = impl_->odfPacket_ + FILE_SEPARATOR_STR + pic.xlink_href_;
drawing.fill.bitmap->bCrop = odf_reader::parse_clipping(pic.clipping_string_,fileName,drawing.fill.bitmap->cropRect, NULL);
drawing.fill.bitmap->bStretch = true;
///////////////////////////////////////////////////////////////////////////////////////////////////
std::wstring ref;/// это ссылка на выходной внешний объект
bool isMediaInternal = false;
drawing.fill.bitmap->rId = get_mediaitems().add_or_find(pic.xlink_href_, typeImage, isMediaInternal, ref);
if (drawing.type == typeShape)
{
add_additional_rels(isMediaInternal, drawing.fill.bitmap->rId, ref, typeImage);//собственно это не объект, а доп рел и ref объекта
isMediaInternal = true;
std::wstring rId = get_mediaitems().add_or_find(L"", typeShape, isMediaInternal, ref);
add_drawing(drawing, isMediaInternal, rId, ref, typeShape);//объект
std::wstring ref;/// это ссылка на выходной внешний объект
bool isMediaInternal = false;
drawing.fill.bitmap->rId = impl_->get_mediaitems().add_or_find(pic.xlink_href_, typeImage, isMediaInternal, ref);
if (drawing.type == typeShape)
{
impl_->add_additional_rels(isMediaInternal, drawing.fill.bitmap->rId, ref, typeImage);//собственно это не объект, а доп рел и ref объекта
isMediaInternal = true;
std::wstring rId = impl_->get_mediaitems().add_or_find(L"", typeShape, isMediaInternal, ref);
impl_->add_drawing(drawing, isMediaInternal, rId, ref, typeShape);//объект
}else if (!drawing.fill.bitmap->rId.empty())
{
add_drawing(drawing, isMediaInternal, drawing.fill.bitmap->rId , ref, drawing.type);//объект
}
}else if (!drawing.fill.bitmap->rId.empty())
{
impl_->add_drawing(drawing, isMediaInternal, drawing.fill.bitmap->rId , ref, drawing.type);//объект
}
}
}
}
void pptx_slide_context::Impl::process_chart(drawing_object_description & obj, _pptx_drawing & drawing)
void pptx_slide_context::process_charts()
{
std::wstring ref;
bool isMediaInternal = true;
drawing.objectId = get_mediaitems().add_or_find(obj.xlink_href_, obj.type_, isMediaInternal, ref);
add_drawing(drawing, isMediaInternal, drawing.objectId, ref, drawing.type);
}
BOOST_FOREACH(drawing_object_description & pic, impl_->charts_)
{
_pptx_drawing drawing=_pptx_drawing();
void pptx_slide_context::Impl::process_table(drawing_object_description & obj, _pptx_drawing & drawing)
{
std::wstring ref;
bool isMediaInternal = true;
std::wstring rId = get_mediaitems().add_or_find(L"", obj.type_, isMediaInternal, ref);
add_drawing(drawing, isMediaInternal, rId, ref, drawing.type);
}
drawing.type = pic.type_;
drawing.name = pic.name_;
drawing.id = impl_->next_rId();
void pptx_slide_context::Impl::process_shape(drawing_object_description & obj, _pptx_drawing & drawing)
{
int PlaceHolderIndex = 1;
process_common_properties(pic,drawing);
std::wstring ref;
bool isMediaInternal = true;
if (drawing.fill.bitmap)
{
drawing.fill.bitmap->rId = get_mediaitems().add_or_find(drawing.fill.bitmap->xlink_href_, typeImage, isMediaInternal, ref);
add_additional_rels(isMediaInternal, drawing.fill.bitmap->rId, ref, typeImage);
}
std::wstring rId = get_mediaitems().add_or_find(L"", typeShape, isMediaInternal, ref);
////////////////////////////////////////////////////////////////
_CP_OPT(std::wstring) sPlaceHolderType;
GetProperty(obj.additional_, L"PlaceHolderType", sPlaceHolderType);
if (sPlaceHolderType)
{
drawing.place_holder_type_ = *sPlaceHolderType;
_CP_OPT(int) iPlaceHolderIdx;
GetProperty(obj.additional_, L"PlaceHolderIdx", iPlaceHolderIdx);
if (iPlaceHolderIdx) drawing.place_holder_idx_ = *iPlaceHolderIdx;
}
drawing.sub_type = obj.shape_type_;
add_drawing(drawing, isMediaInternal, rId, ref, typeShape);
std::wstring ref;
bool isMediaInternal = true;
drawing.chartId = impl_->get_mediaitems().add_or_find(pic.xlink_href_, typeChart, isMediaInternal, ref);
impl_->add_drawing(drawing, isMediaInternal, drawing.chartId, ref, typeChart);
}
}
void pptx_slide_context::Impl::process_object(drawing_object_description& obj, _pptx_drawing & drawing)
void pptx_slide_context::process_tables()
{
std::wstring ref;
bool isMediaInternal = true;
drawing.objectId = get_mediaitems().add_or_find(obj.xlink_href_, obj.type_, isMediaInternal, ref);
drawing.objectProgId = obj.descriptor_;
BOOST_FOREACH(drawing_object_description & pic, impl_->tables_)
{
_pptx_drawing drawing=_pptx_drawing();
drawing.type = pic.type_;
drawing.name = pic.name_;
drawing.id = impl_->next_rId();
process_common_properties(pic,drawing);
add_drawing(drawing, isMediaInternal, drawing.objectId, ref, drawing.type);
if (drawing.fill.bitmap)
{
drawing.fill.bitmap->rId = get_mediaitems().add_or_find(drawing.fill.bitmap->xlink_href_, typeImage, isMediaInternal, ref);
add_additional_rels(isMediaInternal, drawing.fill.bitmap->rId, ref, typeImage);
}
////////////////////////////////////////////////////////////////
std::wstring ref;
bool isMediaInternal = true;
std::wstring rId = impl_->get_mediaitems().add_or_find(L"", typeTable, isMediaInternal, ref);
impl_->add_drawing(drawing, isMediaInternal, rId, ref, typeTable);
}
}
void pptx_slide_context::Impl::process_common_properties(drawing_object_description & pic, _pptx_drawing & drawing)
void pptx_slide_context::process_common_properties(drawing_object_description & pic,_pptx_drawing & drawing)
{
if (pic.svg_rect_)
{
@ -577,6 +529,47 @@ void pptx_slide_context::Impl::process_common_properties(drawing_object_descript
drawing.fill = pic.fill_;
}
void pptx_slide_context::process_shapes()
{
int PlaceHolderIndex = 1;
BOOST_FOREACH(drawing_object_description & pic, impl_->shapes_)
{
_pptx_drawing drawing=_pptx_drawing();
drawing.type = pic.type_;
drawing.name = pic.name_;
drawing.id = impl_->next_rId();
process_common_properties(pic,drawing);
std::wstring ref;
bool isMediaInternal = true;
if (drawing.fill.bitmap)
{
drawing.fill.bitmap->rId = impl_->get_mediaitems().add_or_find(drawing.fill.bitmap->xlink_href_, typeImage, isMediaInternal, ref);
impl_->add_additional_rels(isMediaInternal, drawing.fill.bitmap->rId, ref, typeImage);
}
std::wstring rId = impl_->get_mediaitems().add_or_find(L"", typeShape, isMediaInternal, ref);
////////////////////////////////////////////////////////////////
_CP_OPT(std::wstring) sPlaceHolderType;
GetProperty(pic.additional_,L"PlaceHolderType",sPlaceHolderType);
if (sPlaceHolderType)
{
drawing.place_holder_type_ = *sPlaceHolderType;
_CP_OPT(int) iPlaceHolderIdx;
GetProperty(pic.additional_,L"PlaceHolderIdx",iPlaceHolderIdx);
if (iPlaceHolderIdx) drawing.place_holder_idx_ = *iPlaceHolderIdx;
}
drawing.sub_type = pic.shape_type_;
impl_->add_drawing(drawing, isMediaInternal, rId, ref, typeShape);
}
}
void pptx_slide_context::dump_rels(rels & Rels)
{
@ -634,6 +627,7 @@ void pptx_slide_context::serialize_background(std::wostream & strm, bool always)
void pptx_slide_context::serialize_animations(std::wostream & strm)
{
CP_XML_WRITER(strm)
{
if (impl_->transition_.Enabled)
@ -713,10 +707,10 @@ void pptx_slide_context::serialize_objects(std::wostream & strm)
{
CP_XML_NODE(L"a:xfrm")
{
CP_XML_NODE(L"a:off") { CP_XML_ATTR(L"x", 0); CP_XML_ATTR(L"y", 0); }
CP_XML_NODE(L"a:ext") { CP_XML_ATTR(L"cx",0); CP_XML_ATTR(L"cy",0); }
CP_XML_NODE(L"a:chOff") { CP_XML_ATTR(L"x", 0); CP_XML_ATTR(L"y", 0); }
CP_XML_NODE(L"a:chExt") { CP_XML_ATTR(L"cx",0); CP_XML_ATTR(L"cy",0); }
CP_XML_NODE(L"a:off") {CP_XML_ATTR(L"x",0); CP_XML_ATTR(L"y",0);}
CP_XML_NODE(L"a:ext") {CP_XML_ATTR(L"cx",0); CP_XML_ATTR(L"cy",0);}
CP_XML_NODE(L"a:chOff") {CP_XML_ATTR(L"x",0); CP_XML_ATTR(L"y",0);}
CP_XML_NODE(L"a:chExt") {CP_XML_ATTR(L"cx",0); CP_XML_ATTR(L"cy",0);}
}
}
}

View File

@ -50,40 +50,38 @@ public:
pptx_slide_context(pptx_conversion_context & Context);
void start_slide();
void end_slide (){}
void end_slide(){}
////////////////////////////////////////////////////////////////////////////////////////
void start_slide_animation ();
void end_slide_animation (){}
void start_slide_animation();
void end_slide_animation(){}
void set_transitionFilter (std::wstring & type,_CP_OPT(std::wstring) & dir, _CP_OPT(std::wstring) & dop, _CP_OPT(int) & time);
void set_transitionAction (bool val);
void set_transitionSpeed (std::wstring val);
void set_transitionFilter(std::wstring & type,_CP_OPT(std::wstring) & dir, _CP_OPT(std::wstring) & dop, _CP_OPT(int) & time);
void set_transitionAction(bool val);
void set_transitionSpeed(std::wstring val);
///////////////////////////////////////////////////////////////////////////////////////////
void set_rect (double width_pt, double height_pt, double x_pt, double y_pt);
void set_rect(double width_pt, double height_pt, double x_pt, double y_pt);
void set_translate (double x_pt, double y_pt);
void set_scale (double cx_pt, double cy_pt);
void set_rotate (double angle);
void set_translate(double x_pt, double y_pt);
void set_scale(double cx_pt, double cy_pt);
void set_rotate(double angle);
void set_name (std::wstring const & name);
void set_anchor (std::wstring anchor, double x_pt, double y_pt);
void set_property (odf_reader::_property p);
void set_name(std::wstring const & name);
void set_anchor(std::wstring anchor, double x_pt, double y_pt);
void set_property(odf_reader::_property p);
std::vector<odf_reader::_property> & get_properties();
void set_clipping (const std::wstring & str );
void set_fill (_oox_fill & fill);
void set_clipping(const std::wstring & str );
void set_fill(_oox_fill & fill);
void set_placeHolder_type (std::wstring typeHolder);
void set_placeHolder_idx (int idx);
void set_placeHolder_type(std::wstring typeHolder);
void set_placeHolder_idx(int idx);
std::wstring add_hyperlink(std::wstring const & ref, bool object);
void start_frame();
void set_image (const std::wstring & path);
void set_chart (const std::wstring & path);
void set_ms_object (const std::wstring & path, const std::wstring & progId);
void set_ole_object (const std::wstring & path, const std::wstring & progId);
void set_text_box ();
void end_frame();
void start_image(std::wstring const & path);
void end_image();
void start_chart(std::wstring const & path);
void end_chart();
void start_table();
void end_table();
@ -91,6 +89,9 @@ public:
void start_shape(int type);
void end_shape();
void start_object_ole();
void end_object_ole();
void set_use_image_replacement();
bool empty() const;
@ -108,6 +109,7 @@ public:
void add_background(_oox_fill & fill);
void add_rels( bool isInternal,
std::wstring const & rid,
std::wstring const & ref,
@ -119,7 +121,13 @@ public:
void set_page_number();
void set_date_time();
private:
void process_common_properties(drawing_object_description& pic,_pptx_drawing & drawing);
void default_set();
void process_shapes();
void process_images();
void process_charts();
void process_tables();
int hlinks_size_;

View File

@ -141,9 +141,9 @@ public:
if (c.rules[j].text) CP_XML_ATTR(L"text", *c.rules[j].text);
if (c.rules[j].rank) CP_XML_ATTR(L"rank", *c.rules[j].rank);
//CP_XML_ATTR(L"bottom" , 0);
//CP_XML_ATTR(L"equalAverage" , 0);
//CP_XML_ATTR(L"aboveAverage" , 0);
//CP_XML_ATTR(L"bottom" , 0);
//CP_XML_ATTR(L"equalAverage" , 0);
//CP_XML_ATTR(L"aboveAverage" , 0);
if (c.rules[j].type == 1)
{
CP_XML_ATTR(L"type", *c.rules[j].formula_type);

View File

@ -48,7 +48,7 @@ std::wostream & operator << (std::wostream & strm, xlsx_drawing_position::type_t
}
}
void xlsx_serialize_text(std::wostream & strm, _xlsx_drawing & val)
void xlsx_serialize_text(std::wostream & strm, _xlsx_drawing & val )
{
_CP_OPT(std::wstring) strTextContent;
odf_reader::GetProperty ( val.additional ,L"text-content", strTextContent);
@ -60,8 +60,7 @@ void xlsx_serialize_text(std::wostream & strm, _xlsx_drawing & val)
{
CP_XML_NODE(L"xdr:txBody")
{
val.serialize_bodyPr(CP_XML_STREAM());
oox_serialize_bodyPr(CP_XML_STREAM(), val);
CP_XML_NODE(L"a:lstStyle");
if (strTextContent)
{
@ -71,30 +70,30 @@ void xlsx_serialize_text(std::wostream & strm, _xlsx_drawing & val)
}
}
void xlsx_drawing_position::serialize(std::wostream & strm, std::wstring ns)
void xlsx_serialize(std::wostream & strm, const xlsx_drawing_position & val)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE( ns + (type == xlsx_drawing_position::from ? L"from" : L"to") )
CP_XML_NODE(std::wstring(L"xdr:") + (val.type == xlsx_drawing_position::from ? L"from" : L"to") )
{
CP_XML_NODE(L"xdr:col")
{
CP_XML_CONTENT(position.col);
CP_XML_CONTENT(val.position.col);
}
CP_XML_NODE(L"xdr:colOff")
{
CP_XML_CONTENT(static_cast<size_t>(position.colOff));
CP_XML_CONTENT(static_cast<size_t>(val.position.colOff));
}
CP_XML_NODE(L"xdr:row")
{
CP_XML_CONTENT(position.row);
CP_XML_CONTENT(val.position.row);
}
CP_XML_NODE(L"xdr:rowOff")
{
CP_XML_CONTENT(static_cast<size_t>(position.rowOff));
CP_XML_CONTENT(static_cast<size_t>(val.position.rowOff));
}
}
}
@ -130,7 +129,7 @@ void xlsx_serialize_image(std::wostream & strm, _xlsx_drawing & val)
CP_XML_NODE(L"xdr:spPr")
{
val.serialize_xfrm(CP_XML_STREAM());
oox_serialize_xfrm(CP_XML_STREAM(),val);
CP_XML_NODE(L"a:prstGeom")
{
@ -167,9 +166,9 @@ void xlsx_serialize_shape(std::wostream & strm, _xlsx_drawing & val)
} // xdr:nv_Pr
CP_XML_NODE(L"xdr:spPr")
{
val.serialize_xfrm(CP_XML_STREAM());
oox_serialize_xfrm(CP_XML_STREAM(),val);
val.serialize_shape(CP_XML_STREAM());
oox_serialize_shape(CP_XML_STREAM(),val);
bool draw_always = false;
if (val.sub_type == 5 || val.sub_type == 6)//line собственно ) - если ее нет - в свойствах будет
@ -182,34 +181,6 @@ void xlsx_serialize_shape(std::wostream & strm, _xlsx_drawing & val)
}
} // CP_XML_WRITER
}
void xlsx_serialize_object(std::wostream & strm, _xlsx_drawing & val)
{//отображательная часть
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"xdr:sp")
{
CP_XML_NODE(L"xdr:nvSpPr")
{
CP_XML_NODE(L"xdr:cNvPr")
{
CP_XML_ATTR(L"id", val.id); //числовое значение val.rId
CP_XML_ATTR(L"name", val.name);
}
CP_XML_NODE(L"xdr:cNvSpPr");
}
CP_XML_NODE(L"xdr:spPr")
{
val.serialize_xfrm(CP_XML_STREAM());
CP_XML_NODE(L"a:prstGeom")
{
CP_XML_ATTR(L"prst", L"rect");
}
}
}
}
}
void xlsx_serialize_group(std::wostream & strm, _xlsx_drawing & val)
{
CP_XML_WRITER(strm)
@ -220,14 +191,14 @@ void xlsx_serialize_group(std::wostream & strm, _xlsx_drawing & val)
{
CP_XML_NODE(L"xdr:cNvPr")
{
CP_XML_ATTR(L"id", val.id);
CP_XML_ATTR(L"name", val.name);
CP_XML_ATTR(L"id", val.id);
CP_XML_ATTR(L"name", val.name);
}
CP_XML_NODE(L"xdr:cNvGrpSpPr");
}
CP_XML_NODE(L"xdr:grpSpPr")
{
val.serialize_xfrm(CP_XML_STREAM());
oox_serialize_xfrm(CP_XML_STREAM(),val);
}
CP_XML_STREAM() << val.content_group_;
@ -236,7 +207,7 @@ void xlsx_serialize_group(std::wostream & strm, _xlsx_drawing & val)
}
void xlsx_serialize_chart(std::wostream & strm, _xlsx_drawing & val)
{//отображательная часть
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"xdr:graphicFrame")
@ -245,13 +216,14 @@ void xlsx_serialize_chart(std::wostream & strm, _xlsx_drawing & val)
{
CP_XML_NODE(L"xdr:cNvPr")
{
CP_XML_ATTR(L"id", val.id);
CP_XML_ATTR(L"name", val.name);
CP_XML_ATTR(L"id", val.id);
CP_XML_ATTR(L"name", val.name);
}
CP_XML_NODE(L"xdr:cNvGraphicFramePr");
}
val.serialize_xfrm(CP_XML_STREAM(), L"xdr");
oox_serialize_xfrm(CP_XML_STREAM(),val,L"xdr");
//oox_serialize_ln(CP_XML_STREAM(),val.additional);
CP_XML_NODE(L"a:graphic")
@ -263,14 +235,14 @@ void xlsx_serialize_chart(std::wostream & strm, _xlsx_drawing & val)
{
CP_XML_ATTR(L"xmlns:c", L"http://schemas.openxmlformats.org/drawingml/2006/chart");
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
CP_XML_ATTR(L"r:id", val.objectId);
CP_XML_ATTR(L"r:id", val.chartId);
}
}
}
}
}
} // xdr:graphicFrame
} // CP_XML_WRITER
}
void xlsx_serialize(std::wostream & strm, _xlsx_drawing & val)
void xlsx_serialize_object(std::wostream & strm, _xlsx_drawing & val)
{
if (val.type == typeShape)
{
@ -288,30 +260,24 @@ void xlsx_serialize(std::wostream & strm, _xlsx_drawing & val)
{
xlsx_serialize_group(strm, val);
}
else if (val.type == typeOleObject ||
val.type == typeMsObject )
{
xlsx_serialize_object(strm, val);
}
}
void _xlsx_drawing::serialize(std::wostream & strm)
void xlsx_serialize(std::wostream & strm, _xlsx_drawing & val)
{
if (inGroup)
return xlsx_serialize(strm, *this);
if (val.inGroup) return xlsx_serialize_object(strm, val);
CP_XML_WRITER(strm)
{
if (type_anchor == 1)
if (val.type_anchor == 1)
{
CP_XML_NODE(L"xdr:twoCellAnchor")
{
CP_XML_ATTR(L"editAs", L"oneCell");//"absolute");oneCell
from_.serialize (CP_XML_STREAM());
to_.serialize (CP_XML_STREAM());
xlsx_serialize (CP_XML_STREAM(), val.from_);
xlsx_serialize (CP_XML_STREAM(), val.to_);
xlsx_serialize (CP_XML_STREAM(), *this);
xlsx_serialize_object (CP_XML_STREAM(),val);
CP_XML_NODE(L"xdr:clientData");
}
}
@ -321,15 +287,18 @@ void _xlsx_drawing::serialize(std::wostream & strm)
{
CP_XML_NODE(L"xdr:pos")
{
CP_XML_ATTR(L"x", x);
CP_XML_ATTR(L"y", y);
CP_XML_ATTR(L"x", val.x);
CP_XML_ATTR(L"y", val.y);
}
CP_XML_NODE(L"xdr:ext")
{
CP_XML_ATTR(L"cx", cx);
CP_XML_ATTR(L"cy", cy);
CP_XML_ATTR(L"cx", val.cx);
CP_XML_ATTR(L"cy", val.cy);
}
xlsx_serialize(CP_XML_STREAM(), *this);
xlsx_serialize_object (CP_XML_STREAM(),val);
CP_XML_NODE(L"xdr:clientData");
}
}
@ -338,38 +307,5 @@ void _xlsx_drawing::serialize(std::wostream & strm)
}
void _xlsx_drawing::serialize_object (std::wostream & strm)
{
if (type != typeOleObject && type != typeMsObject) return;
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"oleObject")
{
CP_XML_ATTR(L"r:id", objectId);
CP_XML_ATTR(L"shapeId", id);
CP_XML_ATTR(L"progId", objectProgId);
CP_XML_NODE(L"objectPr")
{
CP_XML_ATTR(L"defaultSize", 0);
if (fill.bitmap)
{
CP_XML_ATTR(L"r:id", fill.bitmap->rId);
}
CP_XML_NODE(L"anchor")
{
CP_XML_ATTR(L"moveWithCells", 1);
from_.serialize (CP_XML_STREAM(), L"");
to_.serialize (CP_XML_STREAM(), L"");
}
}
}
}
}
}
}

View File

@ -46,16 +46,16 @@ namespace oox {
struct xlsx_drawing_position
{
enum type_t {from, to} type;
xlsx_table_position position;
enum type_t {from, to};
type_t type;
xlsx_table_position position;
void serialize(std::wostream & _Wostream, std::wstring ns = L"xdr:");
friend void xlsx_serialize(std::wostream & _Wostream, xlsx_drawing_position const & val);
};
class _xlsx_drawing : public _oox_drawing
struct _xlsx_drawing : _oox_drawing
{
public:
_xlsx_drawing() : _oox_drawing(), type_anchor(1) {}
int type_anchor;
@ -65,8 +65,8 @@ public:
std::wstring content_group_;
void serialize (std::wostream & strm);
void serialize_object (std::wostream & strm);
friend void xlsx_serialize(std::wostream & _Wostream, _xlsx_drawing & val);
};
}
}

View File

@ -34,6 +34,8 @@
#include <iostream>
#include <cpdoccore/xml/utils.h>
#include "mediaitems_utils.h"
#include "xlsx_drawing.h"
#include "xlsx_drawings.h"
#include "xlsx_utils.h"
@ -109,8 +111,7 @@ class xlsx_drawing_context::Impl
public:
Impl(xlsx_drawing_context_handle & handle) : xlsx_drawings_(xlsx_drawings::create(false)), handle_(handle)
{
current_level_ = &objects_;
use_image_replacement_ = false;
current_level_ = &objects_;
}
xlsx_drawing_context_handle& handle_;
@ -120,14 +121,13 @@ public:
std::vector<drawing_object_description*> groups_;
std::vector<drawing_object_description> * current_level_;
bool use_image_replacement_;
//-----------------------------------------------------------------------------------
mediaitems & get_mediaitems() { return handle_.impl_->get_mediaitems(); }
void serialize(std::wostream & strm)
{
xlsx_drawings_->serialize(strm);
xlsx_serialize(strm, *xlsx_drawings_);
}
bool empty() const
@ -167,12 +167,12 @@ void xlsx_drawing_context::clear()
impl_->object_description_.anchor_y_ = 0;
impl_->object_description_.clipping_string_ = L"";
impl_->object_description_.svg_rect_ = boost::none;
impl_->object_description_.use_image_replace_ = false;
impl_->object_description_.additional_.clear();
impl_->object_description_.hlinks_.clear();
impl_->object_description_.additional_.clear();
impl_->use_image_replacement_ = false;
}
xlsx_drawing_context::~xlsx_drawing_context()
@ -272,62 +272,37 @@ void xlsx_drawing_context::end_shape()
impl_->current_level_->push_back(impl_->object_description_);
}
void xlsx_drawing_context::set_use_image_replacement()
void xlsx_drawing_context::start_object_ole()
{
impl_->use_image_replacement_ = true;
}
void xlsx_drawing_context::set_text_box()
{
impl_->object_description_.type_ = typeShape;
impl_->object_description_.shape_type_ = 2; //2,3...
}
void xlsx_drawing_context::set_ole_object(const std::wstring & path, const std::wstring & progId)
void xlsx_drawing_context::end_object_ole()
{
impl_->object_description_.type_ = typeOleObject;
}
void xlsx_drawing_context::start_image(std::wstring const & path)
{
impl_->object_description_.type_ = typeImage;
impl_->object_description_.xlink_href_ = path;
impl_->object_description_.descriptor_ = progId;
}
void xlsx_drawing_context::set_ms_object(const std::wstring & path, const std::wstring & progId)
{
impl_->object_description_.type_ = typeMsObject;
impl_->object_description_.xlink_href_ = path;
impl_->object_description_.descriptor_ = progId;
}
void xlsx_drawing_context::set_image(const std::wstring & path)
{
if (impl_->object_description_.type_ == typeUnknown)
{
impl_->object_description_.type_ = typeImage;
impl_->object_description_.xlink_href_ = path;
}
else if (impl_->use_image_replacement_)
{
impl_->object_description_.fill_.type = 2;
impl_->object_description_.fill_.bitmap = oox::oox_bitmap_fill::create();
impl_->object_description_.fill_.bitmap->xlink_href_ = path;
}
}
void xlsx_drawing_context::start_frame()
{
impl_->object_description_.type_ = typeUnknown;
}
void xlsx_drawing_context::end_frame()
void xlsx_drawing_context::end_image()
{
impl_->current_level_->push_back(impl_->object_description_);
}
void xlsx_drawing_context::set_chart(const std::wstring & path)
void xlsx_drawing_context::start_chart(std::wstring const & path)
{
impl_->object_description_.type_ = typeChart;
impl_->object_description_.xlink_href_ = path;
}
void xlsx_drawing_context::end_chart()
{
impl_->current_level_->push_back(impl_->object_description_);
}
void xlsx_drawing_context::set_rect(double width_pt, double height_pt, double x_pt, double y_pt)
{
impl_->object_description_.svg_rect_ = _rect(width_pt, height_pt, x_pt, y_pt);
}
void xlsx_drawing_context::set_translate(double x_pt, double y_pt)
{
if (impl_->object_description_.svg_rect_)
@ -338,7 +313,6 @@ void xlsx_drawing_context::set_translate(double x_pt, double y_pt)
r.y += y_pt;
}
}
void xlsx_drawing_context::set_rotate(double angle)
{
set_property(odf_reader::_property(L"svg:rotate", angle));
@ -395,7 +369,6 @@ void xlsx_drawing_context::set_fill(_oox_fill & fill)
{
impl_->object_description_.fill_= fill;
}
std::wstring xlsx_drawing_context::add_hyperlink(std::wstring const & href,bool object)
{
++hlinks_size_;
@ -411,6 +384,11 @@ std::wstring xlsx_drawing_context::add_hyperlink(std::wstring const & href,bool
return hId;
}
void xlsx_drawing_context::set_use_image_replacement()
{
impl_->object_description_.use_image_replace_ = true;
}
bool xlsx_drawing_context::empty() const
{
return impl_->empty();
@ -557,26 +535,13 @@ void xlsx_drawing_context::process_chart(drawing_object_description & obj,_xlsx_
std::wstring ref;
bool isMediaInternal = true;
drawing.objectId = impl_->get_mediaitems().add_or_find(obj.xlink_href_, obj.type_, isMediaInternal, ref);
xlsx_drawings_->add(drawing, isMediaInternal, drawing.objectId, ref, obj.type_);
drawing.chartId = impl_->get_mediaitems().add_or_find(obj.xlink_href_, obj.type_, isMediaInternal, ref);
xlsx_drawings_->add(drawing, isMediaInternal, drawing.chartId, ref, obj.type_);
if (drawing.inGroup)
impl_->get_drawings()->add(isMediaInternal, drawing.objectId, ref, obj.type_); // не объект
impl_->get_drawings()->add(isMediaInternal, drawing.chartId, ref, obj.type_); // не объект
}
void xlsx_drawing_context::process_object(drawing_object_description & obj,_xlsx_drawing & drawing, xlsx_drawings_ptr xlsx_drawings_)
{
std::wstring ref;
bool isMediaInternal = true;
drawing.objectId = impl_->get_mediaitems().add_or_find(obj.xlink_href_, obj.type_, isMediaInternal, ref);
drawing.objectProgId = obj.descriptor_;
xlsx_drawings_->add(drawing, isMediaInternal, drawing.objectId, ref, obj.type_, true);
if (drawing.inGroup)
impl_->get_drawings()->add(isMediaInternal, drawing.objectId, ref, obj.type_); // не объект
}
void xlsx_drawing_context::process_shape(drawing_object_description & obj,_xlsx_drawing & drawing, xlsx_drawings_ptr xlsx_drawings_)
{
std::wstring ref;
@ -594,7 +559,7 @@ void xlsx_drawing_context::process_group(drawing_object_description & obj, xlsx_
std::wstringstream strm;
xlsx_drawings_child->serialize(strm);
xlsx_serialize(strm, *xlsx_drawings_child);
drawing.content_group_ = strm.str();
@ -616,6 +581,9 @@ void xlsx_drawing_context::process_objects(std::vector<drawing_object_descriptio
{
drawing_object_description & obj = objects[i];
int pos_replaicement = obj.xlink_href_.find(L"ObjectReplacements");
if (pos_replaicement >= 0 && !obj.use_image_replace_)continue; //объект
_xlsx_drawing drawing =_xlsx_drawing();
drawing.type = obj.type_;
@ -632,11 +600,7 @@ void xlsx_drawing_context::process_objects(std::vector<drawing_object_descriptio
bool isMediaInternal = true;
drawing.fill.bitmap->rId = impl_->get_mediaitems().add_or_find(drawing.fill.bitmap->xlink_href_, typeImage, isMediaInternal, ref);
bool in_sheet = (obj.type_== typeOleObject || obj.type_== typeMsObject) ? true : false;
impl_->get_drawings()->add(isMediaInternal, drawing.fill.bitmap->rId, ref, typeImage, in_sheet);//собственно это не объект, а доп рел и ref объекта
//object dumps in sheet rels !!
impl_->get_drawings()->add(isMediaInternal, drawing.fill.bitmap->rId, ref, typeImage);//собственно это не объект, а доп рел и ref объекта
}
process_common_properties(obj, drawing, table_metrics);
@ -647,9 +611,6 @@ void xlsx_drawing_context::process_objects(std::vector<drawing_object_descriptio
case typeImage: process_image ( obj, drawing, xlsx_drawings_); break;
case typeShape: process_shape ( obj, drawing, xlsx_drawings_); break;
case typeGroupShape: process_group ( obj, table_metrics, drawing, xlsx_drawings_); break;
case typeMsObject:
case typeOleObject:
process_object ( obj, drawing, xlsx_drawings_); break;
}
}
}

View File

@ -80,34 +80,35 @@ public:
void set_odf_packet_path(std::wstring path){odf_packet_path_ = path;}//для анализа картинок
void start_drawing (std::wstring const & name);
void end_drawing ();
void start_drawing(std::wstring const & name);
void end_drawing();
void start_group(std::wstring const & name);
void end_group ();
void end_group();
void start_image(std::wstring const & path);
void end_image();
void start_chart(std::wstring const & path);
void end_chart();
void start_shape(int type);
//...пока тока общие свойства ... частные для каждого объекта пооозже
void end_shape();
void start_frame();
void set_image (const std::wstring & path);
void set_chart (const std::wstring & path);
void set_ole_object (const std::wstring & path, const std::wstring & progId);
void set_ms_object (const std::wstring & path, const std::wstring & progId);
void set_text_box ();
void end_frame();
void start_object_ole();
void end_object_ole();
void set_rect(double width_pt, double height_pt, double x_pt, double y_pt);
void set_translate (double x_pt, double y_pt);
void set_scale (double cx_pt, double cy_pt);
void set_rotate (double angle);
void set_translate(double x_pt, double y_pt);
void set_scale(double cx_pt, double cy_pt);
void set_rotate(double angle);
void set_anchor (std::wstring anchor, double x_pt, double y_pt, bool group = false);
void set_property (odf_reader::_property p);
void set_clipping (const std::wstring & str );
void set_fill (_oox_fill & fill);
void set_anchor(std::wstring anchor, double x_pt, double y_pt, bool group = false);
void set_property(odf_reader::_property p);
void set_clipping(const std::wstring & str );
void set_fill(_oox_fill & fill);
std::vector<odf_reader::_property> & get_properties();
@ -135,7 +136,6 @@ private:
void process_image (drawing_object_description & obj, _xlsx_drawing & drawing, xlsx_drawings_ptr xlsx_drawings_);
void process_chart (drawing_object_description & obj, _xlsx_drawing & drawing, xlsx_drawings_ptr xlsx_drawings_);
void process_shape (drawing_object_description & obj, _xlsx_drawing & drawing, xlsx_drawings_ptr xlsx_drawings_);
void process_object (drawing_object_description & obj, _xlsx_drawing & drawing, xlsx_drawings_ptr xlsx_drawings_);
void process_common_properties (drawing_object_description & obj, _xlsx_drawing & drawing, xlsx_table_metrics & table_metrics);

View File

@ -36,6 +36,7 @@
#include <vector>
#include <cpdoccore/xml/simple_xml_writer.h>
#include "mediaitems_utils.h"
#include "oox_rels.h"
namespace cpdoccore {
@ -44,44 +45,40 @@ namespace oox {
class xlsx_drawings::Impl
{
public:
void add(_xlsx_drawing const & d, bool isInternal, std::wstring const & rid, std::wstring const & ref, RelsType type, bool sheet_rel )//объект
void add(_xlsx_drawing const & d, bool isInternal, std::wstring const & rid, std::wstring const & ref, RelsType type)
{
xlsx_drawings_.push_back(d);
add (isInternal, rid, ref, type, sheet_rel);
for (int i = 0 ; i < d.hlinks.size(); i++)
bool present = false;
for (int i = 0 ; i < xlsx_drawing_rels_.size(); i++)
{
if (xlsx_drawing_rels_[i].rid == rid && xlsx_drawing_rels_[i].ref == ref)
present = true;
}
if (!present)
{
xlsx_drawing_rels_.push_back(_rel(isInternal, rid, ref, type));
}
for (int i = 0 ; i < d.hlinks.size(); i++)
{
xlsx_drawing_rels_.push_back(_rel(false, d.hlinks[i].hId, d.hlinks[i].hRef, typeHyperlink));
}
}
void add( bool isInternal, std::wstring const & rid, std::wstring const & ref, RelsType type, bool sheet_rel) //не объект
void add( bool isInternal, std::wstring const & rid, std::wstring const & ref, RelsType type)
{
bool present = false;
if (type == typeHyperlink) isInternal = false;
if (sheet_rel)
{
for (int i = 0 ; i < xlsx_sheet_rels_.size(); i++)
{
if (xlsx_sheet_rels_[i].rid == rid && xlsx_sheet_rels_[i].ref == ref)
present = true;
}
if (!present)
xlsx_sheet_rels_.push_back (_rel(isInternal, rid, ref, type));
for (int i = 0 ; i < xlsx_drawing_rels_.size(); i++)
{
if (xlsx_drawing_rels_[i].rid == rid && xlsx_drawing_rels_[i].ref == ref)
present = true;
}
else
if (!present)
{
for (int i = 0 ; i < xlsx_drawing_rels_.size(); i++)
{
if (xlsx_drawing_rels_[i].rid == rid && xlsx_drawing_rels_[i].ref == ref)
present = true;
}
if (!present)
xlsx_drawing_rels_.push_back(_rel(isInternal, rid, ref, type));
xlsx_drawing_rels_.push_back(_rel(isInternal, rid, ref, type));
}
}
void serialize(std::wostream & strm)
{
@ -89,7 +86,7 @@ public:
{
for (int i = 0 ; i < xlsx_drawings_.size(); i++)
{
xlsx_drawings_[i].serialize(strm);
xlsx_serialize(strm, xlsx_drawings_[i]);
}
}
else
@ -104,62 +101,60 @@ public:
for (int i = 0 ; i < xlsx_drawings_.size(); i++)
{
xlsx_drawings_[i].serialize(CP_XML_STREAM());
xlsx_serialize(CP_XML_STREAM(), xlsx_drawings_[i]);
}
}
}
}
}
void serialize_objects(std::wostream & strm)
{
for (int i = 0 ; i < xlsx_drawings_.size(); i++)
{
if (xlsx_drawings_[i].type != typeOleObject && xlsx_drawings_[i].type != typeMsObject) continue;
xlsx_drawings_[i].serialize_object(strm);
}
}
bool empty() const
{
return (xlsx_drawings_.empty());
}
void dump_rels_drawing(rels & Rels)
void dump_rels(rels & Rels)
{
for (int i = 0 ; i < xlsx_drawing_rels_.size(); i++)
{
if (xlsx_drawing_rels_[i].type == typeImage ||
xlsx_drawing_rels_[i].type == typeMedia ||
xlsx_drawing_rels_[i].type == typeChart ||
xlsx_drawing_rels_[i].type == typeHyperlink )
if (xlsx_drawing_rels_[i].type == typeChart)
{
Rels.add(relationship( xlsx_drawing_rels_[i].rid,
mediaitems::get_rel_type(xlsx_drawing_rels_[i].type),
Rels.add(relationship(
xlsx_drawing_rels_[i].rid,
utils::media::get_rel_type(xlsx_drawing_rels_[i].type),
(xlsx_drawing_rels_[i].is_internal ? std::wstring(L"../") + xlsx_drawing_rels_[i].ref : xlsx_drawing_rels_[i].ref),
(xlsx_drawing_rels_[i].is_internal ? L"" : L"External")) );
(xlsx_drawing_rels_[i].is_internal ? L"" : L"External")
)
);
}
else if (xlsx_drawing_rels_[i].type == typeImage)
{
Rels.add(relationship(
xlsx_drawing_rels_[i].rid,
utils::media::get_rel_type(xlsx_drawing_rels_[i].type),
xlsx_drawing_rels_[i].is_internal ? std::wstring(L"../") + xlsx_drawing_rels_[i].ref : xlsx_drawing_rels_[i].ref,
(xlsx_drawing_rels_[i].is_internal ? L"" : L"External")
)
);
}
else if (xlsx_drawing_rels_[i].type == typeHyperlink)
{
Rels.add(relationship(
xlsx_drawing_rels_[i].rid,
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
xlsx_drawing_rels_[i].ref,
L"External")
);
}
}
}
void dump_rels_sheet(rels & Rels)
{
for (int i = 0 ; i < xlsx_sheet_rels_.size(); i++)
{
Rels.add(relationship( xlsx_sheet_rels_[i].rid,
mediaitems::get_rel_type(xlsx_sheet_rels_[i].type),
(xlsx_sheet_rels_[i].is_internal ? std::wstring(L"../") + xlsx_sheet_rels_[i].ref : xlsx_sheet_rels_[i].ref),
(xlsx_sheet_rels_[i].is_internal ? L"" : L"External")) );
}
}
bool inGroup;
private:
std::vector<_xlsx_drawing> xlsx_drawings_;
std::vector<_rel> xlsx_drawing_rels_;
std::vector<_rel> xlsx_sheet_rels_;
};
xlsx_drawings::xlsx_drawings(bool inGroup_) : impl_( new xlsx_drawings::Impl() )
@ -172,24 +167,19 @@ xlsx_drawings::~xlsx_drawings()
}
void xlsx_drawings::add(_xlsx_drawing const & d, bool isInternal, std::wstring const & rid,
std::wstring const & ref, RelsType type, bool sheet_rel)
std::wstring const & ref, RelsType type)
{
impl_->add(d, isInternal, rid, ref, type, sheet_rel);
impl_->add(d, isInternal, rid, ref, type);
}
void xlsx_drawings::add( bool isInternal, std::wstring const & rid, std::wstring const & ref, RelsType type, bool sheet_rel)
void xlsx_drawings::add( bool isInternal, std::wstring const & rid, std::wstring const & ref, RelsType type)
{
impl_->add(isInternal, rid, ref, type, sheet_rel);
impl_->add(isInternal, rid, ref, type);
}
void xlsx_drawings::serialize(std::wostream & strm)
void xlsx_serialize(std::wostream & _Wostream, xlsx_drawings const & val)
{
impl_->serialize(strm);
}
void xlsx_drawings::serialize_objects(std::wostream & strm)
{
impl_->serialize_objects(strm);
val.impl_->serialize(_Wostream);
}
bool xlsx_drawings::empty() const
@ -197,14 +187,9 @@ bool xlsx_drawings::empty() const
return impl_->empty();
}
void xlsx_drawings::dump_rels_drawing(rels & Rels)
void xlsx_drawings::dump_rels(rels & Rels)
{
return impl_->dump_rels_drawing(Rels);
}
void xlsx_drawings::dump_rels_sheet(rels & Rels)
{
return impl_->dump_rels_sheet(Rels);
return impl_->dump_rels(Rels);
}
xlsx_drawings_ptr xlsx_drawings::create(bool inGroup)

View File

@ -55,7 +55,7 @@ struct drawing_elm
xlsx_drawings_ptr drawings;
};
class _xlsx_drawing;
struct _xlsx_drawing;
class xlsx_drawings
{
@ -64,15 +64,14 @@ public:
~xlsx_drawings ();
static xlsx_drawings_ptr create(bool inGroup);
void add ( _xlsx_drawing const & d, bool isInternal, std::wstring const & rid, std::wstring const & ref, RelsType type, bool sheet_rel = false );
void add ( bool isInternal, std::wstring const & rid, std::wstring const & ref, RelsType type, bool sheet_rel = false );
public:
void add (_xlsx_drawing const & d, bool isInternal, std::wstring const & rid, std::wstring const & ref, RelsType type);
void add (bool isInternal, std::wstring const & rid, std::wstring const & ref, RelsType type );
bool empty () const;
void dump_rels_sheet (rels & Rels);
void dump_rels_drawing (rels & Rels);
bool empty () const;
void dump_rels (rels & Rels);
void serialize (std::wostream & _Wostream);
void serialize_objects (std::wostream & _Wostream);
friend void xlsx_serialize(std::wostream & _Wostream, xlsx_drawings const & val);
private:
class Impl;
_CP_SCOPED_PTR(Impl) impl_;

View File

@ -54,10 +54,8 @@ public:
std::wstringstream sort_;
std::wstringstream autofilter_;
std::wstringstream conditionalFormatting_;
std::wstringstream ole_objects_;
rels hyperlinks_rels_;
rels ole_objects_rels_;
std::wstring drawingName_;
std::wstring drawingId_;
@ -130,31 +128,20 @@ std::wostream & xlsx_xml_worksheet::hyperlinks()
{
return impl_->hyperlinks_;
}
std::wostream & xlsx_xml_worksheet::ole_objects()
{
return impl_->ole_objects_;
}
//---------------------------------------------------------------------------------------
rels & xlsx_xml_worksheet::hyperlinks_rels()
{
return impl_->hyperlinks_rels_;
}
rels & xlsx_xml_worksheet::ole_objects_rels()
{
return impl_->ole_objects_rels_;
}
void xlsx_xml_worksheet::write_to(std::wostream & strm)
{
CP_XML_WRITER(strm)
{
CP_XML_NODE(L"worksheet")
{
CP_XML_ATTR(L"xmlns", L"http://schemas.openxmlformats.org/spreadsheetml/2006/main");
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
CP_XML_ATTR(L"xmlns:xdr", L"http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing");
CP_XML_ATTR(L"xmlns:x14", L"http://schemas.microsoft.com/office/spreadsheetml/2009/9/main");
CP_XML_ATTR(L"xmlns:mc", L"http://schemas.openxmlformats.org/markup-compatibility/2006");
CP_XML_ATTR(L"mc:Ignorable",L"x14ac");
CP_XML_ATTR(L"xmlns", L"http://schemas.openxmlformats.org/spreadsheetml/2006/main");
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
CP_XML_ATTR(L"xmlns:mc", L"http://schemas.openxmlformats.org/markup-compatibility/2006");
CP_XML_ATTR(L"mc:Ignorable", L"x14ac");
CP_XML_ATTR(L"xmlns:x14ac", L"http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac");
CP_XML_STREAM() << impl_->sheetFormat_.str();
@ -192,13 +179,7 @@ void xlsx_xml_worksheet::write_to(std::wostream & strm)
CP_XML_ATTR(L"r:id",impl_->vml_drawingId_);
}
}
if (!impl_->ole_objects_.str().empty())
{
CP_XML_NODE(L"oleObjects")
{
CP_XML_STREAM() << impl_->ole_objects_.str();
}
}
//CP_XML_NODE(L"headerFooter){}
//CP_XML_NODE(L"rowBreaks){}
@ -236,5 +217,43 @@ std::pair<std::wstring, std::wstring> xlsx_xml_worksheet::get_vml_drawing_link()
return std::pair<std::wstring, std::wstring>(impl_->vml_drawingName_, impl_->vml_drawingId_);
}
//class xlsx_xml_workbook::Impl: noncopyable
//{
//public:
// std::wstringstream sheets_;
//};
//
//xlsx_xml_workbook::xlsx_xml_workbook() : impl_(new xlsx_xml_workbook::Impl)
//{
//}
//
//xlsx_xml_workbook::~xlsx_xml_workbook()
//{
//}
//
//std::wostream & xlsx_xml_workbook::sheets()
//{
// return impl_->sheets_;
//}
//
//void xlsx_xml_workbook::write_to(std::wostream & strm)
//{
// CP_XML_WRITER(strm)
// {
// CP_XML_NODE(L"workbook")
// {
// CP_XML_ATTR(L"xmlns", L"http://schemas.openxmlformats.org/spreadsheetml/2006/main");
// CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
//
// CP_XML_NODE(L"sheets")
// {
// CP_XML_STREAM() << impl_->sheets_.str();
// }
// }
// }
//}
//
}
}

View File

@ -62,10 +62,8 @@ public:
std::wostream & autofilter();
std::wostream & conditionalFormatting();
std::wostream & sort();
std::wostream & ole_objects();
rels & hyperlinks_rels();
rels & ole_objects_rels();
void write_to(std::wostream & strm);

View File

@ -181,30 +181,30 @@ void xl_files::write(const std::wstring & RootPath)
sharedStrings_->write(path);
rels_files_.add( relationship( L"shId1", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings", L"sharedStrings.xml" ) );
}
if (styles_)
{
styles_->write(path);
rels_files_.add( relationship( L"stId1", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles", L"styles.xml" ) );
}
if (workbook_)
{
workbook_->write(path);
}
if (theme_)
{
theme_->write(path);
}
if (media_)
{
media_->set_main_document(get_main_document());
media_->write(path);
}
if (embeddings_)
{
embeddings_->set_main_document(get_main_document());
embeddings_->write(path);
}
{
charts_files_.set_main_document(get_main_document());
charts_files_.write(path);
}
@ -243,15 +243,7 @@ void xl_files::add_sheet(sheet_content_ptr sheet)
void xl_files::set_media(mediaitems & _Mediaitems, CApplicationFonts *pAppFonts)
{
if (_Mediaitems.count_image + _Mediaitems.count_media > 0)
{
media_ = element_ptr( new media(_Mediaitems, pAppFonts) );
}
if (_Mediaitems.count_object > 0)
{
embeddings_ = element_ptr( new embeddings(_Mediaitems) );
}
media_ = element_ptr( new media(_Mediaitems, pAppFonts) );
}
void xl_files::set_comments(element_ptr Element)
{
@ -321,7 +313,7 @@ void xl_drawings::write(const std::wstring & RootPath)
rels_files relFiles;
rels_file_ptr r = rels_file::create(e.filename + L".rels");
e.drawings->dump_rels_drawing(r->get_rels());
e.drawings->dump_rels(r->get_rels());
relFiles.add_rel_file(r);
relFiles.write(path);

View File

@ -169,20 +169,18 @@ public:
void add_charts(chart_content_ptr chart);
private:
rels_files rels_files_;
sheets_files sheets_files_;
rels_files rels_files_;
sheets_files sheets_files_;
xl_charts_files charts_files_;
element_ptr theme_;
element_ptr workbook_;
element_ptr theme_;
element_ptr workbook_;
element_ptr styles_;
element_ptr sharedStrings_;
element_ptr media_;
element_ptr embeddings_;
element_ptr drawings_;
element_ptr vml_drawings_;
element_ptr comments_;
element_ptr styles_;
element_ptr sharedStrings_;
element_ptr media_;
element_ptr drawings_;
element_ptr vml_drawings_;
element_ptr comments_;
};
@ -193,7 +191,7 @@ public:
xlsx_document();
public:
virtual void write(const std::wstring & RootPath);
virtual void write(const std::wstring & RootPath);
virtual content_types_file & get_content_types_file() { return content_type_file_; }
xl_files & get_xl_files() { return xl_files_; }

View File

@ -344,7 +344,6 @@ double charsToSize(unsigned int charsCount, double maxDigitSize)
void xlsx_table_state::serialize_table_format(std::wostream & _Wostream)
{
odf_reader::odf_read_context & odfContext = context_->root()->odf_context();
CP_XML_WRITER(_Wostream)
{
odf_reader::style_table_properties * table_prop = NULL;
@ -368,64 +367,13 @@ void xlsx_table_state::serialize_table_format(std::wostream & _Wostream)
//<pageSetUpPr fitToPage="true"/>
}
}
int columns = (std::max)(current_table_column_, (int)columns_count_);
int rows = (std::max)(current_table_row_, 1);
if (columns < 1024 && columns > 1 &&
rows < 1024 && rows > 1)
//<dimension ref="B1:T65536"/>
CP_XML_NODE(L"sheetView")
{
CP_XML_NODE(L"dimension")
{
std::wstring ref2 = getCellAddress( current_table_column_, current_table_row_);
CP_XML_ATTR(L"ref", L"A1:" + ref2);
}
}
if (odfContext.Settings().get_views_count() > 0)
{
CP_XML_NODE(L"sheetViews")
{
CP_XML_NODE(L"sheetView")
{
CP_XML_ATTR(L"workbookViewId", 0);
std::wstring s_col, s_row;
for (int i = 0; i < odfContext.Settings().get_table_view_count(0, tableName_); i++)
{
std::pair<std::wstring, std::wstring> value = odfContext.Settings().get_table_view(0, tableName_, i);
if (value.first == L"ZoomValue")
{
CP_XML_ATTR(L"zoomScale", value.second);
CP_XML_ATTR(L"zoomScaleNormal", value.second);
}
if (value.first == L"ShowGrid") CP_XML_ATTR(L"showGridLines", value.second);
if (value.first == L"CursorPositionX") s_col = value.second;
if (value.first == L"CursorPositionY") s_row = value.second;
}
int col = -1, row = -1;
try
{
col = boost::lexical_cast<int>(s_col);
row = boost::lexical_cast<int>(s_row);
}
catch(...){}
if (col >= 0 && row >= 0)
{
CP_XML_NODE(L"selection")
{
CP_XML_ATTR(L"sqref", getCellAddress(col, row));
CP_XML_ATTR(L"activeCellId", 0);
CP_XML_ATTR(L"activeCell", getCellAddress(col, row));
CP_XML_ATTR(L"pane", L"topLeft");
}
}
}
}
// -showGridLines
// -showRowColHeaders
// -rightToLeft
// -zoomScale
}
double default_height = (2 * context_->getMaxDigitSize().second * 72. / 96. * 100.) /100.;//in point size.
@ -455,10 +403,7 @@ void xlsx_table_state::serialize_merge_cells(std::wostream & _Wostream)
{
return xlsx_merge_cells_.xlsx_serialize(_Wostream);
}
void xlsx_table_state::serialize_ole_objects(std::wostream & _Wostream)
{
return xlsx_drawing_context_.get_drawings()->serialize_objects(_Wostream);
}
void xlsx_table_state::serialize_hyperlinks(std::wostream & _Wostream)
{
return xlsx_hyperlinks_.xlsx_serialize(_Wostream);
@ -471,10 +416,6 @@ void xlsx_table_state::dump_rels_hyperlinks(rels & Rels)
{
return xlsx_hyperlinks_.dump_rels(Rels);
}
void xlsx_table_state::dump_rels_ole_objects(rels & Rels)
{
return get_drawing_context().get_drawings()->dump_rels_sheet(Rels);
}
void xlsx_table_state::start_hyperlink()
{

View File

@ -127,10 +127,7 @@ public:
void serialize_table_format (std::wostream & _Wostream);
void serialize_merge_cells (std::wostream & _Wostream);
void serialize_hyperlinks (std::wostream & _Wostream);
void serialize_ole_objects (std::wostream & _Wostream);
void dump_rels_hyperlinks (rels & Rels);
void dump_rels_ole_objects (rels & Rels);
void dump_rels_hyperlinks (rels & Rels);
std::wstring get_table_name() const { return tableName_; }
int get_table_id() const { return tableId_; }

View File

@ -320,18 +320,10 @@ void xlsx_table_context::serialize_hyperlinks(std::wostream & _Wostream)
{
return state()->serialize_hyperlinks(_Wostream);
}
void xlsx_table_context::serialize_ole_objects(std::wostream & _Wostream)
{
return state()->serialize_ole_objects(_Wostream);
}
void xlsx_table_context::dump_rels_hyperlinks(rels & Rels)
{
return state()->dump_rels_hyperlinks(Rels);
}
void xlsx_table_context::dump_rels_ole_objects(rels & Rels)
{
return state()->dump_rels_ole_objects(Rels);
}
xlsx_table_metrics & xlsx_table_context::get_table_metrics()
{

View File

@ -88,8 +88,6 @@ public:
void serialize_merge_cells (std::wostream & _Wostream);
void serialize_table_format (std::wostream & _Wostream);
void serialize_conditionalFormatting(std::wostream & _Wostream);
void serialize_hyperlinks (std::wostream & _Wostream);
void serialize_ole_objects (std::wostream & _Wostream);
xlsx_table_metrics & get_table_metrics();
@ -105,9 +103,10 @@ public:
void start_hyperlink();
std::wstring end_hyperlink(std::wstring const & ref, std::wstring const & href, std::wstring const & display);
void dump_rels_hyperlinks (rels & Rels);
void dump_rels_ole_objects (rels & Rels);
void dump_rels_hyperlinks(rels & Rels);
void serialize_hyperlinks(std::wostream & _Wostream);
void start_database_range(std::wstring table_name, std::wstring ref);
void set_database_orientation (bool val);
void set_database_header (bool val);

Some files were not shown because too many files have changed in this diff Show More