Commit 635a5d23 authored by ElenaSubbotina's avatar ElenaSubbotina

DocFormatReader - background page

parent 6fa18eb2
......@@ -54,6 +54,7 @@ namespace DocFileFormat
friend class SettingsMapping;
bool bDisplayBackgroundShape;
private:
// True when facing pages should be printed
bool fFacingPages;
......
......@@ -1162,6 +1162,8 @@ 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();
}
}
......
......@@ -53,33 +53,47 @@ namespace DocFileFormat
m_context->_docx->RegisterDocument();
// Header
m_pXmlWriter->WriteNodeBegin(_T("?xml version=\"1.0\" encoding=\"UTF-8\"?"));
m_pXmlWriter->WriteNodeBegin(_T("w:document"), TRUE );
m_pXmlWriter->WriteNodeBegin(L"?xml version=\"1.0\" encoding=\"UTF-8\"?");
m_pXmlWriter->WriteNodeBegin(L"w:document", TRUE );
// Namespaces
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(_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->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(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->WriteNodeEnd( _T( "" ), TRUE, FALSE );
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );
m_pXmlWriter->WriteNodeBegin( _T("w:body"), FALSE );
if ((m_document->GetOfficeArt()) && (m_document->GetOfficeArt()->GetShapeBackgound()))
{
m_document->DocProperties->bDisplayBackgroundShape = true;
ShapeContainer* pShape = m_document->GetOfficeArt()->GetShapeBackgound();
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)
{
......@@ -175,8 +189,8 @@ namespace DocFileFormat
}
}
m_pXmlWriter->WriteNodeEnd( _T( "w:body" ) );
m_pXmlWriter->WriteNodeEnd( _T( "w:document" ) );
m_pXmlWriter->WriteNodeEnd( L"w:body" );
m_pXmlWriter->WriteNodeEnd( L"w:document" );
m_context->_docx->DocumentXML = std::wstring(m_pXmlWriter->GetXmlString());
}
......
......@@ -34,6 +34,7 @@
#include "OfficeDrawing/RecordFactory.h"
#include "OfficeDrawing/DrawingContainer.h"
#include "OfficeDrawing/DrawingRecord.h"
#include "OfficeDrawing/DrawingGroup.h"
#include "OfficeDrawing/GroupContainer.h"
#include "OfficeDrawing/Shape.h"
......@@ -57,7 +58,7 @@ namespace DocFileFormat
public:
OfficeArtContent (const FileInformationBlock* pFIB, POLE::Stream* pStream): m_pDrawingGroupData(NULL)
OfficeArtContent (const FileInformationBlock* pFIB, POLE::Stream* pStream): m_pDrawingGroupData(NULL), m_pBackgroud(NULL)
{
VirtualStreamReader oStearmReader(pStream, 0 , pFIB->m_bOlderVersion);
......@@ -87,15 +88,23 @@ namespace DocFileFormat
{
// the child is a subgroup
GroupContainer* group = static_cast<GroupContainer*>(groupChild);
group->Index = i;
drawing.container->Children[i] = group;
if (group)
{
group->Index = i;
}
}
else if (ShapeContainer::TYPE_CODE_0xF004 == groupChild->TypeCode)
{
// the child is a shape
ShapeContainer* shape = static_cast<ShapeContainer*>(groupChild);
shape->Index = i;
drawing.container->Children[i] = shape;
if (shape)
{
shape->Index = i;
if (shape->isBackground())
{
m_pBackgroud = shape;
}
}
}
}
}
......@@ -112,7 +121,10 @@ 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;
......@@ -138,7 +150,6 @@ namespace DocFileFormat
if (shape->GetShapeID() == spid)
{
ret = container;
break;
}
}
......@@ -150,7 +161,7 @@ namespace DocFileFormat
if (shape->GetShapeID() == spid)
{
ret = container;
ret = container;
break;
}
}
......@@ -174,7 +185,7 @@ namespace DocFileFormat
}
private:
ShapeContainer* m_pBackgroud;
DrawingGroup* m_pDrawingGroupData;
std::list<OfficeArtWordDrawing> m_arrDrawings;
};
......
......@@ -39,11 +39,9 @@ namespace DocFileFormat
{
public:
static const unsigned short TYPE_CODE_0xF008 = 0xF008;
/// The number of shapes in this drawing
unsigned int csp;
/// The last MSOSPID given to an SP in this DG
int spidCur;
unsigned int csp; // The number of shapes in this drawing
int spidCur; // The last MSOSPID given to an SP in this DG
DrawingRecord():
Record(), csp(0), spidCur(0)
......@@ -53,8 +51,8 @@ namespace DocFileFormat
DrawingRecord( IBinaryReader* _reader, unsigned int size, unsigned int typeCode, unsigned int version, unsigned int instance ):
Record( _reader, size, typeCode, version, instance )
{
this->csp = this->Reader->ReadUInt32();
this->spidCur = this->Reader->ReadInt32();
csp = Reader->ReadUInt32();
spidCur = Reader->ReadInt32();
}
virtual ~DrawingRecord()
......
......@@ -93,29 +93,23 @@ 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
......@@ -125,25 +119,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(); break;
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(); break;
return new MetafilePictBlip();
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 ();
default:
return new UnknownRecord();
}
}
}
......@@ -39,33 +39,20 @@ namespace DocFileFormat
class Shape: public Record
{
public:
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
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;
ShapeType* shapeType;
public:
......
......@@ -69,7 +69,20 @@ 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;
}
virtual ~ShapeContainer()
{
}
......@@ -79,7 +92,6 @@ 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;
......
......@@ -476,6 +476,7 @@ namespace DocFileFormat
default:
{
int sz = iter->argumentsSize;
}break;
}
}
......
......@@ -112,23 +112,14 @@ namespace DocFileFormat
friend class PropertiesMapping;
private:
/// 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
unsigned int cvFore; // 24-bit foreground color
bool cvForeAuto;
int icoFore; // Foreground color.
unsigned int cvBack;
bool cvBackAuto;
int icoBack;
ShadingPattern ipat;
ShadingType shadingType;
ShadingSpecialValue shadingSpecialValue;
public:
......@@ -236,7 +227,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))
//{
......@@ -250,7 +241,6 @@ namespace DocFileFormat
}
else
{
//throw new ByteParseException("Cannot parse the struct SHD, the length of the struct doesn't match");
}
}
}
......
......@@ -50,8 +50,10 @@
int _tmain(int argc, _TCHAR* argv[])
{
if (argc < 2) return 1;
std::wstring sSrcDoc = argv[1];
std::wstring sDstDocx = argv[2];
std::wstring sDstDocx = argc > 2 ? argv[2] : sSrcDoc + L"-my.docx";
std::wstring outputDir = FileSystem::Directory::GetFolderPath(sDstDocx);
std::wstring dstTempPath = FileSystem::Directory::CreateDirectoryWithUniqueName(outputDir);
......
......@@ -37,12 +37,21 @@
#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 = argv[2];
std::wstring dstPath = argc > 2 ? argv[2] : sSrcDoc + L"-my.docx"; //xlsx pptx
std::wstring outputDir = FileSystem::Directory::GetFolderPath(dstPath);
std::wstring srcTempPath = FileSystem::Directory::CreateDirectoryWithUniqueName(outputDir);
......
......@@ -345,10 +345,6 @@
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\..\Common\3dParty\icu\win_32\lib\icuuc.lib"
>
</File>
<File
RelativePath="..\..\..\Common\3dParty\pole\pole.cpp"
>
......
......@@ -38,10 +38,10 @@
int _tmain(int argc, _TCHAR* argv[])
{
if (argc < 3) return 3;
if (argc < 2) return 1;
std::wstring sSrcPpt = argv[1];
std::wstring sDstPptx = argv[2];
std::wstring sDstPptx = argc > 2 ? argv[2] : sSrcDoc + L"-my.pptx";
std::wstring outputDir = FileSystem::Directory::GetFolderPath(sDstPptx);
std::wstring dstTempPath = FileSystem::Directory::CreateDirectoryWithUniqueName(outputDir);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment