mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-18 05:46:08 +08:00
Compare commits
163 Commits
core-linux
...
core-linux
| Author | SHA1 | Date | |
|---|---|---|---|
| 0181cf493f | |||
| 25f20877df | |||
| 37889217cd | |||
| 89d6a7ec7e | |||
| 310b8605f0 | |||
| c515c2bf00 | |||
| bea475a3cd | |||
| a2454e78d4 | |||
| c0bb704ed9 | |||
| 1b49f53f03 | |||
| abbbda090d | |||
| 38e82f0414 | |||
| 25574aff48 | |||
| f4d9901576 | |||
| ebaa8b9769 | |||
| 855442c1c9 | |||
| 30008873fe | |||
| 8d247dfb6e | |||
| a9f32fd7d0 | |||
| c727f0cba8 | |||
| 181f613893 | |||
| 8c4d1cde6c | |||
| 6e515a1ee5 | |||
| 3532d4088d | |||
| eec7ab20fd | |||
| 8b568ddefb | |||
| 708c07c072 | |||
| c7524a2509 | |||
| 90240caa0b | |||
| f8098f1237 | |||
| 760dfbf0d7 | |||
| 784f57dea4 | |||
| e280dcbb27 | |||
| 3953fd1add | |||
| 30986e3c36 | |||
| 6eb596080c | |||
| b45d705e2b | |||
| 21dffa628d | |||
| 1b949a978b | |||
| 17e140debf | |||
| 6452e9956e | |||
| f8ad532f77 | |||
| e05551e679 | |||
| 850959f791 | |||
| d0661e871d | |||
| ec173776ea | |||
| 0a3b9fb8e9 | |||
| 097559c25e | |||
| 6a571ba1c9 | |||
| c4a46114a2 | |||
| 724335bdda | |||
| 7e85df3cc5 | |||
| 326cfbde93 | |||
| 5df8901b59 | |||
| 9c24fa2ff1 | |||
| 82dca18ebc | |||
| 86d97d050d | |||
| a6ab10d585 | |||
| 2b8efdd9b1 | |||
| 1022754391 | |||
| 2c10457a63 | |||
| e0630979c5 | |||
| 8bc8b7cf58 | |||
| 14f4364962 | |||
| 9de3cb016f | |||
| f12cd8ff8f | |||
| 436015b5d2 | |||
| c078df93c9 | |||
| e5e8e01490 | |||
| 4fcc3b4f41 | |||
| ce44e50d0e | |||
| 143590f17b | |||
| abb7a85337 | |||
| f0fe00aa3e | |||
| 98a568177d | |||
| e58f1929e1 | |||
| 2143869e69 | |||
| ac6a1a19da | |||
| fb574f1994 | |||
| f9af786d5a | |||
| 3cde3a4444 | |||
| eb2221f006 | |||
| 394d1e7b38 | |||
| d9d1473fd0 | |||
| 45ba99b9bf | |||
| 9576ce5f28 | |||
| 7092922d1b | |||
| e112c63f12 | |||
| ae9ec197f1 | |||
| af7640e736 | |||
| f467912988 | |||
| 292781e6fb | |||
| 9cd97d48b8 | |||
| 579b441edc | |||
| 63b71d256b | |||
| 90f1aa055c | |||
| d75352f1f2 | |||
| 51cbcfa9f2 | |||
| eef66b3498 | |||
| 945d43997a | |||
| b41170a233 | |||
| b64541e6bd | |||
| 5626963bdf | |||
| 5b7d637c78 | |||
| 643f117a92 | |||
| f6d38c1f1b | |||
| dd24ca837f | |||
| f555e3f821 | |||
| 503e87077b | |||
| 07a07a1abd | |||
| 30473ee9b7 | |||
| 73ef4140a2 | |||
| 8b6e5f17c8 | |||
| fcede43d99 | |||
| c37f011d6d | |||
| 52ec27a679 | |||
| a687e49a6a | |||
| 4d0e44c8b6 | |||
| 4dddc6d9bc | |||
| b6b79576a1 | |||
| 1c1223b148 | |||
| 9947f058a9 | |||
| 54f55ad2ac | |||
| e4edb9cca4 | |||
| 8bb23e9ce1 | |||
| aacea2f015 | |||
| 1475b2fef9 | |||
| 8e58975095 | |||
| 04550f06ad | |||
| d2b6444730 | |||
| 08738092c6 | |||
| 8e220427eb | |||
| 962c31dc2a | |||
| d12cc81745 | |||
| 988423f6e0 | |||
| 2b096f0977 | |||
| 7c0962f834 | |||
| 17423cdcdb | |||
| 5dc512dc3b | |||
| 1393073694 | |||
| 7da761a009 | |||
| e21e0afb45 | |||
| 626eb87203 | |||
| 5b0dad3d99 | |||
| 9d3b7b91af | |||
| f40d82a097 | |||
| 9112c87b1f | |||
| 01691950b9 | |||
| 78bbaecefe | |||
| 9e085c5ae8 | |||
| f55cafa2af | |||
| 17bc27199c | |||
| ee4167ec8c | |||
| e436c13fcc | |||
| 8e2c980152 | |||
| 658bfbc348 | |||
| ff9ef8f941 | |||
| 0a2401471e | |||
| 5ca5597c58 | |||
| e55dc5ea75 | |||
| e2db849b03 | |||
| fef30772fd | |||
| 866af012eb |
5
.gitignore
vendored
5
.gitignore
vendored
@ -18,6 +18,9 @@ Common/3dParty/curl/win_32
|
||||
Common/3dParty/curl/linux_64
|
||||
Common/3dParty/curl/linux_32
|
||||
Common/3dParty/curl/mac_64
|
||||
Common/3dParty/v8/.cipd
|
||||
Common/3dParty/v8/.gclient
|
||||
Common/3dParty/v8/.gclient_entries
|
||||
Common/3dParty/v8/v8
|
||||
Common/3dParty/v8/depot_tools
|
||||
Common/3dParty/v8/win_64
|
||||
@ -47,6 +50,8 @@ ASCOfficeXlsFile2/win32/_ASCOfficeXlsFile2_p.c
|
||||
ASCOfficeXlsFile2/win32/dlldata.c
|
||||
OfficeUtils/win32/OfficeUtilsLib/OfficeUtilsLib/ReadMe.txt
|
||||
X2tConverter/**/Makefile.*
|
||||
X2tConverter/ASCOfficePPTXFile/PPTXLib/Linux/PPTXFormatLib/Makefile
|
||||
X2tConverter/Common/DocxFormat/DocxFormatLib/Makefile
|
||||
*.7z
|
||||
*.obj
|
||||
*.pdb
|
||||
|
||||
@ -992,6 +992,11 @@ namespace DocFileFormat
|
||||
_writeAfterRun = oVmlMapper.m_equationXml;
|
||||
bFormula = true;
|
||||
}
|
||||
else if (oVmlMapper.m_isBlob)
|
||||
{
|
||||
_writeAfterRun = oVmlMapper.m_blobXml;
|
||||
bFormula = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1071,7 +1076,9 @@ namespace DocFileFormat
|
||||
int cpPic = searchNextTextMark(m_document->Text, cpFieldStart, TextMark::Picture);
|
||||
int cpFieldEnd = searchNextTextMark( m_document->Text, cpFieldStart, TextMark::FieldEndMark );
|
||||
|
||||
if (cpFieldStart < cpPic && cpPic < cpFieldEnd)
|
||||
bool bStartField = _fieldLevels.empty() ? false : (_fieldLevels.back().bBegin && !_fieldLevels.back().bSeparate);
|
||||
|
||||
if (cpFieldStart < cpPic && cpPic < cpFieldEnd && !bStartField)
|
||||
{
|
||||
writeField(text, cpFieldStart, cpFieldEnd);
|
||||
text.clear();
|
||||
|
||||
@ -31,6 +31,7 @@
|
||||
*/
|
||||
|
||||
#include "MainDocumentMapping.h"
|
||||
#include "OfficeDrawing/FillStyleBooleanProperties.h"
|
||||
|
||||
namespace DocFileFormat
|
||||
{
|
||||
@ -83,16 +84,27 @@ namespace DocFileFormat
|
||||
|
||||
if ((m_document->GetOfficeArt()) && (m_document->GetOfficeArt()->GetShapeBackgound()))
|
||||
{
|
||||
bool bFilled = true;
|
||||
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");
|
||||
OptionEntryPtr boolFill = pShape->ExtractOption(fillStyleBooleanProperties);
|
||||
|
||||
FillStyleBooleanProperties booleans(boolFill ? boolFill->op : 0);
|
||||
if (booleans.fUsefFilled && !booleans.fFilled)
|
||||
{
|
||||
bFilled = false;
|
||||
}
|
||||
if (bFilled)
|
||||
{
|
||||
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 );
|
||||
|
||||
@ -101,6 +101,24 @@ namespace DocFileFormat
|
||||
return new ShapeContainer( _reader, bodySize, typeCode, version, instance );
|
||||
}
|
||||
|
||||
OptionEntryPtr ExtractOption(const PropertyId & prop) const
|
||||
{
|
||||
OptionEntryPtr ret;
|
||||
for ( size_t i = 0; i < this->Children.size(); ++i )
|
||||
{
|
||||
ShapeOptions* opt = dynamic_cast<ShapeOptions*>( this->Children[i] );
|
||||
|
||||
if ( opt == NULL ) continue;
|
||||
|
||||
std::map<PropertyId, OptionEntryPtr>::iterator pFind = opt->OptionsByID.find(prop);
|
||||
if (pFind != opt->OptionsByID.end())
|
||||
{
|
||||
ret = pFind->second;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::vector<OptionEntryPtr> ExtractOptions() const
|
||||
{
|
||||
std::vector<OptionEntryPtr> ret;
|
||||
|
||||
@ -32,9 +32,38 @@
|
||||
|
||||
|
||||
#include "SettingsMapping.h"
|
||||
#include "../../OfficeCryptReader/source/CryptTransform.h"
|
||||
|
||||
namespace DocFileFormat
|
||||
{
|
||||
std::string DecodeBase64(const std::string & value)
|
||||
{
|
||||
int nLength = 0;
|
||||
unsigned char *pData = NULL;
|
||||
std::string result;
|
||||
|
||||
NSFile::CBase64Converter::Decode(value.c_str(), value.length(), pData, nLength);
|
||||
if (pData)
|
||||
{
|
||||
result = std::string((char*)pData, nLength);
|
||||
delete []pData; pData = NULL;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
std::wstring EncodeBase64(const std::string & value)
|
||||
{
|
||||
int nLength = 0;
|
||||
char *pData = NULL;
|
||||
std::string result;
|
||||
|
||||
NSFile::CBase64Converter::Encode((BYTE*)value.c_str(), value.length(), pData, nLength, NSBase64::B64_BASE64_FLAG_NOCRLF);
|
||||
if (pData)
|
||||
{
|
||||
result = std::string(pData, nLength);
|
||||
delete []pData; pData = NULL;
|
||||
}
|
||||
return std::wstring(result.begin(), result.end());
|
||||
}
|
||||
SettingsMapping::SettingsMapping (ConversionContext* ctx): PropertiesMapping(&m_oXmlWriter)
|
||||
{
|
||||
_ctx = ctx;
|
||||
@ -49,11 +78,39 @@ namespace DocFileFormat
|
||||
//start w:settings
|
||||
m_oXmlWriter.WriteNodeBegin( L"?xml version=\"1.0\" encoding=\"UTF-8\"?" );
|
||||
m_oXmlWriter.WriteNodeBegin( L"w:settings", TRUE );
|
||||
|
||||
//write namespaces
|
||||
m_oXmlWriter.WriteAttribute( L"xmlns:w", OpenXmlNamespaces::WordprocessingML );
|
||||
m_oXmlWriter.WriteNodeEnd( L"", TRUE, FALSE );
|
||||
|
||||
if (_ctx->_doc->FIB->m_FibBase.fWriteReservation)
|
||||
{
|
||||
m_oXmlWriter.WriteNodeBegin( L"w:writeProtection", TRUE );
|
||||
WideString* passw = static_cast<WideString*>(_ctx->_doc->AssocNames->operator[]( 17 ));
|
||||
if (passw && false == passw->empty())
|
||||
{
|
||||
CRYPT::_ecmaWriteProtectData data;
|
||||
|
||||
CRYPT::ECMAWriteProtect protect;
|
||||
protect.SetCryptData(data);
|
||||
protect.SetPassword(*passw);
|
||||
|
||||
protect.Generate();
|
||||
protect.GetCryptData(data);
|
||||
|
||||
//m_oXmlWriter.WriteAttribute ( L"w:cryptProviderType", L"rsaAES");
|
||||
//m_oXmlWriter.WriteAttribute ( L"w:cryptAlgorithmSid", 14); //sha-512
|
||||
//m_oXmlWriter.WriteAttribute ( L"w:cryptAlgorithmType", L"typeAny");
|
||||
//m_oXmlWriter.WriteAttribute ( L"w:cryptAlgorithmClass", L"hash");
|
||||
//m_oXmlWriter.WriteAttribute ( L"w:cryptSpinCount", data.spinCount);
|
||||
//m_oXmlWriter.WriteAttribute ( L"w:hash", EncodeBase64(data.hashValue));
|
||||
//m_oXmlWriter.WriteAttribute ( L"w:salt", EncodeBase64(data.saltValue));
|
||||
m_oXmlWriter.WriteAttribute ( L"w:algorithmName", L"SHA-512");
|
||||
m_oXmlWriter.WriteAttribute ( L"w:spinCount", data.spinCount);
|
||||
m_oXmlWriter.WriteAttribute ( L"w:hashValue", EncodeBase64(data.hashValue));
|
||||
m_oXmlWriter.WriteAttribute ( L"w:saltValue", EncodeBase64(data.saltValue));
|
||||
}
|
||||
m_oXmlWriter.WriteNodeEnd( L"", TRUE, TRUE );
|
||||
}
|
||||
//zoom
|
||||
m_oXmlWriter.WriteNodeBegin ( L"w:zoom", TRUE );
|
||||
m_oXmlWriter.WriteAttribute ( L"w:percent", FormatUtils::IntToWideString( dop->wScaleSaved > 0 ? dop->wScaleSaved : 100 ) );
|
||||
|
||||
@ -38,7 +38,7 @@
|
||||
#include "OfficeDrawing/GroupShapeBooleanProperties.h"
|
||||
#include "OfficeDrawing/MetafilePictBlip.h"
|
||||
|
||||
#include "../../DesktopEditor/common/String.h"
|
||||
#include "../../DesktopEditor/common/StringExt.h"
|
||||
#include "../../Common/DocxFormat/Source/DocxFormat/Document.h"
|
||||
|
||||
#include "../../DesktopEditor/common/File.h"
|
||||
@ -138,6 +138,51 @@ namespace DocFileFormat
|
||||
}
|
||||
return btWin32;
|
||||
}
|
||||
bool VMLPictureMapping::ParseEmbeddedBlob( const std::string & xmlString, std::wstring & newXmlString)
|
||||
{
|
||||
newXmlString.clear();
|
||||
|
||||
std::wstring sTempFolder = m_context->_doc->m_sTempFolder;
|
||||
if (sTempFolder.empty())
|
||||
{
|
||||
sTempFolder = NSFile::CFileBinary::GetTempPath();
|
||||
}
|
||||
|
||||
std::wstring sTempXmlFile = NSDirectory::CreateTempFileWithUniqueName(sTempFolder, L"emb");
|
||||
|
||||
NSFile::CFileBinary file;
|
||||
file.CreateFileW(sTempXmlFile);
|
||||
file.WriteFile((BYTE*)xmlString.c_str(), xmlString.size());
|
||||
file.CloseFile();
|
||||
|
||||
COfficeUtils officeUtils(NULL);
|
||||
|
||||
BYTE *utf8Data = NULL;
|
||||
ULONG utf8DataSize = 0;
|
||||
if (S_OK != officeUtils.LoadFileFromArchive(sTempXmlFile, L"drs/shapexml.xml", &utf8Data, utf8DataSize))
|
||||
{
|
||||
if (S_OK == officeUtils.IsFileExistInArchive(sTempXmlFile, L"drs/diagrams"))
|
||||
{
|
||||
officeUtils.LoadFileFromArchive(sTempXmlFile, L"drs/diagrams/drawing1.xml", &utf8Data, utf8DataSize);
|
||||
}
|
||||
else if (S_OK != officeUtils.LoadFileFromArchive(sTempXmlFile, L"drs/e2oDoc.xml", &utf8Data, utf8DataSize))
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (utf8Data && utf8DataSize > 0)
|
||||
{
|
||||
newXmlString = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8(utf8Data, utf8DataSize);
|
||||
|
||||
delete []utf8Data;
|
||||
}
|
||||
NSFile::CFileBinary::Remove(sTempXmlFile);
|
||||
|
||||
if (newXmlString.empty()) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
bool VMLPictureMapping::ParseEmbeddedEquation( const std::string & xmlString, std::wstring & newXmlString)
|
||||
{
|
||||
newXmlString.clear();
|
||||
@ -221,6 +266,7 @@ namespace DocFileFormat
|
||||
m_isBullete = false;
|
||||
m_isEquation = false;
|
||||
m_isEmbedded = false;
|
||||
m_isBlob = false;
|
||||
|
||||
m_imageData = new XMLTools::XMLElement( L"v:imagedata" );
|
||||
}
|
||||
@ -314,7 +360,9 @@ namespace DocFileFormat
|
||||
case metroBlob:
|
||||
{
|
||||
//встроенная неведомая хуйня
|
||||
m_isBlob = true;
|
||||
m_isEmbedded = true;
|
||||
|
||||
m_embeddedData = std::string((char*)iter->opComplex.get(), iter->op);
|
||||
|
||||
//if (ParseEmbeddedBlob( m_embeddedData, m_blobXml)) // todoooo
|
||||
|
||||
@ -58,6 +58,7 @@ namespace DocFileFormat
|
||||
void writePictureBorder (const std::wstring & name, const BorderCode* brc);
|
||||
void appendStyleProperty( std::wstring* b, const std::wstring& propName, const std::wstring& propValue ) const;
|
||||
bool ParseEmbeddedEquation( const std::string & xmlString, std::wstring & newXmlString );
|
||||
bool ParseEmbeddedBlob(const std::string & xmlString, std::wstring & newXmlString);
|
||||
std::wstring GetShapeID(const Shape* pShape) const;
|
||||
protected:
|
||||
/// Copies the picture from the binary stream to the zip archive
|
||||
@ -69,11 +70,13 @@ namespace DocFileFormat
|
||||
static std::wstring GetTargetExt (Global::BlipType nType);
|
||||
static std::wstring GetContentType (Global::BlipType nType);
|
||||
|
||||
bool m_isBlob;
|
||||
bool m_isBullete;
|
||||
bool m_isEquation;
|
||||
bool m_isEmbedded;
|
||||
std::string m_embeddedData;
|
||||
std::wstring m_equationXml;
|
||||
std::wstring m_blobXml;
|
||||
|
||||
std::wstring m_shapeId;
|
||||
private:
|
||||
|
||||
@ -55,7 +55,7 @@
|
||||
|
||||
#include "DrawingPrimitives.h"
|
||||
|
||||
#include "../../DesktopEditor/common/String.h"
|
||||
#include "../../DesktopEditor/common/StringExt.h"
|
||||
|
||||
#include "../Common/FormatUtils.h"
|
||||
|
||||
|
||||
@ -88,6 +88,7 @@ namespace DocFileFormat
|
||||
friend class VMLPictureMapping;
|
||||
friend class OpenXmlPackage;
|
||||
friend class TextboxMapping;
|
||||
friend class SettingsMapping;
|
||||
|
||||
public:
|
||||
|
||||
|
||||
@ -145,7 +145,8 @@ extern int g_nCurFormatVersion;
|
||||
Endnotes = 11,
|
||||
Background = 12,
|
||||
VbaProject = 13,
|
||||
App = 14
|
||||
App = 15,
|
||||
Core = 16
|
||||
};}
|
||||
namespace c_oSerSigTypes{enum c_oSerSigTypes
|
||||
{
|
||||
|
||||
@ -36,6 +36,8 @@
|
||||
#include "../DocWrapper/FontProcessor.h"
|
||||
#include "../../Common/Base64.h"
|
||||
#include "../../ASCOfficePPTXFile/Editor/FontCutter.h"
|
||||
#include "../../ASCOfficePPTXFile/PPTXFormat/App.h"
|
||||
#include "../../ASCOfficePPTXFile/PPTXFormat/Core.h"
|
||||
#include "../../XlsxSerializerCom/Reader/BinaryWriter.h"
|
||||
#include "BinEquationWriter.h"
|
||||
|
||||
@ -7961,38 +7963,6 @@ namespace BinDocxRW
|
||||
m_oBcw.WriteItemEnd(nCurPos);
|
||||
}
|
||||
};
|
||||
class BinaryAppTableWriter
|
||||
{
|
||||
BinaryCommonWriter m_oBcw;
|
||||
ParamsWriter& m_oParamsWriter;
|
||||
public:
|
||||
BinaryAppTableWriter(ParamsWriter& oParamsWriter):
|
||||
m_oBcw(oParamsWriter),m_oParamsWriter(oParamsWriter)
|
||||
{
|
||||
}
|
||||
void Write(OOX::CApp& oApp)
|
||||
{
|
||||
int nStart = m_oBcw.WriteItemWithLengthStart();
|
||||
WriteProperties(oApp);
|
||||
m_oBcw.WriteItemWithLengthEnd(nStart);
|
||||
}
|
||||
void WriteProperties(OOX::CApp& oApp)
|
||||
{
|
||||
int nCurPos = 0;
|
||||
if (oApp.m_sApplication.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSerApp::Application);
|
||||
m_oBcw.m_oStream.WriteStringW3(oApp.m_sApplication.get());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
if (oApp.m_sAppVersion.IsInit())
|
||||
{
|
||||
nCurPos = m_oBcw.WriteItemStart(c_oSerApp::AppVersion);
|
||||
m_oBcw.m_oStream.WriteStringW3(oApp.m_sAppVersion.get());
|
||||
m_oBcw.WriteItemWithLengthEnd(nCurPos);
|
||||
}
|
||||
}
|
||||
};
|
||||
class BinaryFileWriter
|
||||
{
|
||||
BinaryCommonWriter m_oBcw;
|
||||
@ -8148,9 +8118,15 @@ namespace BinDocxRW
|
||||
//Write App
|
||||
if(NULL != oDocx.m_pApp)
|
||||
{
|
||||
BinDocxRW::BinaryAppTableWriter oBinaryAppWriter(m_oParamsWriter);
|
||||
nCurPos = this->WriteTableStart(BinDocxRW::c_oSerTableTypes::App);
|
||||
oBinaryAppWriter.Write(*oDocx.m_pApp);
|
||||
oDocx.m_pApp->ToPptxApp()->toPPTY(&oBufferedStream);
|
||||
this->WriteTableEnd(nCurPos);
|
||||
}
|
||||
|
||||
if(NULL != oDocx.m_pCore)
|
||||
{
|
||||
nCurPos = this->WriteTableStart(BinDocxRW::c_oSerTableTypes::Core);
|
||||
oDocx.m_pCore->ToPptxCore()->toPPTY(&oBufferedStream);
|
||||
this->WriteTableEnd(nCurPos);
|
||||
}
|
||||
|
||||
|
||||
@ -265,4 +265,11 @@ namespace BinXlsxRW{
|
||||
NSDirectory::DeleteDirectory(sTempDir);
|
||||
return res;
|
||||
}
|
||||
bool CXlsxSerializer::hasPivot(const std::wstring& sSrcPath)
|
||||
{
|
||||
//todo CXlsx
|
||||
std::wstring sData;
|
||||
NSFile::CFileBinary::ReadAllTextUtf8(sSrcPath + FILE_SEPARATOR_STR + L"[Content_Types].xml", sData);
|
||||
return std::wstring::npos != sData.find(OOX::Spreadsheet::FileTypes::PivotTable.OverrideType());
|
||||
}
|
||||
};
|
||||
|
||||
@ -74,6 +74,7 @@ namespace BinXlsxRW {
|
||||
void setIsNoBase64 (bool bIsNoBase64);
|
||||
|
||||
bool writeChartXlsx (const std::wstring& sDstFile ,const OOX::Spreadsheet::CChartSpace& oChart);
|
||||
bool hasPivot (const std::wstring& sSrcPath);
|
||||
};
|
||||
}
|
||||
#endif // #ifndef XLSX_SERIALIZER
|
||||
|
||||
@ -18,7 +18,8 @@ DEFINES += UNICODE \
|
||||
_UNICODE \
|
||||
SOLUTION_ASCOFFICEDOCXFILE2 \
|
||||
#DISABLE_FILE_DOWNLOADER \
|
||||
DONT_WRITE_EMBEDDED_FONTS
|
||||
DONT_WRITE_EMBEDDED_FONTS \
|
||||
AVS_USE_CONVERT_PPTX_TOCUSTOM_VML
|
||||
|
||||
|
||||
SOURCES += \
|
||||
|
||||
@ -36,6 +36,7 @@
|
||||
#include "../include/CPScopedPtr.h"
|
||||
|
||||
namespace cpdoccore {
|
||||
|
||||
namespace formulasconvert {
|
||||
|
||||
|
||||
@ -44,7 +45,7 @@ namespace formulasconvert {
|
||||
class odf2oox_converter
|
||||
{
|
||||
public:
|
||||
odf2oox_converter();
|
||||
odf2oox_converter();
|
||||
~odf2oox_converter();
|
||||
|
||||
// of:=SUM([.DDA1:.BA3]) -> SUM(DDA1:BA3)
|
||||
|
||||
@ -35,6 +35,7 @@
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
#include"../../Common/DocxFormat/Source/XML/Utils.h"
|
||||
#include "../src/docx/xlsxconversioncontext.h"
|
||||
|
||||
namespace cpdoccore {
|
||||
namespace formulasconvert {
|
||||
@ -42,6 +43,9 @@ namespace formulasconvert {
|
||||
class odf2oox_converter::Impl
|
||||
{
|
||||
public:
|
||||
Impl() {}
|
||||
|
||||
static std::unordered_map<std::wstring, int> & mapExternalLink_;
|
||||
|
||||
std::wstring convert(const std::wstring& expr);
|
||||
std::wstring convert_chart_distance(const std::wstring& expr);
|
||||
@ -54,21 +58,155 @@ namespace formulasconvert {
|
||||
void replace_tilda(std::wstring& expr);
|
||||
void replace_vertical(std::wstring& expr);
|
||||
void replace_space(std::wstring& expr);
|
||||
|
||||
|
||||
std::wstring convert_named_ref(const std::wstring& expr, bool withTableName, std::wstring separator);
|
||||
std::wstring convert_named_expr(const std::wstring& expr, bool withTableName);
|
||||
|
||||
static std::wstring replace_named_ref_formater(boost::wsmatch const & what);
|
||||
static std::wstring replace_named_ref_formater1(boost::wsmatch const & what);
|
||||
static std::wstring replace_cell_range_formater(boost::wsmatch const & what);
|
||||
//static std::wstring replace_cell_range_formater(boost::wsmatch const & what);
|
||||
|
||||
void replace_named_formula(std::wstring & expr, bool w = true);
|
||||
void replace_named_ref(std::wstring & expr, bool w = true);
|
||||
|
||||
bool find_first_ref(std::wstring const & expr, std::wstring & table, std::wstring & ref);
|
||||
bool find_first_last_ref(std::wstring const & expr, std::wstring & table, std::wstring & ref_first,std::wstring & ref_last);
|
||||
|
||||
static bool convert_with_TableName;
|
||||
static std::wstring table_name_;
|
||||
static bool convert_with_TableName;
|
||||
static std::wstring table_name_;
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------
|
||||
static std::wstring replace_semicolons_formater(boost::wsmatch const & what)
|
||||
{
|
||||
if (what[1].matched)
|
||||
return L",";
|
||||
else if (what[2].matched)
|
||||
return what[2].str();
|
||||
else if (what[3].matched)
|
||||
return what[3].str();
|
||||
else
|
||||
return L"";
|
||||
}
|
||||
static std::wstring replace_tilda_formater(boost::wsmatch const & what)
|
||||
{
|
||||
if (what[1].matched)
|
||||
return L";";
|
||||
else if (what[2].matched)
|
||||
return what[2].str();
|
||||
else if (what[3].matched)
|
||||
return what[3].str();
|
||||
else
|
||||
return L"";
|
||||
}
|
||||
static std::wstring replace_vertical_formater(boost::wsmatch const & what)
|
||||
{
|
||||
if (what[1].matched)
|
||||
{
|
||||
std::wstring inner = what[1].str();
|
||||
XmlUtils::replace_all( inner, L"|", L";");
|
||||
return L"{" + inner + L"}";
|
||||
}
|
||||
else if (what[2].matched)
|
||||
return what[2].str();
|
||||
else if (what[3].matched)
|
||||
return what[3].str();
|
||||
|
||||
return L"";
|
||||
}
|
||||
|
||||
static void replace_tmp_back(std::wstring &expr)
|
||||
{
|
||||
XmlUtils::replace_all( expr, L"ТОСHKA", L".");
|
||||
XmlUtils::replace_all( expr, L"VOSKL", L"!");
|
||||
|
||||
XmlUtils::replace_all( expr, L"SCOBCAIN", L"(");
|
||||
XmlUtils::replace_all( expr, L"SCOBCAOUT", L")");
|
||||
|
||||
XmlUtils::replace_all( expr, L"KVADRATIN", L"[");
|
||||
XmlUtils::replace_all( expr, L"KVADRATOUT", L"]");
|
||||
|
||||
XmlUtils::replace_all( expr, L"PROBEL", L" ");
|
||||
XmlUtils::replace_all( expr, L"APOSTROF", L"'");
|
||||
XmlUtils::replace_all( expr, L"KAVYCHKA", L"\"");
|
||||
}
|
||||
static void replace_tmp(std::wstring &expr)
|
||||
{
|
||||
XmlUtils::replace_all( expr, L".", L"ТОСHKA");
|
||||
XmlUtils::replace_all( expr, L"!", L"VOSKL");
|
||||
|
||||
XmlUtils::replace_all( expr, L"(", L"SCOBCAIN");
|
||||
XmlUtils::replace_all( expr, L")", L"SCOBCAOUT");
|
||||
|
||||
//XmlUtils::replace_all( expr, L"[", L"KVADRATIN");
|
||||
//XmlUtils::replace_all( expr, L"]", L"KVADRATOUT");
|
||||
|
||||
XmlUtils::replace_all( expr, L" ", L"PROBEL");
|
||||
// XmlUtils::replace_all( expr, L"'", L"APOSTROF");
|
||||
// XmlUtils::replace_all( expr, L"\"", L"KAVYCHKA");
|
||||
}
|
||||
static std::wstring convert_scobci(boost::wsmatch const & what)
|
||||
{
|
||||
if (what[1].matched)
|
||||
{
|
||||
std::wstring inner = what[1].str();
|
||||
|
||||
replace_tmp(inner);
|
||||
|
||||
return inner;
|
||||
}
|
||||
else if (what[2].matched)
|
||||
{
|
||||
std::wstring inner = what[2].str();
|
||||
|
||||
replace_tmp(inner);
|
||||
|
||||
return inner;
|
||||
}
|
||||
else if (what[3].matched)
|
||||
return what[3].str();
|
||||
|
||||
return L"";
|
||||
}
|
||||
static std::wstring replace_space_formater(boost::wsmatch const & what)
|
||||
{
|
||||
if (what[1].matched)
|
||||
{
|
||||
std::wstring inner = what[1].str();
|
||||
XmlUtils::replace_all( inner, L" ", L",");
|
||||
return inner;
|
||||
}
|
||||
else if (what[2].matched)
|
||||
return what[2].str();
|
||||
else if (what[3].matched)
|
||||
return what[3].str();
|
||||
|
||||
return L"";
|
||||
}
|
||||
|
||||
static std::wstring is_forbidden(const std::wstring & formula)
|
||||
{
|
||||
std::wstring result = formula;
|
||||
std::map<std::wstring, std::wstring> forbidden_formulas;
|
||||
|
||||
forbidden_formulas.insert(std::make_pair(L"FORMULA", L"_xlfn.FORMULATEXT"));
|
||||
|
||||
for (std::map<std::wstring, std::wstring>::iterator it = forbidden_formulas.begin(); it != forbidden_formulas.end(); ++it)
|
||||
{
|
||||
if (boost::algorithm::contains(formula, it->first))
|
||||
{
|
||||
|
||||
XmlUtils::replace_all(result, it->first, it->second);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
bool odf2oox_converter::Impl::convert_with_TableName = true;
|
||||
std::wstring odf2oox_converter::Impl::table_name_ = L"";
|
||||
|
||||
std::unordered_map<std::wstring, int> &odf2oox_converter::Impl::mapExternalLink_ = oox::xlsx_conversion_context::mapExternalLink_;
|
||||
|
||||
bool odf2oox_converter::Impl::find_first_last_ref(std::wstring const & expr, std::wstring & table,std::wstring & ref_first,std::wstring & ref_last)
|
||||
{
|
||||
@ -76,14 +214,14 @@ namespace formulasconvert {
|
||||
|
||||
boost::algorithm::split(splitted, expr, boost::algorithm::is_any_of(L".:"), boost::algorithm::token_compress_on);
|
||||
|
||||
if (splitted.size()==3)
|
||||
if (splitted.size() == 3)
|
||||
{
|
||||
table = splitted[0];
|
||||
ref_first = splitted[1];
|
||||
ref_last = splitted[2];
|
||||
return true;
|
||||
}
|
||||
if (splitted.size()==4)
|
||||
if (splitted.size() == 4)
|
||||
{
|
||||
table = splitted[0];
|
||||
ref_first = splitted[1];
|
||||
@ -95,7 +233,7 @@ namespace formulasconvert {
|
||||
|
||||
bool odf2oox_converter::Impl::find_first_ref(std::wstring const & expr, std::wstring & table, std::wstring & ref)
|
||||
{
|
||||
boost::wregex re(L"\\[(?:\\$)?([^\\.]+?){0,1}\\.([a-zA-Z\\$]+\\d+)(?::\\.([a-zA-Z]+\\d+)){0,1}\\]");
|
||||
boost::wregex re(L"\\[(?:\\$)?([^\\.]+?){0,1}\\.([\\w^0-9\\$]+\\d+)(?::\\.([\\w^0-9]+\\d+)){0,1}\\]");
|
||||
boost::wsmatch result;
|
||||
bool b = boost::regex_search(expr, result, re);
|
||||
|
||||
@ -118,101 +256,92 @@ namespace formulasconvert {
|
||||
}
|
||||
|
||||
|
||||
std::wstring odf2oox_converter::Impl::replace_cell_range_formater(boost::wsmatch const & what)
|
||||
{
|
||||
const size_t sz = what.size();
|
||||
if (sz == 4 && !what[1].matched)
|
||||
{
|
||||
const std::wstring c1 = what[2].str();
|
||||
const std::wstring c2 = what[3].str();
|
||||
const std::wstring s = c1 + (c2.empty() ? L"" : (L":" + c2) );
|
||||
return s;
|
||||
}
|
||||
else if (sz == 4 && what[1].matched)
|
||||
{
|
||||
std::wstring sheet1 = what[1].str();
|
||||
XmlUtils::replace_all( sheet1, L"$", L"");
|
||||
//std::wstring odf2oox_converter::Impl::replace_cell_range_formater(boost::wsmatch const & what)
|
||||
//{
|
||||
// const size_t sz = what.size();
|
||||
// if (sz == 4 && !what[1].matched)
|
||||
// {
|
||||
// const std::wstring c1 = what[2].str();
|
||||
// const std::wstring c2 = what[3].str();
|
||||
// const std::wstring s = c1 + (c2.empty() ? L"" : (L":" + c2) );
|
||||
// return s;
|
||||
// }
|
||||
// else if (sz == 4 && what[1].matched)
|
||||
// {
|
||||
// std::wstring sheet1 = what[1].str();
|
||||
// XmlUtils::replace_all( sheet1, L"$", L"");
|
||||
|
||||
const std::wstring c1 = what[2].str();
|
||||
std::wstring c2 = what[3].str();
|
||||
if (c2.empty()) c2 = what[4].str();
|
||||
const std::wstring s = sheet1 + L"!" + c1 + (c2.empty() ? L"" : (L":" + c2) );
|
||||
return s;
|
||||
}
|
||||
return L"";
|
||||
}
|
||||
// const std::wstring c1 = what[2].str();
|
||||
// std::wstring c2 = what[3].str();
|
||||
// if (c2.empty()) c2 = what[4].str();
|
||||
// const std::wstring s = sheet1 + L"!" + c1 + (c2.empty() ? L"" : (L":" + c2) );
|
||||
// return s;
|
||||
// }
|
||||
// return L"";
|
||||
//}
|
||||
|
||||
std::wstring odf2oox_converter::Impl::replace_named_ref_formater(boost::wsmatch const & what)
|
||||
{
|
||||
const size_t sz = what.size();
|
||||
|
||||
if (sz == 4 && !what[1].matched)
|
||||
if (sz < 6) return what[0].str();
|
||||
|
||||
std::wstring c0 = what[0].str();
|
||||
std::wstring external = sz == 7 ? what[1].matched ? what[1].str() : what[2].str() : what[1].str();
|
||||
std::wstring sheet1 = sz == 7 ? what[3].str() : what[2].str();
|
||||
std::wstring ref1 = sz == 7 ? what[4].str() : what[3].str();
|
||||
std::wstring sheet2 = sz == 7 ? what[5].str() : what[4].str();
|
||||
std::wstring ref2 = sz == 7 ? what[6].str() : what[5].str();
|
||||
|
||||
XmlUtils::replace_all( sheet1, L"$", L"");
|
||||
//XmlUtils::replace_all( sheet2, L"$", L"");
|
||||
|
||||
std::wstring result;
|
||||
|
||||
if (false == external.empty())
|
||||
{
|
||||
const std::wstring c1 = what[2].str();
|
||||
const std::wstring c2 = what[3].str();
|
||||
const std::wstring s = c1 + (c2.empty() ? L"" : (L":" + c2) );
|
||||
return s;
|
||||
}
|
||||
else if (sz == 4 && what[1].matched)
|
||||
{
|
||||
std::wstring sheet1 = what[1].str();
|
||||
XmlUtils::replace_all( sheet1, L"$", L"");
|
||||
replace_tmp_back(external);
|
||||
|
||||
table_name_ = sheet1;
|
||||
|
||||
const std::wstring c1 = what[2].str();
|
||||
const std::wstring c2 = what[3].str();
|
||||
|
||||
if (convert_with_TableName)
|
||||
int id = -1;//add_external_link(external);
|
||||
std::unordered_map<std::wstring, int>::iterator pFind = mapExternalLink_.find(external);
|
||||
if ( pFind == mapExternalLink_.end())
|
||||
{
|
||||
if (std::wstring::npos != sheet1.find(L" "))
|
||||
{
|
||||
if (sheet1[0] != L'\'')
|
||||
{
|
||||
sheet1 = L"'" + sheet1 + L"'";
|
||||
}
|
||||
}
|
||||
return (sheet1 + L"!") + c1 + (c2.empty() ? L"" : (L":" + c2) );
|
||||
id = (int)mapExternalLink_.size() + 1;
|
||||
mapExternalLink_.insert(std::make_pair(external, id));
|
||||
}
|
||||
else
|
||||
{
|
||||
return c1 + (c2.empty() ? L"" : (L":" + c2) );
|
||||
id = pFind->second;
|
||||
}
|
||||
}
|
||||
else if (sz == 5 && what[1].matched)
|
||||
{
|
||||
std::wstring sheet1 = what[1].str();
|
||||
XmlUtils::replace_all( sheet1, L"$", L"");
|
||||
|
||||
const std::wstring c1 = what[2].str();
|
||||
const std::wstring c2 = what[3].str(); //sheet name 2
|
||||
const std::wstring c3 = what[4].str();
|
||||
|
||||
table_name_ = sheet1;
|
||||
|
||||
if (convert_with_TableName)
|
||||
if (sheet1[0] == L'\'')
|
||||
{
|
||||
return (sheet1 + L"!") + c1 + (c3.empty() ? L"" : (L":" + c3) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return c1 + (c3.empty() ? L"" : (L":" + c3) );
|
||||
sheet1 = sheet1.substr(1, sheet1.length() - 2);
|
||||
}
|
||||
sheet1 = L"'[" + std::to_wstring(id) + L"]" + sheet1 + L"'";
|
||||
}
|
||||
else if (sz == 5 && !what[1].matched)
|
||||
else if (std::wstring::npos != sheet1.find(L" "))
|
||||
{
|
||||
const std::wstring c1 = what[2].str();
|
||||
const std::wstring c2 = what[3].str(); //sheet name 2
|
||||
const std::wstring c3 = what[4].str();
|
||||
|
||||
return c1 + (c3.empty() ? L"" : (L":" + c3) );
|
||||
if (sheet1[0] != L'\'')
|
||||
{
|
||||
sheet1 = L"'" + sheet1 + L"'";
|
||||
}
|
||||
}
|
||||
|
||||
table_name_ = sheet1;
|
||||
|
||||
if (convert_with_TableName)
|
||||
{
|
||||
return (sheet1.empty() ? L"" : (sheet1 + L"!")) + ref1 + (ref2.empty() ? L"" : (L":" + ref2) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return ref1 + (ref2.empty() ? L"" : (L":" + ref2) );
|
||||
}
|
||||
return L"";
|
||||
}
|
||||
std::wstring odf2oox_converter::Impl::replace_named_ref_formater1(boost::wsmatch const & what)
|
||||
{
|
||||
boost::wregex complexRef(L"\\${0,1}([^\\.]+?){0,1}\\.(\\${0,1}[a-zA-Z]+\\${0,1}\\d+)(?::\\.(\\${0,1}[a-zA-Z]+\\${0,1}\\d+)){0,1}");
|
||||
|
||||
boost::wregex complexRef(L"(?:\'([^\']*)\'#){0,1}\\${0,1}([^\\.]+?){0,1}\\.(\\${0,1}[\\w^0-9]+\\${0,1}\\d+)(?::\\.(\\${0,1}[\\w^0-9]+\\${0,1}\\d+)){0,1}");
|
||||
// 'external'# $ Sheet2 . A1 : ( $ Sheet2)? . B5
|
||||
std::wstring expr = what[1].str();
|
||||
const std::wstring res = boost::regex_replace(
|
||||
expr,
|
||||
@ -233,26 +362,34 @@ namespace formulasconvert {
|
||||
// [$'Sheet2 A'.$B2] -> 'Sheet2 A'!$B2
|
||||
void odf2oox_converter::Impl::replace_cells_range(std::wstring& expr, bool withTableName)
|
||||
{
|
||||
XmlUtils::replace_all( expr, L"#REF !", L"#REF!");
|
||||
XmlUtils::replace_all( expr, L"#REF!#REF!", L"#REF!");
|
||||
XmlUtils::replace_all( expr, L"$#REF!$#REF!", L"#REF!");
|
||||
|
||||
convert_with_TableName = withTableName;
|
||||
|
||||
boost::wregex complexRef(L"\\[(?:\$)?([^\\.]+?){0,1}\\.(\\${0,1}[a-zA-Z]*\\${0,1}\\d*)(?::(\\${0,1}[^\\.]+?){0,1}\\.(\\${0,1}[a-zA-Z]*\\${0,1}\\d*)){0,1}\\]");
|
||||
/*
|
||||
[ $ Sheet2 . A1 : ( $ Sheet2)? . B5 ]
|
||||
*/
|
||||
//boost::wregex complexRef(L"\\[(?:\'([^\']*)\'#){0,1}\\[{0,1}(?:\\$){0,1}([^\\.]+?){0,1}\\.(\\${0,1}[\\w^0-9]*\\${0,1}\\d*)(?::(\\${0,1}[^\\.]+?){0,1}\\.(\\${0,1}[\\w^0-9]*\\${0,1}\\d*)){0,1}\\]{0,1}");
|
||||
boost::wregex complexRef(L"(?:(?:(?:(?:\\[\'([^\']*)\'#)|(?:\'([^\']*)\'#\\[)))|(?:\\[))\
|
||||
(?:\\$){0,1}([^\\.]+?){0,1}\\.(\\${0,1}[\\w^0-9]*\\${0,1}\\d*)(?::(\\${0,1}[^\\.]+?){0,1}\\.(\\${0,1}[\\w^0-9]*\\${0,1}\\d*)){0,1}\\]");
|
||||
// [ 'external'# [ $ Sheet2 . A1 : ( $ Sheet2)? . B5 ]
|
||||
|
||||
const std::wstring res = boost::regex_replace(
|
||||
expr,
|
||||
expr = boost::regex_replace(
|
||||
expr,
|
||||
complexRef,
|
||||
&replace_named_ref_formater,
|
||||
boost::match_default | boost::format_all);
|
||||
expr = res;
|
||||
}
|
||||
void odf2oox_converter::Impl::replace_named_ref(std::wstring & expr, bool withTableName)
|
||||
{
|
||||
XmlUtils::replace_all( expr, L"#REF !", L"#REF!");
|
||||
XmlUtils::replace_all( expr, L"#REF!#REF!", L"#REF!");
|
||||
XmlUtils::replace_all( expr, L"$#REF!$#REF!", L"#REF!");
|
||||
|
||||
convert_with_TableName = withTableName;
|
||||
|
||||
//boost::wregex complexRef(L"\\${0,1}([^\\.]+?){0,1}\\.(\\${0,1}[a-zA-Z]+\\${0,1}\\d+)(?::\\.(\\${0,1}[a-zA-Z]+\\${0,1}\\d+)){0,1}");
|
||||
boost::wregex complexRef(L"\\${0,1}([^\\.\\s]+?){0,1}\\.(\\${0,1}[a-zA-Z]*\\${0,1}\\d*)(?::\\${0,1}([^\\.\\s]+?){0,1}\\.(\\${0,1}[a-zA-Z]*\\${0,1}\\d*)){0,1}");
|
||||
boost::wregex complexRef(L"\\[{0,1}(?:\'([^\']*)\'#){0,1}\\${0,1}([^\\.\\s]+?){0,1}\\.(\\${0,1}[\\w^0-9]*\\${0,1}\\d*)(?::\\${0,1}([^\\.\\s]+?){0,1}\\.(\\${0,1}[\\w^0-9]*\\${0,1}\\d*)){0,1}\\]{0,1}");
|
||||
// 'external'# $ Sheet2 . A1 : ( $ Sheet2)? . B5
|
||||
|
||||
const std::wstring res = boost::regex_replace(
|
||||
expr,
|
||||
@ -281,29 +418,7 @@ namespace formulasconvert {
|
||||
}
|
||||
|
||||
|
||||
std::wstring replace_semicolons_formater(boost::wsmatch const & what)
|
||||
{
|
||||
if (what[1].matched)
|
||||
return L",";
|
||||
else if (what[2].matched)
|
||||
return what[2].str();
|
||||
else if (what[3].matched)
|
||||
return what[3].str();
|
||||
else
|
||||
return L"";
|
||||
}
|
||||
std::wstring replace_tilda_formater(boost::wsmatch const & what)
|
||||
{
|
||||
if (what[1].matched)
|
||||
return L";";
|
||||
else if (what[2].matched)
|
||||
return what[2].str();
|
||||
else if (what[3].matched)
|
||||
return what[3].str();
|
||||
else
|
||||
return L"";
|
||||
}
|
||||
// TODO
|
||||
|
||||
// заменить точки с запятой во всех вхождениях кроме находящихся в кавычках --*и в фигурных скобках*--
|
||||
void odf2oox_converter::Impl::replace_semicolons(std::wstring& expr)
|
||||
{
|
||||
@ -327,123 +442,6 @@ namespace formulasconvert {
|
||||
|
||||
expr = res;
|
||||
}
|
||||
std::wstring replace_vertical_formater(boost::wsmatch const & what)
|
||||
{
|
||||
if (what[1].matched)
|
||||
{
|
||||
std::wstring inner = what[1].str();
|
||||
XmlUtils::replace_all( inner, L"|", L";");
|
||||
return L"{" + inner + L"}";
|
||||
}
|
||||
else if (what[2].matched)
|
||||
return what[2].str();
|
||||
else if (what[3].matched)
|
||||
return what[3].str();
|
||||
|
||||
return L"";
|
||||
}
|
||||
|
||||
std::wstring replace_point_space(boost::wsmatch const & what)
|
||||
{
|
||||
if (what[1].matched)
|
||||
{
|
||||
std::wstring inner = what[1].str();
|
||||
XmlUtils::replace_all( inner, L" ", L"PROBEL");
|
||||
return inner;
|
||||
}
|
||||
else if (what[2].matched)
|
||||
return what[2].str();
|
||||
else if (what[3].matched)
|
||||
return what[3].str();
|
||||
|
||||
return L"";
|
||||
}
|
||||
std::wstring convert_scobci(boost::wsmatch const & what)
|
||||
{
|
||||
if (what[1].matched)
|
||||
{
|
||||
std::wstring inner = what[1].str();
|
||||
XmlUtils::replace_all( inner, L".", L"ТОСHKA");
|
||||
XmlUtils::replace_all( inner, L"(", L"SCOBCAIN");
|
||||
XmlUtils::replace_all( inner, L")", L"SCOBCAOUT");
|
||||
|
||||
XmlUtils::replace_all( inner, L"[", L"KVADRATIN");
|
||||
XmlUtils::replace_all( inner, L"]", L"KVADRATOUT");
|
||||
|
||||
XmlUtils::replace_all( inner, L" ", L"PROBEL");
|
||||
XmlUtils::replace_all( inner, L"'", L"APOSTROF");
|
||||
return inner;
|
||||
}
|
||||
else if (what[2].matched)
|
||||
{
|
||||
std::wstring inner = what[2].str();
|
||||
XmlUtils::replace_all( inner, L".", L"ТОСHKA");
|
||||
|
||||
XmlUtils::replace_all( inner, L"(", L"SCOBCAIN");
|
||||
XmlUtils::replace_all( inner, L")", L"SCOBCAOUT");
|
||||
|
||||
XmlUtils::replace_all( inner, L"[", L"KVADRATIN");
|
||||
XmlUtils::replace_all( inner, L"]", L"KVADRATOUT");
|
||||
|
||||
XmlUtils::replace_all( inner, L" ", L"PROBEL");
|
||||
XmlUtils::replace_all( inner, L"\"", L"KAVYCHKA");
|
||||
return inner;
|
||||
}
|
||||
else if (what[3].matched)
|
||||
return what[3].str();
|
||||
|
||||
return L"";
|
||||
}
|
||||
std::wstring replace_space_formater(boost::wsmatch const & what)
|
||||
{
|
||||
if (what[1].matched)
|
||||
{
|
||||
std::wstring inner = what[1].str();
|
||||
XmlUtils::replace_all( inner, L" ", L",");
|
||||
return inner;
|
||||
}
|
||||
else if (what[2].matched)
|
||||
return what[2].str();
|
||||
else if (what[3].matched)
|
||||
return what[3].str();
|
||||
|
||||
return L"";
|
||||
}
|
||||
|
||||
|
||||
//std::wstring forbidden_formulas[] =
|
||||
//{
|
||||
// L"NULLFORMULA"
|
||||
// //L"BETADIST",
|
||||
// //L"CEILING",
|
||||
// //L"FLOOR",
|
||||
// //L"RANK",
|
||||
// //L"ROUND",
|
||||
// //L"ROUNDDOWN",
|
||||
// //L"ROUNDUP",
|
||||
// //L"SUBTOTAL",
|
||||
// //L"FORMULA",
|
||||
// //L"ISREF"
|
||||
//};
|
||||
|
||||
std::wstring is_forbidden(const std::wstring & formula)
|
||||
{
|
||||
std::wstring result = formula;
|
||||
std::map<std::wstring, std::wstring> forbidden_formulas;
|
||||
|
||||
forbidden_formulas.insert(std::make_pair(L"FORMULA", L"_xlfn.FORMULATEXT"));
|
||||
|
||||
for (std::map<std::wstring, std::wstring>::iterator it = forbidden_formulas.begin(); it != forbidden_formulas.end(); ++it)
|
||||
{
|
||||
if (boost::algorithm::contains(formula, it->first))
|
||||
{
|
||||
|
||||
XmlUtils::replace_all(result, it->first, it->second);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// заменить вертикальную черту во всех вхождениях в фигурных скобках, но не внутри строк
|
||||
void odf2oox_converter::Impl::replace_vertical(std::wstring& expr)
|
||||
{
|
||||
@ -468,17 +466,11 @@ namespace formulasconvert {
|
||||
std::wstring odf2oox_converter::Impl::convert(const std::wstring& expr)
|
||||
{
|
||||
std::wstring workstr = is_forbidden(expr);
|
||||
//boost::wregex complexRef(L"('(?!\\s\\'){0,1}.*?')");// Better_Donut.ods- cell(c27)
|
||||
//std::wstring workstr = boost::regex_replace(
|
||||
// expr,
|
||||
// complexRef,
|
||||
// &replace_point_space,
|
||||
// boost::match_default | boost::format_all);
|
||||
|
||||
bool isFormula = check_formula(workstr);
|
||||
|
||||
boost::regex_replace(
|
||||
workstr,
|
||||
//экранирование
|
||||
workstr = boost::regex_replace(workstr,
|
||||
boost::wregex(L"('.*?')|(\".*?\")"),
|
||||
&convert_scobci, boost::match_default | boost::format_all);
|
||||
|
||||
@ -492,9 +484,9 @@ namespace formulasconvert {
|
||||
XmlUtils::replace_all( workstr, L"FDIST(", L"_xlfn.F.DIST(");
|
||||
// ROUNDUP( - тут в oox 2 параметра - разрядность нужно - ,0) - EV Requirements v2.2.3.ods
|
||||
|
||||
int res_find=0;
|
||||
if ((res_find = workstr.find(L"CONCATINATE")) > 0)
|
||||
if (std::wstring::npos != workstr.find(L"CONCATINATE"))
|
||||
{
|
||||
bool l = true;
|
||||
//могут быть частично заданы диапазоны
|
||||
//todooo
|
||||
}
|
||||
@ -509,39 +501,23 @@ namespace formulasconvert {
|
||||
|
||||
|
||||
//-----------------------------------------------------------
|
||||
XmlUtils::replace_all( workstr, L"PROBEL" , L" ");
|
||||
XmlUtils::replace_all( workstr, L"APOSTROF" , L"'");
|
||||
XmlUtils::replace_all( workstr, L"ТОСHKA" , L".");
|
||||
|
||||
XmlUtils::replace_all( workstr, L"SCOBCAIN" , L"(");
|
||||
XmlUtils::replace_all( workstr, L"SCOBCAOUT" , L")");
|
||||
|
||||
XmlUtils::replace_all( workstr, L"KVADRATIN" , L"[");
|
||||
XmlUtils::replace_all( workstr, L"KVADRATOUT", L"]");
|
||||
|
||||
XmlUtils::replace_all( workstr, L"PROBEL" , L" ");
|
||||
XmlUtils::replace_all( workstr, L"KAVYCHKA" , L"\"");
|
||||
replace_tmp_back(workstr);
|
||||
|
||||
return workstr;
|
||||
}
|
||||
|
||||
void odf2oox_converter::Impl::split_distance_by(const std::wstring& expr, const std::wstring& by, std::vector<std::wstring>& out)
|
||||
{
|
||||
std::wstring workstr = expr;
|
||||
boost::wregex complexRef(L"('(?!\\s\\'){0,1}.*?')");// поиск того что в апострофах и замена там
|
||||
|
||||
workstr = boost::regex_replace(
|
||||
std::wstring workstr = boost::regex_replace(
|
||||
expr,
|
||||
complexRef,
|
||||
&replace_point_space,
|
||||
boost::match_default | boost::format_all);
|
||||
boost::wregex(L"('.*?')|(\".*?\")"),
|
||||
&convert_scobci, boost::match_default | boost::format_all);
|
||||
|
||||
boost::algorithm::split(out, workstr, boost::algorithm::is_any_of(by), boost::algorithm::token_compress_on);
|
||||
|
||||
for (size_t i = 0; i < out.size(); i++)
|
||||
{
|
||||
XmlUtils::replace_all( out[i], L"PROBEL", L" ");
|
||||
XmlUtils::replace_all( out[i], L"TOCHKA", L".");
|
||||
replace_tmp_back(out[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -551,15 +527,10 @@ namespace formulasconvert {
|
||||
|
||||
std::wstring odf2oox_converter::Impl::convert_chart_distance(const std::wstring& expr)
|
||||
{
|
||||
std::wstring workstr = is_forbidden(expr);
|
||||
|
||||
boost::wregex complexRef(L"('(?!\\s\\'){0,1}.*?')");// поиск того что в апострофах и замена там
|
||||
|
||||
workstr = boost::regex_replace(
|
||||
expr,
|
||||
complexRef,
|
||||
&replace_point_space,
|
||||
boost::match_default | boost::format_all);
|
||||
std::wstring workstr = boost::regex_replace(
|
||||
is_forbidden(expr),
|
||||
boost::wregex(L"('.*?')|(\".*?\")"),
|
||||
&convert_scobci, boost::match_default | boost::format_all);
|
||||
|
||||
//распарсить по диапазонам - одф-пробел, ик-эль-запятая
|
||||
|
||||
@ -591,10 +562,10 @@ namespace formulasconvert {
|
||||
cells_out.append(cells[j]);
|
||||
cells_out.append(L":");
|
||||
}
|
||||
int res1 = sheet.find(L"-");
|
||||
int res2 = sheet.find(L"'");
|
||||
size_t res1 = sheet.find(L"-");
|
||||
size_t res2 = sheet.find(L"'");
|
||||
|
||||
if (res1 >= 0 && !(res2 == 0))
|
||||
if (res1 != std::wstring::npos && res2 != std::wstring::npos && !(res2 == 0))
|
||||
{
|
||||
sheet = L"'" + sheet + L"'";
|
||||
}
|
||||
@ -608,12 +579,78 @@ namespace formulasconvert {
|
||||
result.append(distance_out[i]);
|
||||
result.append(L",");
|
||||
}
|
||||
XmlUtils::replace_all( result, L"PROBEL" , L" ");
|
||||
XmlUtils::replace_all( result, L"TOCHKA", L".");
|
||||
replace_tmp_back( result );
|
||||
|
||||
return result.substr(0, result.size() - 1);// минус последняя лишняя запятая
|
||||
}
|
||||
odf2oox_converter::odf2oox_converter(): impl_(new odf2oox_converter::Impl)
|
||||
std::wstring odf2oox_converter::Impl::convert_named_ref(const std::wstring& expr, bool withTableName, std::wstring separator)
|
||||
{
|
||||
boost::wregex complexRef(L"('(?!\\s\\'){0,1}.*?')");// поиск того что в апострофах и замена там
|
||||
|
||||
std::wstring workstr = expr;
|
||||
|
||||
workstr = boost::regex_replace(
|
||||
workstr,
|
||||
boost::wregex(L"('.*?')|(\".*?\")"),
|
||||
&convert_scobci, boost::match_default | boost::format_all);
|
||||
|
||||
replace_named_ref(workstr, withTableName);
|
||||
|
||||
if (separator != L" ")
|
||||
{
|
||||
XmlUtils::replace_all( workstr, L" ", separator);
|
||||
}
|
||||
|
||||
replace_tmp_back( workstr );
|
||||
|
||||
if (table_name_.empty() == false)
|
||||
{
|
||||
replace_tmp_back( table_name_ );
|
||||
}
|
||||
return workstr;
|
||||
}
|
||||
std::wstring odf2oox_converter::Impl::convert_named_expr(const std::wstring& expr, bool withTableName)
|
||||
{
|
||||
std::wstring workstr = expr;
|
||||
|
||||
bool isFormula = check_formula(workstr);
|
||||
|
||||
if (isFormula)
|
||||
{
|
||||
workstr = convert(expr);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
workstr = boost::regex_replace(
|
||||
workstr,
|
||||
boost::wregex(L"('.*?')|(\".*?\")"),
|
||||
&convert_scobci, boost::match_default | boost::format_all);
|
||||
|
||||
|
||||
replace_cells_range(workstr, withTableName);
|
||||
replace_semicolons(workstr);
|
||||
replace_vertical(workstr);
|
||||
|
||||
size_t res_find = 0;
|
||||
if ((res_find = workstr.find(L"CONCATINATE")) != std::wstring::npos)
|
||||
{
|
||||
//могут быть частично заданы диапазоны
|
||||
//todooo
|
||||
|
||||
}
|
||||
replace_tmp_back(workstr);
|
||||
|
||||
if (table_name_.empty() == false)
|
||||
{
|
||||
replace_tmp_back(table_name_);
|
||||
}
|
||||
}
|
||||
return workstr;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------
|
||||
odf2oox_converter::odf2oox_converter() : impl_(new odf2oox_converter::Impl())
|
||||
{
|
||||
}
|
||||
|
||||
@ -640,82 +677,11 @@ namespace formulasconvert {
|
||||
}
|
||||
std::wstring odf2oox_converter::convert_named_ref(const std::wstring& expr, bool withTableName, std::wstring separator)
|
||||
{
|
||||
boost::wregex complexRef(L"('(?!\\s\\'){0,1}.*?')");// поиск того что в апострофах и замена там
|
||||
|
||||
std::wstring workstr = boost::regex_replace(
|
||||
expr,
|
||||
complexRef,
|
||||
&replace_point_space,
|
||||
boost::match_default | boost::format_all);
|
||||
|
||||
XmlUtils::replace_all( workstr, L"'", L"APOSTROF");
|
||||
//XmlUtils::replace_all( workstr, L"", L"APOSTROF");
|
||||
|
||||
impl_->replace_named_ref(workstr, withTableName);
|
||||
|
||||
if (separator != L" ")
|
||||
{
|
||||
XmlUtils::replace_all( workstr, L" " , separator);
|
||||
}
|
||||
|
||||
XmlUtils::replace_all( workstr, L"PROBEL" , L" ");
|
||||
XmlUtils::replace_all( workstr, L"APOSTROF" , L"'");
|
||||
XmlUtils::replace_all( workstr, L"TOCHKA" , L".");
|
||||
|
||||
if (impl_->table_name_.empty() == false)
|
||||
{
|
||||
XmlUtils::replace_all( impl_->table_name_, L"PROBEL" , L" ");
|
||||
XmlUtils::replace_all( impl_->table_name_, L"APOSTROF" , L"'");
|
||||
XmlUtils::replace_all( impl_->table_name_, L"TOCHKA" , L".");
|
||||
}
|
||||
return workstr;
|
||||
return impl_->convert_named_ref(expr, withTableName, separator);
|
||||
}
|
||||
std::wstring odf2oox_converter::convert_named_expr(const std::wstring& expr, bool withTableName)
|
||||
{
|
||||
std::wstring workstr = expr;
|
||||
|
||||
bool isFormula = impl_->check_formula(workstr);
|
||||
|
||||
if (isFormula)
|
||||
{
|
||||
workstr = impl_->convert(expr);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
boost::wregex complexRef(L"('(?!\\s\\'){0,1}.*?')");// поиск того что в апострофах и замена там
|
||||
|
||||
workstr = boost::regex_replace(
|
||||
workstr,
|
||||
complexRef,
|
||||
&replace_point_space,
|
||||
boost::match_default | boost::format_all);
|
||||
|
||||
XmlUtils::replace_all( workstr, L"'", L"APOSTROF");
|
||||
|
||||
impl_->replace_cells_range(workstr, withTableName);
|
||||
impl_->replace_semicolons(workstr);
|
||||
impl_->replace_vertical(workstr);
|
||||
|
||||
int res_find=0;
|
||||
if ((res_find = workstr.find(L"CONCATINATE")) > 0)
|
||||
{
|
||||
//могут быть частично заданы диапазоны
|
||||
//todooo
|
||||
|
||||
}
|
||||
XmlUtils::replace_all( workstr, L"PROBEL" , L" ");
|
||||
XmlUtils::replace_all( workstr, L"APOSTROF" , L"'");
|
||||
XmlUtils::replace_all( workstr, L"TOCHKA" , L".");
|
||||
|
||||
if (impl_->table_name_.empty() == false)
|
||||
{
|
||||
XmlUtils::replace_all( impl_->table_name_, L"PROBEL" , L" ");
|
||||
XmlUtils::replace_all( impl_->table_name_, L"APOSTROF" , L"'");
|
||||
XmlUtils::replace_all( impl_->table_name_, L"TOCHKA" , L".");
|
||||
}
|
||||
}
|
||||
return workstr;
|
||||
return impl_->convert_named_expr(expr, withTableName);
|
||||
}
|
||||
|
||||
std::wstring odf2oox_converter::convert_ref(std::wstring const & expr)
|
||||
@ -728,8 +694,8 @@ namespace formulasconvert {
|
||||
{
|
||||
while(true)
|
||||
{
|
||||
int pos = expr.find(L"%20");
|
||||
if (pos <0)break;
|
||||
size_t pos = expr.find(L"%20");
|
||||
if (pos == std::wstring::npos)break;
|
||||
|
||||
expr.replace(pos,3,L" ");
|
||||
}
|
||||
|
||||
@ -39,6 +39,22 @@
|
||||
namespace cpdoccore {
|
||||
namespace formulasconvert {
|
||||
|
||||
static std::wstring forbidden_formulas1[] =
|
||||
{
|
||||
L"NULLFORMULA()"
|
||||
/*
|
||||
L"BETADIST",
|
||||
L"CEILING",
|
||||
L"FLOOR",
|
||||
L"RANK",
|
||||
L"ROUND",
|
||||
L"ROUNDDOWN",
|
||||
L"ROUNDUP",
|
||||
L"SUBTOTAL",
|
||||
L"FORMULA",
|
||||
L"ISREF"*/
|
||||
};
|
||||
|
||||
class oox2odf_converter::Impl
|
||||
{
|
||||
public:
|
||||
@ -48,7 +64,7 @@ public:
|
||||
std::wstring convert_conditional_formula(const std::wstring& expr);
|
||||
|
||||
std::wstring convert_chart_distance(const std::wstring& expr);
|
||||
static void replace_cells_range(std::wstring& expr);
|
||||
static void replace_cells_range(std::wstring& expr, bool bSelect = true);
|
||||
|
||||
static void replace_semicolons(std::wstring& expr);
|
||||
static void replace_vertical(std::wstring& expr);
|
||||
@ -59,7 +75,104 @@ public:
|
||||
static std::wstring replace_arguments(boost::wsmatch const & what);
|
||||
static std::wstring convert_scobci(boost::wsmatch const & what);
|
||||
|
||||
void replace_named_ref(std::wstring & expr);
|
||||
static std::wstring replace_tilda_formater(boost::wsmatch const & what)
|
||||
{
|
||||
if (what[1].matched)
|
||||
return L";";
|
||||
else if (what[2].matched)
|
||||
return what[2].str();
|
||||
else if (what[3].matched)
|
||||
return what[3].str();
|
||||
//else if (what[4].matched)
|
||||
// return what[4].str();
|
||||
else
|
||||
return L"";
|
||||
}
|
||||
static std::wstring replace_semicolons_formater(boost::wsmatch const & what)
|
||||
{
|
||||
if (what[1].matched)
|
||||
return L";";
|
||||
else if (what[2].matched)
|
||||
return what[2].str();
|
||||
else if (what[3].matched)
|
||||
return what[3].str();
|
||||
//else if (what[4].matched)
|
||||
// return what[4].str();
|
||||
else
|
||||
return L"";
|
||||
}
|
||||
static std::wstring replace_vertical_formater(boost::wsmatch const & what)
|
||||
{
|
||||
if (what[1].matched)
|
||||
{
|
||||
std::wstring inner = what[1].str();
|
||||
XmlUtils::replace_all( inner, L";", L"|");
|
||||
return L"{" + inner + L"}";
|
||||
}
|
||||
else if (what[2].matched)
|
||||
return what[2].str();
|
||||
else if (what[3].matched)
|
||||
return what[3].str();
|
||||
|
||||
return L"";
|
||||
}
|
||||
static std::wstring replace_space_formater(boost::wsmatch const & what)
|
||||
{
|
||||
if (what[1].matched)
|
||||
{
|
||||
std::wstring inner = what[1].str();
|
||||
XmlUtils::replace_all( inner, L",", L" ");
|
||||
return inner;
|
||||
}
|
||||
else if (what[2].matched)
|
||||
return what[2].str();
|
||||
else if (what[3].matched)
|
||||
return what[3].str();
|
||||
|
||||
return L"";
|
||||
}
|
||||
static void oox_replace_tmp_back(std::wstring &expr)
|
||||
{
|
||||
XmlUtils::replace_all( expr, L"ТОСHKA", L".");
|
||||
XmlUtils::replace_all( expr, L"VOSKL", L"!");
|
||||
|
||||
XmlUtils::replace_all( expr, L"SCOBCAIN", L"(");
|
||||
XmlUtils::replace_all( expr, L"SCOBCAOUT", L")");
|
||||
|
||||
XmlUtils::replace_all( expr, L"KVADRATIN", L"[");
|
||||
XmlUtils::replace_all( expr, L"KVADRATOUT", L"]");
|
||||
|
||||
XmlUtils::replace_all( expr, L"PROBEL", L" ");
|
||||
XmlUtils::replace_all( expr, L"APOSTROF", L"'");
|
||||
XmlUtils::replace_all( expr, L"KAVYCHKA", L"\"");
|
||||
}
|
||||
|
||||
static void oox_replace_tmp(std::wstring &expr)
|
||||
{
|
||||
XmlUtils::replace_all( expr, L".", L"ТОСHKA");
|
||||
XmlUtils::replace_all( expr, L"!", L"VOSKL");
|
||||
|
||||
XmlUtils::replace_all( expr, L"(", L"SCOBCAIN");
|
||||
XmlUtils::replace_all( expr, L")", L"SCOBCAOUT");
|
||||
|
||||
XmlUtils::replace_all( expr, L"[", L"KVADRATIN");
|
||||
XmlUtils::replace_all( expr, L"]", L"KVADRATOUT");
|
||||
|
||||
XmlUtils::replace_all( expr, L" ", L"PROBEL");
|
||||
XmlUtils::replace_all( expr, L"'", L"APOSTROF");
|
||||
XmlUtils::replace_all( expr, L"\"", L"KAVYCHKA");
|
||||
}
|
||||
|
||||
static bool is_forbidden1(const std::wstring & formula)
|
||||
{
|
||||
for (size_t i = 0; i < 1; i++)
|
||||
{
|
||||
if (boost::algorithm::contains(formula, forbidden_formulas1[i]))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
void replace_named_ref(std::wstring & expr);
|
||||
void replace_named_formula(std::wstring & expr);
|
||||
|
||||
static bool isFindBaseCell_;
|
||||
@ -70,8 +183,11 @@ public:
|
||||
bool oox2odf_converter::Impl::isFindBaseCell_ = false;
|
||||
std::wstring oox2odf_converter::Impl::table_name_ = L"";
|
||||
|
||||
void oox2odf_converter::Impl::replace_cells_range(std::wstring& expr)
|
||||
void oox2odf_converter::Impl::replace_cells_range(std::wstring& expr, bool bSelect)
|
||||
{
|
||||
if ((0 == expr.find(L"KAVYCHKA")) && (expr.length() - 8 == expr.rfind(L"KAVYCHKA") ))
|
||||
return;
|
||||
|
||||
boost::wregex re(L"([:$!])+");
|
||||
|
||||
boost::wsmatch result;
|
||||
@ -79,7 +195,7 @@ void oox2odf_converter::Impl::replace_cells_range(std::wstring& expr)
|
||||
|
||||
if (b)
|
||||
{
|
||||
boost::wregex re1(L"(\\$?\\w+\\!)?([a-zA-Z$]*\\d*)\\:?([a-zA-Z$]*\\d*)?");
|
||||
boost::wregex re1(L"(\\$?[^\']+\\!)?([\\w^0-9$]*\\d*)\\:?([\\w^0-9$]*\\d*)?");
|
||||
// $ Sheet2 ! $ A1 : $ B5
|
||||
// $ Sheet2 ! $ A : $ A
|
||||
// $ Sheet2 ! $ 1 : $ 1
|
||||
@ -88,7 +204,7 @@ void oox2odf_converter::Impl::replace_cells_range(std::wstring& expr)
|
||||
std::wstring res = boost::regex_replace(
|
||||
workstr,
|
||||
re1,
|
||||
&replace_cells_range_formater1,
|
||||
bSelect ? &replace_cells_range_formater1 : &replace_cells_range_formater2,
|
||||
boost::match_default | boost::format_all);
|
||||
|
||||
expr = res;
|
||||
@ -111,8 +227,12 @@ std::wstring oox2odf_converter::Impl::replace_cells_range_formater1(boost::wsmat
|
||||
|
||||
std::wstring c1 = what[2].str();
|
||||
std::wstring c2 = what[3].str();
|
||||
|
||||
if (!c1.empty() || !c2.empty() || !sheet.empty())
|
||||
|
||||
if ((0 == c1.find(L"KAVYCHKA")) && (c1.length() - 8 == c1.rfind(L"KAVYCHKA") ))
|
||||
{
|
||||
return c1;
|
||||
}
|
||||
else if (!c1.empty() || !c2.empty() || !sheet.empty())
|
||||
{
|
||||
XmlUtils::replace_all( sheet, L"!", L"");
|
||||
|
||||
@ -122,9 +242,8 @@ std::wstring oox2odf_converter::Impl::replace_cells_range_formater1(boost::wsmat
|
||||
}
|
||||
if (!sheet.empty() && (std::wstring::npos != c1.find(L"$"))) sheet = L"$" + sheet;
|
||||
|
||||
s = std::wstring(L"[") + sheet + L"." +
|
||||
c1 +
|
||||
(c2.empty() ? L"" : (L":" + sheet + L"." + c2) ) + std::wstring(L"]");
|
||||
|
||||
s = L"[" + sheet + L"." + c1 + (c2.empty() ? L"" : (L":" + sheet + L"." + c2)) + std::wstring(L"]");
|
||||
}
|
||||
return s;
|
||||
}
|
||||
@ -144,18 +263,43 @@ std::wstring oox2odf_converter::Impl::replace_cells_range_formater2(boost::wsmat
|
||||
{
|
||||
const size_t sz = what.size();
|
||||
|
||||
if (sz > 2)
|
||||
if (sz > 3)
|
||||
{
|
||||
std::wstring s;
|
||||
std::wstring sheet = what[1].matched ? what[1].str() : L"";
|
||||
|
||||
std::wstring c1 = what[2].str();
|
||||
std::wstring c2 = what[3].str();
|
||||
|
||||
if ((0 == c1.find(L"KAVYCHKA")) && (c1.length() - 8 == c1.rfind(L"KAVYCHKA") ))
|
||||
{
|
||||
return c1;
|
||||
}
|
||||
else if (!c1.empty() || !c2.empty() || !sheet.empty())
|
||||
{
|
||||
XmlUtils::replace_all( sheet, L"!", L"");
|
||||
|
||||
if (isFindBaseCell_ && table_name_.empty() && !sheet.empty())
|
||||
{
|
||||
table_name_ = sheet + L".$A$1";
|
||||
}
|
||||
if (!sheet.empty() && (std::wstring::npos != c1.find(L"$"))) sheet = L"$" + sheet;
|
||||
|
||||
|
||||
s = sheet + L"." + c1 + (c2.empty() ? L"" : (L":" + sheet + L"." + c2)) + std::wstring(L"");
|
||||
}
|
||||
return s;
|
||||
}
|
||||
else
|
||||
{
|
||||
const std::wstring c1 = what[1].str();
|
||||
const std::wstring c2 = what[2].str();
|
||||
|
||||
const std::wstring s = std::wstring(L"[.") + c1 + (c2.empty() ? L"" : (L":." + c2) ) + std::wstring(L"]");
|
||||
const std::wstring s = std::wstring(L".") + c1 + (c2.empty() ? L"" : (L":." + c2) );
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
return L"";
|
||||
|
||||
return L"";
|
||||
}
|
||||
|
||||
void oox2odf_converter::Impl::replace_named_formula(std::wstring & expr)
|
||||
@ -167,7 +311,6 @@ void oox2odf_converter::Impl::replace_named_formula(std::wstring & expr)
|
||||
isFindBaseCell_ = false;
|
||||
}
|
||||
|
||||
// Лист1!$A$1 -> $Лист1.$A$1
|
||||
void oox2odf_converter::Impl::replace_named_ref(std::wstring & expr)
|
||||
{
|
||||
table_name_.clear();
|
||||
@ -178,27 +321,22 @@ void oox2odf_converter::Impl::replace_named_ref(std::wstring & expr)
|
||||
replace_vertical(workstr);
|
||||
replace_semicolons(workstr);
|
||||
|
||||
std::wstring res1 = boost::regex_replace(
|
||||
workstr,
|
||||
boost::wregex(L"('.*?')|(\".*?\")"),
|
||||
&oox2odf_converter::Impl::convert_scobci, boost::match_default | boost::format_all);
|
||||
|
||||
std::vector<std::wstring> distance;
|
||||
|
||||
boost::algorithm::split(distance,workstr, boost::algorithm::is_any_of(L";"), boost::algorithm::token_compress_on);
|
||||
boost::algorithm::split(distance, res1, boost::algorithm::is_any_of(L";"), boost::algorithm::token_compress_on);
|
||||
|
||||
for (size_t i = 0; i < distance.size(); i++)
|
||||
{
|
||||
std::wstring &d = distance[i];
|
||||
|
||||
XmlUtils::replace_all( d, L"(", L"SCOBCAIN");
|
||||
XmlUtils::replace_all( d, L")", L"SCOBCAOUT");
|
||||
XmlUtils::replace_all( d, L" ", L"PROBEL");
|
||||
XmlUtils::replace_all( d, L"'", L"APOSTROF");
|
||||
XmlUtils::replace_all( d, L"\"", L"KAVYCHKA");
|
||||
|
||||
replace_cells_range(d);
|
||||
replace_cells_range(d, false);
|
||||
|
||||
XmlUtils::replace_all( d, L"SCOBCAIN", L"(");
|
||||
XmlUtils::replace_all( d, L"SCOBCAOUT", L")");
|
||||
XmlUtils::replace_all( d, L"PROBEL", L" ");
|
||||
XmlUtils::replace_all( d, L"APOSTROF", L"'");
|
||||
XmlUtils::replace_all( d, L"KAVYCHKA", L"\"");
|
||||
oox_replace_tmp_back(d);
|
||||
|
||||
out = out + d + std::wstring(L";");
|
||||
}
|
||||
@ -209,47 +347,11 @@ void oox2odf_converter::Impl::replace_named_ref(std::wstring & expr)
|
||||
|
||||
if (table_name_.empty() == false)
|
||||
{
|
||||
XmlUtils::replace_all( table_name_, L"SCOBCAIN", L"(");
|
||||
XmlUtils::replace_all( table_name_, L"SCOBCAOUT", L")");
|
||||
XmlUtils::replace_all( table_name_, L"PROBEL", L" ");
|
||||
XmlUtils::replace_all( table_name_, L"APOSTROF", L"'");
|
||||
XmlUtils::replace_all( table_name_, L"KAVYCHKA", L"\"");
|
||||
oox_replace_tmp_back(table_name_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
std::wstring replace_tilda_formater(boost::wsmatch const & what)
|
||||
{
|
||||
if (what[1].matched)
|
||||
return L";";
|
||||
else if (what[2].matched)
|
||||
return what[2].str();
|
||||
else if (what[3].matched)
|
||||
return what[3].str();
|
||||
//else if (what[4].matched)
|
||||
// return what[4].str();
|
||||
else
|
||||
return L"";
|
||||
}
|
||||
|
||||
|
||||
std::wstring replace_semicolons_formater(boost::wsmatch const & what)
|
||||
{
|
||||
if (what[1].matched)
|
||||
return L";";
|
||||
else if (what[2].matched)
|
||||
return what[2].str();
|
||||
else if (what[3].matched)
|
||||
return what[3].str();
|
||||
//else if (what[4].matched)
|
||||
// return what[4].str();
|
||||
else
|
||||
return L"";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// TODO
|
||||
// заменить запятые на точки с запятой во всех вхождениях кроме находящихся в кавычках --*и в фигурных скобках*--
|
||||
@ -264,67 +366,8 @@ void oox2odf_converter::Impl::replace_semicolons(std::wstring& expr)
|
||||
boost::match_default | boost::format_all);
|
||||
expr = res;
|
||||
}
|
||||
namespace
|
||||
{
|
||||
|
||||
std::wstring replace_vertical_formater(boost::wsmatch const & what)
|
||||
{
|
||||
if (what[1].matched)
|
||||
{
|
||||
std::wstring inner = what[1].str();
|
||||
XmlUtils::replace_all( inner, L";", L"|");
|
||||
return L"{" + inner + L"}";
|
||||
}
|
||||
else if (what[2].matched)
|
||||
return what[2].str();
|
||||
else if (what[3].matched)
|
||||
return what[3].str();
|
||||
|
||||
return L"";
|
||||
}
|
||||
std::wstring replace_space_formater(boost::wsmatch const & what)
|
||||
{
|
||||
if (what[1].matched)
|
||||
{
|
||||
std::wstring inner = what[1].str();
|
||||
XmlUtils::replace_all( inner, L",", L" ");
|
||||
return inner;
|
||||
}
|
||||
else if (what[2].matched)
|
||||
return what[2].str();
|
||||
else if (what[3].matched)
|
||||
return what[3].str();
|
||||
|
||||
return L"";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::wstring forbidden_formulas1[] =
|
||||
{
|
||||
L"NULLFORMULA()"
|
||||
/*
|
||||
L"BETADIST",
|
||||
L"CEILING",
|
||||
L"FLOOR",
|
||||
L"RANK",
|
||||
L"ROUND",
|
||||
L"ROUNDDOWN",
|
||||
L"ROUNDUP",
|
||||
L"SUBTOTAL",
|
||||
L"FORMULA",
|
||||
L"ISREF"*/
|
||||
};
|
||||
|
||||
bool is_forbidden1(const std::wstring & formula)
|
||||
{
|
||||
for (size_t i = 0; i < 1; i++)
|
||||
{
|
||||
if (boost::algorithm::contains(formula, forbidden_formulas1[i]))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//void oox2odf_converter::Impl::split_(std::wstring& expr)
|
||||
//{
|
||||
// const std::wstring res = boost::regex_split(
|
||||
@ -355,47 +398,18 @@ void oox2odf_converter::Impl::replace_space(std::wstring& expr)
|
||||
expr = res;
|
||||
}
|
||||
|
||||
std::wstring replace_(boost::wsmatch const & what)
|
||||
{
|
||||
if (what[1].matched)
|
||||
{
|
||||
std::wstring inner = what[1].str();
|
||||
XmlUtils::replace_all( inner, L",", L" ");
|
||||
return inner;
|
||||
}
|
||||
else if (what[2].matched)
|
||||
return what[2].str();
|
||||
else if (what[3].matched)
|
||||
return what[3].str();
|
||||
|
||||
return L"";
|
||||
}
|
||||
std::wstring oox2odf_converter::Impl::convert_scobci(boost::wsmatch const & what)
|
||||
{
|
||||
if (what[1].matched)
|
||||
{
|
||||
std::wstring inner = what[1].str();
|
||||
XmlUtils::replace_all( inner, L"(", L"SCOBCAIN");
|
||||
XmlUtils::replace_all( inner, L")", L"SCOBCAOUT");
|
||||
|
||||
XmlUtils::replace_all( inner, L"[", L"KVADRATIN");
|
||||
XmlUtils::replace_all( inner, L"]", L"KVADRATOUT");
|
||||
|
||||
XmlUtils::replace_all( inner, L" ", L"PROBEL");
|
||||
XmlUtils::replace_all( inner, L"'", L"APOSTROF");
|
||||
oox_replace_tmp(inner);
|
||||
return inner;
|
||||
}
|
||||
else if (what[2].matched)
|
||||
{
|
||||
std::wstring inner = what[2].str();
|
||||
XmlUtils::replace_all( inner, L"(", L"SCOBCAIN");
|
||||
XmlUtils::replace_all( inner, L")", L"SCOBCAOUT");
|
||||
|
||||
XmlUtils::replace_all( inner, L"[", L"KVADRATIN");
|
||||
XmlUtils::replace_all( inner, L"]", L"KVADRATOUT");
|
||||
|
||||
XmlUtils::replace_all( inner, L" ", L"PROBEL");
|
||||
XmlUtils::replace_all( inner, L"\"", L"KAVYCHKA");
|
||||
oox_replace_tmp(inner);
|
||||
return inner;
|
||||
}
|
||||
else if (what[3].matched)
|
||||
@ -444,13 +458,13 @@ std::wstring oox2odf_converter::Impl::convert(const std::wstring& expr)
|
||||
if (is_forbidden1(expr))
|
||||
return L"NULLFORMULA";
|
||||
|
||||
std::wstring workstr = expr;
|
||||
std::wstring workstr = expr;
|
||||
replace_cells_range(workstr);
|
||||
replace_vertical(workstr);
|
||||
replace_semicolons(workstr);
|
||||
return workstr;
|
||||
}
|
||||
// of:=(Formula) -> (Formula)
|
||||
// (Formula) -> of:=(Formula)
|
||||
std::wstring oox2odf_converter::Impl::convert_formula(const std::wstring & expr)
|
||||
{
|
||||
std::wstring workstr = expr;
|
||||
@ -462,7 +476,7 @@ std::wstring oox2odf_converter::Impl::convert_formula(const std::wstring & expr)
|
||||
|
||||
std::wstring res = boost::regex_replace(
|
||||
res1,
|
||||
boost::wregex(L"(?!([a-zA-Z]+\\d*\\())(([a-zA-Z]+\\!)?\\$?[a-zA-Z]*\\$?\\d*(\\:\\$?[a-zA-Z]*\\$?\\d*){0,1})"),
|
||||
boost::wregex(L"(?!([\\w^0-9]+\\d*\\())(([\\w^0-9]+\\!)?\\$?[\\w^0-9]*\\$?\\d*(\\:\\$?[\\w^0-9]*\\$?\\d*){0,1})"),
|
||||
&oox2odf_converter::Impl::replace_arguments, boost::match_default | boost::format_all);
|
||||
|
||||
//SUBTOTAL(109,Expense31[Amount])
|
||||
@ -480,16 +494,7 @@ std::wstring oox2odf_converter::Impl::convert_formula(const std::wstring & expr)
|
||||
boost::match_default | boost::format_all);
|
||||
}
|
||||
|
||||
XmlUtils::replace_all( res, L"SCOBCAIN", L"(");
|
||||
XmlUtils::replace_all( res, L"SCOBCAOUT", L")");
|
||||
|
||||
XmlUtils::replace_all( res, L"KVADRATIN", L"[");
|
||||
XmlUtils::replace_all( res, L"KVADRATOUT", L"]");
|
||||
|
||||
|
||||
XmlUtils::replace_all( res, L"APOSTROF", L"'");
|
||||
|
||||
XmlUtils::replace_all( res, L"KAVYCHKA", L"\"");
|
||||
oox_replace_tmp_back(res);
|
||||
|
||||
replace_vertical(res);
|
||||
replace_semicolons(res);
|
||||
@ -498,17 +503,7 @@ std::wstring oox2odf_converter::Impl::convert_formula(const std::wstring & expr)
|
||||
|
||||
if (table_name_.empty() == false)
|
||||
{
|
||||
XmlUtils::replace_all( table_name_, L"SCOBCAIN", L"(");
|
||||
XmlUtils::replace_all( table_name_, L"SCOBCAOUT", L")");
|
||||
|
||||
XmlUtils::replace_all( table_name_, L"KVADRATIN", L"[");
|
||||
XmlUtils::replace_all( table_name_, L"KVADRATOUT", L"]");
|
||||
|
||||
|
||||
XmlUtils::replace_all( table_name_, L"APOSTROF", L"'");
|
||||
|
||||
XmlUtils::replace_all( table_name_, L"KAVYCHKA", L"\"");
|
||||
XmlUtils::replace_all( table_name_, L"PROBEL", L" ");
|
||||
oox_replace_tmp_back(table_name_);
|
||||
}
|
||||
|
||||
return std::wstring(L"of:=") + res;
|
||||
@ -537,12 +532,7 @@ std::wstring oox2odf_converter::Impl::convert_conditional_formula(const std::wst
|
||||
|
||||
}
|
||||
|
||||
XmlUtils::replace_all( res, L"SCOBCAIN", L"(");
|
||||
XmlUtils::replace_all( res, L"SCOBCAOUT", L")");
|
||||
|
||||
XmlUtils::replace_all( res, L"APOSTROF", L"'");
|
||||
|
||||
XmlUtils::replace_all( res, L"KAVYCHKA", L"\"");
|
||||
oox_replace_tmp_back( res);
|
||||
|
||||
replace_vertical(res);
|
||||
replace_semicolons(res);
|
||||
@ -658,8 +648,6 @@ std::wstring oox2odf_converter::get_table_name()
|
||||
{
|
||||
return impl_->table_name_;
|
||||
}
|
||||
|
||||
|
||||
std::wstring oox2odf_converter::convert_ref(std::wstring const & expr)
|
||||
{
|
||||
std::wstring workstr = expr;
|
||||
|
||||
@ -332,6 +332,7 @@ enum ElementType
|
||||
typeTableTableRowGroup,
|
||||
typeTableTableRowNoGroup,
|
||||
typeTableTableSource,
|
||||
typeTableTableProtection,
|
||||
|
||||
typeTableDataPilotTables,
|
||||
typeTableDataPilotTable,
|
||||
@ -454,6 +455,7 @@ enum ElementType
|
||||
typeDrawPolyline,
|
||||
typeDrawRegularPolyline,
|
||||
typeDrawPath,
|
||||
typeDrawContourPath,
|
||||
typeDrawCircle,
|
||||
typeDrawg,
|
||||
typeDrawPageThumbnail,
|
||||
|
||||
@ -43,7 +43,7 @@
|
||||
#include <boost/variant.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include "../../../../Common/DocxFormat/Source/XML/Utils.h"
|
||||
#include "../../../Common/DocxFormat/Source/XML/Utils.h"
|
||||
|
||||
namespace cpdoccore
|
||||
{
|
||||
|
||||
@ -131,6 +131,7 @@ text_tracked_context::_state & text_tracked_context::get_tracked_change(std::wst
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------
|
||||
docx_conversion_context::docx_conversion_context(odf_reader::odf_document * OdfDocument) :
|
||||
last_dump_page_properties_ (true),
|
||||
next_dump_page_properties_ (false),
|
||||
page_break_ (false),
|
||||
page_break_after_ (false),
|
||||
@ -155,12 +156,9 @@ docx_conversion_context::docx_conversion_context(odf_reader::odf_document * OdfD
|
||||
odf_document_ (OdfDocument)
|
||||
{
|
||||
streams_man_ = streams_man::create(temp_stream_);
|
||||
applicationFonts_ = NSFonts::NSApplication::Create();
|
||||
}
|
||||
docx_conversion_context::~docx_conversion_context()
|
||||
{
|
||||
if (applicationFonts_)
|
||||
delete applicationFonts_;
|
||||
}
|
||||
void docx_conversion_context::set_output_document(package::docx_document * document)
|
||||
{
|
||||
@ -168,8 +166,7 @@ void docx_conversion_context::set_output_document(package::docx_document * docum
|
||||
}
|
||||
void docx_conversion_context::set_font_directory(std::wstring pathFonts)
|
||||
{
|
||||
if (applicationFonts_)
|
||||
applicationFonts_->InitializeFromFolder(pathFonts);
|
||||
mediaitems_.set_font_directory(pathFonts);
|
||||
}
|
||||
std::wstring styles_map::get(const std::wstring & Name, odf_types::style_family::type Type)
|
||||
{
|
||||
@ -686,7 +683,7 @@ void docx_conversion_context::end_document()
|
||||
|
||||
output_document_->get_word_files().set_document ( package::simple_element::create(L"document.xml", document_xml_.str()) );
|
||||
output_document_->get_word_files().set_settings ( package::simple_element::create(L"settings.xml", dump_settings_document()));
|
||||
output_document_->get_word_files().set_media ( mediaitems_, applicationFonts_);
|
||||
output_document_->get_word_files().set_media ( mediaitems_);
|
||||
output_document_->get_word_files().set_comments ( comments_context_);
|
||||
output_document_->get_word_files().set_headers_footers( headers_footers_);
|
||||
|
||||
@ -1429,14 +1426,22 @@ void docx_conversion_context::next_dump_page_properties(bool val)
|
||||
if (process_headers_footers_ && val) return;
|
||||
|
||||
next_dump_page_properties_ = val;
|
||||
if (val)
|
||||
last_dump_page_properties(true);
|
||||
}
|
||||
|
||||
bool docx_conversion_context::is_next_dump_page_properties()
|
||||
{
|
||||
return next_dump_page_properties_;
|
||||
}
|
||||
|
||||
|
||||
void docx_conversion_context::last_dump_page_properties(bool val)
|
||||
{
|
||||
last_dump_page_properties_ = val;
|
||||
}
|
||||
bool docx_conversion_context::is_last_dump_page_properties()
|
||||
{
|
||||
return last_dump_page_properties_;
|
||||
}
|
||||
void docx_conversion_context::start_text_list_style(const std::wstring & StyleName)
|
||||
{
|
||||
text_list_style_name_ = StyleName;
|
||||
|
||||
@ -47,8 +47,6 @@
|
||||
#include "hyperlinks.h"
|
||||
#include "mediaitems.h"
|
||||
|
||||
#include "../../../DesktopEditor/graphics/pro/Fonts.h"
|
||||
|
||||
namespace cpdoccore {
|
||||
|
||||
namespace odf_types
|
||||
@ -190,14 +188,14 @@ public:
|
||||
}
|
||||
void set_position_child_group(_INT32 x, _INT32 y)
|
||||
{
|
||||
if (groups_.size() < 1) return;
|
||||
if (groups_.empty()) return;
|
||||
|
||||
if (groups_.back().x > x) groups_.back().x = x;
|
||||
if (groups_.back().y > y) groups_.back().y = y;
|
||||
}
|
||||
void set_size_child_group(_INT32 cx, _INT32 cy)
|
||||
{
|
||||
if (groups_.size() < 1) return;
|
||||
if (groups_.empty()) return;
|
||||
|
||||
if (groups_.back().cx < cx) groups_.back().cx = cx;
|
||||
if (groups_.back().cy < cy) groups_.back().cy = cy;
|
||||
@ -205,7 +203,7 @@ public:
|
||||
void get_position_group(_INT32 & x, _INT32 & y)
|
||||
{
|
||||
x = y = 0;
|
||||
if (groups_.size() < 1) return;
|
||||
if (groups_.empty()) return;
|
||||
|
||||
x = groups_.back().x;
|
||||
y = groups_.back().y;
|
||||
@ -213,7 +211,7 @@ public:
|
||||
void get_size_group(_INT32 & cx, _INT32 & cy)
|
||||
{
|
||||
cx = cy = 0;
|
||||
if (groups_.size() < 1) return;
|
||||
if (groups_.empty()) return;
|
||||
|
||||
cx = groups_.back().cx;
|
||||
cy = groups_.back().cy;
|
||||
@ -795,12 +793,12 @@ public:
|
||||
|
||||
bool next_dump_page_properties_;
|
||||
bool next_dump_section_;
|
||||
bool last_dump_page_properties_;
|
||||
|
||||
odf_reader::odf_document * root()
|
||||
odf_reader::odf_document *root()
|
||||
{
|
||||
return odf_document_;
|
||||
}
|
||||
|
||||
void start_document ();
|
||||
void end_document ();
|
||||
|
||||
@ -865,6 +863,8 @@ public:
|
||||
|
||||
void next_dump_page_properties (bool val);
|
||||
bool is_next_dump_page_properties ();
|
||||
void last_dump_page_properties (bool val);
|
||||
bool is_last_dump_page_properties ();
|
||||
|
||||
void set_master_page_name(const std::wstring & MasterPageName);
|
||||
const std::wstring & get_master_page_name() const;
|
||||
@ -1000,7 +1000,6 @@ private:
|
||||
|
||||
package::docx_document * output_document_;
|
||||
odf_reader::odf_document * odf_document_;
|
||||
NSFonts::IApplicationFonts * applicationFonts_;
|
||||
|
||||
std::vector<odf_reader::_property> settings_properties_;
|
||||
|
||||
|
||||
@ -147,11 +147,11 @@ void word_files::update_rels(docx_conversion_context & Context)
|
||||
Context.dump_notes (rels_files_.get_rel_file()->get_rels());
|
||||
}
|
||||
|
||||
void word_files::set_media(mediaitems & _Mediaitems, NSFonts::IApplicationFonts *pAppFonts)
|
||||
void word_files::set_media(mediaitems & _Mediaitems)
|
||||
{
|
||||
if (_Mediaitems.count_image + _Mediaitems.count_media > 0)
|
||||
{
|
||||
media_ = element_ptr( new media(_Mediaitems, pAppFonts) );
|
||||
media_ = element_ptr( new media(_Mediaitems, _Mediaitems.applicationFonts()) );
|
||||
}
|
||||
if (_Mediaitems.count_object > 0)
|
||||
{
|
||||
|
||||
@ -40,8 +40,6 @@
|
||||
#include "docx_content_type.h"
|
||||
#include "oox_package.h"
|
||||
|
||||
#include "../../../DesktopEditor/graphics/pro/Fonts.h"
|
||||
|
||||
namespace cpdoccore {
|
||||
namespace oox {
|
||||
|
||||
@ -139,7 +137,7 @@ public:
|
||||
void set_numbering (element_ptr Element);
|
||||
void set_settings (element_ptr Element);
|
||||
bool has_numbering ();
|
||||
void set_media (mediaitems & _Mediaitems, NSFonts::IApplicationFonts *pAppFonts);
|
||||
void set_media (mediaitems & mediaitems_);
|
||||
void set_headers_footers(headers_footers & HeadersFooters);
|
||||
void set_notes (notes_context & notesContext);
|
||||
void set_comments (comments_context & commentsContext);
|
||||
|
||||
@ -73,7 +73,8 @@ struct drawing_object_description
|
||||
_oox_fill fill_;
|
||||
|
||||
bool in_group_;
|
||||
|
||||
bool lined_;
|
||||
bool connector_;
|
||||
int shape_type_; //default - frame
|
||||
|
||||
std::vector<drawing_object_description> child_objects_;
|
||||
|
||||
@ -36,7 +36,7 @@
|
||||
|
||||
#include <float.h>
|
||||
|
||||
#include "../../DesktopEditor/graphics/pro/Fonts.h"
|
||||
#include "../../../DesktopEditor/graphics/pro/Fonts.h"
|
||||
|
||||
namespace cpdoccore {
|
||||
namespace utils {
|
||||
|
||||
@ -41,6 +41,7 @@
|
||||
|
||||
#include "../../DesktopEditor/common/Directory.h"
|
||||
#include "../../DesktopEditor/raster/ImageFileFormatChecker.h"
|
||||
#include "../../DesktopEditor/graphics/pro/Fonts.h"
|
||||
|
||||
namespace cpdoccore {
|
||||
namespace oox {
|
||||
@ -74,7 +75,32 @@ mediaitems::item::item( std::wstring const & _href,
|
||||
count_add = 1;
|
||||
count_used = 0;
|
||||
}
|
||||
mediaitems::mediaitems(const std::wstring & odfPacket) : odf_packet_(odfPacket)
|
||||
{
|
||||
count_charts = 0;
|
||||
count_shape = 0;
|
||||
count_image = 0;
|
||||
count_tables = 0;
|
||||
count_media = 0;
|
||||
count_object = 0;
|
||||
count_audio = 0;
|
||||
count_video = 0;
|
||||
count_slide = 0;
|
||||
count_activeX = 0;
|
||||
count_control = 0;
|
||||
|
||||
applicationFonts_ = NSFonts::NSApplication::Create();
|
||||
}
|
||||
mediaitems::~mediaitems()
|
||||
{
|
||||
if (applicationFonts_)
|
||||
delete applicationFonts_;
|
||||
}
|
||||
void mediaitems::set_font_directory(std::wstring pathFonts)
|
||||
{
|
||||
if (applicationFonts_)
|
||||
applicationFonts_->InitializeFromFolder(pathFonts);
|
||||
}
|
||||
std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, bool & isInternal)
|
||||
{
|
||||
std::wstring ref;
|
||||
@ -126,8 +152,8 @@ std::wstring mediaitems::create_file_name(const std::wstring & uri, RelsType typ
|
||||
|
||||
if (sExt.empty())
|
||||
{
|
||||
int n = uri.find(L"ObjectReplacements");
|
||||
if (n >= 0)
|
||||
size_t n = uri.find(L"ObjectReplacements");
|
||||
if (n != std::wstring::npos)
|
||||
{
|
||||
if (!isInternal) return L"";
|
||||
|
||||
@ -138,14 +164,16 @@ std::wstring mediaitems::create_file_name(const std::wstring & uri, RelsType typ
|
||||
if (sExt.empty())
|
||||
{
|
||||
//то что есть ..
|
||||
int n = uri.rfind(L".");
|
||||
if (n > 0)
|
||||
sExt = uri.substr(n);
|
||||
size_t n = uri.rfind(L".");
|
||||
if (n != std::wstring::npos)
|
||||
sExt = XmlUtils::GetLower(uri.substr(n));
|
||||
}
|
||||
}
|
||||
|
||||
if (type == typeOleObject && sExt.empty())
|
||||
sExt = L".bin";
|
||||
else if ( type == typeChart)
|
||||
sExt = L".xml";
|
||||
|
||||
return get_default_file_name(type) + std::to_wstring(Num) + sExt;
|
||||
}
|
||||
@ -167,7 +195,7 @@ std::wstring mediaitems::detectImageFileExtension(const std::wstring &fileName)
|
||||
|
||||
if (!sExt.empty()) sExt = std::wstring(L".") + sExt;
|
||||
}
|
||||
return sExt;
|
||||
return XmlUtils::GetLower(sExt);
|
||||
}
|
||||
|
||||
std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, bool & isInternal, std::wstring & ref)
|
||||
@ -214,8 +242,6 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b
|
||||
|
||||
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";
|
||||
|
||||
std::wstring id;
|
||||
for (size_t i = 0 ; i < items_.size(); i++)
|
||||
@ -242,8 +268,8 @@ std::wstring mediaitems::add_or_find(const std::wstring & href, RelsType type, b
|
||||
}
|
||||
else if ( type == typeImage)
|
||||
{
|
||||
int n_svm = outputPath.rfind (L".svm");
|
||||
if ( n_svm >= 0 )
|
||||
size_t n_svm = outputPath.rfind (L".svm");
|
||||
if ( n_svm != std::wstring::npos )
|
||||
{
|
||||
outputPath = outputPath.substr(0, n_svm) + L".png";
|
||||
}
|
||||
|
||||
@ -33,7 +33,12 @@
|
||||
|
||||
#include "oox_rels.h"
|
||||
|
||||
#include "../../../../Common/DocxFormat/Source/XML/Utils.h"
|
||||
#include "../../../Common/DocxFormat/Source/XML/Utils.h"
|
||||
|
||||
namespace NSFonts
|
||||
{
|
||||
class IApplicationFonts;
|
||||
}
|
||||
|
||||
namespace cpdoccore {
|
||||
namespace oox {
|
||||
@ -41,20 +46,8 @@ namespace oox {
|
||||
class mediaitems
|
||||
{
|
||||
public:
|
||||
mediaitems(const std::wstring & odfPacket) : odf_packet_(odfPacket)
|
||||
{
|
||||
count_charts = 0;
|
||||
count_shape = 0;
|
||||
count_image = 0;
|
||||
count_tables = 0;
|
||||
count_media = 0;
|
||||
count_object = 0;
|
||||
count_audio = 0;
|
||||
count_video = 0;
|
||||
count_slide = 0;
|
||||
count_activeX = 0;
|
||||
count_control = 0;
|
||||
}
|
||||
mediaitems(const std::wstring & odfPacket);
|
||||
virtual ~mediaitems();
|
||||
|
||||
struct item
|
||||
{
|
||||
@ -87,6 +80,9 @@ public:
|
||||
size_t count_activeX;
|
||||
size_t count_control;
|
||||
|
||||
void set_font_directory(std::wstring pathFonts);
|
||||
NSFonts::IApplicationFonts *applicationFonts() {return applicationFonts_;}
|
||||
|
||||
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);
|
||||
|
||||
@ -117,9 +113,9 @@ public:
|
||||
}
|
||||
static RelsType detectMediaType(const std::wstring & fileName)
|
||||
{
|
||||
int pos = fileName.rfind(L".");
|
||||
size_t pos = fileName.rfind(L".");
|
||||
|
||||
std::wstring sExt = (pos >=0 ? fileName.substr(pos + 1) : L"");
|
||||
std::wstring sExt = (pos != std::wstring::npos ? fileName.substr(pos + 1) : L"");
|
||||
|
||||
if (sExt.empty()) return typeMedia;
|
||||
|
||||
@ -147,6 +143,7 @@ private:
|
||||
items_array items_;
|
||||
std::wstring odf_packet_;
|
||||
|
||||
NSFonts::IApplicationFonts *applicationFonts_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@ -108,6 +108,14 @@ static const std::wstring _ooxShapeType[]=
|
||||
L"custGeom",//uses sub-sub type,
|
||||
L"polygon",
|
||||
L"roundRect",
|
||||
L"bentConnector3",
|
||||
L"curvedConnector3",
|
||||
L"",//3-D shape
|
||||
L"",
|
||||
L"polyline",
|
||||
L"cube",
|
||||
L"ellipse", //sphere
|
||||
L""
|
||||
};
|
||||
|
||||
|
||||
@ -243,12 +251,16 @@ void oox_serialize_aLst(std::wostream & strm, const std::vector<odf_reader::_pro
|
||||
{
|
||||
names.push_back(L"adj1");
|
||||
}
|
||||
else if (std::wstring::npos != shapeGeomPreset.find(L"heptagon") ||
|
||||
std::wstring::npos != shapeGeomPreset.find(L"decagon"))
|
||||
{
|
||||
values.clear();
|
||||
}
|
||||
else if (std::wstring::npos != shapeGeomPreset.find(L"decagon"))
|
||||
{
|
||||
names.push_back(L"vf");
|
||||
}
|
||||
else if (std::wstring::npos != shapeGeomPreset.find(L"heptagon") ||
|
||||
std::wstring::npos != shapeGeomPreset.find(L"pentagon"))
|
||||
else if (std::wstring::npos != shapeGeomPreset.find(L"pentagon"))
|
||||
{
|
||||
names.push_back(L"hf");
|
||||
names.push_back(L"vf");
|
||||
@ -418,7 +430,7 @@ void _oox_drawing::serialize_shape(std::wostream & strm)
|
||||
shapeGeomPreset = L"rect";
|
||||
}
|
||||
}
|
||||
else if (sub_type < 10 && sub_type >= 0)
|
||||
else if (sub_type <= 16 && sub_type >= 0)
|
||||
{
|
||||
shapeGeomPreset = _ooxShapeType[sub_type]; //odf -> oox
|
||||
}
|
||||
@ -428,7 +440,7 @@ void _oox_drawing::serialize_shape(std::wostream & strm)
|
||||
|
||||
CP_XML_WRITER(strm)
|
||||
{
|
||||
if (sub_type == 6 || sub_type == 8)
|
||||
if (sub_type == 6 || sub_type == 8 || sub_type == 14)
|
||||
{
|
||||
CP_XML_NODE(L"a:custGeom")
|
||||
{
|
||||
@ -487,7 +499,7 @@ void _oox_drawing::serialize_shape(std::wostream & strm)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (bWordArt)
|
||||
if (bWordArt || lined)
|
||||
{
|
||||
_oox_fill no_fill;
|
||||
oox_serialize_fill(strm, no_fill);
|
||||
@ -512,29 +524,16 @@ void _oox_drawing::serialize_xfrm(std::wostream & strm, const std::wstring & nam
|
||||
|
||||
_CP_OPT(double) dSkewY;
|
||||
odf_reader::GetProperty(additional, L"svg:skewY", dSkewY);
|
||||
|
||||
_CP_OPT(double) dRotateAngle;
|
||||
|
||||
if (dRotate || dSkewX || dSkewY)
|
||||
{
|
||||
double tmp=0;
|
||||
if (dRotate)tmp += *dRotate;
|
||||
//if (dSkewX)tmp += *dSkewX;
|
||||
//if (dSkewY)tmp += (*dSkewY) + 3.1415926;
|
||||
|
||||
dRotateAngle = tmp;
|
||||
}
|
||||
|
||||
CP_XML_NODE(xfrm)
|
||||
{
|
||||
if (dRotateAngle)
|
||||
if (dRotate)
|
||||
{
|
||||
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);
|
||||
double d = 360 - dRotate.get() * 180. / 3.14159265358979323846;
|
||||
CP_XML_ATTR(L"rot", (int)( d * 60000) ); //60 000 per 1 gr - 19.5.5 oox
|
||||
}
|
||||
_CP_OPT(bool)bVal;
|
||||
if (odf_reader::GetProperty(additional,L"flipH", bVal))
|
||||
if (odf_reader::GetProperty(additional, L"flipH", bVal))
|
||||
CP_XML_ATTR(L"flipH", bVal.get());
|
||||
|
||||
if (odf_reader::GetProperty(additional,L"flipV", bVal))
|
||||
|
||||
@ -83,13 +83,15 @@ namespace oox {
|
||||
class _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"), extExternal(false)
|
||||
_oox_drawing() : type(typeUnknown), id(0), x(0), y(0), cx(0), cy(0), sub_type(0), inGroup(false), lined(false), connector(false), name(L"object"), extExternal(false)
|
||||
{
|
||||
}
|
||||
RelsType type;
|
||||
|
||||
bool inGroup;
|
||||
size_t id;
|
||||
bool lined;
|
||||
bool connector;
|
||||
|
||||
std::wstring name;
|
||||
int sub_type; //odf
|
||||
|
||||
@ -37,9 +37,9 @@
|
||||
namespace cpdoccore {
|
||||
namespace oox {
|
||||
|
||||
oox_bitmap_fill::oox_bitmap_fill() : name_space(L"a"), bStretch(false), bCrop(false), bTile(false), isInternal(true)
|
||||
oox_bitmap_fill::oox_bitmap_fill() : name_space(L"a"), bStretch(false), bCrop(false), bTile(false), isInternal(true), bGrayscale(false)
|
||||
{
|
||||
memset(cropRect,0,sizeof(double)*4);
|
||||
memset(cropRect, 0, sizeof(double)*4);
|
||||
}
|
||||
|
||||
oox_bitmap_fill_ptr oox_bitmap_fill::create(){return boost::make_shared<oox_bitmap_fill>();}
|
||||
@ -189,7 +189,19 @@ void oox_serialize_bitmap_fill(std::wostream & strm, const _oox_fill & val, cons
|
||||
{
|
||||
CP_XML_ATTR2(ns_att + L"amt", (int)(*val.opacity * 1000));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (val.bitmap->bGrayscale)
|
||||
{
|
||||
CP_XML_NODE(ns + L":grayscl");
|
||||
}
|
||||
if (val.bitmap->luminance || val.bitmap->contrast)
|
||||
{
|
||||
CP_XML_NODE(ns + L":lum")
|
||||
{
|
||||
if (val.bitmap->luminance) CP_XML_ATTR2(L"bright", (int)(*val.bitmap->luminance * 1000));
|
||||
if (val.bitmap->contrast) CP_XML_ATTR2(L"contrast", (int)(*val.bitmap->contrast * 1000));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (val.bitmap->bCrop)
|
||||
{
|
||||
|
||||
@ -75,6 +75,10 @@ namespace oox {
|
||||
|
||||
_CP_OPT(int) dpi;
|
||||
_CP_OPT(bool) rotate;
|
||||
|
||||
bool bGrayscale;
|
||||
_CP_OPT(double) luminance;
|
||||
_CP_OPT(double) contrast;
|
||||
};
|
||||
/////////////////////////////////////////////////////////
|
||||
class oox_hatch_fill;
|
||||
|
||||
@ -79,14 +79,15 @@ static std::wstring get_mime_type(const std::wstring & extension)
|
||||
else if (L"wav" == extension) return L"audio/wav";
|
||||
else if (L"mp3" == extension) return L"audio/mpeg";
|
||||
else if (L"wma" == extension) return L"audio/x-ms-wma";
|
||||
else if (L"m4a" == extension) return L"audio/unknown";
|
||||
else if (L"m4a" == extension) return L"audio/m4a";
|
||||
|
||||
else if (L"avi" == extension) return L"video/x-msvideo";
|
||||
else if (L"wmv" == extension) return L"video/x-ms-wmv";
|
||||
else if (L"mov" == extension) return L"video/unknown";
|
||||
else if (L"mp4" == extension) return L"video/unknown";
|
||||
else if (L"m4v" == extension) return L"video/unknown";
|
||||
else if (L"mkv" == extension) return L"video/unknown";
|
||||
else if (L"mov" == extension) return L"video/mov";
|
||||
else if (L"mp4" == extension) return L"video/mp4";
|
||||
else if (L"m4v" == extension) return L"video/m4v";
|
||||
else if (L"mkv" == extension) return L"video/mkv";
|
||||
else if (L"webm" == extension) return L"video/webm";
|
||||
|
||||
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";
|
||||
|
||||
@ -42,7 +42,7 @@ namespace oox {
|
||||
|
||||
struct _pptx_comment
|
||||
{
|
||||
size_t x_, y_;
|
||||
int x_, y_;
|
||||
|
||||
int author_id_;
|
||||
int idx_;
|
||||
|
||||
@ -45,8 +45,6 @@
|
||||
|
||||
#include "pptx_default_serializes.h"
|
||||
|
||||
#include "../../DesktopEditor/graphics/pro/Fonts.h"
|
||||
|
||||
namespace cpdoccore {
|
||||
|
||||
namespace odf_reader
|
||||
@ -72,13 +70,10 @@ pptx_conversion_context::pptx_conversion_context( odf_reader::odf_document * odf
|
||||
,last_idx_placeHolder (1)
|
||||
,last_uniq_big_id (1)
|
||||
{
|
||||
applicationFonts_ = NSFonts::NSApplication::Create();
|
||||
}
|
||||
|
||||
pptx_conversion_context::~pptx_conversion_context()
|
||||
{
|
||||
if (applicationFonts_)
|
||||
delete applicationFonts_;
|
||||
}
|
||||
|
||||
void pptx_conversion_context::set_output_document(package::pptx_document * document)
|
||||
@ -88,8 +83,7 @@ void pptx_conversion_context::set_output_document(package::pptx_document * docum
|
||||
|
||||
void pptx_conversion_context::set_font_directory(std::wstring pathFonts)
|
||||
{
|
||||
if (applicationFonts_ )
|
||||
applicationFonts_->InitializeFromFolder(pathFonts);
|
||||
pptx_slide_context_.get_mediaitems().set_font_directory(pathFonts);
|
||||
}
|
||||
|
||||
void pptx_conversion_context::process_layouts()
|
||||
@ -333,7 +327,7 @@ void pptx_conversion_context::end_document()
|
||||
output_document_->get_ppt_files().set_presentation (presentation_);
|
||||
output_document_->get_ppt_files().set_comments (comments);
|
||||
output_document_->get_ppt_files().set_authors_comments (authors_comments_);
|
||||
output_document_->get_ppt_files().set_media (get_mediaitems(), applicationFonts_);
|
||||
output_document_->get_ppt_files().set_media (get_mediaitems());
|
||||
|
||||
output_document_->get_content_types_file().set_media(get_mediaitems());
|
||||
}
|
||||
|
||||
@ -157,7 +157,6 @@ private:
|
||||
|
||||
package::pptx_document * output_document_;
|
||||
odf_reader::odf_document * odf_document_;
|
||||
NSFonts::IApplicationFonts * applicationFonts_;
|
||||
|
||||
pptx_slide_context pptx_slide_context_;
|
||||
pptx_text_context pptx_text_context_;
|
||||
|
||||
@ -212,7 +212,7 @@ void pptx_serialize_shape(std::wostream & strm, _pptx_drawing & val)
|
||||
}
|
||||
CP_XML_NODE(L"p:cNvSpPr")//non visual properies (собственно тока 1 там)
|
||||
{
|
||||
if (val.sub_type==1 || val.sub_type==2)CP_XML_ATTR(L"txBox", 1);
|
||||
if (val.sub_type == 1 || val.sub_type == 2)CP_XML_ATTR(L"txBox", 1);
|
||||
CP_XML_NODE(L"a:spLocks")
|
||||
{
|
||||
CP_XML_ATTR(L"noGrp", 1);
|
||||
@ -254,7 +254,65 @@ void pptx_serialize_shape(std::wostream & strm, _pptx_drawing & val)
|
||||
}
|
||||
} // CP_XML_WRITER
|
||||
}
|
||||
void pptx_serialize_connector(std::wostream & strm, _pptx_drawing & val)
|
||||
{
|
||||
CP_XML_WRITER(strm)
|
||||
{
|
||||
CP_XML_NODE(L"p:cxnSp")
|
||||
{
|
||||
CP_XML_NODE(L"p:nvCxnSpPr")
|
||||
{
|
||||
CP_XML_NODE(L"p:cNvPr")
|
||||
{
|
||||
CP_XML_ATTR(L"id", val.id);//числовое значение val.rId
|
||||
CP_XML_ATTR(L"name", val.name);
|
||||
|
||||
oox_serialize_action(CP_XML_STREAM(), val.action);
|
||||
}
|
||||
CP_XML_NODE(L"p:cNvCxnSpPr")//non visual properies (собственно тока 1 там)
|
||||
{
|
||||
if (val.sub_type == 1 || val.sub_type == 2)CP_XML_ATTR(L"txBox", 1);
|
||||
CP_XML_NODE(L"a:spLocks")
|
||||
{
|
||||
CP_XML_ATTR(L"noGrp", 1);
|
||||
}
|
||||
}
|
||||
CP_XML_NODE(L"p:nvPr")
|
||||
{
|
||||
if (val.place_holder_type_.length()>0)
|
||||
{
|
||||
CP_XML_NODE(L"p:ph")
|
||||
{
|
||||
CP_XML_ATTR(L"type",val.place_holder_type_);
|
||||
if (val.place_holder_idx_ > 0) CP_XML_ATTR(L"idx", val.place_holder_idx_);
|
||||
|
||||
if (val.place_holder_type_ == L"dt") { CP_XML_ATTR(L"sz", L"half"); }
|
||||
if (val.place_holder_type_ == L"ftr") { CP_XML_ATTR(L"sz", L"quarter"); }
|
||||
if (val.place_holder_type_ == L"sldNum"){ CP_XML_ATTR(L"sz", L"quarter"); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
CP_XML_NODE(L"p:spPr")
|
||||
{
|
||||
_CP_OPT(bool) bNoRect;
|
||||
odf_reader::GetProperty(val.additional,L"no_rect",bNoRect);
|
||||
|
||||
if (!bNoRect)
|
||||
{
|
||||
if (val.cx != 0 || val.cy != 0) //layout
|
||||
{
|
||||
val.serialize_xfrm(CP_XML_STREAM(), L"a", true);
|
||||
}
|
||||
val.serialize_shape(CP_XML_STREAM());
|
||||
|
||||
oox_serialize_ln(CP_XML_STREAM(), val.additional);
|
||||
}
|
||||
}
|
||||
pptx_serialize_text(CP_XML_STREAM(), val);
|
||||
}
|
||||
} // CP_XML_WRITER
|
||||
}
|
||||
void pptx_serialize_chart(std::wostream & strm, _pptx_drawing & val)
|
||||
{
|
||||
CP_XML_WRITER(strm)
|
||||
@ -381,7 +439,10 @@ void _pptx_drawing::serialize(std::wostream & strm)
|
||||
{
|
||||
if (type == typeShape)
|
||||
{
|
||||
pptx_serialize_shape(strm, *this);
|
||||
//if (connector) only for ms prst connectors, but not custom!!
|
||||
// pptx_serialize_connector(strm, *this);
|
||||
//else
|
||||
pptx_serialize_shape(strm, *this);
|
||||
}
|
||||
else if (type == typeImage)
|
||||
{
|
||||
|
||||
@ -509,11 +509,11 @@ void ppt_files::add_notesMaster(slide_content_ptr slide)
|
||||
{
|
||||
notesMaster_files_.add_slide(slide);
|
||||
}
|
||||
void ppt_files::set_media(mediaitems & _Mediaitems, NSFonts::IApplicationFonts *pAppFonts)
|
||||
void ppt_files::set_media(mediaitems & _Mediaitems)
|
||||
{
|
||||
if (_Mediaitems.count_image + _Mediaitems.count_media > 0)
|
||||
{
|
||||
media_ = element_ptr( new media(_Mediaitems, pAppFonts) );
|
||||
media_ = element_ptr( new media(_Mediaitems, _Mediaitems.applicationFonts()) );
|
||||
}
|
||||
if (_Mediaitems.count_object > 0)
|
||||
{
|
||||
|
||||
@ -217,7 +217,7 @@ public:
|
||||
void add_notes (slide_content_ptr sheet);
|
||||
void add_notesMaster(slide_content_ptr sheet);
|
||||
|
||||
void set_media(mediaitems & _Mediaitems, NSFonts::IApplicationFonts *pAppFonts);
|
||||
void set_media(mediaitems & _Mediaitems);
|
||||
void add_charts(chart_content_ptr chart);
|
||||
void add_theme (pptx_xml_theme_ptr theme);
|
||||
|
||||
|
||||
@ -147,11 +147,13 @@ void pptx_slide_context::Impl::process_drawings()
|
||||
{
|
||||
for (size_t i = 0; i < objects_.size(); i++)
|
||||
{
|
||||
_pptx_drawing drawing =_pptx_drawing();
|
||||
_pptx_drawing drawing = _pptx_drawing();
|
||||
|
||||
drawing.type = objects_[i].type_;
|
||||
drawing.name = objects_[i].name_;
|
||||
drawing.id = next_rId();
|
||||
drawing.type = objects_[i].type_;
|
||||
drawing.name = objects_[i].name_;
|
||||
drawing.id = next_rId();
|
||||
drawing.lined = objects_[i].lined_;
|
||||
drawing.connector = objects_[i].connector_;
|
||||
|
||||
process_common_properties(objects_[i], drawing);
|
||||
|
||||
@ -228,6 +230,8 @@ void pptx_slide_context::default_set()
|
||||
|
||||
impl_->object_description_.clipping_string_= L"";
|
||||
impl_->object_description_.svg_rect_ = boost::none;
|
||||
impl_->object_description_.connector_ = false;
|
||||
impl_->object_description_.lined_ = false;
|
||||
|
||||
impl_->object_description_.hlinks_.clear();
|
||||
impl_->object_description_.action_.clear();
|
||||
@ -263,21 +267,20 @@ void pptx_slide_context::set_rect(double width_pt, double height_pt, double x_pt
|
||||
impl_->object_description_.svg_rect_ = _rect(width_pt, height_pt, x_pt, y_pt);
|
||||
}
|
||||
|
||||
void pptx_slide_context::set_rotate(double angle)
|
||||
void pptx_slide_context::set_rotate(double angle, bool translate)
|
||||
{
|
||||
set_property(odf_reader::_property(L"svg:rotate",angle));
|
||||
set_property(odf_reader::_property(L"svg:rotate", angle));
|
||||
|
||||
if (impl_->object_description_.svg_rect_)
|
||||
if (impl_->object_description_.svg_rect_ && translate)
|
||||
{
|
||||
//вращение в open office от центральной точки
|
||||
_rect r = impl_->object_description_.svg_rect_.get();
|
||||
//r.x_-=r.width_;
|
||||
//r.y_-=r.height_;
|
||||
|
||||
impl_->object_description_.svg_rect_= r;
|
||||
_rect &r = impl_->object_description_.svg_rect_.get();
|
||||
double new_x = (r.cx / 2 * cos(-angle) - r.cy / 2 * sin(-angle) ) - r.cx / 2;
|
||||
double new_y = (r.cx / 2 * sin(-angle) + r.cy / 2 * cos(-angle) ) - r.cy / 2;
|
||||
|
||||
r.x += new_x;
|
||||
r.y += new_y;
|
||||
}
|
||||
}
|
||||
|
||||
void pptx_slide_context::set_translate(double x_pt, double y_pt)
|
||||
{
|
||||
if (impl_->object_description_.svg_rect_)
|
||||
@ -321,12 +324,18 @@ void pptx_slide_context::set_clipping(const std::wstring & str)
|
||||
{
|
||||
impl_->object_description_.clipping_string_= str;
|
||||
}
|
||||
|
||||
void pptx_slide_context::set_fill(_oox_fill & fill)
|
||||
{
|
||||
impl_->object_description_.fill_= fill;
|
||||
}
|
||||
|
||||
void pptx_slide_context::set_is_line_shape(bool val)
|
||||
{
|
||||
impl_->object_description_.lined_ = val;
|
||||
}
|
||||
void pptx_slide_context::set_is_connector_shape(bool val)
|
||||
{
|
||||
impl_->object_description_.connector_ = val;
|
||||
}
|
||||
std::wstring pptx_slide_context::add_hyperlink(std::wstring const & href)
|
||||
{
|
||||
++hlinks_size_;
|
||||
@ -472,8 +481,8 @@ void pptx_slide_context::set_media_param(std::wstring name, std::wstring value)
|
||||
|
||||
void pptx_slide_context::set_image(const std::wstring & path)
|
||||
{
|
||||
int pos_replaicement = path.find(L"ObjectReplacements");
|
||||
if (pos_replaicement >= 0)
|
||||
size_t pos_replaicement = path.find(L"ObjectReplacements");
|
||||
if (pos_replaicement != std::wstring::npos)
|
||||
{
|
||||
if (path.length() - (pos_replaicement + 18) < 2)
|
||||
return; //object without image
|
||||
@ -486,7 +495,7 @@ void pptx_slide_context::set_image(const std::wstring & path)
|
||||
}
|
||||
else if (impl_->use_image_replacement_)
|
||||
{
|
||||
impl_->object_description_.fill_.type = 2;
|
||||
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;
|
||||
@ -538,8 +547,14 @@ void pptx_slide_context::Impl::process_image(drawing_object_description& obj, _p
|
||||
drawing.fill.bitmap = oox_bitmap_fill::create();
|
||||
drawing.fill.type = 2;
|
||||
|
||||
_CP_OPT(std::wstring) sTextContent;
|
||||
_CP_OPT(std::wstring) sTextContent, sColorMode;
|
||||
_CP_OPT(double) dLuminance, dContrast;
|
||||
|
||||
GetProperty(obj.additional_, L"text-content", sTextContent);
|
||||
GetProperty(obj.additional_, L"color-mode", sColorMode);
|
||||
GetProperty(obj.additional_, L"luminance", drawing.fill.bitmap->luminance);
|
||||
GetProperty(obj.additional_, L"contrast", drawing.fill.bitmap->contrast);
|
||||
|
||||
if (sTextContent)//в ms office на картинке нельзя сделать надпись - меняем тип на рект с заливкой картинкой
|
||||
{
|
||||
drawing.type = typeShape;
|
||||
@ -547,8 +562,11 @@ void pptx_slide_context::Impl::process_image(drawing_object_description& obj, _p
|
||||
}
|
||||
|
||||
std::wstring fileName = odfPacket_ + FILE_SEPARATOR_STR + obj.xlink_href_;
|
||||
drawing.fill.bitmap->bCrop = odf_reader::parse_clipping(obj.clipping_string_, fileName, drawing.fill.bitmap->cropRect, NULL);
|
||||
drawing.fill.bitmap->bCrop = odf_reader::parse_clipping(obj.clipping_string_, fileName, drawing.fill.bitmap->cropRect, get_mediaitems().applicationFonts());
|
||||
drawing.fill.bitmap->bStretch = true;
|
||||
|
||||
if ((sColorMode) && (*sColorMode == L"greyscale"))
|
||||
drawing.fill.bitmap->luminance = true;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
std::wstring ref;/// это ссылка на выходной внешний объект
|
||||
@ -626,25 +644,29 @@ void pptx_slide_context::Impl::process_shape(drawing_object_description & obj, _
|
||||
}
|
||||
void pptx_slide_context::Impl::process_object(drawing_object_description& obj, _pptx_drawing & drawing)
|
||||
{
|
||||
std::wstring ref;
|
||||
bool isMediaInternal = true;
|
||||
std::wstring ref, ref_image;
|
||||
bool isMediaInternal = true, isMediaInternal_image = true;
|
||||
|
||||
drawing.objectId = get_mediaitems().add_or_find(obj.xlink_href_, obj.type_, isMediaInternal, ref);
|
||||
drawing.objectProgId = obj.descriptor_;
|
||||
|
||||
add_drawing(drawing, isMediaInternal, drawing.objectId, ref, drawing.type);
|
||||
|
||||
if (drawing.fill.bitmap)
|
||||
if (!drawing.fill.bitmap)
|
||||
{
|
||||
drawing.fill.bitmap->rId = get_mediaitems().add_or_find(drawing.fill.bitmap->xlink_href_, typeImage, isMediaInternal, ref);
|
||||
drawing.fill.bitmap = oox::oox_bitmap_fill::create();
|
||||
drawing.fill.bitmap->xlink_href_ = L"zero.png";
|
||||
|
||||
add_additional_rels(isMediaInternal, drawing.fill.bitmap->rId, ref, typeImage);
|
||||
_image_file_::GenerateZeroImage(odfPacket_ + FILE_SEPARATOR_STR + L"zero.png");
|
||||
}
|
||||
|
||||
drawing.fill.bitmap->rId = get_mediaitems().add_or_find(drawing.fill.bitmap->xlink_href_, typeImage, isMediaInternal_image, ref_image);
|
||||
add_additional_rels(isMediaInternal_image, drawing.fill.bitmap->rId, ref_image, typeImage);
|
||||
|
||||
add_drawing(drawing, isMediaInternal, drawing.objectId, ref, drawing.type);
|
||||
}
|
||||
void pptx_slide_context::Impl::process_media(drawing_object_description& obj, _pptx_drawing & drawing)
|
||||
{
|
||||
std::wstring ref;
|
||||
bool isMediaInternal = true;
|
||||
std::wstring ref, ref_image;
|
||||
bool isMediaInternal = true, isMediaInternal_image = true;
|
||||
|
||||
drawing.type = mediaitems::detectMediaType(obj.xlink_href_); //reset from Media to Audio, Video, ... QuickTime? AudioCD? ...
|
||||
|
||||
@ -652,26 +674,27 @@ void pptx_slide_context::Impl::process_media(drawing_object_description& obj, _p
|
||||
drawing.extId = L"ext" + drawing.objectId;
|
||||
drawing.extExternal = !isMediaInternal;
|
||||
|
||||
if (!drawing.fill.bitmap)
|
||||
{
|
||||
drawing.fill.bitmap = oox::oox_bitmap_fill::create();
|
||||
drawing.fill.bitmap->xlink_href_ = L"zero.png";
|
||||
|
||||
_image_file_::GenerateZeroImage(odfPacket_ + FILE_SEPARATOR_STR + L"zero.png");
|
||||
}
|
||||
drawing.fill.bitmap->rId = get_mediaitems().add_or_find(drawing.fill.bitmap->xlink_href_, typeImage, isMediaInternal_image, ref_image);
|
||||
add_additional_rels(isMediaInternal_image, drawing.fill.bitmap->rId, ref_image, typeImage);
|
||||
|
||||
add_drawing(drawing, false, drawing.objectId, L"NULL", drawing.type);
|
||||
add_additional_rels( isMediaInternal, drawing.extId, ref, typeMedia);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
void pptx_slide_context::Impl::process_common_properties(drawing_object_description & pic, _pptx_drawing & drawing)
|
||||
{
|
||||
if (pic.svg_rect_)
|
||||
{
|
||||
int val;
|
||||
//todooo непонятки с отрицательными значениями
|
||||
int val = (int)(0.5 + odf_types::length(pic.svg_rect_->x, odf_types::length::pt).get_value_unit(odf_types::length::emu));
|
||||
if ( val >= 0) drawing.x = val;
|
||||
|
||||
val = (int)(0.5 + odf_types::length(pic.svg_rect_->y, odf_types::length::pt).get_value_unit(odf_types::length::emu));
|
||||
if ( val >= 0 ) drawing.y = val;
|
||||
drawing.x = (int)(0.5 + odf_types::length(pic.svg_rect_->x, odf_types::length::pt).get_value_unit(odf_types::length::emu));
|
||||
drawing.y = (int)(0.5 + odf_types::length(pic.svg_rect_->y, odf_types::length::pt).get_value_unit(odf_types::length::emu));
|
||||
|
||||
val = (int)(0.5 + odf_types::length(pic.svg_rect_->cx, odf_types::length::pt).get_value_unit(odf_types::length::emu));
|
||||
if ( val >=0 ) drawing.cx = val;
|
||||
|
||||
@ -59,11 +59,11 @@ public:
|
||||
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_rotate (double angle, bool translate = false);
|
||||
|
||||
void set_name (std::wstring const & name);
|
||||
void set_anchor (std::wstring anchor, double x_pt, double y_pt);
|
||||
@ -72,6 +72,9 @@ public:
|
||||
void set_clipping (const std::wstring & str );
|
||||
void set_fill (_oox_fill & fill);
|
||||
|
||||
void set_is_line_shape(bool val);
|
||||
void set_is_connector_shape(bool val);
|
||||
|
||||
void set_placeHolder_type (std::wstring typeHolder);
|
||||
void set_placeHolder_idx (int idx);
|
||||
|
||||
|
||||
@ -99,7 +99,6 @@ private:
|
||||
|
||||
odf_reader::odf_read_context & odf_context_ ;
|
||||
std::wstring hyperlink_hId;
|
||||
|
||||
|
||||
bool in_span;
|
||||
bool in_paragraph;
|
||||
@ -275,7 +274,7 @@ void pptx_text_context::Impl::ApplyTextProperties(std::wstring style_name, std::
|
||||
|
||||
void pptx_text_context::Impl::ApplyListProperties(odf_reader::paragraph_format_properties & propertiesOut, int Level)
|
||||
{
|
||||
if (Level <0)return;
|
||||
if (Level < 0)return;
|
||||
if (list_style_stack_.empty())return;
|
||||
|
||||
odf_reader::style_list_level_properties *list_properties= NULL;
|
||||
@ -362,7 +361,7 @@ void pptx_text_context::Impl::write_pPr(std::wostream & strm)
|
||||
{
|
||||
get_styles_context().start();
|
||||
|
||||
int level = list_style_stack_.size()-1;
|
||||
int level = list_style_stack_.size() - 1;
|
||||
|
||||
odf_reader::paragraph_format_properties paragraph_properties_;
|
||||
|
||||
@ -643,7 +642,7 @@ void pptx_text_context::Impl::start_list_item(bool restart)
|
||||
|
||||
void pptx_text_context::Impl::start_list(const std::wstring & StyleName, bool Continue)
|
||||
{
|
||||
if (paragraphs_cout_ > 0 && in_paragraph)
|
||||
if (paragraphs_cout_ > 0 && ( in_paragraph || list_style_stack_.empty()))
|
||||
{
|
||||
dump_paragraph();
|
||||
}
|
||||
|
||||
@ -36,8 +36,10 @@
|
||||
#include <vector>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <xml/simple_xml_writer.h>
|
||||
#include "../../../Common/DocxFormat/Source/XML/Utils.h"
|
||||
|
||||
#include "../formulasconvert/formulasconvert.h"
|
||||
|
||||
namespace cpdoccore {
|
||||
namespace oox {
|
||||
|
||||
@ -148,7 +150,10 @@ public:
|
||||
//CP_XML_ATTR(L"aboveAverage" , 0);
|
||||
if (c.rules[j].type == 1)
|
||||
{
|
||||
CP_XML_ATTR(L"type", *c.rules[j].formula_type);
|
||||
if (c.rules[j].formula_type)
|
||||
CP_XML_ATTR(L"type", *c.rules[j].formula_type);
|
||||
else
|
||||
CP_XML_ATTR(L"type", L"cellIs");
|
||||
if ((c.rules[j].formula) && (!c.rules[j].formula->empty()))
|
||||
{
|
||||
CP_XML_NODE(L"formula")
|
||||
@ -177,13 +182,11 @@ public:
|
||||
{
|
||||
c.rules[j].cfvo[k].serialize(CP_XML_STREAM());
|
||||
}
|
||||
if (c.rules[j].color.size() > 0)
|
||||
|
||||
CP_XML_NODE(L"color")
|
||||
{
|
||||
CP_XML_NODE(L"color")
|
||||
{
|
||||
CP_XML_ATTR(L"rgb", c.rules[j].color[0]);
|
||||
}
|
||||
}
|
||||
CP_XML_ATTR(L"rgb", !c.rules[j].color.empty() ? c.rules[j].color[0] : L"FF000000");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (c.rules[j].type == 3)
|
||||
@ -245,7 +248,7 @@ void xlsx_conditionalFormatting_context::add(std::wstring ref)
|
||||
formulasconvert::odf2oox_converter converter;
|
||||
impl_->conditionalFormattings_.push_back(conditionalFormatting());
|
||||
|
||||
impl_->conditionalFormattings_.back().ref = converter.convert_named_ref(ref, false, L";");
|
||||
impl_->conditionalFormattings_.back().ref = converter.convert_named_ref(ref, false, L" ");
|
||||
}
|
||||
|
||||
void xlsx_conditionalFormatting_context::add_rule(int type)
|
||||
@ -260,7 +263,21 @@ void xlsx_conditionalFormatting_context::set_formula(std::wstring f)
|
||||
int pos = -1;
|
||||
std::wstring val;
|
||||
|
||||
if ( 0 <= (pos = f.find(L"formula-is(")))
|
||||
if ( f == L"unique")
|
||||
{
|
||||
impl_->conditionalFormattings_.back().rules.back().formula_type = L"uniqueValues";
|
||||
impl_->conditionalFormattings_.back().rules.back().formula = L"0";
|
||||
}
|
||||
else if ( f == L"duplicate")
|
||||
{
|
||||
impl_->conditionalFormattings_.back().rules.back().formula_type = L"duplicateValues";
|
||||
impl_->conditionalFormattings_.back().rules.back().formula = L"0";
|
||||
}
|
||||
else if ( f == L"above-average")
|
||||
{
|
||||
impl_->conditionalFormattings_.back().rules.back().formula_type = L"aboveAverage";
|
||||
}
|
||||
else if ( 0 <= (pos = f.find(L"formula-is(")))
|
||||
{
|
||||
impl_->conditionalFormattings_.back().rules.back().formula_type = L"expression";
|
||||
val = f.substr(11, f.size() - 12);
|
||||
@ -292,6 +309,45 @@ void xlsx_conditionalFormatting_context::set_formula(std::wstring f)
|
||||
{
|
||||
impl_->conditionalFormattings_.back().rules.back().formula_type = L"duplicateValues";
|
||||
}
|
||||
else if (0 <= (pos = f.find(L"contains-text")))
|
||||
{
|
||||
impl_->conditionalFormattings_.back().rules.back().formula_type = L"containsText";
|
||||
|
||||
std::wstring text = f.substr(14, f.length() - 15);
|
||||
|
||||
if (std::wstring::npos != text.find(L"IF(") ||
|
||||
std::wstring::npos != text.find(L"AND(") ||
|
||||
std::wstring::npos != text.find(L"NOT(") ||
|
||||
std::wstring::npos != text.find(L"ISERROR(") ||
|
||||
std::wstring::npos != text.find(L"SEARCH("))
|
||||
{
|
||||
impl_->conditionalFormattings_.back().rules.back().text = L"";
|
||||
impl_->conditionalFormattings_.back().rules.back().formula = converter.convert(text);
|
||||
}
|
||||
else if (std::wstring::npos != text.find(L"LEN(TRIM(") &&
|
||||
std::wstring::npos != text.find(L"=0"))
|
||||
{
|
||||
impl_->conditionalFormattings_.back().rules.back().text = L"";
|
||||
impl_->conditionalFormattings_.back().rules.back().formula = L"0";
|
||||
}
|
||||
else
|
||||
{
|
||||
impl_->conditionalFormattings_.back().rules.back().operator_ = L"containsText";
|
||||
if ( 0 == text.find(L"\"") && text.length() - 1 == text.rfind(L"\""))
|
||||
{
|
||||
text = text.substr(1, text.length() - 2);
|
||||
}
|
||||
std::wstring ref = impl_->conditionalFormattings_.back().ref;
|
||||
|
||||
size_t pos;
|
||||
if ((pos = ref.find(L":")) != std::wstring::npos)
|
||||
{
|
||||
ref = ref.substr(0, pos);
|
||||
}
|
||||
impl_->conditionalFormattings_.back().rules.back().text = text;
|
||||
impl_->conditionalFormattings_.back().rules.back().formula = L"NOT(ISERROR(SEARCH(\"" + text + L"\"," + ref + L")))";
|
||||
}
|
||||
}
|
||||
else if (0 <= (pos = f.find(L"top")))
|
||||
{
|
||||
impl_->conditionalFormattings_.back().rules.back().formula_type = L"top10";
|
||||
@ -302,14 +358,10 @@ void xlsx_conditionalFormatting_context::set_formula(std::wstring f)
|
||||
if (0 <= (pos = f.find(L"(")))
|
||||
{
|
||||
val = f.substr(pos + 1, f.length() - pos - 2);
|
||||
impl_->conditionalFormattings_.back().rules.back().rank = boost::lexical_cast<int>(val);
|
||||
if (!val.empty())
|
||||
impl_->conditionalFormattings_.back().rules.back().rank = boost::lexical_cast<int>(val);
|
||||
}
|
||||
}
|
||||
else if (0 <= (pos = f.find(L"contains-text")))
|
||||
{
|
||||
impl_->conditionalFormattings_.back().rules.back().formula_type = L"containsText";
|
||||
impl_->conditionalFormattings_.back().rules.back().text = f.substr(15, f.length() - 17);
|
||||
}
|
||||
else
|
||||
{
|
||||
impl_->conditionalFormattings_.back().rules.back().formula_type = L"cellIs";
|
||||
@ -361,6 +413,8 @@ void xlsx_conditionalFormatting_context::set_formula(std::wstring f)
|
||||
impl_->conditionalFormattings_.back().rules.back().operator_ = L"between";
|
||||
val = f.substr(8, f.length() - 9);
|
||||
|
||||
XmlUtils::replace_all(val, L"(", L"");
|
||||
XmlUtils::replace_all(val, L")", L"");
|
||||
if (0 <= (pos = val.find(L",")))
|
||||
{
|
||||
impl_->conditionalFormattings_.back().rules.back().formula2 = converter.convert_named_expr( val.substr(pos + 1) );
|
||||
@ -398,7 +452,11 @@ void xlsx_conditionalFormatting_context::add_sfv(int type, std::wstring value)
|
||||
|
||||
impl_->conditionalFormattings_.back().rules.back().formula.reset();
|
||||
}
|
||||
else if (!value.empty()) cfvo.val = value;
|
||||
else
|
||||
{
|
||||
if (!value.empty()) cfvo.val = value;
|
||||
else cfvo.val = L"0";
|
||||
}
|
||||
|
||||
impl_->conditionalFormattings_.back().rules.back().cfvo.push_back(cfvo);
|
||||
}
|
||||
|
||||
@ -45,13 +45,6 @@ class xlsx_defined_names::Impl
|
||||
public:
|
||||
void add(std::wstring const & name, std::wstring const & ref, bool formula, int tableId)
|
||||
{
|
||||
int is_file_link = 0;
|
||||
|
||||
if (!formula)
|
||||
{
|
||||
if ((is_file_link = ref.find(L"\\")) >=0) return;
|
||||
if ((is_file_link = ref.find(L"/")) >=0) return;
|
||||
}
|
||||
formulasconvert::odf2oox_converter converter;
|
||||
std::wstring oox_ref;
|
||||
|
||||
@ -72,34 +65,31 @@ public:
|
||||
|
||||
void xlsx_serialize(std::wostream & _Wostream)
|
||||
{
|
||||
if (content_.size() > 0)
|
||||
if (content_.empty()) return;
|
||||
|
||||
CP_XML_WRITER(_Wostream)
|
||||
{
|
||||
CP_XML_WRITER(_Wostream)
|
||||
CP_XML_NODE(L"definedNames")
|
||||
{
|
||||
CP_XML_NODE(L"definedNames")
|
||||
for (size_t i = 0 ; i < content_.size(); i++)
|
||||
{
|
||||
for (size_t i = 0 ; i < content_.size(); i++)
|
||||
CP_XML_NODE(L"definedName")
|
||||
{
|
||||
CP_XML_NODE(L"definedName")
|
||||
{
|
||||
CP_XML_ATTR(L"name", content_[i].name);
|
||||
|
||||
if (content_[i].tableId >= 0)
|
||||
{
|
||||
CP_XML_ATTR(L"localSheetId", content_[i].tableId);
|
||||
}
|
||||
|
||||
int pos;
|
||||
if ( (pos = content_[i].ref.find(L"#REF!")) >= 0 )
|
||||
{
|
||||
CP_XML_ATTR(L"comment", content_[i].ref);
|
||||
CP_XML_CONTENT(L"#REF!");
|
||||
}
|
||||
else
|
||||
CP_XML_CONTENT(content_[i].ref);
|
||||
CP_XML_ATTR(L"name", content_[i].name);
|
||||
|
||||
if (content_[i].tableId >= 0)
|
||||
{
|
||||
CP_XML_ATTR(L"localSheetId", content_[i].tableId);
|
||||
}
|
||||
|
||||
if ( content_[i].ref.find(L"#REF!") != std::wstring::npos )
|
||||
{
|
||||
CP_XML_ATTR(L"comment", content_[i].ref);
|
||||
CP_XML_CONTENT(L"#REF!");
|
||||
}
|
||||
else
|
||||
CP_XML_CONTENT(content_[i].ref);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,7 +46,6 @@ namespace oox {
|
||||
xlsx_defined_names();
|
||||
~xlsx_defined_names();
|
||||
|
||||
public:
|
||||
void add(std::wstring const & name, std::wstring const & ref, bool formula, int tableId);
|
||||
void xlsx_serialize(std::wostream & _Wostream);
|
||||
|
||||
|
||||
@ -162,7 +162,7 @@ void xlsx_serialize_shape(std::wostream & strm, _xlsx_drawing & val)
|
||||
}
|
||||
CP_XML_NODE(L"xdr:cNvSpPr")//non visual properies (собственно тока 1 там)
|
||||
{
|
||||
if (val.sub_type==1)CP_XML_ATTR(L"txBox", 1);
|
||||
if (val.sub_type == 1)CP_XML_ATTR(L"txBox", 1);
|
||||
}
|
||||
} // xdr:nv_Pr
|
||||
CP_XML_NODE(L"xdr:spPr")
|
||||
@ -171,11 +171,7 @@ void xlsx_serialize_shape(std::wostream & strm, _xlsx_drawing & val)
|
||||
|
||||
val.serialize_shape(CP_XML_STREAM());
|
||||
|
||||
bool draw_always = false;
|
||||
if (val.sub_type == 5 || val.sub_type == 6)//line собственно ) - если ее нет - в свойствах будет
|
||||
draw_always = true;
|
||||
|
||||
oox_serialize_ln(CP_XML_STREAM(),val.additional, draw_always);
|
||||
oox_serialize_ln(CP_XML_STREAM(),val.additional, val.lined);
|
||||
} // xdr:spPr
|
||||
|
||||
xlsx_serialize_text(CP_XML_STREAM(), val);
|
||||
|
||||
@ -53,8 +53,7 @@ namespace oox {
|
||||
class xlsx_drawing_context_handle::Impl
|
||||
{
|
||||
public:
|
||||
Impl(mediaitems & items)
|
||||
: items_(items), next_rId_(1), next_drawing_id_(1)
|
||||
Impl(mediaitems & items) : items_(items), next_rId_(1), next_drawing_id_(1)
|
||||
{
|
||||
}
|
||||
|
||||
@ -162,6 +161,8 @@ void xlsx_drawing_context::clear()
|
||||
{
|
||||
impl_->object_description_.type_ = typeUnknown;
|
||||
impl_->object_description_.in_group_ = false;
|
||||
impl_->object_description_.lined_ = false;
|
||||
impl_->object_description_.connector_ = false;
|
||||
impl_->object_description_.xlink_href_ = L"";
|
||||
impl_->object_description_.name_ = L"";
|
||||
impl_->object_description_.anchor_ = L"";
|
||||
@ -202,20 +203,25 @@ void xlsx_drawing_context::end_group()
|
||||
{
|
||||
if (impl_->groups_.size() < 1) return;
|
||||
|
||||
_rect & group_rect = impl_->groups_.back()->svg_rect_.get();
|
||||
|
||||
group_rect.cy -= group_rect.y;
|
||||
group_rect.cx -= group_rect.x;
|
||||
|
||||
for (size_t i = 0; i < impl_->groups_.back()->child_objects_.size(); i++)
|
||||
if (impl_->groups_.back()->svg_rect_)
|
||||
{
|
||||
_rect & r = impl_->groups_.back()->child_objects_[i].svg_rect_.get();
|
||||
|
||||
r.y -= group_rect.y;
|
||||
r.x -= group_rect.x;
|
||||
_rect & group_rect = impl_->groups_.back()->svg_rect_.get();
|
||||
|
||||
group_rect.cy -= group_rect.y;
|
||||
group_rect.cx -= group_rect.x;
|
||||
|
||||
for (size_t i = 0; i < impl_->groups_.back()->child_objects_.size(); i++)
|
||||
{
|
||||
if (!impl_->groups_.back()->child_objects_[i].svg_rect_) continue;
|
||||
|
||||
_rect & r = impl_->groups_.back()->child_objects_[i].svg_rect_.get();
|
||||
|
||||
r.y -= group_rect.y;
|
||||
r.x -= group_rect.x;
|
||||
}
|
||||
}
|
||||
|
||||
if (impl_->groups_.back()->in_group_)
|
||||
if (impl_->groups_.back()->in_group_ && impl_->groups_.back()->svg_rect_)
|
||||
{
|
||||
_rect & objct_rect = impl_->groups_.back()->svg_rect_.get();
|
||||
|
||||
@ -251,7 +257,8 @@ void xlsx_drawing_context::start_drawing(std::wstring const & name)
|
||||
|
||||
void xlsx_drawing_context::end_drawing()
|
||||
{
|
||||
if (impl_->object_description_.in_group_)
|
||||
if (impl_->object_description_.in_group_ &&
|
||||
impl_->object_description_.svg_rect_)
|
||||
{
|
||||
_rect & objct_rect = impl_->object_description_.svg_rect_.get();
|
||||
_rect & group_rect = impl_->groups_.back()->svg_rect_.get();
|
||||
@ -354,17 +361,18 @@ void xlsx_drawing_context::set_translate(double x_pt, double y_pt)
|
||||
}
|
||||
}
|
||||
|
||||
void xlsx_drawing_context::set_rotate(double angle)
|
||||
void xlsx_drawing_context::set_rotate(double angle, bool translate)
|
||||
{
|
||||
set_property(odf_reader::_property(L"svg:rotate", angle));
|
||||
|
||||
if (impl_->object_description_.svg_rect_)
|
||||
if (impl_->object_description_.svg_rect_ && translate)
|
||||
{
|
||||
_rect & r = impl_->object_description_.svg_rect_.get();
|
||||
_rect &r = impl_->object_description_.svg_rect_.get();
|
||||
double new_x = (r.cx / 2 * cos(-angle) - r.cy / 2 * sin(-angle) ) - r.cx / 2;
|
||||
double new_y = (r.cx / 2 * sin(-angle) + r.cy / 2 * cos(-angle) ) - r.cy / 2;
|
||||
|
||||
//r.x -= r.width_/2;
|
||||
//r.y -= r.height_/2;
|
||||
|
||||
r.x += new_x;
|
||||
r.y += new_y;
|
||||
}
|
||||
}
|
||||
void xlsx_drawing_context::set_scale(double cx_pt, double cy_pt)
|
||||
@ -533,8 +541,12 @@ void xlsx_drawing_context::process_image(drawing_object_description & obj, _xlsx
|
||||
drawing.fill.bitmap = oox_bitmap_fill::create();
|
||||
drawing.fill.type = 2;
|
||||
}
|
||||
_CP_OPT(std::wstring) sTextContent;
|
||||
GetProperty(obj.additional_,L"text-content",sTextContent);
|
||||
_CP_OPT(std::wstring) sTextContent, sColorMode;
|
||||
|
||||
GetProperty(obj.additional_, L"text-content", sTextContent);
|
||||
GetProperty(obj.additional_, L"color-mode", sColorMode);
|
||||
GetProperty(obj.additional_, L"luminance", drawing.fill.bitmap->luminance);
|
||||
GetProperty(obj.additional_, L"contrast", drawing.fill.bitmap->contrast);
|
||||
|
||||
if (sTextContent)//в ms office на картинке нельзя сделать надпись - меняем тип на рект с заливкой картинкой
|
||||
{
|
||||
@ -543,9 +555,12 @@ void xlsx_drawing_context::process_image(drawing_object_description & obj, _xlsx
|
||||
}
|
||||
std::wstring fileName = odf_packet_path_ + FILE_SEPARATOR_STR + obj.xlink_href_;
|
||||
|
||||
drawing.fill.bitmap->bCrop = odf_reader::parse_clipping(obj.clipping_string_, fileName, drawing.fill.bitmap->cropRect, NULL/*applicationFonts_*/);
|
||||
drawing.fill.bitmap->bCrop = odf_reader::parse_clipping(obj.clipping_string_, fileName, drawing.fill.bitmap->cropRect, impl_->get_mediaitems().applicationFonts());
|
||||
drawing.fill.bitmap->bStretch = true;
|
||||
|
||||
if ((sColorMode) && (*sColorMode == L"greyscale"))
|
||||
drawing.fill.bitmap->bGrayscale = true;
|
||||
|
||||
std::wstring ref;/// это ссылка на выходной внешний объект
|
||||
bool isMediaInternal = false;
|
||||
|
||||
@ -662,11 +677,13 @@ void xlsx_drawing_context::process_group_objects(std::vector<drawing_object_desc
|
||||
|
||||
_xlsx_drawing drawing =_xlsx_drawing();
|
||||
|
||||
drawing.type = obj.type_;
|
||||
drawing.name = obj.name_;
|
||||
drawing.fill = obj.fill_;
|
||||
drawing.inGroup = obj.in_group_;
|
||||
drawing.id = impl_->next_rId();
|
||||
drawing.type = obj.type_;
|
||||
drawing.name = obj.name_;
|
||||
drawing.fill = obj.fill_;
|
||||
drawing.inGroup = obj.in_group_;
|
||||
drawing.id = impl_->next_rId();
|
||||
drawing.lined = obj.lined_;
|
||||
drawing.connector = obj.connector_;
|
||||
|
||||
drawing.sub_type = obj.shape_type_;
|
||||
|
||||
@ -730,6 +747,14 @@ void xlsx_drawing_context::set_link(std::wstring link, RelsType typeRels)
|
||||
void xlsx_drawing_context::end_action()
|
||||
{
|
||||
}
|
||||
void xlsx_drawing_context::set_is_line_shape(bool val)
|
||||
{
|
||||
impl_->object_description_.lined_ = val;
|
||||
}
|
||||
void xlsx_drawing_context::set_is_connector_shape(bool val)
|
||||
{
|
||||
impl_->object_description_.connector_ = val;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -103,13 +103,16 @@ public:
|
||||
|
||||
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_rotate (double angle, bool translate = false);
|
||||
|
||||
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_is_line_shape(bool val);
|
||||
void set_is_connector_shape(bool val);
|
||||
|
||||
std::vector<odf_reader::_property> & get_properties();
|
||||
|
||||
std::wstring add_hyperlink(std::wstring const & ref);
|
||||
|
||||
@ -41,8 +41,9 @@ namespace oox {
|
||||
class xlsx_xml_worksheet::Impl
|
||||
{
|
||||
public:
|
||||
Impl(std::wstring const & name) : name_(name){}
|
||||
Impl(std::wstring const & name, bool hidden) : name_(name), hidden_(hidden) {}
|
||||
std::wstring name_;
|
||||
bool hidden_;
|
||||
|
||||
std::wstringstream cols_;
|
||||
std::wstringstream sheetFormat_;
|
||||
@ -52,6 +53,7 @@ public:
|
||||
std::wstringstream hyperlinks_;
|
||||
std::wstringstream comments_;
|
||||
std::wstringstream sort_;
|
||||
std::wstringstream tableParts_;
|
||||
std::wstringstream autofilter_;
|
||||
std::wstringstream conditionalFormatting_;
|
||||
std::wstringstream picture_background_;
|
||||
@ -59,6 +61,7 @@ public:
|
||||
std::wstringstream ole_objects_;
|
||||
std::wstringstream page_props_;
|
||||
std::wstringstream controls_;
|
||||
std::wstringstream protection_;
|
||||
|
||||
rels sheet_rels_;
|
||||
|
||||
@ -76,14 +79,18 @@ std::wstring xlsx_xml_worksheet::name() const
|
||||
{
|
||||
return impl_->name_;
|
||||
}
|
||||
|
||||
xlsx_xml_worksheet_ptr xlsx_xml_worksheet::create(std::wstring const & name)
|
||||
bool xlsx_xml_worksheet::hidden() const
|
||||
{
|
||||
return boost::make_shared<xlsx_xml_worksheet>(name);
|
||||
return impl_->hidden_;
|
||||
}
|
||||
|
||||
xlsx_xml_worksheet::xlsx_xml_worksheet(std::wstring const & name)
|
||||
: impl_(new xlsx_xml_worksheet::Impl(name))
|
||||
xlsx_xml_worksheet_ptr xlsx_xml_worksheet::create(std::wstring const & name, bool hidden)
|
||||
{
|
||||
return boost::make_shared<xlsx_xml_worksheet>(name, hidden);
|
||||
}
|
||||
|
||||
xlsx_xml_worksheet::xlsx_xml_worksheet(std::wstring const & name, bool hidden)
|
||||
: impl_(new xlsx_xml_worksheet::Impl(name, hidden))
|
||||
{
|
||||
}
|
||||
|
||||
@ -99,16 +106,18 @@ std::wostream & xlsx_xml_worksheet::sheetFormat()
|
||||
{
|
||||
return impl_->sheetFormat_;
|
||||
}
|
||||
|
||||
std::wostream & xlsx_xml_worksheet::sheetData()
|
||||
{
|
||||
return impl_->sheetData_;
|
||||
}
|
||||
|
||||
std::wostream & xlsx_xml_worksheet::mergeCells()
|
||||
{
|
||||
return impl_->mergeCells_;
|
||||
}
|
||||
std::wostream & xlsx_xml_worksheet::tableParts()
|
||||
{
|
||||
return impl_->tableParts_;
|
||||
}
|
||||
std::wostream & xlsx_xml_worksheet::conditionalFormatting()
|
||||
{
|
||||
return impl_->conditionalFormatting_;
|
||||
@ -153,6 +162,10 @@ std::wostream & xlsx_xml_worksheet::dataValidations()
|
||||
{
|
||||
return impl_->dataValidations_;
|
||||
}
|
||||
std::wostream & xlsx_xml_worksheet::protection()
|
||||
{
|
||||
return impl_->protection_;
|
||||
}
|
||||
//---------------------------------------------------------------------------------------
|
||||
rels & xlsx_xml_worksheet::sheet_rels()
|
||||
{
|
||||
@ -181,6 +194,10 @@ void xlsx_xml_worksheet::write_to(std::wostream & strm)
|
||||
{
|
||||
CP_XML_STREAM() << impl_->sheetData_.str();
|
||||
}
|
||||
if (!impl_->protection_.str().empty())
|
||||
{
|
||||
CP_XML_STREAM() << impl_->protection_.str();
|
||||
}
|
||||
//оказывается порядок нахождения элементов важен !!! (для office 2010)
|
||||
//объединенные ячейки раньше чем гиперлинки !!!
|
||||
|
||||
@ -200,7 +217,6 @@ void xlsx_xml_worksheet::write_to(std::wostream & strm)
|
||||
CP_XML_STREAM() << impl_->hyperlinks_.str();
|
||||
}
|
||||
}
|
||||
|
||||
if (!impl_->page_props_.str().empty())
|
||||
{
|
||||
CP_XML_STREAM() << impl_->page_props_.str();
|
||||
@ -229,6 +245,13 @@ void xlsx_xml_worksheet::write_to(std::wostream & strm)
|
||||
CP_XML_STREAM() << impl_->controls_.str();
|
||||
}
|
||||
}
|
||||
if (!impl_->tableParts_.str().empty())
|
||||
{
|
||||
CP_XML_NODE(L"tableParts")
|
||||
{
|
||||
CP_XML_STREAM() << impl_->tableParts_.str();
|
||||
}
|
||||
}
|
||||
CP_XML_STREAM() << impl_->picture_background_.str();
|
||||
|
||||
//CP_XML_NODE(L"headerFooter){}
|
||||
|
||||
@ -47,10 +47,11 @@ typedef _CP_PTR(xlsx_xml_worksheet) xlsx_xml_worksheet_ptr;
|
||||
class xlsx_xml_worksheet: noncopyable
|
||||
{
|
||||
public:
|
||||
xlsx_xml_worksheet(std::wstring const & name);
|
||||
xlsx_xml_worksheet(std::wstring const & name, bool hidden);
|
||||
~xlsx_xml_worksheet();
|
||||
|
||||
std::wstring name() const;
|
||||
bool hidden() const;
|
||||
|
||||
std::wostream & cols();
|
||||
std::wostream & sheetFormat();
|
||||
@ -60,6 +61,7 @@ public:
|
||||
std::wostream & drawing();
|
||||
std::wostream & comments();
|
||||
std::wostream & autofilter();
|
||||
std::wostream & tableParts();
|
||||
std::wostream & conditionalFormatting();
|
||||
std::wostream & picture_background();
|
||||
std::wostream & dataValidations();
|
||||
@ -67,6 +69,7 @@ public:
|
||||
std::wostream & ole_objects();
|
||||
std::wostream & page_properties();
|
||||
std::wostream & controls();
|
||||
std::wostream & protection();
|
||||
|
||||
rels & sheet_rels(); //hyperlink, background image, external, media ...
|
||||
|
||||
@ -80,7 +83,7 @@ public:
|
||||
std::pair<std::wstring, std::wstring> get_vml_drawing_link() const;
|
||||
std::pair<std::wstring, std::wstring> get_comments_link() const;
|
||||
|
||||
static xlsx_xml_worksheet_ptr create(std::wstring const & name);
|
||||
static xlsx_xml_worksheet_ptr create(std::wstring const & name, bool hidden);
|
||||
|
||||
private:
|
||||
class Impl;
|
||||
|
||||
@ -88,7 +88,6 @@ void xlsx_document::write(const std::wstring & RootPath)
|
||||
pivot_cache_content::pivot_cache_content() : definitions_rels_file_(rels_file::create(L""))
|
||||
{
|
||||
}
|
||||
|
||||
_CP_PTR(pivot_cache_content) pivot_cache_content::create()
|
||||
{
|
||||
return boost::make_shared<pivot_cache_content>();
|
||||
@ -97,17 +96,23 @@ _CP_PTR(pivot_cache_content) pivot_cache_content::create()
|
||||
pivot_table_content::pivot_table_content() : rels_file_(rels_file::create(L""))
|
||||
{
|
||||
}
|
||||
|
||||
_CP_PTR(pivot_table_content) pivot_table_content::create()
|
||||
{
|
||||
return boost::make_shared<pivot_table_content>();
|
||||
}
|
||||
//--------------------------------------------------------------------------------------------
|
||||
external_links_content::external_links_content() : rels_file_(rels_file::create(L""))
|
||||
{
|
||||
}
|
||||
_CP_PTR(external_links_content) external_links_content::create()
|
||||
{
|
||||
return boost::make_shared<external_links_content>();
|
||||
}
|
||||
//--------------------------------------------------------------------------------------------
|
||||
sheet_content::sheet_content() : rels_(rels_file::create(L""))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
_CP_PTR(sheet_content) sheet_content::create()
|
||||
{
|
||||
return boost::make_shared<sheet_content>();
|
||||
@ -198,8 +203,11 @@ void xl_files::write(const std::wstring & RootPath)
|
||||
control_props_files_.set_main_document( this->get_main_document() );
|
||||
control_props_files_.write(path);
|
||||
}
|
||||
int index = 1;
|
||||
if (true)
|
||||
{
|
||||
external_links_files_.set_rels(&rels_files_);
|
||||
external_links_files_.set_main_document(get_main_document());
|
||||
external_links_files_.write(path);
|
||||
}
|
||||
{
|
||||
//workbook_->hyperlinks->write(path);
|
||||
rels_files_.add( relationship( L"hId1", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument", L"xl/workbook.xml" ) );
|
||||
@ -217,7 +225,6 @@ void xl_files::write(const std::wstring & RootPath)
|
||||
content_type * contentTypes = this->get_main_document()->get_content_types_file().content();
|
||||
contentTypes->add_override(L"/xl/connections.xml", L"application/vnd.openxmlformats-officedocument.spreadsheetml.connections+xml");
|
||||
}
|
||||
|
||||
if (styles_)
|
||||
{
|
||||
styles_->write(path);
|
||||
@ -245,6 +252,11 @@ void xl_files::write(const std::wstring & RootPath)
|
||||
charts_files_.set_main_document(get_main_document());
|
||||
charts_files_.write(path);
|
||||
}
|
||||
{
|
||||
table_part_files_.set_main_document(get_main_document());
|
||||
table_part_files_.write(path);
|
||||
}
|
||||
|
||||
if (drawings_)
|
||||
{
|
||||
drawings_->set_main_document(get_main_document());
|
||||
@ -286,11 +298,11 @@ void xl_files::add_sheet(sheet_content_ptr sheet)
|
||||
sheets_files_.add_sheet(sheet);
|
||||
}
|
||||
|
||||
void xl_files::set_media(mediaitems & _Mediaitems, NSFonts::IApplicationFonts *pAppFonts)
|
||||
void xl_files::set_media(mediaitems & _Mediaitems)
|
||||
{
|
||||
if (_Mediaitems.count_image + _Mediaitems.count_media > 0)
|
||||
{
|
||||
media_ = element_ptr( new media(_Mediaitems, pAppFonts) );
|
||||
media_ = element_ptr( new media(_Mediaitems, _Mediaitems.applicationFonts()) );
|
||||
}
|
||||
|
||||
if (_Mediaitems.count_object > 0)
|
||||
@ -322,6 +334,10 @@ void xl_files::add_pivot_table(pivot_table_content_ptr pivot_table)
|
||||
{
|
||||
pivot_table_files_.add_pivot_table(pivot_table);
|
||||
}
|
||||
void xl_files::add_table_part(const std::wstring &content)
|
||||
{
|
||||
table_part_files_.add_table_part(content);
|
||||
}
|
||||
void xl_files::add_jsaProject(const std::string &content)
|
||||
{
|
||||
jsaProject_ = package::simple_element::create(L"jsaProject.bin", content);
|
||||
@ -330,6 +346,10 @@ void xl_files::add_control_props (simple_element_ptr element)
|
||||
{
|
||||
control_props_files_.add_control_props(element);
|
||||
}
|
||||
void xl_files::add_external_links(external_links_content_ptr content)
|
||||
{
|
||||
external_links_files_.add_external_links(content);
|
||||
}
|
||||
//----------------------------------------------------------------------------------------
|
||||
void xl_pivot_cache_files::add_pivot_cache(pivot_cache_content_ptr pivot_cache)
|
||||
{
|
||||
@ -418,20 +438,80 @@ void xl_pivot_table_files::write(const std::wstring & RootPath)
|
||||
}
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------
|
||||
void xl_external_links_files::add_external_links(external_links_content_ptr content)
|
||||
{
|
||||
external_links_.push_back(content);
|
||||
}
|
||||
void xl_external_links_files::write(const std::wstring & RootPath)
|
||||
{
|
||||
if (external_links_.empty()) return;
|
||||
|
||||
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"externalLinks";
|
||||
NSDirectory::CreateDirectory(path.c_str());
|
||||
|
||||
for (size_t i = 0; i < external_links_.size(); i++)
|
||||
{
|
||||
const std::wstring fileName = std::wstring(L"externalLink") + std::to_wstring(i + 1) + L".xml";
|
||||
content_type * contentTypes = this->get_main_document()->get_content_types_file().content();
|
||||
|
||||
static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.spreadsheetml.externalLink+xml";
|
||||
contentTypes->add_override(std::wstring(L"/xl/externalLinks/") + fileName, kWSConType);
|
||||
|
||||
package::simple_element(fileName, external_links_[i]->content_.str()).write(path);
|
||||
|
||||
{
|
||||
rels_files relFiles;
|
||||
external_links_[i]->rels_file_->set_file_name(fileName + L".rels");
|
||||
|
||||
relFiles.add_rel_file(external_links_[i]->rels_file_);
|
||||
relFiles.write(path);
|
||||
}
|
||||
if (rels_)
|
||||
{
|
||||
static const std::wstring kWSRel = L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLink";
|
||||
const std::wstring fileRef = std::wstring(L"externalLinks/") + fileName;
|
||||
rels_->add(external_links_[i]->rId_, kWSRel, fileRef);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------
|
||||
void xl_table_part_files::add_table_part(const std::wstring & table_part)
|
||||
{
|
||||
table_parts_.push_back(table_part);
|
||||
}
|
||||
void xl_table_part_files::write(const std::wstring & RootPath)
|
||||
{
|
||||
if (table_parts_.empty()) return;
|
||||
|
||||
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"tables";
|
||||
NSDirectory::CreateDirectory(path.c_str());
|
||||
|
||||
for (size_t i = 0; i < table_parts_.size(); i++)
|
||||
{
|
||||
const std::wstring fileName = std::wstring(L"table") + std::to_wstring(i + 1) + L".xml";
|
||||
content_type * contentTypes = this->get_main_document()->get_content_types_file().content();
|
||||
|
||||
static const std::wstring kWSConType = L"application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml";
|
||||
contentTypes->add_override(std::wstring(L"/xl/tables/") + fileName, kWSConType);
|
||||
|
||||
package::simple_element(fileName, table_parts_[i]).write(path);
|
||||
}
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------
|
||||
void xl_charts_files::add_chart(chart_content_ptr chart)
|
||||
{
|
||||
charts_.push_back(chart);
|
||||
}
|
||||
void xl_charts_files::write(const std::wstring & RootPath)
|
||||
{
|
||||
if (charts_.empty()) return;
|
||||
|
||||
std::wstring path = RootPath + FILE_SEPARATOR_STR + L"charts";
|
||||
NSDirectory::CreateDirectory(path.c_str());
|
||||
|
||||
size_t count = 0;
|
||||
|
||||
for (size_t i = 0; i < charts_.size(); i++)
|
||||
{
|
||||
count++;
|
||||
const std::wstring fileName = std::wstring(L"chart") + std::to_wstring(i + 1) + L".xml";
|
||||
content_type * contentTypes = this->get_main_document()->get_content_types_file().content();
|
||||
|
||||
|
||||
@ -72,6 +72,7 @@ typedef _CP_PTR(sheet_content) sheet_content_ptr;
|
||||
//------------------------------------------------------------------------
|
||||
class pivot_cache_content;
|
||||
typedef _CP_PTR(pivot_cache_content) pivot_cache_content_ptr;
|
||||
|
||||
class pivot_cache_content : boost::noncopyable
|
||||
{
|
||||
public:
|
||||
@ -94,6 +95,7 @@ private:
|
||||
//------------------------------------------------------------------------
|
||||
class pivot_table_content;
|
||||
typedef _CP_PTR(pivot_table_content) pivot_table_content_ptr;
|
||||
|
||||
class pivot_table_content : boost::noncopyable
|
||||
{
|
||||
public:
|
||||
@ -111,6 +113,28 @@ private:
|
||||
rels_file_ptr rels_file_;
|
||||
};
|
||||
//------------------------------------------------------------------------
|
||||
class external_links_content;
|
||||
typedef _CP_PTR(external_links_content) external_links_content_ptr;
|
||||
|
||||
class external_links_content : boost::noncopyable
|
||||
{
|
||||
public:
|
||||
external_links_content();
|
||||
static external_links_content_ptr create();
|
||||
|
||||
std::wstring & rId() { return rId_;}
|
||||
std::wostream & content() { return content_; }
|
||||
rels & get_rels() { return rels_file_->get_rels(); }
|
||||
|
||||
std::wstring str() { return content_.str(); }
|
||||
|
||||
friend class xl_external_links_files;
|
||||
private:
|
||||
std::wstringstream content_;
|
||||
rels_file_ptr rels_file_;
|
||||
std::wstring rId_;
|
||||
};
|
||||
//------------------------------------------------------------------------
|
||||
class sheets_files : public element
|
||||
{
|
||||
public:
|
||||
@ -131,7 +155,17 @@ public:
|
||||
|
||||
};
|
||||
|
||||
class xl_table_part_files : public element
|
||||
{
|
||||
public:
|
||||
xl_table_part_files(){}
|
||||
|
||||
void add_table_part(const std::wstring & table_part);
|
||||
virtual void write(const std::wstring & RootPath);
|
||||
|
||||
std::vector<std::wstring> table_parts_;
|
||||
|
||||
};
|
||||
class xl_charts_files : public element
|
||||
{
|
||||
public:
|
||||
@ -143,7 +177,22 @@ public:
|
||||
std::vector<chart_content_ptr> charts_;
|
||||
|
||||
};
|
||||
|
||||
class xl_external_links_files : public element
|
||||
{
|
||||
public:
|
||||
xl_external_links_files(){}
|
||||
|
||||
void add_external_links(external_links_content_ptr content);
|
||||
virtual void write(const std::wstring & RootPath);
|
||||
|
||||
void set_rels(rels_files * rels)
|
||||
{
|
||||
rels_ = rels;
|
||||
}
|
||||
private:
|
||||
std::vector<external_links_content_ptr> external_links_;
|
||||
rels_files * rels_;
|
||||
};
|
||||
class xl_pivot_table_files : public element
|
||||
{
|
||||
public:
|
||||
@ -235,7 +284,7 @@ public:
|
||||
void set_sharedStrings (element_ptr Element);
|
||||
void set_connections (element_ptr Element);
|
||||
void add_sheet (sheet_content_ptr sheet);
|
||||
void set_media (mediaitems & _Mediaitems, NSFonts::IApplicationFonts *pAppFonts);
|
||||
void set_media (mediaitems & _Mediaitems);
|
||||
void set_drawings (element_ptr Element);
|
||||
void set_vml_drawings (element_ptr Element);
|
||||
void set_comments (element_ptr Element);
|
||||
@ -244,6 +293,8 @@ public:
|
||||
void add_pivot_table (pivot_table_content_ptr table);
|
||||
void add_jsaProject (const std::string &content);
|
||||
void add_control_props (simple_element_ptr Element);
|
||||
void add_table_part (const std::wstring &content);
|
||||
void add_external_links (external_links_content_ptr content);
|
||||
|
||||
private:
|
||||
rels_files rels_files_;
|
||||
@ -252,7 +303,9 @@ private:
|
||||
xl_pivot_cache_files pivot_cache_files_;
|
||||
xl_pivot_table_files pivot_table_files_;
|
||||
xl_control_props_files control_props_files_;
|
||||
|
||||
xl_table_part_files table_part_files_;
|
||||
xl_external_links_files external_links_files_;
|
||||
|
||||
element_ptr theme_;
|
||||
element_ptr workbook_;
|
||||
|
||||
@ -277,7 +330,7 @@ public:
|
||||
|
||||
virtual content_types_file & get_content_types_file() { return content_type_file_; }
|
||||
xl_files & get_xl_files() { return xl_files_; }
|
||||
|
||||
rels_files & get_rels_files() { return rels_files_; }
|
||||
private:
|
||||
xlsx_content_types_file content_type_file_;
|
||||
xl_files xl_files_;
|
||||
|
||||
@ -302,12 +302,24 @@ void xlsx_pivots_context::Impl::calc_headers()
|
||||
|
||||
std::map<size_t, size_t>::iterator pFind;
|
||||
|
||||
//current_.bAxisCol = false;
|
||||
//current_.bAxisRow = false;
|
||||
|
||||
size_t min_col = 0xffffff, min_row = 0xffffff;
|
||||
size_t prev_col, prev_row;
|
||||
for (size_t i = 0; i < current_.headers.size(); i++)//("F18","F19","F23","G21","H21")
|
||||
{
|
||||
size_t row = 0, col = 0;
|
||||
oox::getCellAddressInv(current_.headers[i], col, row);
|
||||
|
||||
//if (i > 0)
|
||||
//{
|
||||
// if (col != prev_col)current_.bAxisCol = true;
|
||||
// if (row != prev_row)current_.bAxisRow = true;
|
||||
//}
|
||||
prev_col = col;
|
||||
prev_row = row;
|
||||
|
||||
if (col < min_col) min_col = col;
|
||||
if (row < min_row) min_row = row;
|
||||
|
||||
@ -578,11 +590,17 @@ void xlsx_pivots_context::Impl::sort_fields()
|
||||
i--;
|
||||
}
|
||||
}
|
||||
if ((bAddRepeateCol || (count_items_col == 0 && current_.bAxisCol))/* && bShowEmptyCol*/) ///* || (bEmptyColCache && current_.grand_total < 0)*/?? Financial Execution (template).ods
|
||||
bool data_col_repeate = false;
|
||||
if ((bAddRepeateRow || (count_items_row == 0 && current_.bAxisRow)) && (current_.grand_total == 1 || current_.grand_total == 3 || current_.data_on_row))/* && bShowEmptyRow*/
|
||||
{
|
||||
current_.row_fields.push_back(-2);
|
||||
data_col_repeate = true;
|
||||
}
|
||||
|
||||
if (!data_col_repeate && (bAddRepeateCol || (count_items_col == 0 && current_.bAxisCol)) && (current_.grand_total == 1 || current_.grand_total == 2 || current_.data_fields.size() > 1 ))/* && bShowEmptyCol*/ ///* || (bEmptyColCache && current_.grand_total < 0)*/?? Financial Execution (template).ods
|
||||
current_.col_fields.push_back(-2);
|
||||
|
||||
if ((bAddRepeateRow || (count_items_row == 0 && current_.bAxisRow))/* && bShowEmptyRow*/)
|
||||
current_.row_fields.push_back(-2);
|
||||
|
||||
}
|
||||
void xlsx_pivots_context::Impl::serialize_view(std::wostream & strm)
|
||||
{
|
||||
|
||||
@ -44,6 +44,7 @@
|
||||
|
||||
#include "../formulasconvert/formulasconvert.h"
|
||||
|
||||
#include "../../../OfficeCryptReader/source/CryptTransform.h"
|
||||
|
||||
namespace cpdoccore {
|
||||
namespace oox {
|
||||
@ -81,8 +82,8 @@ void xlsx_data_range::serialize_sort (std::wostream & _Wostream)
|
||||
std::wstring ref1, ref2;
|
||||
size_t col_1, row_1, col_2, row_2;
|
||||
|
||||
int pos = ref.find(L":");
|
||||
if (pos >= 0)
|
||||
size_t pos = ref.find(L":");
|
||||
if (pos != std::wstring::npos)
|
||||
{
|
||||
ref1 = ref.substr(0, pos );
|
||||
ref2 = ref.substr(pos + 1);
|
||||
@ -134,10 +135,29 @@ xlsx_table_state::xlsx_table_state(xlsx_conversion_context * Context, std::wstri
|
||||
xlsx_comments_context_ (Context->get_comments_context_handle()),
|
||||
table_column_last_width_(0.0),
|
||||
in_cell(false),
|
||||
bEndTable(false)
|
||||
|
||||
bEndTable(false),
|
||||
bRTL(false),
|
||||
bHidden(false),
|
||||
bProtected(false)
|
||||
{
|
||||
memset(&group_row_,0,sizeof(_group_row));
|
||||
odf_reader::style_table_properties * table_prop = NULL;
|
||||
odf_reader::style_instance * tableStyle = context_->root()->odf_context().styleContainer().style_by_name(table_style_, odf_types::style_family::Table, false);
|
||||
|
||||
if ((tableStyle) && (tableStyle->content()))
|
||||
table_prop = tableStyle->content()->get_style_table_properties();
|
||||
|
||||
if (table_prop)
|
||||
{
|
||||
if (table_prop->content().common_writing_mode_attlist_.style_writing_mode_)
|
||||
{
|
||||
if (table_prop->content().common_writing_mode_attlist_.style_writing_mode_->get_type() == odf_types::writing_mode::RlTb)
|
||||
bRTL = true;
|
||||
}
|
||||
if ((table_prop->content().table_display_) && (false == table_prop->content().table_display_))
|
||||
{
|
||||
bHidden = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void xlsx_table_state::start_column(unsigned int repeated, const std::wstring & defaultCellStyleName)
|
||||
@ -149,6 +169,31 @@ void xlsx_table_state::start_column(unsigned int repeated, const std::wstring &
|
||||
columns_.push_back(repeated);
|
||||
}
|
||||
|
||||
void xlsx_table_state::set_rtl(bool val)
|
||||
{
|
||||
bRTL = val;
|
||||
}
|
||||
|
||||
void xlsx_table_state::set_protection(bool val, const std::wstring &key, const std::wstring &algorithm)
|
||||
{
|
||||
bProtected = val;
|
||||
protect_key = key;
|
||||
|
||||
size_t pos = algorithm.find(L"#");
|
||||
if (pos != std::wstring::npos)
|
||||
{
|
||||
protect_key_algorithm = algorithm.substr(pos + 1);
|
||||
}
|
||||
|
||||
//test
|
||||
//CRYPT::odfWriteProtect protect;
|
||||
//protect.SetProtectKey(DecodeBase64(protect_key));
|
||||
//protect.SetPassword(L"123");
|
||||
|
||||
//bool res = protect.Verify();
|
||||
|
||||
}
|
||||
|
||||
unsigned int xlsx_table_state::columns_count() const
|
||||
{
|
||||
return columns_count_;
|
||||
@ -224,10 +269,10 @@ void xlsx_table_state::start_cell(size_t columnsSpanned, size_t rowsSpanned)
|
||||
xlsx_merge_cells_.add_merge(current_table_column_, current_table_row_, columnsSpanned, rowsSpanned);
|
||||
}
|
||||
|
||||
if ( current_columns_spaned() > 0 )
|
||||
{
|
||||
_CP_LOG << L"[warning] current columns spanned > 0\n";
|
||||
}
|
||||
//if ( current_columns_spaned() > 0 )
|
||||
//{
|
||||
// _CP_LOG << L"[warning] current columns spanned > 0\n";
|
||||
//}
|
||||
|
||||
columns_spanned_num_ = static_cast<int>(columnsSpanned);
|
||||
|
||||
@ -247,10 +292,10 @@ void xlsx_table_state::start_cell(size_t columnsSpanned, size_t rowsSpanned)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (rows_spanned_[current_table_column_].num() > 0)
|
||||
{
|
||||
_CP_LOG << L"[warning] current rows spanned > 0\n";
|
||||
}
|
||||
//if (rows_spanned_[current_table_column_].num() > 0)
|
||||
//{
|
||||
// _CP_LOG << L"[warning] current rows spanned > 0\n";
|
||||
//}
|
||||
rows_spanned_[current_table_column_].num(static_cast<unsigned int>(rowsSpanned));
|
||||
rows_spanned_[current_table_column_].column_spanned(static_cast<unsigned int>(columnsSpanned));
|
||||
for (size_t i = 0; i <= columns_spanned_num_; ++i)
|
||||
@ -373,6 +418,21 @@ void xlsx_table_state::serialize_background (std::wostream & strm)
|
||||
}
|
||||
}
|
||||
}
|
||||
void xlsx_table_state::serialize_protection (std::wostream & strm)
|
||||
{
|
||||
if (!bProtected) return;
|
||||
|
||||
CP_XML_WRITER(strm)
|
||||
{
|
||||
CP_XML_NODE(L"sheetProtection")
|
||||
{
|
||||
CP_XML_ATTR(L"sheet", 1);
|
||||
CP_XML_ATTR(L"objects", 1);
|
||||
CP_XML_ATTR(L"scenarios", 1);
|
||||
//convert protection odf->ooxml impossible without password !!!
|
||||
}
|
||||
}
|
||||
}
|
||||
void xlsx_table_state::serialize_table_format (std::wostream & strm)
|
||||
{
|
||||
odf_reader::odf_read_context & odfContext = context_->root()->odf_context();
|
||||
@ -421,6 +481,9 @@ void xlsx_table_state::serialize_table_format (std::wostream & strm)
|
||||
{
|
||||
CP_XML_ATTR(L"workbookViewId", 0);
|
||||
|
||||
if (bRTL)
|
||||
CP_XML_ATTR(L"rightToLeft", 1);
|
||||
|
||||
std::wstring s_col, s_row;
|
||||
for (int i = 0; i < odfContext.Settings().get_table_view_count(0, tableName_); i++)
|
||||
{
|
||||
@ -458,7 +521,6 @@ void xlsx_table_state::serialize_table_format (std::wostream & strm)
|
||||
}
|
||||
}
|
||||
// -showRowColHeaders
|
||||
// -rightToLeft
|
||||
}
|
||||
|
||||
double default_height = (2 * context_->getMaxDigitSize().second * 72. / 96. * 100.) /100.;//in point size.
|
||||
|
||||
@ -32,6 +32,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
#include "xlsx_row_spanned.h"
|
||||
#include "xlsx_merge_cells.h"
|
||||
@ -53,19 +54,20 @@ typedef _CP_PTR(xlsx_table_state) xlsx_table_state_ptr;
|
||||
class xlsx_data_range;
|
||||
typedef _CP_PTR(xlsx_data_range) xlsx_data_range_ptr;
|
||||
|
||||
|
||||
class xlsx_data_range
|
||||
{
|
||||
public:
|
||||
xlsx_data_range() : byRow(true), filter(false), withHeader(false), cell_start(0,0), cell_end(0,0) {}
|
||||
xlsx_data_range() : byRow(true), filter(false), bTablePart(true), withHeader(false), cell_start(0,0), cell_end(0,0) {}
|
||||
|
||||
std::wstring table_name;
|
||||
std::wstring name;
|
||||
|
||||
std::wstring ref;
|
||||
|
||||
std::pair<int, int> cell_start;
|
||||
std::pair<int, int> cell_end;
|
||||
|
||||
bool bTablePart;
|
||||
bool byRow;
|
||||
bool filter;
|
||||
bool withHeader;
|
||||
@ -74,6 +76,46 @@ public:
|
||||
|
||||
void serialize_sort (std::wostream & _Wostream);
|
||||
void serialize_autofilter (std::wostream & _Wostream);
|
||||
|
||||
std::vector<std::wstring> header_values;
|
||||
|
||||
void set_header(size_t row, size_t col1, size_t col2)
|
||||
{
|
||||
row_header = row;
|
||||
start_column_header = col1;
|
||||
end_column_header = col2;
|
||||
|
||||
for (size_t i = start_column_header; i <= end_column_header; i++)
|
||||
header_values.push_back(L"");
|
||||
}
|
||||
void set_header_value(size_t col, size_t row, const std::wstring& value)
|
||||
{
|
||||
while (col - start_column_header + 1 >= header_values.size())
|
||||
header_values.push_back(L"");
|
||||
|
||||
std::map<std::wstring, int>::iterator pFind = map_unique_header_values.find(value);
|
||||
if (pFind == map_unique_header_values.end())
|
||||
{
|
||||
map_unique_header_values.insert(std::make_pair(value, 1));
|
||||
header_values[col - start_column_header] = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
pFind->second++;
|
||||
header_values[col - start_column_header] = value + std::to_wstring(pFind->second);
|
||||
}
|
||||
}
|
||||
bool in_header(size_t col, size_t row)
|
||||
{
|
||||
return (row_header == row && (col >= start_column_header && col <= end_column_header));
|
||||
}
|
||||
|
||||
private:
|
||||
size_t row_header;
|
||||
size_t start_column_header;
|
||||
size_t end_column_header;
|
||||
|
||||
std::map<std::wstring, int> map_unique_header_values;
|
||||
};
|
||||
|
||||
class xlsx_table_state
|
||||
@ -82,7 +124,10 @@ public:
|
||||
xlsx_table_state(xlsx_conversion_context * Context, std::wstring styleName, std::wstring tableName, int tableId);
|
||||
|
||||
std::wstring current_style() const { return table_style_; }
|
||||
|
||||
|
||||
void set_rtl(bool val);
|
||||
void set_protection(bool val, const std::wstring &key, const std::wstring &algorithm);
|
||||
|
||||
void start_column (unsigned int repeated, const std::wstring & defaultCellStyleName);
|
||||
void start_row (const std::wstring & StyleName, const std::wstring & defaultCellStyleName);
|
||||
|
||||
@ -138,28 +183,36 @@ public:
|
||||
void serialize_ole_objects (std::wostream & _Wostream);
|
||||
void serialize_page_properties (std::wostream & _Wostream);
|
||||
void serialize_background (std::wostream & _Wostream);
|
||||
void serialize_protection (std::wostream & _Wostream);
|
||||
|
||||
void dump_rels_hyperlinks (rels & Rels);
|
||||
void dump_rels_ole_objects (rels & Rels);
|
||||
|
||||
std::wstring get_table_name() const { return tableName_; }
|
||||
int get_table_id() const { return tableId_; }
|
||||
bool get_table_hidden() const { return bHidden; }
|
||||
|
||||
struct _group_row
|
||||
{
|
||||
bool enabled;
|
||||
int count;
|
||||
int level;
|
||||
bool collapsed;
|
||||
bool enabled = false;
|
||||
int count = 0;
|
||||
int level = 0;
|
||||
bool collapsed = false;
|
||||
}group_row_;
|
||||
|
||||
friend class xlsx_conversion_context;
|
||||
friend class xlsx_table_context;
|
||||
|
||||
private:
|
||||
bool bEndTable;
|
||||
xlsx_conversion_context * context_;
|
||||
|
||||
bool bProtected;
|
||||
std::wstring protect_key;
|
||||
std::wstring protect_key_algorithm;
|
||||
bool bRTL;
|
||||
bool bEndTable;
|
||||
bool bHidden;
|
||||
|
||||
std::wstring tableName_;
|
||||
int tableId_;
|
||||
std::wstring tableBackground_;
|
||||
|
||||
@ -60,23 +60,20 @@ xlsx_table_state_ptr xlsx_table_context::state()
|
||||
return xlsx_table_state_ptr();
|
||||
}
|
||||
|
||||
void xlsx_table_context::start_database_range(std::wstring tableName, std::wstring ref)
|
||||
bool xlsx_table_context::start_database_range(const std::wstring & name, const std::wstring & ref)
|
||||
{
|
||||
formulasconvert::odf2oox_converter convert;
|
||||
ref = convert.convert_named_ref(ref);
|
||||
std::wstring oox_ref = convert.convert_named_ref(ref);
|
||||
|
||||
std::wstring ref1, ref2;
|
||||
int pos = ref.find(L":");
|
||||
size_t pos = oox_ref.find(L":");
|
||||
|
||||
std::wstring xlsx_table_name;
|
||||
|
||||
if (pos >= 0)
|
||||
if (pos != std::wstring::npos)
|
||||
{
|
||||
xlsx_data_ranges_.push_back(xlsx_data_range_ptr(new xlsx_data_range()));
|
||||
xlsx_data_ranges_.back()->table_name = tableName;
|
||||
|
||||
ref1 = ref.substr(0, pos );
|
||||
ref2 = ref.substr(pos + 1);
|
||||
ref1 = oox_ref.substr(0, pos );
|
||||
ref2 = oox_ref.substr(pos + 1);
|
||||
|
||||
pos = ref1.find(L"!");
|
||||
if (pos > 0)
|
||||
@ -88,23 +85,33 @@ void xlsx_table_context::start_database_range(std::wstring tableName, std::wstri
|
||||
pos = ref2.find(L"!");
|
||||
if (pos > 0) ref2 = ref2.substr(pos + 1);
|
||||
|
||||
xlsx_data_ranges_.back()->ref = ref1 + L":" + ref2;
|
||||
|
||||
size_t col, row;
|
||||
size_t col1, col2, row1, row2;
|
||||
|
||||
getCellAddressInv(ref1, col, row);
|
||||
xlsx_data_ranges_.back()->cell_start = std::pair<int, int>(col,row);
|
||||
XmlUtils::replace_all( xlsx_table_name, L"'", L"");
|
||||
|
||||
getCellAddressInv(ref2, col, row);
|
||||
xlsx_data_ranges_.back()->cell_end = std::pair<int, int>(col,row);
|
||||
getCellAddressInv(ref1, col1, row1);
|
||||
getCellAddressInv(ref2, col2, row2);
|
||||
|
||||
xlsx_data_ranges_.push_back(xlsx_data_range_ptr(new xlsx_data_range()));
|
||||
|
||||
if (/*name.find(L"__Anonymous_Sheet_DB__") != std::wstring::npos ||*/ col1 == col2)
|
||||
{//check range in pivots
|
||||
xlsx_data_ranges_.back()->bTablePart = false;
|
||||
}
|
||||
xlsx_data_ranges_.back()->name = name;
|
||||
xlsx_data_ranges_.back()->table_name = xlsx_table_name;
|
||||
xlsx_data_ranges_.back()->ref = ref1 + L":" + ref2;
|
||||
xlsx_data_ranges_.back()->cell_start = std::pair<int, int>(col1, row1);
|
||||
xlsx_data_ranges_.back()->cell_end = std::pair<int, int>(col2, row2);
|
||||
|
||||
xlsx_data_ranges_.back()->set_header(row1, col1, col2);
|
||||
}
|
||||
|
||||
if (!xlsx_table_name.empty())
|
||||
{
|
||||
XmlUtils::replace_all( xlsx_table_name, L"'", L"");
|
||||
xlsx_data_ranges_map_.insert(std::pair<std::wstring, int> (xlsx_table_name, xlsx_data_ranges_.size() - 1));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
void xlsx_table_context::set_database_orientation (bool val)
|
||||
{
|
||||
@ -128,6 +135,63 @@ void xlsx_table_context::end_database_range()
|
||||
{
|
||||
}
|
||||
|
||||
void xlsx_table_context::set_database_range_value(int index, const std::wstring& value)
|
||||
{
|
||||
if (index < 0 || index > xlsx_data_ranges_.size()) return;
|
||||
|
||||
size_t col = state()->current_column();
|
||||
size_t row = state()->current_row();
|
||||
|
||||
xlsx_data_ranges_[index]->set_header_value(col, row, value);
|
||||
}
|
||||
void xlsx_table_context::check_database_range_intersection(const std::wstring& table_name, const std::wstring& ref)
|
||||
{
|
||||
std::wstring ref1, ref2;
|
||||
size_t col_1, row_1, col_2, row_2;
|
||||
|
||||
size_t pos = ref.find(L":");
|
||||
if (pos != std::wstring::npos)
|
||||
{
|
||||
ref1 = ref.substr(0, pos );
|
||||
ref2 = ref.substr(pos + 1);
|
||||
}
|
||||
getCellAddressInv(ref1, col_1, row_1);
|
||||
getCellAddressInv(ref2, col_2, row_2);
|
||||
|
||||
for (size_t i = 0; i < xlsx_data_ranges_.size(); i++)
|
||||
{
|
||||
if (xlsx_data_ranges_[i]->table_name != table_name) continue;
|
||||
|
||||
//if ( xlsx_data_ranges_[i]->cell_start.second < row_2 || xlsx_data_ranges_[i]->cell_end.second > row_1
|
||||
// || xlsx_data_ranges_[i]->cell_end.first < col_1 || xlsx_data_ranges_[i]->cell_start.first > col_2 )
|
||||
|
||||
if (((col_1 <= xlsx_data_ranges_[i]->cell_start.first && xlsx_data_ranges_[i]->cell_start.first <= col_2) ||
|
||||
(xlsx_data_ranges_[i]->cell_start.first <= col_1 && col_1 <= xlsx_data_ranges_[i]->cell_end.first))
|
||||
&&
|
||||
(( row_1 <= xlsx_data_ranges_[i]->cell_start.second && xlsx_data_ranges_[i]->cell_start.second <= row_2) ||
|
||||
(xlsx_data_ranges_[i]->cell_start.second <= row_1 && row_1 <= xlsx_data_ranges_[i]->cell_end.second )))
|
||||
{
|
||||
xlsx_data_ranges_[i]->bTablePart = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
int xlsx_table_context::in_database_range()
|
||||
{
|
||||
int col = state()->current_column();
|
||||
int row = state()->current_row();
|
||||
|
||||
for (size_t i = 0; i < xlsx_data_ranges_.size(); i++)
|
||||
{
|
||||
if (xlsx_data_ranges_[i]->table_name != state()->get_table_name()) continue;
|
||||
|
||||
if (/*(xlsx_data_ranges_values_[i]->withHeader || xlsx_data_ranges_values_[i]->filter)&& */
|
||||
xlsx_data_ranges_[i]->in_header(col, row))
|
||||
{
|
||||
return (int)i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
void xlsx_table_context::add_database_sort(int field_number, int order)
|
||||
{
|
||||
xlsx_data_ranges_.back()->bySort.push_back(std::pair<int, bool>(field_number, order == 1 ? false : true ));
|
||||
@ -140,17 +204,19 @@ xlsx_text_context_(textContext)
|
||||
{
|
||||
}
|
||||
|
||||
void xlsx_table_context::start_table(std::wstring tableName, std::wstring tableStyleName, int id)
|
||||
void xlsx_table_context::start_table(const std::wstring & tableName, const std::wstring & tableStyleName, int id)
|
||||
{
|
||||
xlsx_table_state_ptr state = boost::make_shared<xlsx_table_state>(xlsx_conversion_context_, tableStyleName, tableName, id);
|
||||
xlsx_table_states_.push_back( state);
|
||||
}
|
||||
|
||||
void xlsx_table_context::set_protection(bool val, const std::wstring &key, const std::wstring &algorithm)
|
||||
{
|
||||
xlsx_table_states_.back()->set_protection(val, key, algorithm);
|
||||
}
|
||||
void xlsx_table_context::end_table()
|
||||
{
|
||||
//xlsx_table_states_.pop_back();
|
||||
}
|
||||
|
||||
}
|
||||
void xlsx_table_context::start_cell(const std::wstring & formula, size_t columnsSpanned, size_t rowsSpanned)
|
||||
{
|
||||
state()->start_cell(columnsSpanned, rowsSpanned);
|
||||
@ -255,9 +321,122 @@ void xlsx_table_context::serialize_sort(std::wostream & _Wostream)
|
||||
|
||||
for (std::multimap<std::wstring, int>::iterator it = range.first; it != range.second; ++it)
|
||||
{
|
||||
if (xlsx_data_ranges_[it->second]->bTablePart) continue;
|
||||
|
||||
xlsx_data_ranges_[it->second]->serialize_sort(_Wostream);
|
||||
}
|
||||
}
|
||||
void xlsx_table_context::serialize_tableParts(std::wostream & _Wostream, rels & Rels)
|
||||
{
|
||||
if (xlsx_data_ranges_.empty()) return;
|
||||
|
||||
std::pair<std::multimap<std::wstring, int>::iterator, std::multimap<std::wstring, int>::iterator> range;
|
||||
|
||||
range = xlsx_data_ranges_map_.equal_range(state()->get_table_name());
|
||||
|
||||
for (std::multimap<std::wstring, int>::iterator it = range.first; it != range.second; ++it)
|
||||
{
|
||||
if (false == xlsx_data_ranges_[it->second]->bTablePart) continue;
|
||||
|
||||
// из за дебелизма мсофис которому ОБЯЗАТЕЛЬНО нужно прописывать имена колонок таблицы (и они должны быть еще
|
||||
// прописаны и в самих данных таблицы !!
|
||||
int i = xlsx_data_ranges_[it->second]->header_values.size() - 1;
|
||||
for (; i >= 0; i--)
|
||||
{
|
||||
if (false == xlsx_data_ranges_[it->second]->header_values[i].empty())
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == -1)
|
||||
{
|
||||
xlsx_data_ranges_[it->second]->bTablePart = false;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t erase = xlsx_data_ranges_[it->second]->header_values.size() - 1 - i;
|
||||
if (erase > 0)
|
||||
{
|
||||
xlsx_data_ranges_[it->second]->header_values.erase(xlsx_data_ranges_[it->second]->header_values.begin() + i + 1, xlsx_data_ranges_[it->second]->header_values.end());
|
||||
xlsx_data_ranges_[it->second]->cell_end.first -= erase;
|
||||
|
||||
std::wstring ref1 = getCellAddress(xlsx_data_ranges_[it->second]->cell_start.first, xlsx_data_ranges_[it->second]->cell_start.second);
|
||||
std::wstring ref2 = getCellAddress(xlsx_data_ranges_[it->second]->cell_end.first, xlsx_data_ranges_[it->second]->cell_end.second);
|
||||
|
||||
xlsx_data_ranges_[it->second]->ref = ref1 + L":" + ref2;
|
||||
}
|
||||
}
|
||||
//--------------------------------------------------------
|
||||
|
||||
size_t id = xlsx_conversion_context_->get_table_parts_size() + 1;
|
||||
|
||||
std::wstring rId = L"tprtId" + std::to_wstring(id);
|
||||
std::wstring ref = L"../tables/table" + std::to_wstring(id) + L".xml";
|
||||
|
||||
CP_XML_WRITER(_Wostream)
|
||||
{
|
||||
CP_XML_NODE(L"tablePart")
|
||||
{
|
||||
CP_XML_ATTR(L"r:id", rId);
|
||||
}
|
||||
}
|
||||
Rels.add( relationship(rId, L"http://schemas.openxmlformats.org/officeDocument/2006/relationships/table", ref));
|
||||
//--------------------------------------------------------
|
||||
std::wstringstream strm;
|
||||
CP_XML_WRITER(strm)
|
||||
{
|
||||
CP_XML_NODE(L"table")
|
||||
{
|
||||
CP_XML_ATTR(L"xmlns", L"http://schemas.openxmlformats.org/spreadsheetml/2006/main");
|
||||
|
||||
CP_XML_ATTR(L"id", id);
|
||||
CP_XML_ATTR(L"name", xlsx_data_ranges_[it->second]->name);
|
||||
CP_XML_ATTR(L"displayName", xlsx_data_ranges_[it->second]->name);
|
||||
CP_XML_ATTR(L"ref", xlsx_data_ranges_[it->second]->ref);
|
||||
|
||||
if (xlsx_data_ranges_[it->second]->withHeader == false &&
|
||||
xlsx_data_ranges_[it->second]->filter == false)
|
||||
CP_XML_ATTR(L"headerRowCount", 0);
|
||||
|
||||
//CP_XML_ATTR(L"totalsRowCount", 0);
|
||||
CP_XML_ATTR(L"totalsRowShown", 0);
|
||||
|
||||
xlsx_data_ranges_[it->second]->serialize_autofilter(CP_XML_STREAM());
|
||||
xlsx_data_ranges_[it->second]->serialize_sort(CP_XML_STREAM());
|
||||
|
||||
CP_XML_NODE(L"tableColumns")
|
||||
{
|
||||
CP_XML_ATTR(L"count", xlsx_data_ranges_[it->second]->cell_end.first -
|
||||
xlsx_data_ranges_[it->second]->cell_start.first + 1);
|
||||
|
||||
for (int id = 0, i = xlsx_data_ranges_[it->second]->cell_start.first; i <= xlsx_data_ranges_[it->second]->cell_end.first; i++, id++)
|
||||
{
|
||||
CP_XML_NODE(L"tableColumn")
|
||||
{
|
||||
std::wstring column_name = xlsx_data_ranges_[it->second]->header_values[id];
|
||||
if (column_name.empty())
|
||||
{
|
||||
column_name = L"Column_" + std::to_wstring(id + 1);
|
||||
}
|
||||
CP_XML_ATTR(L"id", id + 1);
|
||||
CP_XML_ATTR(L"name", column_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
CP_XML_NODE(L"tableStyleInfo")
|
||||
{
|
||||
CP_XML_ATTR(L"showFirstColumn", 0);
|
||||
CP_XML_ATTR(L"showLastColumn", 0);
|
||||
CP_XML_ATTR(L"showRowStripes", 1);
|
||||
CP_XML_ATTR(L"showColumnStripes", 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
xlsx_conversion_context_->add_table_part(strm.str());
|
||||
}
|
||||
}
|
||||
void xlsx_table_context::serialize_autofilter(std::wostream & _Wostream)
|
||||
{
|
||||
if (xlsx_data_ranges_.empty()) return;
|
||||
@ -273,6 +452,8 @@ void xlsx_table_context::serialize_autofilter(std::wostream & _Wostream)
|
||||
|
||||
for (std::multimap<std::wstring, int>::iterator it = range.first; it != range.second; ++it)
|
||||
{
|
||||
if (xlsx_data_ranges_[it->second]->bTablePart) continue;
|
||||
|
||||
if (xlsx_data_ranges_[it->second]->filter)
|
||||
{
|
||||
if (cell_start.first < 0 || xlsx_data_ranges_[it->second]->cell_start.first < cell_start.first )
|
||||
@ -298,12 +479,16 @@ void xlsx_table_context::serialize_autofilter(std::wostream & _Wostream)
|
||||
{
|
||||
CP_XML_NODE(L"autoFilter")
|
||||
{
|
||||
//в автофильтре тока простые диапазоны .. для сложных нужно выделять tablePart - todooo
|
||||
//в автофильтре тока простые диапазоны .. для сложных - tablePart
|
||||
CP_XML_ATTR(L"ref", getCellAddress(cell_start.first, cell_start.second) + L":" + getCellAddress(cell_end.first, cell_end.second));
|
||||
//CP_XML_ATTR(L"ref", ref);
|
||||
}
|
||||
}
|
||||
}
|
||||
void xlsx_table_context::serialize_protection(std::wostream & _Wostream)
|
||||
{
|
||||
return state()->serialize_protection(_Wostream);
|
||||
}
|
||||
void xlsx_table_context::serialize_conditionalFormatting(std::wostream & _Wostream)
|
||||
{
|
||||
return state()->serialize_conditionalFormatting(_Wostream);
|
||||
|
||||
@ -48,7 +48,8 @@ class xlsx_table_context
|
||||
public:
|
||||
xlsx_table_context(xlsx_conversion_context * Context, xlsx_text_context & textCotnext);
|
||||
|
||||
void start_table(std::wstring tableName, std::wstring tableStyleName, int id);
|
||||
void start_table(const std::wstring &tableName, const std::wstring & tableStyleName, int id);
|
||||
void set_protection(bool val, const std::wstring &key, const std::wstring &algorithm);
|
||||
void end_table();
|
||||
|
||||
void start_cell(const std::wstring & formula,
|
||||
@ -82,6 +83,7 @@ public:
|
||||
|
||||
unsigned int columns_count();
|
||||
|
||||
void serialize_tableParts (std::wostream & _Wostream, rels & Rels);
|
||||
void serialize_sort (std::wostream & _Wostream);
|
||||
void serialize_autofilter (std::wostream & _Wostream);
|
||||
void serialize_merge_cells (std::wostream & _Wostream);
|
||||
@ -93,6 +95,7 @@ public:
|
||||
void serialize_page_properties (std::wostream & _Wostream);
|
||||
void serialize_background (std::wostream & _Wostream);
|
||||
void serialize_data_validation (std::wostream & _Wostream);
|
||||
void serialize_protection (std::wostream & _Wostream);
|
||||
|
||||
xlsx_table_metrics & get_table_metrics();
|
||||
|
||||
@ -111,23 +114,25 @@ public:
|
||||
void dump_rels_hyperlinks (rels & Rels);
|
||||
void dump_rels_ole_objects (rels & Rels);
|
||||
|
||||
void start_database_range(std::wstring table_name, std::wstring ref);
|
||||
bool start_database_range(const std::wstring &table_name, const std::wstring &ref);
|
||||
void set_database_orientation (bool val);
|
||||
void set_database_header (bool val);
|
||||
void set_database_filter (bool val);
|
||||
|
||||
void add_database_sort (int field_number, int order);
|
||||
void add_database_sort (int field_number, int order);
|
||||
void end_database_range();
|
||||
|
||||
|
||||
int in_database_range();
|
||||
void set_database_range_value(int index, const std::wstring& value);
|
||||
void check_database_range_intersection(const std::wstring& table_name, const std::wstring& ref);
|
||||
|
||||
private:
|
||||
xlsx_conversion_context *xlsx_conversion_context_;
|
||||
xlsx_text_context &xlsx_text_context_;
|
||||
|
||||
std::vector<xlsx_table_state_ptr> xlsx_table_states_;
|
||||
std::vector<xlsx_data_range_ptr> xlsx_data_ranges_;
|
||||
std::vector<xlsx_table_state_ptr> xlsx_table_states_;
|
||||
std::vector<xlsx_data_range_ptr> xlsx_data_ranges_;
|
||||
|
||||
std::multimap<std::wstring, int> xlsx_data_ranges_map_;
|
||||
std::multimap<std::wstring, int> xlsx_data_ranges_map_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -45,7 +45,6 @@
|
||||
#include "../odf/odfcontext.h"
|
||||
#include "../odf/calcs_styles.h"
|
||||
|
||||
#include "../../DesktopEditor/graphics/pro/Fonts.h"
|
||||
|
||||
|
||||
namespace cpdoccore {
|
||||
@ -71,14 +70,15 @@ xlsx_conversion_context::xlsx_conversion_context(odf_reader::odf_document * odfD
|
||||
math_context_ (odf_document_->odf_context().fontContainer(), true),
|
||||
xlsx_style_ (this),
|
||||
|
||||
maxDigitSize_ (std::pair<float,float>(-1.0, -1.0) ),
|
||||
maxDigitSize_ (std::make_pair(-1.f, -1.f) ),
|
||||
default_style_ ( (std::numeric_limits<size_t>::max)() ),
|
||||
mediaitems_ (odf_document_->get_folder()),
|
||||
xlsx_drawing_context_handle_(mediaitems_)
|
||||
{
|
||||
applicationFonts_ = NSFonts::NSApplication::Create();
|
||||
}
|
||||
|
||||
std::unordered_map<std::wstring, int> xlsx_conversion_context::mapExternalLink_;
|
||||
|
||||
void xlsx_conversion_context::set_output_document (package::xlsx_document * document)
|
||||
{
|
||||
output_document_ = document;
|
||||
@ -86,15 +86,11 @@ void xlsx_conversion_context::set_output_document (package::xlsx_document * docu
|
||||
|
||||
xlsx_conversion_context::~xlsx_conversion_context()
|
||||
{
|
||||
if (applicationFonts_)
|
||||
delete applicationFonts_;
|
||||
}
|
||||
|
||||
void xlsx_conversion_context::set_font_directory(std::wstring pathFonts)
|
||||
{
|
||||
if (applicationFonts_ == NULL) return;
|
||||
|
||||
applicationFonts_->InitializeFromFolder(pathFonts);
|
||||
mediaitems_.set_font_directory(pathFonts);
|
||||
}
|
||||
|
||||
void xlsx_conversion_context::start_chart(std::wstring name)
|
||||
@ -182,7 +178,7 @@ void xlsx_conversion_context::end_document()
|
||||
{
|
||||
CP_XML_ATTR(L"name", sheet->name()); // office 2010 ! ограничение на длину имени !!!
|
||||
CP_XML_ATTR(L"sheetId", i + 1);
|
||||
CP_XML_ATTR(L"state", L"visible");
|
||||
CP_XML_ATTR(L"state", sheet->hidden() ? L"hidden" : L"visible");
|
||||
CP_XML_ATTR(L"r:id", id);
|
||||
}
|
||||
}
|
||||
@ -201,6 +197,10 @@ void xlsx_conversion_context::end_document()
|
||||
|
||||
output_document_->get_xl_files().add_charts(content);
|
||||
}
|
||||
for (size_t i = 0; i < table_parts_.size(); i++)
|
||||
{
|
||||
output_document_->get_xl_files().add_table_part(table_parts_[i]);
|
||||
}
|
||||
//workbook_content << L"<calcPr iterateCount=\"100\" refMode=\"A1\" iterate=\"false\" iterateDelta=\"0.0001\" />";
|
||||
|
||||
{
|
||||
@ -231,7 +231,41 @@ void xlsx_conversion_context::end_document()
|
||||
{
|
||||
CP_XML_STREAM() << workbook_content.str();
|
||||
}
|
||||
if (false == mapExternalLink_.empty())
|
||||
{
|
||||
CP_XML_NODE(L"externalReferences")
|
||||
{
|
||||
for (std::unordered_map<std::wstring, int>::iterator it = mapExternalLink_.begin();
|
||||
it != mapExternalLink_.end(); ++it)
|
||||
{
|
||||
package::external_links_content_ptr content = package::external_links_content::create();
|
||||
content->rId() = L"extRef" + std::to_wstring(it->second);
|
||||
{
|
||||
CP_XML_WRITER(content->content())
|
||||
{
|
||||
CP_XML_NODE(L"externalLink")
|
||||
{
|
||||
CP_XML_ATTR(L"xmlns", L"http://schemas.openxmlformats.org/spreadsheetml/2006/main");
|
||||
CP_XML_NODE(L"externalBook")
|
||||
{
|
||||
CP_XML_ATTR(L"xmlns:r", L"http://schemas.openxmlformats.org/officeDocument/2006/relationships");
|
||||
CP_XML_ATTR(L"r:id", L"rId1");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
content->get_rels().add(relationship(L"rId1", mediaitems::get_rel_type(typeExternalLink), it->first, L"External"));
|
||||
|
||||
output_document_->get_xl_files().add_external_links(content);
|
||||
|
||||
CP_XML_NODE(L"externalReference")
|
||||
{
|
||||
CP_XML_ATTR(L"r:id", content->rId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
get_xlsx_defined_names().xlsx_serialize(CP_XML_STREAM());
|
||||
|
||||
int pivot_cache_count = xlsx_pivots_context_.get_count();
|
||||
@ -287,7 +321,7 @@ void xlsx_conversion_context::end_document()
|
||||
output_document_->get_xl_files().set_workbook( package::simple_element::create(L"workbook.xml", strm_workbook.str()) );
|
||||
|
||||
output_document_->get_content_types_file().set_media(get_mediaitems());
|
||||
output_document_->get_xl_files().set_media(get_mediaitems(), applicationFonts_);
|
||||
output_document_->get_xl_files().set_media(get_mediaitems());
|
||||
|
||||
package::xl_drawings_ptr drawings = package::xl_drawings::create(xlsx_drawing_context_handle_.content());
|
||||
output_document_->get_xl_files().set_drawings(drawings);
|
||||
@ -392,15 +426,12 @@ int xlsx_conversion_context::find_sheet_by_name(std::wstring tableName)
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
void xlsx_conversion_context::create_new_sheet(std::wstring const & name)
|
||||
{
|
||||
sheets_.push_back(xlsx_xml_worksheet::create(name));
|
||||
}
|
||||
|
||||
bool xlsx_conversion_context::start_table(std::wstring tableName, std::wstring tableStyleName)
|
||||
{
|
||||
create_new_sheet(tableName);
|
||||
get_table_context().start_table(tableName, tableStyleName, sheets_.size() - 1);
|
||||
|
||||
sheets_.push_back(xlsx_xml_worksheet::create(tableName, get_table_context().state()->get_table_hidden()));
|
||||
current_sheet().cols() << L"<cols>";
|
||||
return true;
|
||||
}
|
||||
@ -436,11 +467,13 @@ void xlsx_conversion_context::end_table()
|
||||
get_table_context().serialize_table_format (current_sheet().sheetFormat());
|
||||
get_table_context().serialize_page_properties (current_sheet().page_properties());
|
||||
get_table_context().serialize_conditionalFormatting (current_sheet().conditionalFormatting());
|
||||
get_table_context().serialize_tableParts (current_sheet().tableParts(), current_sheet().sheet_rels());
|
||||
get_table_context().serialize_autofilter (current_sheet().autofilter());
|
||||
get_table_context().serialize_sort (current_sheet().sort());
|
||||
get_table_context().serialize_merge_cells (current_sheet().mergeCells());
|
||||
get_table_context().serialize_data_validation (current_sheet().dataValidations());
|
||||
|
||||
get_table_context().serialize_protection (current_sheet().protection());
|
||||
|
||||
get_drawing_context().set_odf_packet_path (root()->get_folder());
|
||||
get_drawing_context().process_objects (get_table_metrics());
|
||||
|
||||
@ -502,6 +535,20 @@ void xlsx_conversion_context::end_table()
|
||||
}
|
||||
get_table_context().end_table();
|
||||
}
|
||||
//int xlsx_conversion_context::add_external_link(const std::wstring & external)
|
||||
//{
|
||||
// std::unordered_map<std::wstring, int>::iterator pFind = mapExternalLink_.find(external);
|
||||
// if ( pFind == mapExternalLink_.end())
|
||||
// {
|
||||
// int id = (int)mapExternalLink_.size() + 1;
|
||||
// mapExternalLink_.insert(std::make_pair(external, id));
|
||||
// return id;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return pFind->second;
|
||||
// }
|
||||
//}
|
||||
void xlsx_conversion_context::add_control_props(const std::wstring & rid, const std::wstring & target, const std::wstring & props)
|
||||
{
|
||||
if (rid.empty()) return;
|
||||
@ -647,26 +694,43 @@ std::pair<float,float> xlsx_conversion_context::getMaxDigitSize()
|
||||
|
||||
odf_reader::odf_read_context & odfContext = root()->odf_context();
|
||||
|
||||
instances.push_back(odfContext.styleContainer().style_default_by_type(odf_types::style_family::TableCell));
|
||||
instances.push_back(odfContext.styleContainer().style_by_name(L"Default",odf_types::style_family::TableCell,false));
|
||||
|
||||
odf_reader::text_format_properties_content textFormatProperties = calc_text_properties_content(instances);
|
||||
|
||||
if (textFormatProperties.style_font_name_)
|
||||
font_name = textFormatProperties.style_font_name_.get();
|
||||
else if (textFormatProperties.style_font_name_complex_)
|
||||
font_name = textFormatProperties.style_font_name_complex_.get();
|
||||
else if (textFormatProperties.style_font_name_asian_)
|
||||
font_name = textFormatProperties.style_font_name_asian_.get();
|
||||
odf_reader::style_instance *inst = odfContext.styleContainer().style_default_by_type(odf_types::style_family::TableCell);
|
||||
if (inst) instances.push_back(inst);
|
||||
|
||||
inst = odfContext.styleContainer().style_by_name(L"Default", odf_types::style_family::TableCell, false);
|
||||
if (inst) instances.push_back(inst);
|
||||
else
|
||||
font_name = L"Arial";
|
||||
{
|
||||
inst = odfContext.styleContainer().style_by_name(L"Normal", odf_types::style_family::TableCell, false);
|
||||
if (inst) instances.push_back(inst);
|
||||
}
|
||||
|
||||
odf_reader::text_format_properties_content textFormatProperties = calc_text_properties_content(instances);
|
||||
|
||||
if (textFormatProperties.fo_font_family_)
|
||||
font_name = textFormatProperties.fo_font_family_.get();
|
||||
else
|
||||
{
|
||||
std::wstring style_font_name;
|
||||
if (textFormatProperties.style_font_name_) style_font_name = textFormatProperties.style_font_name_.get();
|
||||
else if (textFormatProperties.style_font_name_complex_) style_font_name = textFormatProperties.style_font_name_complex_.get();
|
||||
else if (textFormatProperties.style_font_name_asian_) style_font_name = textFormatProperties.style_font_name_asian_.get();
|
||||
|
||||
odf_reader::fonts_container & fonts = odf_document_->odf_context().fontContainer();
|
||||
odf_reader::font_instance * font = fonts.font_by_style_name(style_font_name);
|
||||
if (font)
|
||||
{
|
||||
font_name = font->name();
|
||||
}
|
||||
}
|
||||
if (font_name.empty()) font_name = L"Arial";
|
||||
|
||||
if ((textFormatProperties.fo_font_size_) && (textFormatProperties.fo_font_size_->get_type() == odf_types::font_size::Length))
|
||||
font_size = (int)(0.5 + textFormatProperties.fo_font_size_->get_length().get_value_unit(odf_types::length::pt));
|
||||
else
|
||||
font_size =10;
|
||||
|
||||
maxDigitSize_ = utils::GetMaxDigitSizePixels(font_name.c_str(), font_size, 96., 0, applicationFonts_);
|
||||
maxDigitSize_ = utils::GetMaxDigitSizePixels(font_name.c_str(), font_size, 96., 0, mediaitems_.applicationFonts());
|
||||
}
|
||||
return maxDigitSize_;
|
||||
}
|
||||
|
||||
@ -34,6 +34,8 @@
|
||||
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/regex.hpp>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "oox_conversion_context.h"
|
||||
|
||||
@ -54,11 +56,6 @@
|
||||
|
||||
#include "mediaitems.h"
|
||||
|
||||
namespace NSFonts
|
||||
{
|
||||
class IApplicationFonts;
|
||||
}
|
||||
|
||||
namespace cpdoccore {
|
||||
|
||||
namespace odf_reader
|
||||
@ -160,6 +157,12 @@ public:
|
||||
void add_jsaProject (const std::string &content);
|
||||
|
||||
void add_control_props(const std::wstring & rid, const std::wstring & target, const std::wstring & props);
|
||||
|
||||
//int add_external_link(const std::wstring & external);
|
||||
|
||||
void add_table_part(const std::wstring & table) {table_parts_.push_back(table);}
|
||||
size_t get_table_parts_size() {return table_parts_.size();}
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
odf_reader::odf_document * root()
|
||||
@ -192,9 +195,9 @@ public:
|
||||
|
||||
mediaitems & get_mediaitems() { return mediaitems_; }
|
||||
|
||||
static std::unordered_map<std::wstring, int> mapExternalLink_;
|
||||
std::map<std::wstring, int> mapUsedNames_;
|
||||
private:
|
||||
void create_new_sheet (std::wstring const & name);
|
||||
|
||||
void serialize_bookViews(std::wostream & strm);
|
||||
void serialize_calcPr (std::wostream & strm);
|
||||
|
||||
@ -202,19 +205,18 @@ private:
|
||||
const odf_reader::office_element *spreadsheet_;
|
||||
odf_reader::odf_document *odf_document_;
|
||||
|
||||
NSFonts::IApplicationFonts *applicationFonts_;
|
||||
|
||||
std::vector<xlsx_xml_worksheet_ptr> sheets_;
|
||||
std::vector<oox_chart_context_ptr> charts_;
|
||||
|
||||
std::vector<std::wstring> table_parts_;
|
||||
|
||||
std::wstringstream defaultOutput_;
|
||||
std::pair<float,float> maxDigitSize_;
|
||||
num_format_context num_format_context_;
|
||||
size_t default_style_;
|
||||
mediaitems mediaitems_;
|
||||
std::multimap<std::wstring, int> mapPivotsTableView_;
|
||||
|
||||
std::map<std::wstring, std::wstring>control_props_;
|
||||
|
||||
std::map<std::wstring, std::wstring> control_props_;
|
||||
|
||||
xlsx_style_manager xlsx_style_;
|
||||
xlsx_defined_names xlsx_defined_names_;
|
||||
@ -227,6 +229,8 @@ private:
|
||||
|
||||
math_context math_context_;
|
||||
forms_context forms_context_;
|
||||
|
||||
static std::wstring change_external(boost::wsmatch const & what);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@ -744,6 +744,9 @@ void process_build_object::visit(chart_title& val)
|
||||
if (val.attlist_.common_draw_position_attlist_.svg_x_)
|
||||
{
|
||||
t.pos_x = val.attlist_.common_draw_position_attlist_.svg_x_->get_value_unit(length::pt);
|
||||
}
|
||||
if (val.attlist_.common_draw_position_attlist_.svg_y_)
|
||||
{
|
||||
t.pos_y = val.attlist_.common_draw_position_attlist_.svg_y_->get_value_unit(length::pt);
|
||||
}
|
||||
t.bEnabled = true;
|
||||
@ -1054,7 +1057,7 @@ void process_build_object::visit(table_table_cell& val)
|
||||
if (cell_cash.empty())
|
||||
cell_cash = cell_val;
|
||||
|
||||
object_odf_context::_cell cell_= {object_odf_context_.current_table_column_, object_odf_context_.current_table_row_, cell_cash};
|
||||
object_odf_context::_cell cell_= {(size_t)object_odf_context_.current_table_column_, (size_t)object_odf_context_.current_table_row_, cell_cash};
|
||||
|
||||
object_odf_context_.cash_values.push_back(cell_);
|
||||
|
||||
|
||||
@ -106,6 +106,13 @@ void common_draw_fill_attlist::add_attributes( const xml::attributes_wc_ptr & At
|
||||
CP_APPLY_ATTR(L"draw:fill-image-width", draw_fill_image_width_);
|
||||
CP_APPLY_ATTR(L"draw:fill-image-height", draw_fill_image_height_);
|
||||
|
||||
CP_APPLY_ATTR(L"draw:color-mode", draw_color_mode_);
|
||||
CP_APPLY_ATTR(L"draw:contrast", draw_contrast_);
|
||||
CP_APPLY_ATTR(L"draw:luminance", draw_luminance_);
|
||||
CP_APPLY_ATTR(L"draw:gamma", draw_gamma_);
|
||||
CP_APPLY_ATTR(L"draw:red", draw_red_);
|
||||
CP_APPLY_ATTR(L"draw:green", draw_green_);
|
||||
CP_APPLY_ATTR(L"draw:blue", draw_blue_);
|
||||
}
|
||||
void common_draw_fill_attlist::serialize(CP_ATTR_NODE)
|
||||
{
|
||||
@ -130,6 +137,13 @@ void common_draw_fill_attlist::serialize(CP_ATTR_NODE)
|
||||
CP_XML_ATTR_OPT(L"draw:fill-image-width", draw_fill_image_width_);
|
||||
CP_XML_ATTR_OPT(L"draw:fill-image-height", draw_fill_image_height_);
|
||||
|
||||
CP_XML_ATTR_OPT(L"draw:color-mode", draw_color_mode_);
|
||||
CP_XML_ATTR_OPT(L"draw:contrast", draw_contrast_);
|
||||
CP_XML_ATTR_OPT(L"draw:luminance", draw_luminance_);
|
||||
CP_XML_ATTR_OPT(L"draw:gamma", draw_gamma_);
|
||||
CP_XML_ATTR_OPT(L"draw:red", draw_red_);
|
||||
CP_XML_ATTR_OPT(L"draw:green", draw_green_);
|
||||
CP_XML_ATTR_OPT(L"draw:blue", draw_blue_);
|
||||
}
|
||||
|
||||
void common_draw_fill_attlist::apply_from(const common_draw_fill_attlist & Other)
|
||||
@ -150,6 +164,14 @@ void common_draw_fill_attlist::apply_from(const common_draw_fill_attlist & Other
|
||||
|
||||
_CP_APPLY_PROP2(draw_fill_image_width_);
|
||||
_CP_APPLY_PROP2(draw_fill_image_height_);
|
||||
|
||||
_CP_APPLY_PROP2(draw_color_mode_);
|
||||
_CP_APPLY_PROP2(draw_contrast_);
|
||||
_CP_APPLY_PROP2(draw_luminance_);
|
||||
_CP_APPLY_PROP2(draw_gamma_);
|
||||
_CP_APPLY_PROP2(draw_red_);
|
||||
_CP_APPLY_PROP2(draw_green_);
|
||||
_CP_APPLY_PROP2(draw_blue_);
|
||||
}
|
||||
|
||||
void common_horizontal_margin_attlist::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
|
||||
@ -111,6 +111,14 @@ public:
|
||||
|
||||
_CP_OPT(length_or_percent) draw_fill_image_width_;
|
||||
_CP_OPT(length_or_percent) draw_fill_image_height_;
|
||||
|
||||
_CP_OPT(std::wstring) draw_color_mode_;
|
||||
_CP_OPT(odf_types::percent) draw_contrast_;
|
||||
_CP_OPT(odf_types::percent) draw_luminance_;
|
||||
_CP_OPT(odf_types::percent) draw_gamma_;
|
||||
_CP_OPT(odf_types::percent) draw_red_;
|
||||
_CP_OPT(odf_types::percent) draw_green_;
|
||||
_CP_OPT(odf_types::percent) draw_blue_;
|
||||
};
|
||||
|
||||
// common-horizontal-margin-attlist
|
||||
@ -502,7 +510,7 @@ public:
|
||||
_CP_OPT(std::wstring) draw_id_;
|
||||
_CP_OPT(std::wstring) draw_layer_;
|
||||
_CP_OPT(std::wstring) draw_transform_;
|
||||
_CP_OPT(int) draw_z_index_;
|
||||
_CP_OPT(unsigned int) draw_z_index_;
|
||||
_CP_OPT(std::wstring) drawooo_display_;
|
||||
};
|
||||
|
||||
|
||||
@ -79,8 +79,8 @@ static const _shape_converter _OO_OOX_custom_shapes[]=
|
||||
{L"up-down-arrow-callout" ,L"upDownArrowCallout" ,0 ,0 ,0 },
|
||||
{L"quad-arrow-callout" ,L"quadArrowCallout" ,0 ,0 ,0 },
|
||||
{L"circular-arrow" ,L"circularArrow" ,0 ,0 ,0 },
|
||||
{L"can" ,L"lightningBolt" ,0 ,0 ,0 },
|
||||
{L"lightning" ,L"can" ,0 ,0 ,0 },
|
||||
{L"can" ,L"can" ,0 ,0 ,0 },
|
||||
{L"lightning" ,L"lightningBolt" ,0 ,0 ,0 },
|
||||
{L"heart" ,L"heart" ,0 ,0 ,0 },
|
||||
{L"sun" ,L"sun" ,1 ,46875 ,12500 },
|
||||
{L"moon" ,L"moon" ,0 ,0 ,0 },
|
||||
@ -139,13 +139,6 @@ static const _shape_converter _OO_OOX_custom_shapes[]=
|
||||
{L"mso-spt18" ,L"irregularSeal1" ,0 ,0 ,0 },
|
||||
{L"mso-spt19" ,L"rect" ,0 ,0 ,0 },
|
||||
{L"mso-spt24" ,L"textBox" ,0 ,0 ,0 },
|
||||
{L"mso-spt25" ,L"" ,0 ,0 ,0 },
|
||||
{L"mso-spt26" ,L"" ,0 ,0 ,0 },
|
||||
{L"mso-spt27" ,L"" ,0 ,0 ,0 },
|
||||
{L"mso-spt28" ,L"" ,0 ,0 ,0 },
|
||||
{L"mso-spt29" ,L"" ,0 ,0 ,0 },
|
||||
{L"mso-spt30" ,L"" ,0 ,0 ,0 },
|
||||
{L"mso-spt31" ,L"" ,0 ,0 ,0 },
|
||||
{L"mso-spt32" ,L"straightConnector1" ,0 ,0 ,0 },
|
||||
{L"mso-spt33" ,L"bentConnector2" ,0 ,0 ,0 },
|
||||
{L"mso-spt34" ,L"bentConnector3" ,0 ,0 ,0 },
|
||||
@ -181,10 +174,10 @@ static const _shape_converter _OO_OOX_custom_shapes[]=
|
||||
{L"mso-spt107" ,L"ellipseRibbon" ,0 ,0 ,0 },
|
||||
{L"mso-spt108" ,L"ellipseRibbon2" ,0 ,0 ,0 },
|
||||
{L"mso-spt129" ,L"flowChartMagneticDrum" ,0 ,0 ,0 },
|
||||
{L"mso-spt167" ,L"rect" ,0 ,0 ,0 },
|
||||
{L"mso-spt178" ,L"" ,0 ,0 ,0 },
|
||||
{L"mso-spt179" ,L"" ,0 ,0 ,0 },
|
||||
{L"mso-spt180" ,L"" ,0 ,0 ,0 },
|
||||
|
||||
{L"mso-spt178" ,L"callout1" ,0 ,0 ,0 },
|
||||
{L"mso-spt179" ,L"callout2" ,0 ,0 ,0 },
|
||||
{L"mso-spt180" ,L"callout3" ,0 ,0 ,0 },
|
||||
{L"mso-spt182" ,L"leftRightUpArrow" ,0 ,0 ,0 },
|
||||
{L"mso-spt188" ,L"flowChartPunchedTape",0 ,0 ,0 },
|
||||
{L"mso-spt189" ,L"actionButtonBlank" ,0 ,0 ,0 },
|
||||
@ -222,7 +215,6 @@ static const _shape_converter _OO_OOX_custom_shapes[]=
|
||||
{L"concave-star6" ,L"" ,0 ,0 ,0 },
|
||||
{L"signet" ,L"" ,0 ,0 ,0 },
|
||||
{L"doorplate" ,L"" ,0 ,0 ,0 },
|
||||
|
||||
{L"" ,L"round1Rect" ,0 ,0 ,0 },
|
||||
{L"" ,L"round2DiagRect" ,0 ,0 ,0 },
|
||||
{L"" ,L"snip2DiagRect" ,0 ,0 ,0 },
|
||||
@ -300,6 +292,13 @@ static const _shape_converter _OO_OOX_wordart[]=
|
||||
{L"fontwork-slant-up" ,L"textSlantUp" ,0 ,0 ,0 },
|
||||
{L"fontwork-slant-down" ,L"textSlantDown" ,0 ,0 ,0 },
|
||||
|
||||
{L"mso-spt25" ,L"textPlain" ,0 ,0 ,0 },//
|
||||
{L"mso-spt26" ,L"textPlain" ,0 ,0 ,0 },
|
||||
{L"mso-spt27" ,L"textCurveDown" ,0 ,0 ,0 },
|
||||
{L"mso-spt28" ,L"textWave1" ,0 ,0 ,0 },
|
||||
{L"mso-spt29" ,L"textRingInside" ,0 ,0 ,0 },
|
||||
{L"mso-spt30" ,L"textPlain" ,0 ,0 ,0 },
|
||||
{L"mso-spt31" ,L"textRingOutside" ,0 ,0 ,0 },
|
||||
{L"mso-spt142" ,L"textRingInside" ,0 ,0 ,0 },
|
||||
{L"mso-spt143" ,L"textRingOutside" ,0 ,0 ,0 },
|
||||
{L"mso-spt157" ,L"textWave2" ,0 ,0 ,0 },
|
||||
@ -311,7 +310,8 @@ static const _shape_converter _OO_OOX_wordart[]=
|
||||
{L"mso-spt163" ,L"textDeflateBottom" ,0 ,0 ,0 },
|
||||
{L"mso-spt164" ,L"textInflateTop" ,0 ,0 ,0 },
|
||||
{L"mso-spt165" ,L"textDeflateTop" ,0 ,0 ,0 },
|
||||
{L"mso-spt166" ,L"textDeflateInflateDeflate" ,0 ,0 ,0 },
|
||||
{L"mso-spt166" ,L"textDeflateInflate" ,0 ,0 ,0 },
|
||||
{L"mso-spt167" ,L"textDeflateInflateDeflate" ,0 ,0 ,0 },
|
||||
{L"mso-spt174" ,L"textCanUp" ,0 ,0 ,0 },
|
||||
{L"mso-spt175" ,L"textCanDown" ,0 ,0 ,0 },
|
||||
{L"mso-spt188" ,L"textDoubleWave1" ,0 ,0 ,0 },
|
||||
|
||||
@ -60,6 +60,10 @@ std::wostream & operator << (std::wostream & _Wostream, const marker_style & _Va
|
||||
|
||||
std::wstring marker_style::parse(const std::wstring & Str)
|
||||
{
|
||||
if (Str.empty())
|
||||
{
|
||||
return L"none";
|
||||
}
|
||||
std::wstring tmp = Str;
|
||||
boost::algorithm::to_lower(tmp);
|
||||
|
||||
|
||||
@ -58,13 +58,11 @@ namespace _image_file_
|
||||
{
|
||||
bool GetResolution(const wchar_t* fileName, int & Width, int &Height, NSFonts::IApplicationFonts* appFonts)
|
||||
{
|
||||
if (!appFonts) return false;
|
||||
|
||||
CBgraFrame image;
|
||||
MetaFile::IMetaFile* meta_file = MetaFile::Create(appFonts);
|
||||
|
||||
bool bRet = false;
|
||||
if ( meta_file->LoadFromFile(fileName))
|
||||
if ( appFonts && meta_file->LoadFromFile(fileName))
|
||||
{
|
||||
double dX = 0, dY = 0, dW = 0, dH = 0;
|
||||
meta_file->GetBounds(&dX, &dY, &dW, &dH);
|
||||
@ -83,6 +81,18 @@ namespace _image_file_
|
||||
RELEASEOBJECT(meta_file);
|
||||
return bRet;
|
||||
}
|
||||
|
||||
void GenerateZeroImage(const std::wstring & fileName)
|
||||
{
|
||||
NSFile::CFileBinary file;
|
||||
if (file.CreateFileW(fileName))
|
||||
{
|
||||
BYTE pData[149] = {0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x08, 0x03, 0x00, 0x00, 0x01, 0x5f, 0xcc, 0x04, 0x2d, 0x00, 0x00, 0x00, 0x01, 0x73, 0x52, 0x47, 0x42, 0x00, 0xae, 0xce, 0x1c, 0xe9, 0x00, 0x00, 0x00, 0x04, 0x67, 0x41, 0x4d, 0x41, 0x00, 0x00, 0xb1, 0x8f, 0x0b, 0xfc, 0x61, 0x05, 0x00, 0x00, 0x00, 0x06, 0x50, 0x4c, 0x54, 0x45, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa5, 0x67, 0xb9, 0xcf, 0x00, 0x00, 0x00, 0x02, 0x74, 0x52, 0x4e, 0x53, 0xff, 0x00, 0xe5, 0xb7, 0x30, 0x4a, 0x00, 0x00, 0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x12, 0x74, 0x00, 0x00, 0x12, 0x74, 0x01, 0xde, 0x66, 0x1f, 0x78, 0x00, 0x00, 0x00, 0x0a, 0x49, 0x44, 0x41, 0x54, 0x18, 0x57, 0x63, 0x60, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01, 0xa3, 0xda, 0x3d, 0x94, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82};
|
||||
|
||||
file.WriteFile(pData, 149);
|
||||
file.CloseFile();
|
||||
}
|
||||
}
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
namespace cpdoccore {
|
||||
@ -101,11 +111,11 @@ int get_value_emu(double pt)
|
||||
{
|
||||
return static_cast<int>((pt* 360000 * 2.54) / 72);
|
||||
}
|
||||
bool parse_clipping(std::wstring strClipping,std::wstring fileName, double_4 & clip_rect, NSFonts::IApplicationFonts * appFonts)
|
||||
bool parse_clipping(std::wstring strClipping,std::wstring fileName, double_4 & clip_rect, NSFonts::IApplicationFonts *appFonts)
|
||||
{
|
||||
memset(clip_rect, 0, 4*sizeof(double));
|
||||
|
||||
if (strClipping.length() <1 || fileName.length()<1)return false;
|
||||
if (strClipping.empty() || fileName.empty()) return false;
|
||||
|
||||
//<top>, <right>, <bottom>, <left> - http://www.w3.org/TR/2001/REC-xsl-20011015/xslspec.html#clip
|
||||
|
||||
@ -114,7 +124,7 @@ bool parse_clipping(std::wstring strClipping,std::wstring fileName, double_4 & c
|
||||
std::vector<std::wstring> Points;
|
||||
std::vector<length> Points_pt;
|
||||
|
||||
boost::algorithm::split(Points,strClipping, boost::algorithm::is_any_of(L" ,"), boost::algorithm::token_compress_on);
|
||||
boost::algorithm::split(Points, strClipping, boost::algorithm::is_any_of(L" ,"), boost::algorithm::token_compress_on);
|
||||
|
||||
for (size_t i = 0; i < Points.size(); i++)
|
||||
{
|
||||
@ -125,9 +135,9 @@ bool parse_clipping(std::wstring strClipping,std::wstring fileName, double_4 & c
|
||||
|
||||
if (!bEnableCrop) return false;
|
||||
|
||||
int fileWidth=0,fileHeight=0;
|
||||
int fileWidth = 0,fileHeight = 0;
|
||||
|
||||
if (!_image_file_::GetResolution(fileName.data(), fileWidth, fileHeight, appFonts) || fileWidth<1 || fileHeight<1) return false;
|
||||
if (!_image_file_::GetResolution(fileName.data(), fileWidth, fileHeight, appFonts) || fileWidth < 1 || fileHeight < 1) return false;
|
||||
|
||||
if (Points_pt.size() > 3)//если другое количество точек .. попозже
|
||||
{
|
||||
@ -143,7 +153,7 @@ bool parse_clipping(std::wstring strClipping,std::wstring fileName, double_4 & c
|
||||
clip_rect[1] = clip_rect[1]*100/fileHeight;
|
||||
clip_rect[3] = clip_rect[3]*100/fileHeight;
|
||||
|
||||
if (clip_rect[0]<0.01 && clip_rect[1]<0.01 && clip_rect[2]<0.01 && clip_rect[3]<0.01)
|
||||
if (clip_rect[0] < 0.01 && clip_rect[1] < 0.01 && clip_rect[2] < 0.01 && clip_rect[3] < 0.01)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
@ -475,6 +485,8 @@ void Compute_GraphicFill(const common_draw_fill_attlist & props, const office_el
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((props.draw_color_mode_) && (*props.draw_color_mode_ == L"greyscale"))
|
||||
fill.bitmap->bGrayscale = true;
|
||||
}
|
||||
if (props.draw_fill_gradient_name_)
|
||||
{
|
||||
@ -607,7 +619,7 @@ void parse_string_to_points(std::wstring str, std::vector<length> & Points)
|
||||
}
|
||||
}
|
||||
|
||||
void oox_convert_transforms(std::wstring transformStr,std::vector<odf_reader::_property> & additional)
|
||||
void docx_convert_transforms(std::wstring transformStr,std::vector<odf_reader::_property> & additional)
|
||||
{
|
||||
std::vector<std::wstring> transforms;
|
||||
|
||||
@ -676,10 +688,10 @@ void xlsx_convert_transforms(std::wstring transformStr, oox::xlsx_conversion_con
|
||||
std::vector<std::wstring> transform;
|
||||
boost::algorithm::split(transform, transforms[i], boost::algorithm::is_any_of(L"("), boost::algorithm::token_compress_on);
|
||||
|
||||
if (transform.size()>1)//тока с аргументами
|
||||
if (transform.size() > 1)//тока с аргументами
|
||||
{
|
||||
int res=0;
|
||||
if ((res = transform[0].find(L"translate"))>=0)//перемещение
|
||||
size_t res=0;
|
||||
if ((res = transform[0].find(L"translate")) != std::wstring::npos)//перемещение
|
||||
{
|
||||
std::vector<length> Points ;
|
||||
parse_string_to_points(transform[1], Points);
|
||||
@ -693,7 +705,7 @@ void xlsx_convert_transforms(std::wstring transformStr, oox::xlsx_conversion_con
|
||||
Context.get_drawing_context().set_translate(x_pt,y_pt);
|
||||
}
|
||||
}
|
||||
else if ((res = transform[0].find(L"scale"))>=0)//масштабирование
|
||||
else if ((res = transform[0].find(L"scale")) != std::wstring::npos)//масштабирование
|
||||
{
|
||||
std::vector<length> Points ;
|
||||
parse_string_to_points(transform[1], Points);
|
||||
@ -706,19 +718,19 @@ void xlsx_convert_transforms(std::wstring transformStr, oox::xlsx_conversion_con
|
||||
Context.get_drawing_context().set_scale(x_pt,y_pt);
|
||||
}
|
||||
}
|
||||
else if ((res = transform[0].find(L"rotate"))>=0)//вращение
|
||||
else if ((res = transform[0].find(L"rotate")) != std::wstring::npos)//вращение
|
||||
{
|
||||
Context.get_drawing_context().set_rotate(boost::lexical_cast<double>(transform[1]));
|
||||
Context.get_drawing_context().set_rotate(boost::lexical_cast<double>(transform[1]), true);
|
||||
}
|
||||
else if ((res = transform[0].find(L"skewX"))>=0)//сдвиг
|
||||
else if ((res = transform[0].find(L"skewX")) != std::wstring::npos)//сдвиг
|
||||
{
|
||||
double angle = boost::lexical_cast<double>(transform[1]);
|
||||
Context.get_drawing_context().set_property(_property(L"svg:skewX",angle));
|
||||
Context.get_drawing_context().set_property(_property(L"svg:skewX", angle));
|
||||
}
|
||||
else if ((res = transform[0].find(L"skewY"))>=0)//сдвиг
|
||||
else if ((res = transform[0].find(L"skewY")) != std::wstring::npos)//сдвиг
|
||||
{
|
||||
double angle = boost::lexical_cast<double>(transform[1]);
|
||||
Context.get_drawing_context().set_property(_property(L"svg:skewY",angle));
|
||||
Context.get_drawing_context().set_property(_property(L"svg:skewY", angle));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -736,49 +748,50 @@ void pptx_convert_transforms(std::wstring transformStr, oox::pptx_conversion_con
|
||||
std::vector<std::wstring> transform;
|
||||
boost::algorithm::split(transform, transforms[i], boost::algorithm::is_any_of(L"("), boost::algorithm::token_compress_on);
|
||||
|
||||
if (transform.size()>1)//тока с аргументами
|
||||
if (transform.size() > 1)//тока с аргументами
|
||||
{
|
||||
int res=0;
|
||||
if ((res = transform[0].find(L"translate"))>=0)//перемещение
|
||||
size_t res = 0;
|
||||
if ((res = transform[0].find(L"translate")) != std::wstring::npos)//перемещение
|
||||
{
|
||||
std::vector<length> Points ;
|
||||
parse_string_to_points(transform[1], Points);
|
||||
|
||||
if (Points.size()>0)
|
||||
if (false == Points.empty())
|
||||
{
|
||||
double x_pt = Points[0].get_value_unit(length::pt);
|
||||
double y_pt = 0;
|
||||
if (Points.size()>1)y_pt = Points[1].get_value_unit(length::pt);//ее может не быть
|
||||
|
||||
Context.get_slide_context().set_translate(x_pt,y_pt);
|
||||
Context.get_slide_context().set_translate(x_pt, y_pt);
|
||||
}
|
||||
}
|
||||
else if ((res = transform[0].find(L"scale"))>=0)//масштабирование
|
||||
else if ((res = transform[0].find(L"scale")) != std::wstring::npos)//масштабирование
|
||||
{
|
||||
std::vector<length> Points ;
|
||||
parse_string_to_points(transform[1], Points);
|
||||
if (Points.size()>0)
|
||||
|
||||
if (false == Points.empty())
|
||||
{
|
||||
double x_pt = Points[0].get_value_unit(length::pt);
|
||||
double y_pt = x_pt;
|
||||
if (Points.size()>1)y_pt = Points[1].get_value_unit(length::pt);//ее может не быть
|
||||
|
||||
Context.get_slide_context().set_scale(x_pt,y_pt);
|
||||
Context.get_slide_context().set_scale(x_pt, y_pt);
|
||||
}
|
||||
}
|
||||
else if ((res = transform[0].find(L"rotate"))>=0)//вращение
|
||||
else if ((res = transform[0].find(L"rotate")) != std::wstring::npos)//вращение
|
||||
{
|
||||
Context.get_slide_context().set_rotate( boost::lexical_cast<double>(transform[1]));
|
||||
Context.get_slide_context().set_rotate( boost::lexical_cast<double>(transform[1]), true);
|
||||
}
|
||||
else if ((res = transform[0].find(L"skewX"))>=0)//вращение
|
||||
else if ((res = transform[0].find(L"skewX")) != std::wstring::npos)//вращение
|
||||
{
|
||||
double angle = boost::lexical_cast<double>(transform[1]);
|
||||
Context.get_slide_context().set_property(_property(L"svg:skewX",angle));
|
||||
Context.get_slide_context().set_property(_property(L"svg:skewX", angle));
|
||||
}
|
||||
else if ((res = transform[0].find(L"skewY"))>=0)//вращение
|
||||
else if ((res = transform[0].find(L"skewY")) != std::wstring::npos)//вращение
|
||||
{
|
||||
double angle = boost::lexical_cast<double>(transform[1]);
|
||||
Context.get_slide_context().set_property(_property(L"svg:skewY",angle));
|
||||
Context.get_slide_context().set_property(_property(L"svg:skewY", angle));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,7 +52,8 @@
|
||||
|
||||
namespace _image_file_
|
||||
{
|
||||
bool GetResolution(const wchar_t* fileName, int & Width, int &Height, NSFonts::IApplicationFonts * appFonts);
|
||||
bool GetResolution(const wchar_t* fileName, int & Width, int &Height, NSFonts::IApplicationFonts *appFonts);
|
||||
void GenerateZeroImage(const std::wstring & fileName);
|
||||
}
|
||||
|
||||
namespace cpdoccore {
|
||||
@ -74,7 +75,7 @@ void Compute_GraphicFill(const odf_types::common_draw_fill_attlist & props,
|
||||
const office_element_ptr & style_image, styles_lite_container &styles, oox::_oox_fill & fill, bool txbx = false);
|
||||
|
||||
typedef double double_4[4];
|
||||
bool parse_clipping(std::wstring strClipping,std::wstring fileName,double_4 & clip_rect, NSFonts::IApplicationFonts * appFonts);
|
||||
bool parse_clipping(std::wstring strClipping, std::wstring fileName, double_4 & clip_rect, NSFonts::IApplicationFonts *appFonts);
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
class draw_a : public office_element_impl<draw_a>
|
||||
{
|
||||
@ -110,10 +111,9 @@ private:
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(draw_a);
|
||||
|
||||
void xlsx_convert_transforms(std::wstring transformStr, oox::xlsx_conversion_context & Context);
|
||||
void docx_convert_transforms(std::wstring transformStr, std::vector<odf_reader::_property> & additional);
|
||||
void pptx_convert_transforms(std::wstring transformStr, oox::pptx_conversion_context & Context);
|
||||
void oox_convert_transforms(std::wstring transformStr,std::vector<odf_reader::_property> & additional);
|
||||
//void docx_convert_transforms(std::wstring transformStr, oox::xlsx_conversion_context & Context);
|
||||
void xlsx_convert_transforms(std::wstring transformStr, oox::xlsx_conversion_context & Context);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,8 +30,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "draw_frame.h"
|
||||
|
||||
#include <ostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
@ -42,6 +40,8 @@
|
||||
#include <xml/attributes.h>
|
||||
#include <odf/odf_document.h>
|
||||
|
||||
#include "draw_common.h"
|
||||
|
||||
#include "serialize_elements.h"
|
||||
#include "style_graphic_properties.h"
|
||||
#include "odfcontext.h"
|
||||
@ -54,6 +54,7 @@
|
||||
#include "datatypes/borderstyle.h"
|
||||
|
||||
#include "../../../OfficeUtils/src/OfficeUtils.h"
|
||||
#include "../../../Common/OfficeFileFormatChecker.h"
|
||||
#include "../../../Common/3dParty/pole/pole.h"
|
||||
|
||||
namespace cpdoccore {
|
||||
@ -153,6 +154,75 @@ void draw_g::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
void draw_g::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
CP_CREATE_ELEMENT(content_);
|
||||
|
||||
if (content_.empty()) return;
|
||||
|
||||
draw_g *group = dynamic_cast<draw_g*> (content_.back().get());
|
||||
draw_frame *frame = dynamic_cast<draw_frame*> (content_.back().get());
|
||||
draw_shape *shape = dynamic_cast<draw_shape*> (content_.back().get());
|
||||
|
||||
if (group)
|
||||
{
|
||||
int x = 0, y = 0, cx = 0, cy = 0;
|
||||
if (group->common_draw_attlists_.position_.svg_x_ && group->common_draw_attlists_.position_.svg_y_)
|
||||
{
|
||||
x = get_value_emu(group->common_draw_attlists_.position_.svg_x_);
|
||||
y = get_value_emu(group->common_draw_attlists_.position_.svg_y_);
|
||||
}
|
||||
else
|
||||
{
|
||||
x = group->position_child_x1;
|
||||
y = group->position_child_y1;
|
||||
}
|
||||
|
||||
if (group->common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_width_ &&
|
||||
group->common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_height_)
|
||||
{
|
||||
cx = get_value_emu(group->common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_width_);
|
||||
cy = get_value_emu(group->common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_height_);
|
||||
}
|
||||
else
|
||||
{
|
||||
cx = group->position_child_x2 - group->position_child_x1;
|
||||
cy = group->position_child_y2 - group->position_child_y1;
|
||||
}
|
||||
|
||||
if (position_child_x1 > x || position_child_x1 == 0x7fffffff) position_child_x1 = x;
|
||||
if (position_child_y1 > y || position_child_y1 == 0x7fffffff) position_child_y1 = y;
|
||||
|
||||
if (position_child_x2 < x + cx || position_child_x2 == 0x7fffffff) position_child_x2 = x + cx;
|
||||
if (position_child_y2 < y + cy || position_child_y2 == 0x7fffffff) position_child_y2 = y + cy;
|
||||
}
|
||||
else if (frame)
|
||||
{
|
||||
int x = 0, y = 0, cx = 0, cy = 0;
|
||||
x = get_value_emu(frame->common_draw_attlists_.position_.svg_x_);
|
||||
y = get_value_emu(frame->common_draw_attlists_.position_.svg_y_);
|
||||
|
||||
cx = get_value_emu(frame->common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_width_);
|
||||
cy = get_value_emu(frame->common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_height_);
|
||||
|
||||
if (position_child_x1 > x || position_child_x1 == 0x7fffffff) position_child_x1 = x;
|
||||
if (position_child_y1 > y || position_child_y1 == 0x7fffffff) position_child_y1 = y;
|
||||
|
||||
if (position_child_x2 < x + cx || position_child_x2 == 0x7fffffff) position_child_x2 = x + cx;
|
||||
if (position_child_y2 < y + cy || position_child_y2 == 0x7fffffff) position_child_y2 = y + cy;
|
||||
}
|
||||
else if (shape)
|
||||
{
|
||||
int x = 0, y = 0, cx = 0, cy = 0;
|
||||
x = get_value_emu(shape->common_draw_attlists_.position_.svg_x_);
|
||||
y = get_value_emu(shape->common_draw_attlists_.position_.svg_y_);
|
||||
|
||||
cx = get_value_emu(shape->common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_width_);
|
||||
cy = get_value_emu(shape->common_draw_attlists_.rel_size_.common_draw_size_attlist_.svg_height_);
|
||||
|
||||
if (position_child_x1 > x || position_child_x1 == 0x7fffffff) position_child_x1 = x;
|
||||
if (position_child_y1 > y || position_child_y1 == 0x7fffffff) position_child_y1 = y;
|
||||
|
||||
if (position_child_x2 < x + cx || position_child_x2 == 0x7fffffff) position_child_x2 = x + cx;
|
||||
if (position_child_y2 < y + cy || position_child_y2 == 0x7fffffff) position_child_y2 = y + cy;
|
||||
}
|
||||
}
|
||||
|
||||
std::wostream & draw_g::text_to_stream(std::wostream & _Wostream) const
|
||||
@ -295,50 +365,65 @@ void draw_object_ole::add_child_element( xml::sax * Reader, const std::wstring &
|
||||
CP_NOT_APPLICABLE_ELM();
|
||||
}
|
||||
|
||||
std::wstring draw_object_ole::detectObject(const std::wstring &fileName)
|
||||
void draw_object_ole::detectObject(const std::wstring &fileName, std::wstring &prog, std::wstring &extension, oox::RelsType &rels)
|
||||
{
|
||||
extension = L".bin";
|
||||
|
||||
POLE::Storage *storage = new POLE::Storage(fileName.c_str());
|
||||
if (storage == NULL) return L"";
|
||||
|
||||
if (storage->open(false, false) == false)
|
||||
if ((storage) && (storage->open(false, false) == true))
|
||||
{
|
||||
delete storage;
|
||||
return L"";
|
||||
}
|
||||
std::wstring prog;
|
||||
POLE::Stream* pStream = new POLE::Stream(storage, L"CompObj");
|
||||
if ((pStream) && (pStream->size() > 28))
|
||||
{
|
||||
//skip the CompObjHeader
|
||||
pStream->seek(28);
|
||||
rels = oox::typeOleObject;
|
||||
|
||||
int sz_obj = (int)pStream->size() - 28;
|
||||
|
||||
std::vector<std::string> str;
|
||||
|
||||
while (sz_obj > 0)
|
||||
std::wstring prog;
|
||||
POLE::Stream* pStream = new POLE::Stream(storage, L"CompObj");
|
||||
if ((pStream) && (pStream->size() > 28))
|
||||
{
|
||||
_UINT32 sz = 0;
|
||||
pStream->read((unsigned char*)&sz, 4); sz_obj-= 4;
|
||||
//skip the CompObjHeader
|
||||
pStream->seek(28);
|
||||
|
||||
int sz_obj = (int)pStream->size() - 28;
|
||||
|
||||
std::vector<std::string> str;
|
||||
|
||||
if (sz > sz_obj)
|
||||
break;
|
||||
unsigned char *data = new unsigned char[sz];
|
||||
pStream->read(data, sz);
|
||||
while (sz_obj > 0)
|
||||
{
|
||||
_UINT32 sz = 0;
|
||||
pStream->read((unsigned char*)&sz, 4); sz_obj-= 4;
|
||||
|
||||
if (sz > sz_obj)
|
||||
break;
|
||||
unsigned char *data = new unsigned char[sz];
|
||||
pStream->read(data, sz);
|
||||
|
||||
str.push_back(std::string((char*)data, sz));
|
||||
delete []data;
|
||||
str.push_back(std::string((char*)data, sz));
|
||||
delete []data;
|
||||
|
||||
sz_obj-= sz;
|
||||
}
|
||||
if (!str.empty())
|
||||
{
|
||||
prog = std::wstring (str.back().begin(), str.back().end());
|
||||
}
|
||||
delete pStream;
|
||||
}
|
||||
delete storage;
|
||||
}
|
||||
else
|
||||
{
|
||||
COfficeFileFormatChecker checker(fileName);
|
||||
switch(checker.nFileType)
|
||||
{
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOC: extension = L".doc"; prog = L"Word"; rels = oox::typeOleObject; break;
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX: extension = L".docx"; prog = L"Word"; rels = oox::typeMsObject; break;
|
||||
|
||||
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLS: extension = L".xls"; prog = L"Excel"; rels = oox::typeOleObject; break;
|
||||
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX: extension = L".xlsx"; prog = L"Excel"; rels = oox::typeMsObject; break;
|
||||
|
||||
case AVS_OFFICESTUDIO_FILE_PRESENTATION_PPT: extension = L".ppt"; prog = L"PowerPoint"; rels = oox::typeOleObject; break;
|
||||
case AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX: extension = L".pptx"; prog = L"PowerPoint"; rels = oox::typeMsObject; break;
|
||||
|
||||
sz_obj-= sz;
|
||||
}
|
||||
if (!str.empty())
|
||||
{
|
||||
prog = std::wstring (str.back().begin(), str.back().end());
|
||||
}
|
||||
delete pStream;
|
||||
}
|
||||
delete storage;
|
||||
return prog;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -209,6 +209,8 @@ public:
|
||||
static const ElementType type = typeDrawG;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
draw_g() : position_child_x1(0x7fffffff), position_child_y1(0x7fffffff), position_child_x2(0x7fffffff), position_child_y2(0x7fffffff) {}
|
||||
|
||||
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
|
||||
|
||||
virtual void docx_convert(oox::docx_conversion_context & Context);
|
||||
@ -220,6 +222,12 @@ public:
|
||||
|
||||
office_element_ptr_array content_;
|
||||
|
||||
int position_child_x1;
|
||||
int position_child_y1;
|
||||
|
||||
int position_child_x2;
|
||||
int position_child_y2;
|
||||
|
||||
private:
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
|
||||
@ -327,7 +335,7 @@ private:
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
|
||||
|
||||
std::wstring detectObject(const std::wstring &fileName);
|
||||
void detectObject(const std::wstring &fileName, std::wstring &prog, std::wstring &extension, oox::RelsType &rels);
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(draw_object_ole);
|
||||
|
||||
@ -574,11 +574,7 @@ int ComputeMarginY(const style_page_layout_properties_attlist & pageProperties,
|
||||
const graphic_format_properties & graphicProperties,
|
||||
const std::vector<odf_reader::_property> & additional)
|
||||
{
|
||||
// TODO : recursive result!!!
|
||||
const _CP_OPT(anchor_type) anchor =
|
||||
attlists_.shape_with_text_and_styles_.
|
||||
common_text_anchor_attlist_.
|
||||
type_;
|
||||
const _CP_OPT(anchor_type) anchor = attlists_.shape_with_text_and_styles_.common_text_anchor_attlist_.type_;
|
||||
|
||||
//todooo пока не ясно как привязать к определеной странице в документе ...
|
||||
//const _CP_OPT(unsigned int) anchor_page_number =
|
||||
@ -589,6 +585,15 @@ int ComputeMarginY(const style_page_layout_properties_attlist & pageProperties,
|
||||
_CP_OPT(vertical_rel) styleVerticalRel = graphicProperties.common_vertical_rel_attlist_.style_vertical_rel_;
|
||||
_CP_OPT(vertical_pos) styleVerticallPos = graphicProperties.common_vertical_pos_attlist_.style_vertical_pos_;
|
||||
|
||||
if (!styleVerticalRel && anchor)
|
||||
{
|
||||
switch(anchor->get_type())
|
||||
{
|
||||
case anchor_type::Paragraph: styleVerticalRel = vertical_rel::Paragraph; break;
|
||||
case anchor_type::Page: styleVerticalRel = vertical_rel::Page; break;
|
||||
}
|
||||
}
|
||||
|
||||
_CP_OPT(double) dVal;
|
||||
GetProperty(additional, L"svg:translate_y", dVal);
|
||||
|
||||
@ -817,14 +822,31 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, union_comm
|
||||
}
|
||||
|
||||
_CP_OPT(run_through) styleRunThrough = graphicProperties.style_run_through_;
|
||||
_CP_OPT(anchor_type) anchor = attlists_.shape_with_text_and_styles_.common_text_anchor_attlist_.type_;
|
||||
|
||||
drawing->styleHorizontalRel = graphicProperties.common_horizontal_rel_attlist_.style_horizontal_rel_;
|
||||
drawing->styleHorizontalPos = graphicProperties.common_horizontal_pos_attlist_.style_horizontal_pos_;
|
||||
drawing->styleVerticalPos = graphicProperties.common_vertical_pos_attlist_.style_vertical_pos_;
|
||||
drawing->styleVerticalRel = graphicProperties.common_vertical_rel_attlist_.style_vertical_rel_;
|
||||
|
||||
_CP_OPT(anchor_type) anchor = attlists_.shape_with_text_and_styles_.common_text_anchor_attlist_.type_;
|
||||
|
||||
|
||||
if (!drawing->styleVerticalRel && anchor)
|
||||
{
|
||||
switch(anchor->get_type())
|
||||
{
|
||||
case anchor_type::Paragraph: drawing->styleVerticalRel = vertical_rel::Paragraph; break;
|
||||
case anchor_type::Page: drawing->styleVerticalRel = vertical_rel::Page; break;
|
||||
case anchor_type::Char: drawing->styleVerticalRel = vertical_rel::Char; break;
|
||||
}
|
||||
}
|
||||
if (!drawing->styleHorizontalRel && anchor)
|
||||
{
|
||||
switch(anchor->get_type())
|
||||
{
|
||||
case anchor_type::Paragraph: drawing->styleHorizontalRel = horizontal_rel::Paragraph; break;
|
||||
case anchor_type::Page: drawing->styleHorizontalRel = horizontal_rel::Page; break;
|
||||
case anchor_type::Char: drawing->styleHorizontalRel = horizontal_rel::Char; break;
|
||||
}
|
||||
}
|
||||
int level_drawing = Context.get_drawing_context().get_current_level();
|
||||
|
||||
if (drawing->parallel == 1 || anchor && anchor->get_type() == anchor_type::AsChar || level_drawing >1 )
|
||||
@ -834,7 +856,7 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, union_comm
|
||||
if (attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_transform_)
|
||||
{
|
||||
std::wstring transformStr = attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_transform_.get();
|
||||
oox_convert_transforms(transformStr, drawing->additional);
|
||||
docx_convert_transforms(transformStr, drawing->additional);
|
||||
}
|
||||
if (!drawing->isInline)
|
||||
{
|
||||
@ -852,7 +874,7 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, union_comm
|
||||
if (!drawing->styleWrap)
|
||||
drawing->styleWrap = style_wrap(style_wrap::Parallel);//у опен офис и мс разные дефолты
|
||||
|
||||
_CP_OPT(int) zIndex = attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_z_index_;
|
||||
_CP_OPT(unsigned int) zIndex = attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_.draw_z_index_;
|
||||
|
||||
if (zIndex)//порядок отрисовки объектов
|
||||
{
|
||||
@ -874,20 +896,20 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, union_comm
|
||||
int type = attlists_.rel_size_.style_rel_width_->get_type();
|
||||
|
||||
if (type == odf_types::percent_or_scale::Percent)
|
||||
drawing->pctWidth = attlists_.rel_size_.style_rel_width_->get_percent().get_value();
|
||||
drawing->pctWidth = (int)attlists_.rel_size_.style_rel_width_->get_percent().get_value();
|
||||
}
|
||||
if (attlists_.rel_size_.style_rel_height_ )
|
||||
{
|
||||
int type = attlists_.rel_size_.style_rel_height_->get_type();
|
||||
|
||||
if (type == odf_types::percent_or_scale::Percent)
|
||||
drawing->pctHeight = attlists_.rel_size_.style_rel_height_->get_percent().get_value();
|
||||
drawing->pctHeight = (int)attlists_.rel_size_.style_rel_height_->get_percent().get_value();
|
||||
}
|
||||
|
||||
}
|
||||
drawing->number_wrapped_paragraphs = graphicProperties.style_number_wrapped_paragraphs_.
|
||||
get_value_or( integer_or_nolimit( integer_or_nolimit::NoLimit) ).get_value();
|
||||
if (anchor && anchor->get_type() == anchor_type::AsChar && drawing->posOffsetV< 0)
|
||||
if (anchor && anchor->get_type() == anchor_type::AsChar && drawing->posOffsetV < 0)
|
||||
{
|
||||
drawing->posOffsetV = (int)(length(0.01, length::cm).get_value_unit(length::emu));
|
||||
}
|
||||
@ -936,14 +958,41 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, union_comm
|
||||
drawing->cx = get_value_emu(attlists_.rel_size_.common_draw_size_attlist_.svg_width_);
|
||||
drawing->cy = get_value_emu(attlists_.rel_size_.common_draw_size_attlist_.svg_height_);
|
||||
|
||||
_CP_OPT(double) dVal;
|
||||
|
||||
GetProperty(drawing->additional, L"svg:rotate", dVal);
|
||||
if (dVal)
|
||||
{
|
||||
double new_x = (drawing->cx / 2 * cos(-(*dVal)) - drawing->cy / 2 * sin(-(*dVal)) ) - drawing->cx / 2;
|
||||
double new_y = (drawing->cx / 2 * sin(-(*dVal)) + drawing->cy / 2 * cos(-(*dVal)) ) - drawing->cy / 2;
|
||||
|
||||
drawing->x += new_x;
|
||||
drawing->y += new_y;
|
||||
}
|
||||
|
||||
GetProperty(drawing->additional, L"svg:scale_x",dVal);
|
||||
if (dVal)drawing->cx = (int)(0.5 + drawing->cx * dVal.get());
|
||||
|
||||
GetProperty(drawing->additional, L"svg:scale_y",dVal);
|
||||
if (dVal)drawing->cy = (int)(0.5 + drawing->cy * dVal.get());
|
||||
|
||||
GetProperty(drawing->additional, L"svg:translate_x", dVal);
|
||||
if (dVal)
|
||||
{
|
||||
drawing->x += get_value_emu(dVal.get());
|
||||
}
|
||||
GetProperty(drawing->additional, L"svg:translate_y", dVal);
|
||||
if (dVal)
|
||||
{
|
||||
drawing->y += get_value_emu(dVal.get());
|
||||
}
|
||||
|
||||
if (drawing->cx < 0) //frame textbox int WORD_EXAMPLE.odt = 45 inch !!!!
|
||||
{
|
||||
drawing->cx = -drawing->cx;
|
||||
drawing->additional.push_back(_property(L"fit-to-size", true));
|
||||
}
|
||||
|
||||
if (drawing->cy < 0)
|
||||
drawing->cy = 0;
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
if ((drawing->styleWrap) && (drawing->styleWrap->get_type() == style_wrap::Dynamic)) //автоподбор
|
||||
{
|
||||
@ -988,40 +1037,13 @@ void common_draw_docx_convert(oox::docx_conversion_context & Context, union_comm
|
||||
//}
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
_CP_OPT(double) dVal;
|
||||
|
||||
GetProperty(drawing->additional, L"svg:scale_x",dVal);
|
||||
if (dVal)drawing->cx = (int)(0.5 + drawing->cx * dVal.get());
|
||||
|
||||
GetProperty(drawing->additional, L"svg:scale_y",dVal);
|
||||
if (dVal)drawing->cy = (int)(0.5 + drawing->cy * dVal.get());
|
||||
|
||||
GetProperty(drawing->additional, L"svg:translate_x", dVal);
|
||||
if (dVal)
|
||||
{
|
||||
int val = get_value_emu(dVal.get());
|
||||
drawing->x = val >= 0 ? val : 0; //??? todooo отрицательные величины ...
|
||||
}
|
||||
|
||||
GetProperty(drawing->additional,L"svg:translate_y", dVal);
|
||||
if (dVal)
|
||||
{
|
||||
int val = get_value_emu(dVal.get());
|
||||
drawing->y = val >= 0 ? val : 0; //??? todooo отрицательные величины ...
|
||||
}
|
||||
|
||||
if (drawing->inGroup && drawing->type != oox::typeGroupShape)
|
||||
{
|
||||
Context.get_drawing_context().set_position_child_group (drawing->x, drawing->y);
|
||||
Context.get_drawing_context().set_size_child_group (drawing->cx + drawing->x, drawing->cy + drawing->y);
|
||||
|
||||
// ваще то тут "несовсем" всерно ... нужно сначала все стартовые позиции добавить ..
|
||||
_INT32 x_group_offset, y_group_offset;
|
||||
Context.get_drawing_context().get_position_group(x_group_offset, y_group_offset);
|
||||
|
||||
drawing->x -= x_group_offset;
|
||||
drawing->y -= y_group_offset;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -1030,15 +1052,17 @@ void draw_shape::docx_convert(oox::docx_conversion_context & Context)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
oox::_docx_drawing drawing = oox::_docx_drawing();
|
||||
|
||||
drawing.type = oox::typeShape;
|
||||
drawing.id = Context.get_drawing_context().get_current_shape_id();
|
||||
drawing.name = Context.get_drawing_context().get_current_object_name();
|
||||
drawing.inGroup = Context.get_drawing_context().in_group();
|
||||
drawing.type = oox::typeShape;
|
||||
drawing.id = Context.get_drawing_context().get_current_shape_id();
|
||||
drawing.name = Context.get_drawing_context().get_current_object_name();
|
||||
drawing.inGroup = Context.get_drawing_context().in_group();
|
||||
drawing.lined = lined_shape_;
|
||||
drawing.connector = connector_;
|
||||
|
||||
drawing.sub_type = sub_type_;
|
||||
drawing.additional = additional_;//сюда могут добавиться свойства ...
|
||||
|
||||
if (drawing.sub_type !=5 )//line
|
||||
if (drawing.lined == false)
|
||||
{
|
||||
drawing.additional.push_back(_property(L"text-content", Context.get_drawing_context().get_text_stream_shape()));
|
||||
}
|
||||
@ -1119,7 +1143,7 @@ void draw_image::docx_convert(oox::docx_conversion_context & Context)
|
||||
return;
|
||||
|
||||
std::wstring href = xlink_attlist_.href_.get_value_or(L"");
|
||||
int pos_replaicement = href.find(L"ObjectReplacements");
|
||||
size_t pos_replaicement = href.find(L"ObjectReplacements");
|
||||
|
||||
const draw_frame * frame = Context.get_drawing_context().get_current_frame();//owner
|
||||
if (!frame)
|
||||
@ -1128,7 +1152,7 @@ void draw_image::docx_convert(oox::docx_conversion_context & Context)
|
||||
oox::_docx_drawing * drawing = dynamic_cast<oox::_docx_drawing *>(frame->oox_drawing_.get());
|
||||
if (!drawing) return;
|
||||
|
||||
if (pos_replaicement >= 0)
|
||||
if (pos_replaicement != std::wstring::npos)
|
||||
{
|
||||
if (!Context.get_drawing_context().get_use_image_replace())
|
||||
return; //skip replacement image (math, chart, ...) - возможно записать как альтернативный контент - todooo ???
|
||||
@ -1190,10 +1214,18 @@ void draw_image::docx_convert(oox::docx_conversion_context & Context)
|
||||
std::wstring strRectClip = properties->fo_clip_.get();
|
||||
strRectClip = strRectClip.substr(5, strRectClip.length() - 6);
|
||||
|
||||
std::wstring fileName = Context.root()->get_folder() + FILE_SEPARATOR_STR + href;
|
||||
std::wstring fileName = Context.root()->get_folder() + FILE_SEPARATOR_STR + xlink_attlist_.href_.get_value_or(L"");
|
||||
|
||||
drawing->fill.bitmap->bCrop = parse_clipping(strRectClip, fileName, drawing->fill.bitmap->cropRect, NULL/*Context.applicationFonts_*/);
|
||||
}
|
||||
drawing->fill.bitmap->bCrop = parse_clipping(strRectClip, fileName, drawing->fill.bitmap->cropRect, Context.get_mediaitems().applicationFonts());
|
||||
}
|
||||
if (properties->common_draw_fill_attlist_.draw_luminance_)
|
||||
{
|
||||
drawing->fill.bitmap->luminance = properties->common_draw_fill_attlist_.draw_luminance_->get_value();
|
||||
}
|
||||
if (properties->common_draw_fill_attlist_.draw_contrast_)
|
||||
{
|
||||
drawing->fill.bitmap->contrast = properties->common_draw_fill_attlist_.draw_contrast_->get_value();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1347,9 +1379,18 @@ void draw_g::docx_convert(oox::docx_conversion_context & Context)
|
||||
|
||||
Context.reset_context_state();
|
||||
|
||||
if (position_child_x1 != 0x7fffffff && position_child_y1 != 0x7fffffff )
|
||||
{
|
||||
Context.get_drawing_context().set_position_child_group (position_child_x1, position_child_y1);
|
||||
|
||||
if (position_child_x2 != 0x7fffffff && position_child_y2 != 0x7fffffff )
|
||||
{
|
||||
Context.get_drawing_context().set_size_child_group (position_child_x2 - position_child_x1, position_child_y2 - position_child_y1);
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
{
|
||||
ElementType type = content_[i]->get_type();
|
||||
content_[i]->docx_convert(Context);
|
||||
}
|
||||
drawing.content_group_ = temp_stream.str();
|
||||
@ -1360,18 +1401,11 @@ void draw_g::docx_convert(oox::docx_conversion_context & Context)
|
||||
//--------------------------------------------------
|
||||
Context.get_drawing_context().get_size_group (drawing.cx , drawing.cy);
|
||||
Context.get_drawing_context().get_position_group(drawing.x , drawing.y);
|
||||
|
||||
drawing.cx -= drawing.x;
|
||||
drawing.cy -= drawing.y;
|
||||
|
||||
|
||||
Context.get_drawing_context().stop_group();
|
||||
|
||||
if (drawing.inGroup)
|
||||
{
|
||||
Context.get_drawing_context().set_position_child_group (drawing.x, drawing.y);
|
||||
Context.get_drawing_context().set_size_child_group (drawing.cx + drawing.x, drawing.cy + drawing.y);
|
||||
|
||||
// ваще то тут "несовсем" верно ... нужно сначала все стартовые позиции добавить ..
|
||||
_INT32 x_group_offset, y_group_offset;
|
||||
Context.get_drawing_context().get_position_group(x_group_offset, y_group_offset);
|
||||
|
||||
@ -1636,18 +1670,20 @@ void draw_object_ole::docx_convert(oox::docx_conversion_context & Context)
|
||||
|
||||
if (href.empty()) return;
|
||||
|
||||
draw_frame* frame = Context.get_drawing_context().get_current_frame(); //owner
|
||||
draw_frame* frame = Context.get_drawing_context().get_current_frame(); //owner
|
||||
if (!frame) return;
|
||||
|
||||
oox::_docx_drawing * drawing = dynamic_cast<oox::_docx_drawing *>(frame->oox_drawing_.get());
|
||||
oox::_docx_drawing * drawing = dynamic_cast<oox::_docx_drawing *>(frame->oox_drawing_.get());
|
||||
if (!drawing) return;
|
||||
|
||||
drawing->type = oox::typeOleObject;
|
||||
|
||||
bool isMediaInternal = true;
|
||||
drawing->objectId = Context.get_mediaitems().add_or_find(href, drawing->type, isMediaInternal, href);
|
||||
std::wstring extension;
|
||||
detectObject(objectPath, drawing->objectProgId, extension, drawing->type);
|
||||
|
||||
NSFile::CFileBinary::Copy(objectPath, objectPath + extension);
|
||||
|
||||
bool isMediaInternal = true;
|
||||
drawing->objectId = Context.get_mediaitems().add_or_find(href + extension, drawing->type, isMediaInternal, href);
|
||||
|
||||
drawing->objectProgId = detectObject(objectPath);
|
||||
}
|
||||
void draw_control::docx_convert(oox::docx_conversion_context & Context)
|
||||
{
|
||||
|
||||
@ -88,7 +88,7 @@ void draw_frame::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
common_shape_draw_attlist &common_draw_attlist_ = common_draw_attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_;
|
||||
common_presentation_attlist &common_presentation_attlist_= common_draw_attlists_.shape_with_text_and_styles_.common_presentation_attlist_;
|
||||
|
||||
const int z_index = common_draw_attlist_.draw_z_index_.get_value_or(0);
|
||||
const unsigned int z_index = common_draw_attlist_.draw_z_index_.get_value_or(0);
|
||||
const std::wstring name = common_draw_attlist_.draw_name_.get_value_or(L"");
|
||||
const std::wstring textStyleName = common_draw_attlist_.draw_text_style_name_.get_value_or(L"");
|
||||
|
||||
@ -115,7 +115,7 @@ void draw_frame::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
if (common_draw_attlist_.draw_transform_)
|
||||
{
|
||||
std::wstring transformStr = common_draw_attlist_.draw_transform_.get();
|
||||
pptx_convert_transforms(transformStr,Context);
|
||||
pptx_convert_transforms(transformStr, Context);
|
||||
}
|
||||
////////////////////////////////////////
|
||||
std::wstring Anchor;
|
||||
@ -125,7 +125,7 @@ void draw_frame::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
const double a_x_pt = common_draw_attlists_.shape_with_text_and_styles_.common_shape_table_attlist_.table_end_x_.get_value_or(length(0)).get_value_unit(length::pt);
|
||||
const double a_y_pt = common_draw_attlists_.shape_with_text_and_styles_.common_shape_table_attlist_.table_end_y_.get_value_or(length(0)).get_value_unit(length::pt);
|
||||
|
||||
Context.get_slide_context().set_anchor(Anchor,a_x_pt,a_y_pt);
|
||||
Context.get_slide_context().set_anchor(Anchor, a_x_pt, a_y_pt);
|
||||
}
|
||||
//////////////////////////////////////////////
|
||||
std::vector<const odf_reader::style_instance *> instances;
|
||||
@ -162,7 +162,13 @@ void draw_frame::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
|
||||
oox::_oox_fill fill;
|
||||
Compute_GraphicFill(properties.common_draw_fill_attlist_, properties.style_background_image_,
|
||||
Context.root()->odf_context().drawStyles() ,fill);
|
||||
Context.root()->odf_context().drawStyles(), fill);
|
||||
if (properties.fo_clip_)
|
||||
{
|
||||
std::wstring strRectClip = properties.fo_clip_.get();
|
||||
Context.get_slide_context().set_clipping(strRectClip.substr(5, strRectClip.length() - 6));
|
||||
}
|
||||
|
||||
Context.get_slide_context().set_fill(fill);
|
||||
|
||||
Context.get_slide_context().set_property(odf_reader::_property(L"border_width_left", Compute_BorderWidth(properties, sideLeft)));
|
||||
@ -170,11 +176,6 @@ void draw_frame::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
Context.get_slide_context().set_property(odf_reader::_property(L"border_width_right", Compute_BorderWidth(properties, sideRight)));
|
||||
Context.get_slide_context().set_property(odf_reader::_property(L"border_width_bottom", Compute_BorderWidth(properties, sideBottom)));
|
||||
|
||||
if (properties.fo_clip_)
|
||||
{
|
||||
std::wstring strRectClip = properties.fo_clip_.get();
|
||||
Context.get_slide_context().set_clipping(strRectClip.substr(5,strRectClip.length()-6));
|
||||
}
|
||||
if (common_presentation_attlist_.presentation_class_)
|
||||
{
|
||||
Context.get_slide_context().set_placeHolder_type(common_presentation_attlist_.presentation_class_->get_type_ms());
|
||||
@ -221,7 +222,7 @@ void draw_image::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
}
|
||||
std::wstring text_content_ = Context.get_text_context().end_object();
|
||||
|
||||
if (text_content_.length()>0)
|
||||
if (!text_content_.empty())
|
||||
{
|
||||
Context.get_slide_context().set_property(_property(L"text-content", text_content_));
|
||||
}
|
||||
@ -384,7 +385,18 @@ void draw_object_ole::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
std::wstring objectPath = folderPath + FILE_SEPARATOR_STR + href;
|
||||
|
||||
if (!href.empty())
|
||||
Context.get_slide_context().set_ole_object(href, detectObject(objectPath));
|
||||
{
|
||||
std::wstring prog, extension;
|
||||
oox::RelsType relsType;
|
||||
detectObject(objectPath, prog, extension, relsType);
|
||||
|
||||
NSFile::CFileBinary::Copy(objectPath, objectPath + extension);
|
||||
|
||||
if (relsType == oox::typeMsObject)
|
||||
Context.get_slide_context().set_ms_object(href + extension, prog);
|
||||
else
|
||||
Context.get_slide_context().set_ole_object(href + extension, prog);
|
||||
}
|
||||
}
|
||||
|
||||
void draw_param::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
|
||||
@ -73,8 +73,8 @@ void draw_g::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
common_draw_shape_with_text_and_styles_attlist common_draw_attlist_ = common_draw_attlists_.shape_with_text_and_styles_;
|
||||
|
||||
const int z_index = common_draw_attlist_.common_shape_draw_attlist_.draw_z_index_.get_value_or(0);
|
||||
const std::wstring name = common_draw_attlist_.common_shape_draw_attlist_.draw_name_.get_value_or(L"");
|
||||
const unsigned int z_index = common_draw_attlist_.common_shape_draw_attlist_.draw_z_index_.get_value_or(0);
|
||||
const std::wstring name = common_draw_attlist_.common_shape_draw_attlist_.draw_name_.get_value_or(L"");
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
Context.get_drawing_context().start_group( name);
|
||||
@ -118,7 +118,7 @@ void draw_frame::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
common_draw_shape_with_text_and_styles_attlist common_draw_attlist_ = common_draw_attlists_.shape_with_text_and_styles_;
|
||||
|
||||
const int z_index = common_draw_attlist_.common_shape_draw_attlist_.draw_z_index_.get_value_or(0);
|
||||
const unsigned int z_index = common_draw_attlist_.common_shape_draw_attlist_.draw_z_index_.get_value_or(0);
|
||||
const std::wstring name = common_draw_attlist_.common_shape_draw_attlist_.draw_name_.get_value_or(L"");
|
||||
const std::wstring styleName = common_draw_attlist_.common_shape_draw_attlist_.draw_style_name_.get_value_or(L"");
|
||||
const std::wstring textStyleName = common_draw_attlist_.common_shape_draw_attlist_.draw_text_style_name_.get_value_or(L"");
|
||||
@ -144,7 +144,7 @@ void draw_frame::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
if (common_draw_attlist_.common_shape_draw_attlist_.draw_transform_)
|
||||
{
|
||||
std::wstring transformStr = common_draw_attlist_.common_shape_draw_attlist_.draw_transform_.get();
|
||||
xlsx_convert_transforms(transformStr,Context);
|
||||
xlsx_convert_transforms(transformStr, Context);
|
||||
}
|
||||
////////////////////////////////////////
|
||||
std::wstring Anchor;
|
||||
@ -179,14 +179,14 @@ void draw_frame::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
Context.get_drawing_context().set_property(odf_reader::_property(L"border_width_right", Compute_BorderWidth(properties, sideRight)));
|
||||
Context.get_drawing_context().set_property(odf_reader::_property(L"border_width_bottom", Compute_BorderWidth(properties, sideBottom)));
|
||||
|
||||
oox::_oox_fill fill;
|
||||
Compute_GraphicFill(properties.common_draw_fill_attlist_, properties.style_background_image_,
|
||||
Context.root()->odf_context().drawStyles(), fill);
|
||||
if (properties.fo_clip_)
|
||||
{
|
||||
std::wstring strRectClip = properties.fo_clip_.get();
|
||||
Context.get_drawing_context().set_clipping(strRectClip.substr(5,strRectClip.length()-6));
|
||||
Context.get_drawing_context().set_clipping(strRectClip.substr(5, strRectClip.length() - 6));
|
||||
}
|
||||
oox::_oox_fill fill;
|
||||
Compute_GraphicFill(properties.common_draw_fill_attlist_, properties.style_background_image_,
|
||||
Context.root()->odf_context().drawStyles() ,fill);
|
||||
Context.get_drawing_context().set_fill(fill);
|
||||
|
||||
oox_drawing_ = oox_drawing_ptr(new oox::_xlsx_drawing());
|
||||
@ -228,7 +228,7 @@ void draw_image::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
}
|
||||
std::wstring text_content_ = Context.get_text_context().end_drawing_content();
|
||||
|
||||
if (text_content_.length()>0)
|
||||
if (!text_content_.empty())
|
||||
{
|
||||
Context.get_drawing_context().set_property(_property(L"text-content", text_content_));
|
||||
}
|
||||
@ -359,8 +359,18 @@ void draw_object_ole::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
std::wstring objectPath = folderPath + FILE_SEPARATOR_STR + href;
|
||||
|
||||
if (!href.empty())
|
||||
Context.get_drawing_context().set_ole_object(href, detectObject(objectPath));
|
||||
|
||||
{
|
||||
std::wstring prog, extension;
|
||||
oox::RelsType relsType;
|
||||
detectObject(objectPath, prog, extension, relsType);
|
||||
|
||||
NSFile::CFileBinary::Copy(objectPath, objectPath + extension);
|
||||
|
||||
if (relsType == oox::typeMsObject)
|
||||
Context.get_drawing_context().set_ms_object(href + extension, prog);
|
||||
else
|
||||
Context.get_drawing_context().set_ole_object(href + extension, prog);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -174,6 +174,7 @@ void draw_line::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
draw_shape::add_attributes(Attributes);
|
||||
|
||||
sub_type_ = 5;
|
||||
lined_shape_ = true;
|
||||
}
|
||||
void draw_line::reset_svg_attributes()
|
||||
{
|
||||
@ -256,8 +257,11 @@ void draw_path::reset_svg_path()
|
||||
std::vector<::svg_path::_polyline> o_Polyline_pt;
|
||||
std::vector<::svg_path::_polyline> o_Polyline_cm;
|
||||
|
||||
bool res = ::svg_path::parseSvgD(o_Polyline_cm, draw_path_attlist_.svg_d_.get(), false);
|
||||
bool bClosed = false;
|
||||
bool res = ::svg_path::parseSvgD(o_Polyline_cm, draw_path_attlist_.svg_d_.get(), false, bClosed);
|
||||
|
||||
if (!bClosed) lined_shape_ = true;
|
||||
|
||||
for (size_t i = 0; i < o_Polyline_cm.size(); i++)
|
||||
{
|
||||
::svg_path::_polyline & poly = o_Polyline_cm[i];
|
||||
@ -275,7 +279,7 @@ void draw_path::reset_svg_path()
|
||||
}
|
||||
o_Polyline_pt.push_back(poly);
|
||||
}
|
||||
if (o_Polyline_pt.size()>0)
|
||||
if (false == o_Polyline_pt.empty())
|
||||
{
|
||||
//сформируем xml-oox сдесь ... а то придется плодить массивы в drawing .. хоть и не красиво..
|
||||
std::wstringstream output_;
|
||||
@ -291,18 +295,24 @@ void draw_polygon_attlist::add_attributes( const xml::attributes_wc_ptr & Attrib
|
||||
CP_APPLY_ATTR(L"svg:viewBox", svg_viewbox_);
|
||||
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------
|
||||
// draw:polygon
|
||||
//-------------------------------------------------------------------------------------------
|
||||
const wchar_t * draw_polygon::ns = L"draw";
|
||||
const wchar_t * draw_polygon::name = L"polygon";
|
||||
|
||||
//-------------------------------------------------------------------------------------------
|
||||
// draw:contour-polygon
|
||||
//-------------------------------------------------------------------------------------------
|
||||
const wchar_t * draw_contour_polygon::ns = L"draw";
|
||||
const wchar_t * draw_contour_polygon::name = L"contour-polygon";
|
||||
|
||||
//-------------------------------------------------------------------------------------------
|
||||
// draw:contour-path
|
||||
//-------------------------------------------------------------------------------------------
|
||||
const wchar_t * draw_contour_path::ns = L"draw";
|
||||
const wchar_t * draw_contour_path::name = L"contour-path";
|
||||
|
||||
//-------------------------------------------------------------------------------------------
|
||||
// draw:polygon
|
||||
//-------------------------------------------------------------------------------------------
|
||||
const wchar_t * draw_polygon::ns = L"draw";
|
||||
const wchar_t * draw_polygon::name = L"polygon";
|
||||
|
||||
void draw_polygon::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
draw_polygon_attlist_.add_attributes(Attributes);
|
||||
@ -322,7 +332,7 @@ void draw_polygon::reset_polygon_path()
|
||||
std::vector<::svg_path::_polyline> o_Polyline_pt;
|
||||
std::vector<::svg_path::_polyline> o_Polyline_cm;
|
||||
|
||||
bool res = ::svg_path::parsePolygon(o_Polyline_cm, draw_polygon_attlist_.draw_points_.get(),false, true);
|
||||
bool res = ::svg_path::parsePolygon(o_Polyline_cm, draw_polygon_attlist_.draw_points_.get(), false, true);
|
||||
|
||||
for (size_t ind = 0 ; ind < o_Polyline_cm.size(); ind++)
|
||||
{
|
||||
@ -341,12 +351,12 @@ void draw_polygon::reset_polygon_path()
|
||||
}
|
||||
o_Polyline_pt.push_back(poly);
|
||||
}
|
||||
if (o_Polyline_pt.size()>0)
|
||||
if (false == o_Polyline_pt.empty())
|
||||
{
|
||||
//сформируем xml-oox сдесь ... а то придется плодить массивы в drawing .. хоть и не красиво..
|
||||
std::wstringstream output_;
|
||||
::svg_path::oox_serialize(output_, o_Polyline_pt);
|
||||
additional_.push_back(odf_reader::_property(L"custom_path",output_.str()));
|
||||
additional_.push_back(odf_reader::_property(L"custom_path", output_.str()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -368,7 +378,8 @@ void draw_polyline::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
draw_polyline_attlist_.add_attributes(Attributes);
|
||||
draw_shape::add_attributes(Attributes);
|
||||
|
||||
sub_type_ = 8;
|
||||
sub_type_ = 14;
|
||||
lined_shape_ = true;
|
||||
|
||||
}
|
||||
void draw_polyline::reset_polyline_path()
|
||||
@ -382,7 +393,7 @@ void draw_polyline::reset_polyline_path()
|
||||
std::vector<::svg_path::_polyline> o_Polyline_pt;
|
||||
std::vector<::svg_path::_polyline> o_Polyline_cm;
|
||||
|
||||
bool res = ::svg_path::parsePolygon(o_Polyline_cm, draw_polyline_attlist_.draw_points_.get(), false, true);
|
||||
bool res = ::svg_path::parsePolygon(o_Polyline_cm, draw_polyline_attlist_.draw_points_.get(), false, false);
|
||||
|
||||
_CP_OPT(double) start_x, start_y;
|
||||
|
||||
@ -407,7 +418,7 @@ void draw_polyline::reset_polyline_path()
|
||||
}
|
||||
o_Polyline_pt.push_back(poly);
|
||||
}
|
||||
if (o_Polyline_pt.size()>0)
|
||||
if (false == o_Polyline_pt.empty())
|
||||
{
|
||||
//сформируем xml-oox сдесь ... а то придется плодить массивы в drawing .. хоть и не красиво..
|
||||
std::wstringstream output_;
|
||||
@ -481,6 +492,8 @@ void draw_enhanced_geometry_attlist::add_attributes( const xml::attributes_wc_pt
|
||||
CP_APPLY_ATTR(L"draw:enhanced-path" , draw_enhanced_path_);
|
||||
CP_APPLY_ATTR(L"drawooo:enhanced-path" , drawooo_enhanced_path_);
|
||||
CP_APPLY_ATTR(L"drawooo:sub-view-size" , drawooo_sub_view_size_);
|
||||
CP_APPLY_ATTR(L"draw:mirror-horizontal" , draw_mirror_horizontal_);
|
||||
CP_APPLY_ATTR(L"draw:mirror-vertical" , draw_mirror_vertical_);
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------
|
||||
// draw:enhanced_geometry
|
||||
@ -490,7 +503,7 @@ const wchar_t * draw_enhanced_geometry::name = L"enhanced-geometry";
|
||||
|
||||
void draw_enhanced_geometry::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
draw_enhanced_geometry_attlist_.add_attributes(Attributes);
|
||||
attlist_.add_attributes(Attributes);
|
||||
CP_APPLY_ATTR(L"svg:viewBox", svg_viewbox_);
|
||||
}
|
||||
|
||||
@ -514,20 +527,20 @@ void draw_enhanced_geometry::add_child_element( xml::sax * Reader, const std::ws
|
||||
}
|
||||
void draw_enhanced_geometry::find_draw_type_oox()
|
||||
{
|
||||
word_art_ = false;
|
||||
bOoxType_ = false;
|
||||
word_art_ = false;
|
||||
bOoxType_ = false;
|
||||
|
||||
if (draw_enhanced_geometry_attlist_.draw_text_path_ &&
|
||||
*draw_enhanced_geometry_attlist_.draw_text_path_ == true)
|
||||
if (attlist_.draw_text_path_ &&
|
||||
*attlist_.draw_text_path_ == true)
|
||||
{
|
||||
draw_type_oox_index_ = 0;
|
||||
word_art_ = true;
|
||||
sub_type_ = 1;
|
||||
}
|
||||
|
||||
if (draw_enhanced_geometry_attlist_.draw_type_)
|
||||
if (attlist_.draw_type_)
|
||||
{
|
||||
std::wstring odf_type = draw_enhanced_geometry_attlist_.draw_type_.get();
|
||||
std::wstring odf_type = attlist_.draw_type_.get();
|
||||
|
||||
if (word_art_)
|
||||
{
|
||||
@ -546,11 +559,11 @@ void draw_enhanced_geometry::find_draw_type_oox()
|
||||
if (!draw_type_oox_index_)
|
||||
{
|
||||
int count = sizeof(_OO_OOX_custom_shapes) / sizeof(_shape_converter);
|
||||
int pos = odf_type.find(L"ooxml-");
|
||||
size_t pos = odf_type.find(L"ooxml-");
|
||||
|
||||
if (pos < 0)
|
||||
if (pos == std::wstring::npos)
|
||||
{
|
||||
for (long i = 0; i< count; i++)
|
||||
for (long i = 0; i < count; i++)
|
||||
{
|
||||
if (_OO_OOX_custom_shapes[i].odf_reader == odf_type)
|
||||
{
|
||||
@ -562,7 +575,7 @@ void draw_enhanced_geometry::find_draw_type_oox()
|
||||
else
|
||||
{
|
||||
std::wstring oox_type = odf_type.substr(pos + 6);
|
||||
for (long i = 0; i< count; i++)
|
||||
for (long i = 0; i < count; i++)
|
||||
{
|
||||
if (_OO_OOX_custom_shapes[i].oox == oox_type)
|
||||
{
|
||||
@ -572,7 +585,7 @@ void draw_enhanced_geometry::find_draw_type_oox()
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((draw_type_oox_index_) && (*draw_type_oox_index_== 179))//L"textBox"
|
||||
if ((draw_type_oox_index_) && (*draw_type_oox_index_== 96))//L"textBox" "mso-spt24"
|
||||
{
|
||||
sub_type_ = 1;//textBox
|
||||
}
|
||||
@ -649,21 +662,23 @@ void draw_connector::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
draw_line_attlist_.add_attributes(Attributes);
|
||||
draw_shape::add_attributes(Attributes);
|
||||
|
||||
sub_type_ = 5; //коннектор - линия, если ломаная (ниже определяется) - то путь
|
||||
|
||||
sub_type_ = 10; //коннектор - линия, если ломаная (ниже определяется) - то путь
|
||||
lined_shape_ = true;
|
||||
connector_ = true;
|
||||
}
|
||||
void draw_connector::reset_svg_path()
|
||||
{
|
||||
if (!draw_connector_attlist_.svg_d_)
|
||||
{
|
||||
bad_shape_ = true;
|
||||
}
|
||||
else
|
||||
if (draw_connector_attlist_.svg_d_)
|
||||
{
|
||||
sub_type_ = 8;
|
||||
|
||||
std::vector<::svg_path::_polyline> o_Polyline_pt;
|
||||
std::vector<::svg_path::_polyline> o_Polyline_cm;
|
||||
|
||||
bool res = ::svg_path::parseSvgD(o_Polyline_cm, draw_connector_attlist_.svg_d_.get(), false);
|
||||
bool bClosed = false;
|
||||
bool res = ::svg_path::parseSvgD(o_Polyline_cm, draw_connector_attlist_.svg_d_.get(), false, bClosed);
|
||||
|
||||
if (!bClosed) lined_shape_ = true;
|
||||
|
||||
double x1=common_draw_attlists_.position_.svg_x_.get_value_or(length(0)).get_value_unit(length::emu);
|
||||
double y1=common_draw_attlists_.position_.svg_y_.get_value_or(length(0)).get_value_unit(length::emu);
|
||||
@ -707,7 +722,7 @@ void dr3d_scene::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
draw_shape::add_attributes(Attributes);
|
||||
|
||||
sub_type_ = 10;
|
||||
sub_type_ = 12;
|
||||
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------
|
||||
@ -718,13 +733,22 @@ const wchar_t * dr3d_extrude::name = L"extrude";
|
||||
|
||||
void dr3d_extrude::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
CP_APPLY_ATTR(L"svg:d", svg_d_);
|
||||
CP_APPLY_ATTR(L"svg:viewBox", svg_viewbox_);
|
||||
draw_path::add_attributes(Attributes);
|
||||
|
||||
//sub_type_ = ??
|
||||
}
|
||||
void dr3d_extrude::reset_svg_path()
|
||||
{
|
||||
if (!svg_d_) return;
|
||||
|
||||
//-------------------------------------------------------------------------------------------
|
||||
// dr3d:rotate
|
||||
//-------------------------------------------------------------------------------------------
|
||||
const wchar_t * dr3d_rotate::ns = L"dr3d";
|
||||
const wchar_t * dr3d_rotate::name = L"rotate";
|
||||
|
||||
void dr3d_rotate::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
draw_path::add_attributes(Attributes);
|
||||
|
||||
//sub_type_ = ??
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------
|
||||
// dr3d:light
|
||||
@ -740,6 +764,38 @@ void dr3d_light::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
CP_APPLY_ATTR(L"dr3d:enabled", dr3d_enabled_);
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------
|
||||
// dr3d:cube
|
||||
//-------------------------------------------------------------------------------------------
|
||||
const wchar_t * dr3d_cube::ns = L"dr3d";
|
||||
const wchar_t * dr3d_cube::name = L"cube";
|
||||
|
||||
void dr3d_cube::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
draw_shape::add_attributes(Attributes);
|
||||
|
||||
CP_APPLY_ATTR(L"dr3d:max-edge", dr3d_max_edge_);
|
||||
CP_APPLY_ATTR(L"dr3d:min-edge", dr3d_min_edge_);
|
||||
CP_APPLY_ATTR(L"dr3d:transform", dr3d_transform_);
|
||||
|
||||
sub_type_ = 15;
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------
|
||||
// dr3d:sphere
|
||||
//-------------------------------------------------------------------------------------------
|
||||
const wchar_t * dr3d_sphere::ns = L"dr3d";
|
||||
const wchar_t * dr3d_sphere::name = L"sphere";
|
||||
|
||||
void dr3d_sphere::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
draw_shape::add_attributes(Attributes);
|
||||
|
||||
CP_APPLY_ATTR(L"dr3d:size", dr3d_size_); //vector3D
|
||||
CP_APPLY_ATTR(L"dr3d:center", dr3d_center_); //vector3D
|
||||
CP_APPLY_ATTR(L"dr3d:transform",dr3d_transform_);
|
||||
|
||||
sub_type_ = 16;
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------
|
||||
// draw:control
|
||||
//-------------------------------------------------------------------------------------------
|
||||
const wchar_t * draw_control::ns = L"draw";
|
||||
|
||||
@ -63,7 +63,7 @@ public:
|
||||
static const ElementType type = typeDrawShape;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
|
||||
draw_shape() : bad_shape_(false), word_art_(false), idx_in_owner(-1) {}
|
||||
draw_shape() : bad_shape_(false), word_art_(false), idx_in_owner(-1), lined_shape_(false), connector_(false){}
|
||||
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
friend class odf_document;
|
||||
@ -93,6 +93,8 @@ public:
|
||||
int sub_type_;
|
||||
std::vector<odf_reader::_property> additional_;
|
||||
int idx_in_owner;
|
||||
bool lined_shape_;
|
||||
bool connector_;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -285,7 +287,7 @@ public:
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(draw_polygon);
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
//draw:contour-polygon
|
||||
class draw_contour_polygon : public draw_polygon
|
||||
{
|
||||
@ -297,9 +299,21 @@ public:
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(draw_contour_polygon);
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
//draw:contour-path
|
||||
class draw_contour_path : public draw_path
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
|
||||
static const ElementType type = typeDrawContourPath;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(draw_contour_path);
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
class draw_polyline_attlist
|
||||
{
|
||||
public:
|
||||
@ -441,6 +455,8 @@ public:
|
||||
_CP_OPT(std::wstring) draw_enhanced_path_;
|
||||
_CP_OPT(std::wstring) drawooo_enhanced_path_;
|
||||
_CP_OPT(std::wstring) drawooo_sub_view_size_;
|
||||
_CP_OPT(bool) draw_mirror_horizontal_;
|
||||
_CP_OPT(bool) draw_mirror_vertical_;
|
||||
};
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
class draw_enhanced_geometry : public office_element_impl<draw_enhanced_geometry>
|
||||
@ -462,7 +478,7 @@ public:
|
||||
|
||||
void find_draw_type_oox();
|
||||
|
||||
draw_enhanced_geometry_attlist draw_enhanced_geometry_attlist_;
|
||||
draw_enhanced_geometry_attlist attlist_;
|
||||
|
||||
_CP_OPT(int) sub_type_;
|
||||
_CP_OPT(int) draw_type_oox_index_;
|
||||
@ -572,9 +588,9 @@ public:
|
||||
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(dr3d_scene);
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//------------------------------------------------------------------------------------------------------------
|
||||
|
||||
class dr3d_extrude : public office_element_impl<dr3d_extrude>
|
||||
class dr3d_extrude : public draw_path
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
@ -586,19 +602,31 @@ public:
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
|
||||
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
|
||||
virtual void docx_convert(oox::docx_conversion_context & Context);
|
||||
virtual void pptx_convert(oox::pptx_conversion_context & Context);
|
||||
|
||||
_CP_OPT(std::wstring) svg_d_;
|
||||
_CP_OPT(std::wstring) svg_viewbox_;
|
||||
|
||||
void reset_svg_path();
|
||||
|
||||
//virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
|
||||
//virtual void docx_convert(oox::docx_conversion_context & Context);
|
||||
//virtual void pptx_convert(oox::pptx_conversion_context & Context);
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(dr3d_extrude);
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//------------------------------------------------------------------------------------------------------------
|
||||
|
||||
class dr3d_rotate : public draw_path
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
|
||||
static const ElementType type = typeDr3dRotate;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
|
||||
//virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
|
||||
//virtual void docx_convert(oox::docx_conversion_context & Context);
|
||||
//virtual void pptx_convert(oox::pptx_conversion_context & Context);
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(dr3d_rotate);
|
||||
//------------------------------------------------------------------------------------------------------------
|
||||
class dr3d_light : public office_element_impl<dr3d_light>
|
||||
{
|
||||
public:
|
||||
@ -615,13 +643,61 @@ public:
|
||||
virtual void docx_convert(oox::docx_conversion_context & Context);
|
||||
virtual void pptx_convert(oox::pptx_conversion_context & Context);
|
||||
|
||||
_CP_OPT(std::wstring) dr3d_diffuse_color_;
|
||||
_CP_OPT(std::wstring) dr3d_direction_;
|
||||
_CP_OPT(std::wstring) dr3d_specular_;
|
||||
_CP_OPT(odf_types::Bool)dr3d_enabled_;
|
||||
_CP_OPT(std::wstring) dr3d_diffuse_color_;
|
||||
_CP_OPT(std::wstring) dr3d_direction_;
|
||||
_CP_OPT(odf_types::Bool) dr3d_specular_;
|
||||
_CP_OPT(odf_types::Bool) dr3d_enabled_;
|
||||
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(dr3d_light);
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------
|
||||
class dr3d_cube : public draw_shape
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
|
||||
static const ElementType type = typeDr3dCube;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
|
||||
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
|
||||
virtual void docx_convert(oox::docx_conversion_context & Context);
|
||||
virtual void pptx_convert(oox::pptx_conversion_context & Context);
|
||||
|
||||
_CP_OPT(std::wstring) dr3d_max_edge_;
|
||||
_CP_OPT(std::wstring) dr3d_min_edge_;
|
||||
_CP_OPT(std::wstring) dr3d_transform_;
|
||||
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(dr3d_cube);
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------
|
||||
class dr3d_sphere : public draw_shape
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
|
||||
static const ElementType type = typeDr3dSphere;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
|
||||
virtual void xlsx_convert(oox::xlsx_conversion_context & Context);
|
||||
virtual void docx_convert(oox::docx_conversion_context & Context);
|
||||
virtual void pptx_convert(oox::pptx_conversion_context & Context);
|
||||
|
||||
_CP_OPT(std::wstring) dr3d_size_; //vector3D
|
||||
_CP_OPT(std::wstring) dr3d_center_; //vector3D
|
||||
_CP_OPT(std::wstring) dr3d_transform_;
|
||||
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(dr3d_sphere);
|
||||
//----------------------------------------------------------------------------------------------
|
||||
class draw_control : public draw_shape
|
||||
{
|
||||
|
||||
@ -215,10 +215,18 @@ void draw_path::docx_convert(oox::docx_conversion_context & Context)
|
||||
void draw_connector::docx_convert(oox::docx_conversion_context & Context)
|
||||
{
|
||||
//if (Context.get_drawing_context().get_current_level() >0 )return;
|
||||
|
||||
if (draw_connector_attlist_.draw_type_)
|
||||
{
|
||||
if (*draw_connector_attlist_.draw_type_ == L"curve")
|
||||
{
|
||||
sub_type_ = 11;
|
||||
}
|
||||
}
|
||||
reset_svg_attributes();
|
||||
common_docx_convert(Context);
|
||||
//...
|
||||
reset_svg_path();
|
||||
|
||||
draw_shape::docx_convert(Context);
|
||||
}
|
||||
void draw_polygon::docx_convert(oox::docx_conversion_context & Context)
|
||||
@ -280,6 +288,14 @@ void draw_enhanced_geometry::docx_convert(oox::docx_conversion_context & Context
|
||||
|
||||
bool set_shape = false;
|
||||
|
||||
if (attlist_.draw_mirror_horizontal_)
|
||||
{
|
||||
shape->additional_.push_back(_property(L"flipH", *attlist_.draw_mirror_horizontal_));
|
||||
}
|
||||
if (attlist_.draw_mirror_vertical_)
|
||||
{
|
||||
shape->additional_.push_back(_property(L"flipV", *attlist_.draw_mirror_vertical_));
|
||||
}
|
||||
if (draw_type_oox_index_)
|
||||
{
|
||||
shape->additional_.push_back(_property(L"oox-geom-index", draw_type_oox_index_.get()));
|
||||
@ -297,25 +313,27 @@ void draw_enhanced_geometry::docx_convert(oox::docx_conversion_context & Context
|
||||
set_shape = true;
|
||||
}
|
||||
std::wstring odf_path; //общая часть - объединить ...
|
||||
if (draw_enhanced_geometry_attlist_.drawooo_enhanced_path_)
|
||||
odf_path = draw_enhanced_geometry_attlist_.drawooo_enhanced_path_.get();
|
||||
else if (draw_enhanced_geometry_attlist_.draw_enhanced_path_)
|
||||
odf_path = draw_enhanced_geometry_attlist_.draw_enhanced_path_.get();
|
||||
if (attlist_.drawooo_enhanced_path_)
|
||||
odf_path = attlist_.drawooo_enhanced_path_.get();
|
||||
else if (attlist_.draw_enhanced_path_)
|
||||
odf_path = attlist_.draw_enhanced_path_.get();
|
||||
|
||||
if (!odf_path.empty())
|
||||
{
|
||||
std::vector<::svg_path::_polyline> o_Polyline;
|
||||
|
||||
bool res = false;
|
||||
bool bClosed = false;
|
||||
|
||||
try
|
||||
{
|
||||
res = ::svg_path::parseSvgD(o_Polyline, odf_path, true);
|
||||
res = ::svg_path::parseSvgD(o_Polyline, odf_path, true, bClosed);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
res = false;
|
||||
}
|
||||
//if (!bClosed) lined_shape_ = true;
|
||||
|
||||
if (!o_Polyline.empty() && res )
|
||||
{
|
||||
@ -329,10 +347,10 @@ void draw_enhanced_geometry::docx_convert(oox::docx_conversion_context & Context
|
||||
int w = 0;
|
||||
int h = 0;
|
||||
|
||||
if (draw_enhanced_geometry_attlist_.drawooo_sub_view_size_)
|
||||
if (attlist_.drawooo_sub_view_size_)
|
||||
{
|
||||
std::vector< std::wstring > splitted;
|
||||
boost::algorithm::split(splitted, *draw_enhanced_geometry_attlist_.drawooo_sub_view_size_, boost::algorithm::is_any_of(L" "), boost::algorithm::token_compress_on);
|
||||
boost::algorithm::split(splitted, *attlist_.drawooo_sub_view_size_, boost::algorithm::is_any_of(L" "), boost::algorithm::token_compress_on);
|
||||
|
||||
if (splitted.size() == 2)
|
||||
{
|
||||
@ -365,10 +383,10 @@ void draw_enhanced_geometry::docx_convert(oox::docx_conversion_context & Context
|
||||
}
|
||||
}
|
||||
|
||||
if (draw_enhanced_geometry_attlist_.draw_modifiers_)
|
||||
if (attlist_.draw_modifiers_)
|
||||
{
|
||||
if (bOoxType_)
|
||||
shape->additional_.push_back(_property(L"oox-draw-modifiers", draw_enhanced_geometry_attlist_.draw_modifiers_.get()));
|
||||
shape->additional_.push_back(_property(L"oox-draw-modifiers", attlist_.draw_modifiers_.get()));
|
||||
else
|
||||
{
|
||||
}
|
||||
@ -393,12 +411,15 @@ void dr3d_scene::docx_convert(oox::docx_conversion_context & Context)
|
||||
//...
|
||||
draw_shape::docx_convert(Context);
|
||||
}
|
||||
void dr3d_extrude::docx_convert(oox::docx_conversion_context & Context)
|
||||
void dr3d_light::docx_convert(oox::docx_conversion_context & Context)
|
||||
{
|
||||
reset_svg_path();
|
||||
|
||||
}
|
||||
void dr3d_light::docx_convert(oox::docx_conversion_context & Context)
|
||||
void dr3d_cube::docx_convert(oox::docx_conversion_context & Context)
|
||||
{
|
||||
|
||||
}
|
||||
void dr3d_sphere::docx_convert(oox::docx_conversion_context & Context)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ void draw_shape::common_pptx_convert(oox::pptx_conversion_context & Context)
|
||||
common_shape_draw_attlist &common_draw_attlist_ = common_draw_attlists_.shape_with_text_and_styles_.common_shape_draw_attlist_;
|
||||
common_presentation_attlist &common_presentation_attlist_= common_draw_attlists_.shape_with_text_and_styles_.common_presentation_attlist_;
|
||||
|
||||
const int z_index = common_draw_attlist_.draw_z_index_.get_value_or(0);
|
||||
const unsigned int z_index = common_draw_attlist_.draw_z_index_.get_value_or(0);
|
||||
const std::wstring name = common_draw_attlist_.draw_name_.get_value_or(L"");
|
||||
const std::wstring textStyleName = common_draw_attlist_.draw_text_style_name_.get_value_or(L"");
|
||||
|
||||
@ -92,8 +92,7 @@ void draw_shape::common_pptx_convert(oox::pptx_conversion_context & Context)
|
||||
if (common_draw_attlist_.draw_transform_)
|
||||
{
|
||||
std::wstring transformStr = common_draw_attlist_.draw_transform_.get();
|
||||
pptx_convert_transforms(transformStr,Context);
|
||||
//oox_convert_transforms(transformStr, additional_);
|
||||
pptx_convert_transforms(transformStr, Context);
|
||||
}
|
||||
////////////////////////////////////////
|
||||
std::wstring Anchor;
|
||||
@ -148,6 +147,9 @@ void draw_shape::common_pptx_convert(oox::pptx_conversion_context & Context)
|
||||
paragraph_format_properties paragraph_properties = calc_paragraph_properties_content(textStyleInst);
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
Context.get_slide_context().set_is_line_shape(lined_shape_);
|
||||
Context.get_slide_context().set_is_connector_shape(connector_);
|
||||
|
||||
oox::_oox_fill fill;
|
||||
Compute_GraphicFill(properties.common_draw_fill_attlist_, properties.style_background_image_,
|
||||
Context.root()->odf_context().drawStyles() ,fill);
|
||||
@ -230,6 +232,7 @@ void draw_path::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
}
|
||||
void draw_polygon::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
{
|
||||
//closed shape
|
||||
reset_polygon_path();
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
Context.get_slide_context().start_shape(sub_type_);
|
||||
@ -238,9 +241,9 @@ void draw_polygon::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
|
||||
Context.get_slide_context().end_shape();
|
||||
}
|
||||
|
||||
void draw_polyline::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
{
|
||||
//line
|
||||
reset_polyline_path();
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
Context.get_slide_context().start_shape(sub_type_);
|
||||
@ -249,6 +252,17 @@ void draw_polyline::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
|
||||
Context.get_slide_context().end_shape();
|
||||
}
|
||||
//void dr3d_rotate::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
//{
|
||||
// //closed shape
|
||||
// reset_polygon_path();
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// Context.get_slide_context().start_shape(sub_type_);
|
||||
//
|
||||
// common_pptx_convert(Context);
|
||||
//
|
||||
// Context.get_slide_context().end_shape();
|
||||
//}
|
||||
void draw_custom_shape::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
{
|
||||
Context.get_slide_context().start_shape(sub_type_);
|
||||
@ -298,6 +312,13 @@ void draw_connector::reset_svg_attributes()
|
||||
}
|
||||
void draw_connector::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
{
|
||||
if (draw_connector_attlist_.draw_type_)
|
||||
{
|
||||
if (*draw_connector_attlist_.draw_type_ == L"curve")
|
||||
{
|
||||
sub_type_ = 11;
|
||||
}
|
||||
}
|
||||
reset_svg_attributes();
|
||||
reset_svg_path();
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
@ -319,6 +340,14 @@ void draw_enhanced_geometry::pptx_convert(oox::pptx_conversion_context & Context
|
||||
|
||||
bool set_shape = false;
|
||||
|
||||
if (attlist_.draw_mirror_horizontal_)
|
||||
{
|
||||
Context.get_slide_context().set_property(_property(L"flipH", *attlist_.draw_mirror_horizontal_));
|
||||
}
|
||||
if (attlist_.draw_mirror_vertical_)
|
||||
{
|
||||
Context.get_slide_context().set_property(_property(L"flipV", *attlist_.draw_mirror_vertical_));
|
||||
}
|
||||
if (draw_type_oox_index_)
|
||||
{
|
||||
Context.get_slide_context().set_property(_property(L"oox-geom-index", draw_type_oox_index_.get()));
|
||||
@ -336,25 +365,27 @@ void draw_enhanced_geometry::pptx_convert(oox::pptx_conversion_context & Context
|
||||
}
|
||||
|
||||
std::wstring odf_path;
|
||||
if (draw_enhanced_geometry_attlist_.drawooo_enhanced_path_)
|
||||
odf_path = draw_enhanced_geometry_attlist_.drawooo_enhanced_path_.get();
|
||||
else if (draw_enhanced_geometry_attlist_.draw_enhanced_path_)
|
||||
odf_path = draw_enhanced_geometry_attlist_.draw_enhanced_path_.get();
|
||||
if (attlist_.drawooo_enhanced_path_)
|
||||
odf_path = attlist_.drawooo_enhanced_path_.get();
|
||||
else if (attlist_.draw_enhanced_path_)
|
||||
odf_path = attlist_.draw_enhanced_path_.get();
|
||||
|
||||
if (!odf_path.empty())
|
||||
{
|
||||
std::vector<::svg_path::_polyline> o_Polyline;
|
||||
|
||||
bool res = false;
|
||||
bool bClosed =false;
|
||||
|
||||
try
|
||||
{
|
||||
res = ::svg_path::parseSvgD(o_Polyline, odf_path, true);
|
||||
res = ::svg_path::parseSvgD(o_Polyline, odf_path, true, bClosed);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
res = false;
|
||||
}
|
||||
//if (!bClosed) lined_shape_ = true;
|
||||
|
||||
if (o_Polyline.size() > 1 && res )
|
||||
{
|
||||
@ -365,10 +396,10 @@ void draw_enhanced_geometry::pptx_convert(oox::pptx_conversion_context & Context
|
||||
|
||||
set_shape = true;
|
||||
|
||||
if (draw_enhanced_geometry_attlist_.drawooo_sub_view_size_)
|
||||
if (attlist_.drawooo_sub_view_size_)
|
||||
{
|
||||
std::vector< std::wstring > splitted;
|
||||
boost::algorithm::split(splitted, *draw_enhanced_geometry_attlist_.drawooo_sub_view_size_, boost::algorithm::is_any_of(L" "), boost::algorithm::token_compress_on);
|
||||
boost::algorithm::split(splitted, *attlist_.drawooo_sub_view_size_, boost::algorithm::is_any_of(L" "), boost::algorithm::token_compress_on);
|
||||
|
||||
if (splitted.size() == 2)
|
||||
{
|
||||
@ -389,10 +420,10 @@ void draw_enhanced_geometry::pptx_convert(oox::pptx_conversion_context & Context
|
||||
}
|
||||
}
|
||||
}
|
||||
if (draw_enhanced_geometry_attlist_.draw_modifiers_)
|
||||
if (attlist_.draw_modifiers_)
|
||||
{
|
||||
if (bOoxType_)
|
||||
Context.get_slide_context().set_property(_property(L"oox-draw-modifiers", draw_enhanced_geometry_attlist_.draw_modifiers_.get()));
|
||||
Context.get_slide_context().set_property(_property(L"oox-draw-modifiers", attlist_.draw_modifiers_.get()));
|
||||
else
|
||||
{
|
||||
}
|
||||
@ -419,15 +450,18 @@ void dr3d_scene::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
|
||||
Context.get_slide_context().end_shape();
|
||||
|
||||
}
|
||||
void dr3d_extrude::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
{
|
||||
reset_svg_path();
|
||||
|
||||
}
|
||||
void dr3d_light::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
{
|
||||
|
||||
}
|
||||
void dr3d_cube::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
{
|
||||
Context.get_slide_context().start_shape(sub_type_); //reset type
|
||||
}
|
||||
void dr3d_sphere::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
{
|
||||
Context.get_slide_context().start_shape(sub_type_); //reset type
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -71,7 +71,7 @@ void draw_shape::common_xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
|
||||
common_draw_shape_with_text_and_styles_attlist common_draw_attlist_ = common_draw_attlists_.shape_with_text_and_styles_;
|
||||
|
||||
const int z_index = common_draw_attlist_.common_shape_draw_attlist_.draw_z_index_.get_value_or(0);
|
||||
const unsigned int z_index = common_draw_attlist_.common_shape_draw_attlist_.draw_z_index_.get_value_or(0);
|
||||
const std::wstring name = common_draw_attlist_.common_shape_draw_attlist_.draw_name_.get_value_or(L"");
|
||||
const std::wstring styleName = common_draw_attlist_.common_shape_draw_attlist_.draw_style_name_.get_value_or(L"");
|
||||
const std::wstring textStyleName = common_draw_attlist_.common_shape_draw_attlist_.draw_text_style_name_.get_value_or(L"");
|
||||
@ -96,8 +96,7 @@ void draw_shape::common_xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
if (common_draw_attlist_.common_shape_draw_attlist_.draw_transform_)
|
||||
{
|
||||
std::wstring transformStr = common_draw_attlist_.common_shape_draw_attlist_.draw_transform_.get();
|
||||
xlsx_convert_transforms(transformStr,Context);
|
||||
//oox_convert_transforms(transformStr, additional_);
|
||||
xlsx_convert_transforms(transformStr, Context);
|
||||
}
|
||||
////////////////////////////////////////
|
||||
std::wstring Anchor;
|
||||
@ -130,6 +129,8 @@ void draw_shape::common_xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
Context.get_drawing_context().set_property(additional_[i]);
|
||||
}
|
||||
Context.get_drawing_context().set_is_line_shape(lined_shape_);
|
||||
Context.get_drawing_context().set_is_connector_shape(connector_);
|
||||
|
||||
oox::_oox_fill fill;
|
||||
Compute_GraphicFill(properties.common_draw_fill_attlist_, properties.style_background_image_,
|
||||
@ -211,6 +212,15 @@ void draw_path::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
|
||||
void draw_connector::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
if (draw_connector_attlist_.draw_type_)
|
||||
{
|
||||
if (*draw_connector_attlist_.draw_type_ == L"curve")
|
||||
{
|
||||
sub_type_ = 11;
|
||||
}
|
||||
}
|
||||
reset_svg_attributes();
|
||||
|
||||
reset_svg_path();
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
Context.get_drawing_context().start_shape(6);
|
||||
@ -266,6 +276,14 @@ void draw_enhanced_geometry::xlsx_convert(oox::xlsx_conversion_context & Context
|
||||
{
|
||||
find_draw_type_oox();
|
||||
|
||||
if (attlist_.draw_mirror_horizontal_)
|
||||
{
|
||||
Context.get_drawing_context().set_property(_property(L"flipH", *attlist_.draw_mirror_horizontal_));
|
||||
}
|
||||
if (attlist_.draw_mirror_vertical_)
|
||||
{
|
||||
Context.get_drawing_context().set_property(_property(L"flipV", *attlist_.draw_mirror_vertical_));
|
||||
}
|
||||
if (draw_type_oox_index_)
|
||||
{
|
||||
Context.get_drawing_context().set_property(_property(L"oox-geom-index", draw_type_oox_index_.get()));
|
||||
@ -281,25 +299,27 @@ void draw_enhanced_geometry::xlsx_convert(oox::xlsx_conversion_context & Context
|
||||
}
|
||||
|
||||
std::wstring odf_path;
|
||||
if (draw_enhanced_geometry_attlist_.drawooo_enhanced_path_)
|
||||
odf_path = draw_enhanced_geometry_attlist_.drawooo_enhanced_path_.get();
|
||||
else if (draw_enhanced_geometry_attlist_.draw_enhanced_path_)
|
||||
odf_path = draw_enhanced_geometry_attlist_.draw_enhanced_path_.get();
|
||||
if (attlist_.drawooo_enhanced_path_)
|
||||
odf_path = attlist_.drawooo_enhanced_path_.get();
|
||||
else if (attlist_.draw_enhanced_path_)
|
||||
odf_path = attlist_.draw_enhanced_path_.get();
|
||||
|
||||
if (!odf_path.empty())
|
||||
{
|
||||
std::vector<::svg_path::_polyline> o_Polyline;
|
||||
|
||||
bool res = false;
|
||||
bool bClosed = false;
|
||||
|
||||
try
|
||||
{
|
||||
res = ::svg_path::parseSvgD(o_Polyline, odf_path, true);
|
||||
res = ::svg_path::parseSvgD(o_Polyline, odf_path, true, bClosed);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
res = false;
|
||||
}
|
||||
//if (!bClosed) lined_shape_ = true;
|
||||
|
||||
if (o_Polyline.size() > 1 && res )
|
||||
{
|
||||
@ -308,10 +328,10 @@ void draw_enhanced_geometry::xlsx_convert(oox::xlsx_conversion_context & Context
|
||||
::svg_path::oox_serialize(output_, o_Polyline);
|
||||
Context.get_drawing_context().set_property(odf_reader::_property(L"custom_path", output_.str()));
|
||||
|
||||
if (draw_enhanced_geometry_attlist_.drawooo_sub_view_size_)
|
||||
if (attlist_.drawooo_sub_view_size_)
|
||||
{
|
||||
std::vector< std::wstring > splitted;
|
||||
boost::algorithm::split(splitted, *draw_enhanced_geometry_attlist_.drawooo_sub_view_size_, boost::algorithm::is_any_of(L" "), boost::algorithm::token_compress_on);
|
||||
boost::algorithm::split(splitted, *attlist_.drawooo_sub_view_size_, boost::algorithm::is_any_of(L" "), boost::algorithm::token_compress_on);
|
||||
|
||||
if (splitted.size() == 2)
|
||||
{
|
||||
@ -336,10 +356,10 @@ void draw_enhanced_geometry::xlsx_convert(oox::xlsx_conversion_context & Context
|
||||
draw_type_oox_index_ = 0;
|
||||
}
|
||||
}
|
||||
if (draw_enhanced_geometry_attlist_.draw_modifiers_)
|
||||
if (attlist_.draw_modifiers_)
|
||||
{
|
||||
if (bOoxType_)
|
||||
Context.get_drawing_context().set_property(_property(L"oox-draw-modifiers", draw_enhanced_geometry_attlist_.draw_modifiers_.get()));
|
||||
Context.get_drawing_context().set_property(_property(L"oox-draw-modifiers", attlist_.draw_modifiers_.get()));
|
||||
else
|
||||
{
|
||||
}
|
||||
@ -356,14 +376,18 @@ void dr3d_scene::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
Context.get_drawing_context().end_shape();
|
||||
Context.get_drawing_context().clear();
|
||||
}
|
||||
void dr3d_extrude::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
reset_svg_path();
|
||||
|
||||
}
|
||||
void dr3d_light::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
|
||||
}
|
||||
void dr3d_cube::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
Context.get_drawing_context().start_shape(sub_type_); //reset type
|
||||
}
|
||||
void dr3d_sphere::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
Context.get_drawing_context().start_shape(sub_type_); //reset type
|
||||
|
||||
}
|
||||
void draw_control::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
|
||||
@ -332,22 +332,6 @@ bool odf_document::Impl::decrypt_folder (const std::wstring &password, const std
|
||||
}
|
||||
return result;
|
||||
}
|
||||
std::string DecodeBase64(const std::wstring & value1)
|
||||
{
|
||||
int nLength = 0;
|
||||
unsigned char *pData = NULL;
|
||||
std::string result;
|
||||
|
||||
std::string value(value1.begin(), value1.end());
|
||||
|
||||
NSFile::CBase64Converter::Decode(value.c_str(), value.length(), pData, nLength);
|
||||
if (pData)
|
||||
{
|
||||
result = std::string((char*)pData, nLength);
|
||||
delete []pData; pData = NULL;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
bool odf_document::Impl::decrypt_file (const std::wstring &password, const std::wstring & srcPath, const std::wstring & dstPath, office_element_ptr element, int file_size )
|
||||
{
|
||||
manifest_encryption_data* encryption_data = dynamic_cast<manifest_encryption_data*>(element.get());
|
||||
@ -988,6 +972,28 @@ void odf_document::Impl::parse_styles(office_element *element)
|
||||
continue;
|
||||
|
||||
context_->Templates().add(L"table:" + style->get_text_style_name(), elm);
|
||||
}
|
||||
for (size_t i = 0; i < docStyles->draw_styles_.draw_marker_.size(); i++)
|
||||
{
|
||||
office_element_ptr & elm = docStyles->draw_styles_.draw_marker_[i];
|
||||
|
||||
draw_marker * style = dynamic_cast<draw_marker *>(elm.get());
|
||||
|
||||
if (!style)
|
||||
continue;
|
||||
|
||||
context_->drawStyles().add(L"marker:" + style->get_style_name(), elm);
|
||||
}
|
||||
for (size_t i = 0; i < docStyles->draw_styles_.draw_stroke_dash_.size(); i++)
|
||||
{
|
||||
office_element_ptr & elm = docStyles->draw_styles_.draw_stroke_dash_[i];
|
||||
|
||||
draw_stroke_dash * style = dynamic_cast<draw_stroke_dash *>(elm.get());
|
||||
|
||||
if (!style)
|
||||
continue;
|
||||
|
||||
context_->drawStyles().add(L"stroke_dash:" + style->get_style_name(), elm);
|
||||
}
|
||||
}
|
||||
while(0); // end parse styles
|
||||
|
||||
@ -35,7 +35,23 @@
|
||||
namespace cpdoccore {
|
||||
|
||||
using namespace odf_types;
|
||||
|
||||
std::string DecodeBase64(const std::wstring & value1)
|
||||
{
|
||||
int nLength = 0;
|
||||
unsigned char *pData = NULL;
|
||||
std::string result;
|
||||
|
||||
std::string value(value1.begin(), value1.end());
|
||||
|
||||
NSFile::CBase64Converter::Decode(value.c_str(), value.length(), pData, nLength);
|
||||
if (pData)
|
||||
{
|
||||
result = std::string((char*)pData, nLength);
|
||||
delete []pData; pData = NULL;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
namespace odf_reader {
|
||||
|
||||
style_instance::style_instance(
|
||||
|
||||
@ -44,6 +44,9 @@
|
||||
#include <iosfwd>
|
||||
|
||||
namespace cpdoccore {
|
||||
|
||||
std::string DecodeBase64(const std::wstring & value);
|
||||
|
||||
namespace odf_reader {
|
||||
|
||||
class styles_container;
|
||||
|
||||
@ -268,7 +268,7 @@ void officeooo_annotation::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
}
|
||||
id_idx = Context.add_author_comments(author);
|
||||
|
||||
Context.get_comments_context().start_comment(x, y,id_idx.first,id_idx.second);//author & idx (uniq number for author
|
||||
Context.get_comments_context().start_comment(x, y, id_idx.first, id_idx.second);//author & idx (uniq number for author
|
||||
|
||||
Context.get_text_context().start_comment_content();
|
||||
for (size_t i = 0; i < content_.size(); i++)//текст + текстовый стиль
|
||||
|
||||
@ -151,7 +151,10 @@ void office_body::docx_convert(oox::docx_conversion_context & Context)
|
||||
{
|
||||
if (page_layout_instance *lastPageLayout = Context.root()->odf_context().pageLayoutContainer().page_layout_by_name(Context.get_page_properties()))
|
||||
{
|
||||
Context.next_dump_page_properties(true);
|
||||
if (Context.is_last_dump_page_properties())
|
||||
{
|
||||
Context.next_dump_page_properties(true);
|
||||
}
|
||||
|
||||
lastPageLayout->docx_serialize(Context.output_stream(), Context);
|
||||
//Context.remove_page_properties();
|
||||
|
||||
@ -284,6 +284,7 @@ void form_button::docx_convert(oox::docx_conversion_context & Context)
|
||||
void form_button::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
Context.get_forms_context().start_element(1);
|
||||
Context.get_forms_context().set_element(dynamic_cast<form_element*>(this));
|
||||
|
||||
form_element::xlsx_convert(Context);
|
||||
}
|
||||
|
||||
@ -129,6 +129,16 @@ void office_text::add_child_element( xml::sax * Reader, const std::wstring & Ns,
|
||||
else if (is_text_content(Ns, Name))
|
||||
{
|
||||
CP_CREATE_ELEMENT(content_);
|
||||
|
||||
if (!first_element_style_name && (content_.back()->get_type() == typeTextP ||
|
||||
content_.back()->get_type() == typeTextH))
|
||||
{//bus-modern_l.ott
|
||||
if (content_.back()->element_style_name)
|
||||
first_element_style_name = content_.back()->element_style_name;
|
||||
else
|
||||
first_element_style_name = L""; //default
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
CP_NOT_APPLICABLE_ELM();
|
||||
@ -155,6 +165,26 @@ void office_text::docx_convert(oox::docx_conversion_context & Context)
|
||||
//forms_->docx_convert(Context);
|
||||
|
||||
Context.start_office_text();
|
||||
|
||||
if ((first_element_style_name) && (!first_element_style_name->empty()))
|
||||
{
|
||||
std::wstring text___ = *first_element_style_name;
|
||||
|
||||
const _CP_OPT(std::wstring) masterPageName = Context.root()->odf_context().styleContainer().master_page_name_by_name(text___);
|
||||
|
||||
if (masterPageName)
|
||||
{
|
||||
std::wstring masterPageNameLayout = Context.root()->odf_context().pageLayoutContainer().page_layout_name_by_style(*masterPageName);
|
||||
|
||||
if (false == masterPageNameLayout.empty())
|
||||
{
|
||||
Context.set_master_page_name(*masterPageName); //проверка на то что тема действительно существует????
|
||||
|
||||
Context.remove_page_properties();
|
||||
Context.add_page_properties(masterPageNameLayout);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
{
|
||||
if (content_[i]->element_style_name)
|
||||
|
||||
@ -70,6 +70,8 @@ private:
|
||||
//office_element_ptr forms_; -> content
|
||||
|
||||
office_element_ptr_array content_;
|
||||
|
||||
_CP_OPT(std::wstring) first_element_style_name;
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(office_text);
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
|
||||
@ -1320,6 +1320,67 @@ void sequence::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
text_[i]->pptx_convert(Context);
|
||||
}
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------
|
||||
const wchar_t * expression::ns = L"text";
|
||||
const wchar_t * expression::name = L"expression";
|
||||
|
||||
void expression::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
office_value_.add_attributes(Attributes);
|
||||
CP_APPLY_ATTR(L"style:data-style-name", style_data_style_name_);
|
||||
CP_APPLY_ATTR(L"text:display", text_display_);
|
||||
CP_APPLY_ATTR(L"text:formula", text_formula_);
|
||||
|
||||
}
|
||||
std::wostream & expression::text_to_stream(std::wostream & _Wostream) const
|
||||
{
|
||||
_Wostream << xml::utils::replace_text_to_xml( text_ );
|
||||
return _Wostream;
|
||||
}
|
||||
void expression::add_text(const std::wstring & Text)
|
||||
{
|
||||
text_ = Text;
|
||||
}
|
||||
void expression::docx_convert(oox::docx_conversion_context & Context)
|
||||
{//???
|
||||
std::wostream & strm = Context.output_stream();
|
||||
Context.finish_run();
|
||||
|
||||
strm << L"<w:r><w:fldChar w:fldCharType=\"begin\"></w:fldChar></w:r>";
|
||||
strm << L"<w:r><w:instrText>FORMTEXT</w:instrText></w:r>";
|
||||
strm << L"<w:r><w:fldChar w:fldCharType=\"separate\"/></w:r>";
|
||||
strm << L"<w:r><w:t>" << text_ << L"</w:t></w:r>";
|
||||
strm << L"<w:r><w:fldChar w:fldCharType=\"end\"/></w:r>";
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------
|
||||
const wchar_t * text_input::ns = L"text";
|
||||
const wchar_t * text_input::name = L"text-input";
|
||||
|
||||
void text_input::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
CP_APPLY_ATTR(L"text:description", text_description_);
|
||||
|
||||
}
|
||||
std::wostream & text_input::text_to_stream(std::wostream & _Wostream) const
|
||||
{
|
||||
_Wostream << xml::utils::replace_text_to_xml( text_ );
|
||||
return _Wostream;
|
||||
}
|
||||
void text_input::add_text(const std::wstring & Text)
|
||||
{
|
||||
text_ = Text;
|
||||
}
|
||||
void text_input::docx_convert(oox::docx_conversion_context & Context)
|
||||
{
|
||||
std::wostream & strm = Context.output_stream();
|
||||
Context.finish_run();
|
||||
|
||||
strm << L"<w:r><w:fldChar w:fldCharType=\"begin\"></w:fldChar></w:r>";
|
||||
strm << L"<w:r><w:instrText>FORMTEXT</w:instrText></w:r>";
|
||||
strm << L"<w:r><w:fldChar w:fldCharType=\"separate\"/></w:r>";
|
||||
strm << L"<w:r><w:t>" << text_ << L"</w:t></w:r>";
|
||||
strm << L"<w:r><w:fldChar w:fldCharType=\"end\"/></w:r>";
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------------------------------
|
||||
const wchar_t * text_drop_down::ns = L"text";
|
||||
const wchar_t * text_drop_down::name = L"drop-down";
|
||||
|
||||
@ -875,6 +875,58 @@ private:
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(sequence);
|
||||
//-------------------------------------------------------------------------------------------------------------------
|
||||
// text:expression
|
||||
//-------------------------------------------------------------------------------------------------------------------
|
||||
class expression: public paragraph_content_element<expression>
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeTextExpression;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
void docx_convert(oox::docx_conversion_context & Context);
|
||||
|
||||
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
|
||||
|
||||
_CP_OPT(std::wstring) style_data_style_name_;
|
||||
_CP_OPT(std::wstring) text_display_;
|
||||
_CP_OPT(std::wstring) text_formula_;
|
||||
odf_types::common_value_and_type_attlist office_value_;
|
||||
|
||||
std::wstring text_;
|
||||
private:
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
|
||||
virtual void add_text(const std::wstring & Text);
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(expression);
|
||||
//-------------------------------------------------------------------------------------------------------------------
|
||||
// text:text-input
|
||||
//-------------------------------------------------------------------------------------------------------------------
|
||||
class text_input: public paragraph_content_element<text_input>
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeTextTextInput;
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
void docx_convert(oox::docx_conversion_context & Context);
|
||||
|
||||
virtual std::wostream & text_to_stream(std::wostream & _Wostream) const;
|
||||
|
||||
_CP_OPT(std::wstring) text_description_;
|
||||
std::wstring text_;
|
||||
private:
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
|
||||
virtual void add_text(const std::wstring & Text);
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(text_input);
|
||||
//-------------------------------------------------------------------------------------------------------------------
|
||||
// text:sequence_ref
|
||||
//-------------------------------------------------------------------------------------------------------------------
|
||||
class sequence_ref : public paragraph_content_element<sequence_ref>
|
||||
|
||||
@ -169,7 +169,7 @@ public:
|
||||
|
||||
virtual void visit(const table_table& val)
|
||||
{
|
||||
if (visit_table(val.table_table_attlist_.table_name_.get_value_or(L"")))
|
||||
if (visit_table(val.attlist_.table_name_.get_value_or(L"")))
|
||||
{
|
||||
ACCEPT_ALL_CONTENT_CONST(val.table_columns_and_groups_.content_, stop_);
|
||||
ACCEPT_ALL_CONTENT_CONST(val.table_rows_and_groups_.content_, stop_);
|
||||
|
||||
@ -108,11 +108,26 @@ void graphic_format_properties::apply_to(std::vector<_property> & properties)
|
||||
|
||||
if (draw_stroke_) properties.push_back(_property(L"stroke", draw_stroke_->get_type() ));
|
||||
if (svg_stroke_color_) properties.push_back(_property(L"stroke-color", svg_stroke_color_->get_hex_value() ));
|
||||
if (draw_stroke_dash_) properties.push_back(_property(L"stroke-dash", draw_stroke_dash_.get()));
|
||||
if (draw_stroke_dash_)
|
||||
{
|
||||
if (!draw_stroke_dash_->empty())
|
||||
properties.push_back(_property(L"stroke-dash", draw_stroke_dash_.get()));
|
||||
}
|
||||
if (svg_stroke_width_) properties.push_back(_property(L"stroke-width", svg_stroke_width_->get_length().get_value_unit(odf_types::length::pt) ));
|
||||
if (svg_stroke_opacity_)properties.push_back(_property(L"stroke-opacity",svg_stroke_opacity_->get_percent().get_value()));
|
||||
if (draw_marker_start_) properties.push_back(_property(L"marker-start", draw_marker_start_->get() ));
|
||||
if (draw_marker_end_) properties.push_back(_property(L"marker-end", draw_marker_end_->get() ));
|
||||
if (draw_marker_start_)
|
||||
{
|
||||
properties.push_back(_property(L"marker-start", draw_marker_start_->get() ));
|
||||
}
|
||||
if (draw_marker_end_)
|
||||
{
|
||||
//const std::wstring style_name = draw_marker_end_->get();
|
||||
//if (!style_name.empty())
|
||||
////if (office_element_ptr style = styles.find_by_style_name(style_name))
|
||||
//{
|
||||
properties.push_back(_property(L"marker-end", draw_marker_end_->get() ));
|
||||
//}
|
||||
}
|
||||
|
||||
if (draw_textarea_horizontal_align_)properties.push_back(_property(L"textarea-horizontal_align",draw_textarea_horizontal_align_->get_type() ));
|
||||
if (draw_textarea_vertical_align_) properties.push_back(_property(L"textarea-vertical_align", draw_textarea_vertical_align_->get_type() ));
|
||||
@ -122,6 +137,18 @@ void graphic_format_properties::apply_to(std::vector<_property> & properties)
|
||||
if (draw_fit_to_size_) properties.push_back(_property(L"fit-to-size", *draw_fit_to_size_));
|
||||
if (draw_fit_to_contour_) properties.push_back(_property(L"fit-to-contour", *draw_fit_to_contour_));
|
||||
|
||||
if (common_draw_fill_attlist_.draw_color_mode_)
|
||||
{
|
||||
properties.push_back(_property(L"color-mode", *common_draw_fill_attlist_.draw_color_mode_));
|
||||
}
|
||||
if (common_draw_fill_attlist_.draw_luminance_)
|
||||
{
|
||||
properties.push_back(_property(L"luminance", common_draw_fill_attlist_.draw_luminance_->get_value()));
|
||||
}
|
||||
if (common_draw_fill_attlist_.draw_contrast_)
|
||||
{
|
||||
properties.push_back(_property(L"contrast", common_draw_fill_attlist_.draw_contrast_->get_value()));
|
||||
}
|
||||
if (common_padding_attlist_.fo_padding_)
|
||||
{
|
||||
properties.push_back(_property(L"text-padding-left", common_padding_attlist_.fo_padding_->get_value_unit(length::emu)));
|
||||
|
||||
@ -344,14 +344,14 @@ void style_table_row_properties_attlist::docx_convert(oox::docx_conversion_conte
|
||||
|
||||
if (style_row_height_)
|
||||
{
|
||||
int val = (int)( 0.5 + 20.0 *style_row_height_->get_value_unit(length::pt) );
|
||||
int val = (int)( 0.5 + 20.0 * style_row_height_->get_value_unit(length::pt) );
|
||||
if (val < 0)
|
||||
val = 0;
|
||||
strm << L"<w:trHeight w:hRule=\"exact\" w:val=\"" << val << L"\" />";
|
||||
}
|
||||
else if (style_min_row_height_)
|
||||
{
|
||||
int val = (int)( 0.5 + 20.0 *style_min_row_height_->get_value_unit(length::pt) );
|
||||
int val = (int)( 0.5 + 20.0 * style_min_row_height_->get_value_unit(length::pt) );
|
||||
if (val < 0)
|
||||
val = 0;
|
||||
strm << L"<w:trHeight w:hRule=\"atLeast\" w:val=\"" << val << L"\" />";
|
||||
|
||||
@ -529,7 +529,18 @@ void text_format_properties_content::drawing_serialize(std::wostream & strm, std
|
||||
CP_XML_NODE(L"a:cs"){CP_XML_ATTR(L"typeface", delete_apostroph_in_name(w_cs));}
|
||||
}
|
||||
}
|
||||
if ((fo_background_color_) && (fo_background_color_->get_type() == odf_types::background_color::Enabled ))
|
||||
{
|
||||
std::wstring strRGB = fo_background_color_->get_color().get_hex_value(); //auto ... не нужно
|
||||
if (!strRGB.empty())
|
||||
{
|
||||
CP_XML_NODE(L"a:highlight")
|
||||
{
|
||||
CP_XML_NODE(L"a:srgbClr") {CP_XML_ATTR(L"val", strRGB);}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (!hlink.empty())
|
||||
{
|
||||
CP_XML_NODE(L"a:hlinkClick")
|
||||
|
||||
@ -329,7 +329,44 @@ void draw_fill_image::add_child_element( xml::sax * Reader, const std::wstring &
|
||||
{
|
||||
CP_NOT_APPLICABLE_ELM();
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//----------------------------------------------------------------------------------------
|
||||
const wchar_t * draw_marker::ns = L"draw";
|
||||
const wchar_t * draw_marker::name = L"marker";
|
||||
|
||||
void draw_marker::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
CP_APPLY_ATTR(L"draw:name" , draw_name_);
|
||||
CP_APPLY_ATTR(L"draw:display-name" , draw_display_name_);
|
||||
|
||||
CP_APPLY_ATTR(L"svg:d" , svg_d_);
|
||||
CP_APPLY_ATTR(L"svg:viewBox" , svg_viewBox_);
|
||||
}
|
||||
void draw_marker::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
CP_NOT_APPLICABLE_ELM();
|
||||
}
|
||||
//----------------------------------------------------------------------------------------
|
||||
const wchar_t * draw_stroke_dash::ns = L"draw";
|
||||
const wchar_t * draw_stroke_dash::name = L"stroke-dash";
|
||||
|
||||
void draw_stroke_dash::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
CP_APPLY_ATTR(L"draw:name" , draw_name_);
|
||||
CP_APPLY_ATTR(L"draw:display-name" , draw_display_name_);
|
||||
|
||||
CP_APPLY_ATTR(L"draw:distance" , draw_distance_);
|
||||
CP_APPLY_ATTR(L"draw:dots1-length" , draw_dots1_length_);
|
||||
CP_APPLY_ATTR(L"draw:dots2-length" , draw_dots2_length_);
|
||||
CP_APPLY_ATTR(L"draw:dots1" , draw_dots1_);
|
||||
CP_APPLY_ATTR(L"draw:dots2" , draw_dots2_);
|
||||
CP_APPLY_ATTR(L"draw:style" , draw_style_);//"square"
|
||||
|
||||
}
|
||||
void draw_stroke_dash::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
CP_NOT_APPLICABLE_ELM();
|
||||
}
|
||||
//----------------------------------------------------------------------------------------
|
||||
const wchar_t * draw_gradient::ns = L"draw";
|
||||
const wchar_t * draw_gradient::name = L"gradient";
|
||||
|
||||
|
||||
@ -119,8 +119,7 @@ private:
|
||||
|
||||
};
|
||||
|
||||
// default_style
|
||||
/// style:default-style
|
||||
// style:default-style
|
||||
class default_style : public office_element_impl<default_style>
|
||||
{
|
||||
public:
|
||||
@ -147,10 +146,69 @@ private:
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(default_style);
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// draw:marker
|
||||
class draw_marker : public office_element_impl<draw_marker>
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeStyleDrawMarker;
|
||||
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// style_draw_gradient
|
||||
std::wstring get_style_name(){return draw_name_.get_value_or(L"");}
|
||||
|
||||
_CP_OPT(std::wstring) svg_d_;
|
||||
_CP_OPT(std::wstring) svg_viewBox_;
|
||||
_CP_OPT(std::wstring) draw_name_;
|
||||
_CP_OPT(std::wstring) draw_display_name_;
|
||||
|
||||
friend class odf_document;
|
||||
|
||||
private:
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
|
||||
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(draw_marker);
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// draw:stroke-dash
|
||||
class draw_stroke_dash : public office_element_impl<draw_stroke_dash>
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeStyleDrawStrokeDash;
|
||||
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
std::wstring get_style_name(){return draw_name_.get_value_or(L"");}
|
||||
|
||||
_CP_OPT(odf_types::length_or_percent) draw_distance_;
|
||||
_CP_OPT(odf_types::length_or_percent) draw_dots1_length_;
|
||||
_CP_OPT(odf_types::length_or_percent) draw_dots2_length_;
|
||||
|
||||
_CP_OPT(int) draw_dots1_;
|
||||
_CP_OPT(int) draw_dots2_;
|
||||
|
||||
_CP_OPT(std::wstring) draw_style_; //rect or round:
|
||||
_CP_OPT(std::wstring) draw_name_;
|
||||
_CP_OPT(std::wstring) draw_display_name_;
|
||||
|
||||
friend class odf_document;
|
||||
|
||||
private:
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
|
||||
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(draw_stroke_dash);
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// draw:gradient
|
||||
class draw_gradient : public office_element_impl<draw_gradient>
|
||||
{
|
||||
public:
|
||||
@ -189,7 +247,7 @@ private:
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(draw_gradient);
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// style_draw_hatch
|
||||
// draw:hatch
|
||||
class draw_hatch : public office_element_impl<draw_hatch>
|
||||
{
|
||||
public:
|
||||
@ -355,8 +413,8 @@ public:
|
||||
office_element_ptr_array draw_opacity_;
|
||||
office_element_ptr_array draw_hatch_;
|
||||
|
||||
office_element_ptr_array draw_marker_; // < TODO
|
||||
office_element_ptr_array draw_stroke_dash_; // < TODO
|
||||
office_element_ptr_array draw_marker_;
|
||||
office_element_ptr_array draw_stroke_dash_;
|
||||
|
||||
office_element_ptr_array svg_linearGradient_; // < TODO
|
||||
office_element_ptr_array svg_radialGradient_; // < TODO
|
||||
|
||||
@ -185,12 +185,11 @@ namespace svg_path
|
||||
return bUseRelativeCoordinates ? cLowerCaseCommand : cUpperCaseCommand;
|
||||
}
|
||||
|
||||
bool parseSvgD(std::vector<_polyline> & Polyline, const std::wstring & rSvgDStatement, bool bWrongPositionAfterZ)
|
||||
bool parseSvgD(std::vector<_polyline> & Polyline, const std::wstring & rSvgDStatement, bool bWrongPositionAfterZ, bool & bIsClosed)
|
||||
{
|
||||
Polyline.clear();
|
||||
const int nLen(rSvgDStatement.length());
|
||||
int nPos(0);
|
||||
bool bIsClosed(false);
|
||||
|
||||
double nLastX( 0.0 );
|
||||
double nLastY( 0.0 );
|
||||
@ -200,6 +199,8 @@ namespace svg_path
|
||||
|
||||
_polyline aCurrPoly;
|
||||
|
||||
bIsClosed = false;
|
||||
|
||||
// skip initial whitespace
|
||||
skipSpaces(nPos, rSvgDStatement, nLen);
|
||||
|
||||
|
||||
@ -58,7 +58,7 @@ namespace svg_path
|
||||
};
|
||||
|
||||
bool parseVml(std::vector<_polyline> & Polyline, const std::wstring & path);
|
||||
bool parseSvgD(std::vector<_polyline> & Polyline, const std::wstring & path, bool bWrongPositionAfterZ);
|
||||
bool parseSvgD(std::vector<_polyline> & Polyline, const std::wstring & path, bool bWrongPositionAfterZ, bool & bIsClosed);
|
||||
bool parsePolygon(std::vector<_polyline> & Polyline, const std::wstring & path, bool bWrongPositionAfterZ, bool closed);
|
||||
}
|
||||
|
||||
|
||||
@ -57,6 +57,8 @@ void table_table_attlist::add_attributes( const xml::attributes_wc_ptr & Attribu
|
||||
|
||||
CP_APPLY_ATTR(L"table:protected", table_protected_, false);
|
||||
CP_APPLY_ATTR(L"table:protection-key", table_protection_key_);
|
||||
CP_APPLY_ATTR(L"table:protection-key-digest-algorithm", table_protection_key_digest_algorithm_);
|
||||
|
||||
CP_APPLY_ATTR(L"table:print", table_print_, true);
|
||||
CP_APPLY_ATTR(L"table:print-ranges", table_print_ranges_);
|
||||
|
||||
@ -134,7 +136,23 @@ void table_table_source::add_child_element( xml::sax * Reader, const std::wstrin
|
||||
{
|
||||
CP_NOT_APPLICABLE_ELM();
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// table:table-protection
|
||||
const wchar_t * table_table_protection::ns = L"loext"; //?? table odf 1.3
|
||||
const wchar_t * table_table_protection::name = L"table-protection";
|
||||
|
||||
void table_table_protection::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
CP_APPLY_ATTR(L"loext:select-protected-cells", select_protected_cells);
|
||||
CP_APPLY_ATTR(L"loext:select-unprotected-cells",select_unprotected_cells);
|
||||
CP_APPLY_ATTR(L"loext:insert-columns", insert_columns);
|
||||
CP_APPLY_ATTR(L"loext:insert-rows", insert_rows);
|
||||
CP_APPLY_ATTR(L"loext:delete-columns", delete_columns);
|
||||
CP_APPLY_ATTR(L"loext:delete-rows", delete_rows);
|
||||
//CP_APPLY_ATTR(L"loext:format-columns", format_columns);
|
||||
//CP_APPLY_ATTR(L"loext:format-rows", format_rows);
|
||||
//CP_APPLY_ATTR(L"loext:format-cells", format_cells);
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// table:table
|
||||
const wchar_t * table_table::ns = L"table";
|
||||
@ -144,7 +162,7 @@ void table_table::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
CP_APPLY_ATTR(L"table:style-name", element_style_name);
|
||||
|
||||
table_table_attlist_.add_attributes(Attributes);
|
||||
attlist_.add_attributes(Attributes);
|
||||
}
|
||||
|
||||
void table_table::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
|
||||
@ -172,9 +190,13 @@ void table_table::add_child_element( xml::sax * Reader, const std::wstring & Ns,
|
||||
else if CP_CHECK_NAME(L"table", L"shapes")
|
||||
{
|
||||
CP_CREATE_ELEMENT(table_shapes_);
|
||||
}
|
||||
else if ( L"table-protection" == Name) //ns = loext or table
|
||||
{
|
||||
CP_CREATE_ELEMENT(table_protection_);
|
||||
}
|
||||
else if ( CP_CHECK_NAME(L"table", L"named-expressions") ||
|
||||
CP_CHECK_NAME(L"table", L"named-range") ) //???
|
||||
CP_CHECK_NAME(L"table", L"named-range") )
|
||||
{
|
||||
CP_CREATE_ELEMENT(table_named_);
|
||||
}
|
||||
|
||||
@ -61,15 +61,17 @@ public:
|
||||
_CP_OPT(std::wstring) table_style_name_;
|
||||
_CP_OPT(std::wstring) table_template_name_;
|
||||
|
||||
bool table_protected_; // default false
|
||||
bool table_protected_; // default false
|
||||
_CP_OPT(std::wstring) table_protection_key_;
|
||||
bool table_print_; // default true
|
||||
_CP_OPT(std::wstring) table_protection_key_digest_algorithm_;
|
||||
|
||||
bool table_print_; // default true
|
||||
_CP_OPT(std::wstring) table_print_ranges_;
|
||||
|
||||
bool table_use_first_row_styles_; // default false;
|
||||
bool table_use_banding_rows_styles_; //defualt false;
|
||||
bool table_use_first_column_styles_; //defualt false;
|
||||
bool table_use_banding_columns_styles_; //defualt false;
|
||||
bool table_use_banding_rows_styles_; // defualt false;
|
||||
bool table_use_first_column_styles_; // defualt false;
|
||||
bool table_use_banding_columns_styles_; // defualt false;
|
||||
|
||||
friend class table_table;
|
||||
};
|
||||
@ -617,6 +619,38 @@ public:
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(table_table_row_group);
|
||||
|
||||
class table_table_protection : public office_element_impl<table_table_protection>
|
||||
{
|
||||
public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
static const xml::NodeType xml_type = xml::typeElement;
|
||||
static const ElementType type = typeTableTableProtection;
|
||||
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
|
||||
virtual void docx_convert(oox::docx_conversion_context & Context) {}
|
||||
virtual void xlsx_convert(oox::xlsx_conversion_context & Context) {}
|
||||
virtual void pptx_convert(oox::pptx_conversion_context & Context) {}
|
||||
|
||||
private:
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name){}
|
||||
|
||||
public:
|
||||
_CP_OPT(bool) select_protected_cells;
|
||||
_CP_OPT(bool) select_unprotected_cells;
|
||||
_CP_OPT(bool) insert_columns;
|
||||
_CP_OPT(bool) insert_rows;
|
||||
|
||||
_CP_OPT(bool) delete_columns;
|
||||
_CP_OPT(bool) delete_rows;
|
||||
//_CP_OPT(bool) format_columns; //???
|
||||
//_CP_OPT(bool) format_rows;
|
||||
//_CP_OPT(bool) format_cells;
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(table_table_protection);
|
||||
|
||||
class table_table : public office_element_impl<table_table>
|
||||
{
|
||||
public:
|
||||
@ -636,7 +670,9 @@ private:
|
||||
virtual void add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name);
|
||||
|
||||
public:
|
||||
table_table_attlist table_table_attlist_;
|
||||
table_table_attlist attlist_;
|
||||
|
||||
office_element_ptr table_protection_;
|
||||
|
||||
table_columns_and_groups table_columns_and_groups_;
|
||||
table_rows_and_groups table_rows_and_groups_;
|
||||
|
||||
@ -87,6 +87,7 @@ void table_data_pilot_table::add_child_element( xml::sax * Reader, const std::ws
|
||||
CP_CREATE_ELEMENT (source_);
|
||||
|
||||
}
|
||||
|
||||
void table_data_pilot_table::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
if (!source_) return;
|
||||
@ -105,6 +106,8 @@ void table_data_pilot_table::xlsx_convert(oox::xlsx_conversion_context & Context
|
||||
std::wstring ref = formulas_converter.convert_named_ref(*table_target_range_address_, false);
|
||||
sheet_name = formulas_converter.get_table_name();
|
||||
|
||||
Context.get_table_context().check_database_range_intersection(sheet_name, ref);
|
||||
|
||||
Context.get_pivots_context().set_view_target_range(ref);
|
||||
Context.get_pivots_context().set_view_target_table_name(sheet_name);
|
||||
}
|
||||
@ -195,10 +198,12 @@ void table_data_pilot_field::xlsx_convert(oox::xlsx_conversion_context & Context
|
||||
|
||||
if (type == table_function::String)
|
||||
{
|
||||
formulasconvert::odf2oox_converter formulas_converter;
|
||||
std::wstring formula = table_function_->get_string();
|
||||
|
||||
std::wstring user_funtion = formulas_converter.convert(table_function_->get_string());
|
||||
Context.get_pivots_context().set_field_user_function(user_funtion);
|
||||
formulasconvert::odf2oox_converter formulas_converter;
|
||||
std::wstring oox_formula = formulas_converter.convert(formula);
|
||||
|
||||
Context.get_pivots_context().set_field_user_function(oox_formula);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -88,24 +88,43 @@ void table_database_range::add_child_element( xml::sax * Reader, const std::wstr
|
||||
void table_database_range::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
if (!table_target_range_address_) return;
|
||||
if (!table_name_) return;
|
||||
|
||||
Context.get_table_context().start_database_range(table_name_.get_value_or(L""), *table_target_range_address_);
|
||||
|
||||
if (table_display_filter_buttons_)
|
||||
Context.get_table_context().set_database_filter(table_display_filter_buttons_->get());
|
||||
std::wstring name = table_name_.get();
|
||||
|
||||
if (table_orientation_)
|
||||
Context.get_table_context().set_database_orientation(table_orientation_->get_type() == table_orientation::row ? true : false);
|
||||
|
||||
if (table_contains_header_)
|
||||
Context.get_table_context().set_database_header(table_contains_header_->get());
|
||||
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
std::map<std::wstring, int>::iterator pFind = Context.mapUsedNames_.find(name);
|
||||
if (pFind == Context.mapUsedNames_.end())
|
||||
{
|
||||
content_[i]->xlsx_convert(Context);
|
||||
Context.mapUsedNames_.insert(std::make_pair(name, 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
name += L"_" + std::to_wstring(pFind->second);
|
||||
pFind->second++;
|
||||
}
|
||||
|
||||
if (Context.get_table_context().start_database_range(name, *table_target_range_address_))
|
||||
{
|
||||
if (table_display_filter_buttons_)
|
||||
Context.get_table_context().set_database_filter(table_display_filter_buttons_->get());
|
||||
|
||||
Context.get_table_context().end_database_range();
|
||||
if (table_orientation_)
|
||||
Context.get_table_context().set_database_orientation(table_orientation_->get_type() == table_orientation::row ? true : false);
|
||||
|
||||
if (table_contains_header_)
|
||||
Context.get_table_context().set_database_header(table_contains_header_->get());
|
||||
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
{
|
||||
content_[i]->xlsx_convert(Context);
|
||||
}
|
||||
|
||||
Context.get_table_context().end_database_range();
|
||||
}
|
||||
else
|
||||
{
|
||||
Context.get_xlsx_defined_names().add(name, table_target_range_address_.get(), false, -1);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@ -72,8 +72,9 @@ void table_table_row::docx_convert(oox::docx_conversion_context & Context)
|
||||
const style_instance * inst =
|
||||
Context.root()->odf_context().styleContainer().style_by_name( styleName , style_family::TableRow,Context.process_headers_footers_);
|
||||
|
||||
style_table_cell_properties* cell_props = NULL;
|
||||
style_table_row_properties* row_props = NULL;
|
||||
style_table_cell_properties *cell_props = NULL;
|
||||
style_table_row_properties *row_props = NULL;
|
||||
|
||||
if (inst && inst->content())
|
||||
{
|
||||
cell_props = inst->content()->get_style_table_cell_properties(true);
|
||||
@ -89,8 +90,32 @@ void table_table_row::docx_convert(oox::docx_conversion_context & Context)
|
||||
{
|
||||
_Wostream << L"<w:tr>";
|
||||
|
||||
_Wostream << L"<w:trPr>";
|
||||
_Wostream << L"<w:cantSplit w:val=\"false\" />";
|
||||
_Wostream << L"<w:trPr>";
|
||||
|
||||
bool bCantSplit = false;
|
||||
|
||||
if (row_props)
|
||||
{
|
||||
if (row_props->attlist_.fo_keep_together_ && row_props->attlist_.fo_keep_together_->get_type() == keep_together::Always)
|
||||
{
|
||||
_Wostream << L"<w:cantSplit w:val=\"true\"/>";
|
||||
}
|
||||
if (row_props->attlist_.style_row_height_)
|
||||
{
|
||||
int val = (int)( 0.5 + 20.0 * row_props->attlist_.style_row_height_->get_value_unit(length::pt) );
|
||||
if (val < 0)
|
||||
val = 0;
|
||||
_Wostream << L"<w:trHeight w:val=\"" << val << L"\" w:hRule=\"exact\"/>";
|
||||
}
|
||||
else if (row_props->attlist_.style_min_row_height_)
|
||||
{
|
||||
int val = (int)( 0.5 + 20.0 * row_props->attlist_.style_min_row_height_->get_value_unit(length::pt) );
|
||||
if (val < 0)
|
||||
val = 0;
|
||||
_Wostream << L"<w:trHeight w:val=\"" << val << L"\" w:hRule=\"atLeast\"/>";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (cell_props)
|
||||
cell_props->docx_convert(Context);
|
||||
@ -171,10 +196,10 @@ void table_table::docx_convert(oox::docx_conversion_context & Context)
|
||||
}
|
||||
}
|
||||
|
||||
bool sub_table = table_table_attlist_.table_is_sub_table_.get_value_or(false);
|
||||
bool sub_table = attlist_.table_is_sub_table_.get_value_or(false);
|
||||
//todooo придумать как сделать внешние границы sub-таблицы границами внешней ячейки (чтоб слияние произошло)
|
||||
|
||||
std::wstring tableStyleName = table_table_attlist_.table_style_name_.get_value_or(L"");
|
||||
std::wstring tableStyleName = attlist_.table_style_name_.get_value_or(L"");
|
||||
|
||||
_Wostream << L"<w:tbl>";
|
||||
|
||||
|
||||
@ -94,8 +94,19 @@ void table_named_range::xlsx_convert(oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
tableId = Context.get_table_context().state()->get_table_id();
|
||||
}
|
||||
oox::xlsx_defined_names & ctx = Context.get_xlsx_defined_names();
|
||||
ctx.add(table_name_.get(), table_cell_range_address_.get(), false, tableId);
|
||||
std::wstring name = table_name_.get();
|
||||
std::map<std::wstring, int>::iterator pFind = Context.mapUsedNames_.find(name);
|
||||
if (pFind == Context.mapUsedNames_.end())
|
||||
{
|
||||
Context.mapUsedNames_.insert(std::make_pair(name, 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
name += L"_" + std::to_wstring(pFind->second);
|
||||
pFind->second++;
|
||||
}
|
||||
|
||||
Context.get_xlsx_defined_names().add(name, table_cell_range_address_.get(), false, tableId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -130,8 +141,18 @@ void table_named_expression::xlsx_convert(oox::xlsx_conversion_context & Context
|
||||
{
|
||||
tableId = Context.get_table_context().state()->get_table_id();
|
||||
}
|
||||
oox::xlsx_defined_names & ctx = Context.get_xlsx_defined_names();
|
||||
ctx.add(table_name_.get(), table_expression_.get(), true, tableId);
|
||||
std::wstring name = table_name_.get();
|
||||
std::map<std::wstring, int>::iterator pFind = Context.mapUsedNames_.find(name);
|
||||
if (pFind == Context.mapUsedNames_.end())
|
||||
{
|
||||
Context.mapUsedNames_.insert(std::make_pair(name, 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
name += L"_" + std::to_wstring(pFind->second);
|
||||
pFind->second++;
|
||||
}
|
||||
Context.get_xlsx_defined_names().add(name, table_expression_.get(), true, tableId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -83,14 +83,14 @@ void table_table_row::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
style_table_row_properties_attlist & row_attlist = inst->content()->get_style_table_row_properties()->attlist_;
|
||||
if (row_attlist.style_row_height_)
|
||||
{
|
||||
height = (int)( 0.5 +row_attlist.style_row_height_->get_value_unit(length::emu) );
|
||||
height = (int)( 0.5 + row_attlist.style_row_height_->get_value_unit(length::emu) );
|
||||
}
|
||||
else if (row_attlist.style_min_row_height_)
|
||||
{
|
||||
height = (int)( 0.5 + row_attlist.style_min_row_height_->get_value_unit(length::emu));
|
||||
}
|
||||
}
|
||||
if (height<1) height = 100000;
|
||||
if (height < 1) height = 100000;
|
||||
|
||||
_Wostream << L"<a:tr h=\"" << height << L"\">";
|
||||
|
||||
@ -159,13 +159,13 @@ void table_table::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
Context.get_slide_context().start_table();
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
std::wstring tableStyleName = table_table_attlist_.table_style_name_.get_value_or(L"");
|
||||
std::wstring tableStyleName = attlist_.table_style_name_.get_value_or(L"");
|
||||
|
||||
Context.get_table_context().start_table(tableStyleName);
|
||||
|
||||
if (table_table_attlist_.table_template_name_)
|
||||
if (attlist_.table_template_name_)
|
||||
{
|
||||
std::wstring name = L"table:" + table_table_attlist_.table_template_name_.get() ;
|
||||
std::wstring name = L"table:" + attlist_.table_template_name_.get() ;
|
||||
if (office_element_ptr style = Context.root()->odf_context().Templates().find_by_style_name(name))
|
||||
{
|
||||
if (table_table_template* template_ = dynamic_cast<table_table_template *>(style.get()))
|
||||
@ -184,13 +184,13 @@ void table_table::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
_Wostream << L"<a:tbl>";
|
||||
|
||||
_Wostream << L"<a:tblPr";
|
||||
if (table_table_attlist_.table_use_banding_rows_styles_)
|
||||
if (attlist_.table_use_banding_rows_styles_)
|
||||
_Wostream << L" bandRow=\"1\"";
|
||||
if (table_table_attlist_.table_use_first_row_styles_)
|
||||
if (attlist_.table_use_first_row_styles_)
|
||||
_Wostream << L" firstRow=\"1\"";
|
||||
if (table_table_attlist_.table_use_banding_columns_styles_)
|
||||
if (attlist_.table_use_banding_columns_styles_)
|
||||
_Wostream << L" bandCol=\"1\"";
|
||||
if (table_table_attlist_.table_use_first_column_styles_)
|
||||
if (attlist_.table_use_first_column_styles_)
|
||||
_Wostream << L" firstCol=\"1\"";
|
||||
_Wostream << ">";
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user