mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
Refactoring
This commit is contained in:
40
Common/3dParty/html/css/CssCalculator.pro
Normal file
40
Common/3dParty/html/css/CssCalculator.pro
Normal file
@ -0,0 +1,40 @@
|
||||
#CONFIG -= qt
|
||||
|
||||
#TEMPLATE = lib
|
||||
#DEFINES += CSSCALCULATOR_LIBRARY
|
||||
|
||||
#CONFIG += c++11
|
||||
|
||||
#DEFINES += QT_DEPRECATED_WARNINGS
|
||||
|
||||
QT -= core gui
|
||||
|
||||
VERSION = 1.0.0.0
|
||||
TARGET = CssCalculator
|
||||
TEMPLATE = lib
|
||||
|
||||
CONFIG += shared
|
||||
CONFIG += plugin
|
||||
|
||||
CONFIG += core_static_link_libstd
|
||||
|
||||
DEFINES += CSSCALCULATOR_USE_DYNAMIC_LIBRARY
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/../../../..
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
|
||||
include($$CORE_ROOT_DIR/Common/base.pri)
|
||||
include($$CORE_ROOT_DIR/Common/3dParty/html/katana.pri)
|
||||
|
||||
ADD_DEPENDENCY(kernel)
|
||||
|
||||
HEADERS += \
|
||||
src/CCssCalculator.h \
|
||||
src/CElement.h \
|
||||
src/CssCalculator_global.h
|
||||
|
||||
SOURCES += \
|
||||
src/CCssCalculator.cpp \
|
||||
src/CElement.cpp
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
#include "CGetData.h"
|
||||
#include "CCssCalculator.h"
|
||||
#include <codecvt>
|
||||
|
||||
#include <string>
|
||||
@ -6,7 +6,6 @@
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
|
||||
|
||||
#include "../katana-parser/src/selector.h"
|
||||
|
||||
#define MAX_LINE_LENGTH 80
|
||||
@ -189,6 +188,7 @@ std::pair<std::wstring, std::wstring> CCssCalculator::GetDeclaration(KatanaDecla
|
||||
std::pair<std::wstring, std::wstring> pDeclaration;
|
||||
|
||||
std::wstring sValueList = StringifyValueList(oDecl->values);
|
||||
|
||||
if (oDecl->important)
|
||||
sValueList += L" !important";
|
||||
pDeclaration = std::make_pair(stringToWstring(oDecl->property), sValueList);
|
||||
@ -1759,11 +1759,9 @@ static std::wstring StringifyValueList(KatanaArray* oValues)
|
||||
|
||||
std::wstring buffer;
|
||||
|
||||
|
||||
for (size_t i = 0; i < oValues->length; ++i) {
|
||||
KatanaValue* value = (KatanaValue*)oValues->data[i];
|
||||
std::wstring str = StringifyValue(value);
|
||||
|
||||
buffer += str;
|
||||
|
||||
str.clear();
|
||||
@ -1828,10 +1826,12 @@ static std::wstring StringifyValue(KatanaValue* oValue)
|
||||
break;
|
||||
}
|
||||
case KATANA_VALUE_PARSER_OPERATOR:
|
||||
str = L" ";
|
||||
if (oValue->iValue != '=') {
|
||||
str = (L" " + std::to_wstring(oValue->iValue));
|
||||
str.push_back((wchar_t)static_cast<char>(oValue->iValue));
|
||||
str += L" ";
|
||||
} else {
|
||||
str = (L" " + std::to_wstring(oValue->iValue));
|
||||
str.push_back((wchar_t)static_cast<char>(oValue->iValue));
|
||||
}
|
||||
break;
|
||||
case KATANA_VALUE_PARSER_LIST:
|
||||
@ -1,13 +1,14 @@
|
||||
#ifndef CGETDATA_H
|
||||
#define CGETDATA_H
|
||||
#ifndef CCSSCALCULATOR_H
|
||||
#define CCSSCALCULATOR_H
|
||||
|
||||
#include "../katana-parser/src/katana.h"
|
||||
#include "../katana-parser/src/parser.h"
|
||||
#include "iostream"
|
||||
#include "CssCalculator_global.h"
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include "CElement.h"
|
||||
|
||||
#include "../../katana-parser/src/katana.h"
|
||||
|
||||
|
||||
typedef enum {
|
||||
Defoult,
|
||||
Cantimeter,
|
||||
@ -18,7 +19,7 @@ typedef enum {
|
||||
Peak
|
||||
} UnitMeasure;
|
||||
|
||||
class CCssCalculator
|
||||
class CSSCALCULATOR_EXPORT CCssCalculator
|
||||
{
|
||||
std::vector<CElement*> m_arData;
|
||||
|
||||
@ -129,4 +130,4 @@ public:
|
||||
|
||||
};
|
||||
|
||||
#endif // CGETDATA_H
|
||||
#endif // CCSSCALCULATOR_H
|
||||
130
Common/3dParty/html/css/src/CElement.cpp
Normal file
130
Common/3dParty/html/css/src/CElement.cpp
Normal file
@ -0,0 +1,130 @@
|
||||
#include "CElement.h"
|
||||
#include <iostream>
|
||||
|
||||
CElement::CElement()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CElement::~CElement()
|
||||
{
|
||||
for (size_t i = 0; i < m_arChildrens.size(); i++)
|
||||
delete m_arChildrens[i];
|
||||
|
||||
m_arChildrens.clear();
|
||||
}
|
||||
|
||||
std::wstring CElement::GetText()
|
||||
{
|
||||
std::wstring sText;
|
||||
for (size_t i =0 ; i < m_arSelectors.size(); i++)
|
||||
sText += m_arSelectors[i] + L" ";
|
||||
if (m_arDeclarations.size() != 0 ||
|
||||
m_arChildrens.size() != 0)
|
||||
{
|
||||
sText += L"{\n";
|
||||
|
||||
if (m_arChildrens.size() != 0)
|
||||
for (size_t i = 0; i < m_arChildrens.size(); i++)
|
||||
sText += m_arChildrens[i]->GetText();
|
||||
|
||||
for (size_t i = 0; i < m_arDeclarations.size(); i++)
|
||||
{
|
||||
sText += L" " + m_arDeclarations[i].first + L": " + m_arDeclarations[i].second + L";\n";
|
||||
}
|
||||
sText += L"};\n";
|
||||
}
|
||||
else
|
||||
sText += L";\n";
|
||||
return sText;
|
||||
}
|
||||
|
||||
void CElement::AddChildren(CElement *oChildren)
|
||||
{
|
||||
m_arChildrens.push_back(oChildren);
|
||||
}
|
||||
|
||||
void CElement::AddSelector(std::wstring sSelector)
|
||||
{
|
||||
m_arSelectors.push_back(sSelector);
|
||||
}
|
||||
|
||||
void CElement::AddDeclaration(std::pair<std::wstring, std::wstring> pDeclaration)
|
||||
{
|
||||
m_arDeclarations.push_back(pDeclaration);
|
||||
}
|
||||
|
||||
void CElement::AddSelectors(std::vector<std::wstring> arSelectors)
|
||||
{
|
||||
for (size_t i = 0; i < arSelectors.size(); i++)
|
||||
m_arSelectors.push_back(arSelectors[i]);
|
||||
}
|
||||
|
||||
void CElement::AddDeclarations(std::vector<std::pair<std::wstring, std::wstring> > arDeclarations)
|
||||
{
|
||||
for (size_t i = 0; i < arDeclarations.size(); i++)
|
||||
m_arDeclarations.push_back(arDeclarations[i]);
|
||||
}
|
||||
|
||||
int CElement::GetCountSelectors()
|
||||
{
|
||||
return m_arSelectors.size();
|
||||
}
|
||||
|
||||
int CElement::GetCountDeclarations()
|
||||
{
|
||||
return m_arDeclarations.size();
|
||||
}
|
||||
|
||||
int CElement::GetCountChildrens()
|
||||
{
|
||||
return m_arChildrens.size();
|
||||
}
|
||||
|
||||
std::vector<std::wstring> CElement::GetSelectors()
|
||||
{
|
||||
return m_arSelectors;
|
||||
}
|
||||
|
||||
std::vector<std::pair<std::wstring, std::wstring>> CElement::GetDeclarations()
|
||||
{
|
||||
return m_arDeclarations;
|
||||
}
|
||||
|
||||
std::vector<std::pair<std::wstring, std::vector<std::pair<std::wstring, std::wstring>>>> CElement::GetDeclarations(std::wstring sSelector,
|
||||
std::vector<std::wstring> pParent)
|
||||
{
|
||||
std::vector<std::pair<std::wstring, std::vector<std::pair<std::wstring, std::wstring>>>> arElement;
|
||||
std::vector<std::wstring> arSelectors = GetSelectors();
|
||||
|
||||
for (size_t i = 0; i < arSelectors.size(); i++)
|
||||
{
|
||||
if (arSelectors[i] == sSelector)
|
||||
{
|
||||
std::wstring sTempSelectors;
|
||||
for (size_t j = 0; j < pParent.size(); j++)
|
||||
sTempSelectors += pParent[j];
|
||||
if (!sTempSelectors.empty())
|
||||
sTempSelectors += L" -> " + sSelector;
|
||||
else
|
||||
sTempSelectors = sSelector;
|
||||
arElement.push_back(std::make_pair(sTempSelectors, m_arDeclarations));
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::pair<std::wstring, std::vector<std::pair<std::wstring, std::wstring>>>> TempArElement;
|
||||
|
||||
for (int i = 0; i < GetCountChildrens(); i++)
|
||||
{
|
||||
TempArElement = m_arChildrens[i]->GetDeclarations(sSelector, GetSelectors());
|
||||
for (size_t j = 0; j < TempArElement.size(); j++)
|
||||
arElement.push_back(TempArElement[j]);
|
||||
}
|
||||
|
||||
return arElement;
|
||||
}
|
||||
|
||||
std::vector<CElement*> CElement::GetChildrens()
|
||||
{
|
||||
return m_arChildrens;
|
||||
}
|
||||
18
Common/3dParty/html/css/src/CssCalculator_global.h
Normal file
18
Common/3dParty/html/css/src/CssCalculator_global.h
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef CSSCALCULATOR_GLOBAL_H
|
||||
#define CSSCALCULATOR_GLOBAL_H
|
||||
|
||||
#if defined(_MSC_VER) || defined(WIN64) || defined(_WIN64) || defined(__WIN64__) || defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
|
||||
# define Q_DECL_EXPORT __declspec(dllexport)
|
||||
# define Q_DECL_IMPORT __declspec(dllimport)
|
||||
#else
|
||||
# define Q_DECL_EXPORT __attribute__((visibility("default")))
|
||||
# define Q_DECL_IMPORT __attribute__((visibility("default")))
|
||||
#endif
|
||||
|
||||
#if defined(CSSCALCULATOR_LIBRARY)
|
||||
# define CSSCALCULATOR_EXPORT Q_DECL_EXPORT
|
||||
#else
|
||||
# define CSSCALCULATOR_EXPORT Q_DECL_IMPORT
|
||||
#endif
|
||||
|
||||
#endif // CSSCALCULATOR_GLOBAL_H
|
||||
4074
Common/3dParty/html/css/tests/cssFiles/animate.css
vendored
Normal file
4074
Common/3dParty/html/css/tests/cssFiles/animate.css
vendored
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,15 +1,5 @@
|
||||
/*
|
||||
* Hover.css - Demo Page
|
||||
* Author: Ian Lunn @IanLunn
|
||||
* Author URL: http://ianlunn.co.uk/
|
||||
* Github: https://github.com/IanLunn/Hover
|
||||
* Hover.css Copyright Ian Lunn 2017.
|
||||
*/
|
||||
@charset 'windows-1251';
|
||||
|
||||
/**
|
||||
* The following are default styles for the demo page,
|
||||
* you don't need to include these on your own site.
|
||||
*/
|
||||
|
||||
@media screen and (min-width: 640px) {
|
||||
#forkongithub {
|
||||
@ -47,7 +37,7 @@
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 40px 0 0 0;
|
||||
padding: 40px 0 10px 0;
|
||||
font-family: sans-serif;
|
||||
color: #333;
|
||||
line-height: 140%;
|
||||
@ -223,7 +213,7 @@ small {
|
||||
}
|
||||
|
||||
p,
|
||||
[class^="hvr-"] {
|
||||
{
|
||||
font-family: 'Roboto', sans-serif;
|
||||
}
|
||||
|
||||
@ -9,6 +9,8 @@
|
||||
*/
|
||||
/* 2D TRANSITIONS */
|
||||
/* Grow */
|
||||
|
||||
@charset "UTF-8";
|
||||
.hvr-grow {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
@ -26,11 +28,11 @@
|
||||
}
|
||||
|
||||
/* Shrink */
|
||||
.hvr-shrink {
|
||||
.hvr-grow-shrink {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
-webkit-transform: perspective(1px) translateZ(0);
|
||||
transform: perspective(1px) translateZ(0);
|
||||
-webkit-transform: perspective(13px) translateZ(0);
|
||||
transform: perspective(8px) translateZ(0);
|
||||
box-shadow: 0 0 1px rgba(0, 0, 0, 0);
|
||||
-webkit-transition-duration: 0.3s;
|
||||
transition-duration: 0.3s;
|
||||
@ -68,7 +70,7 @@
|
||||
vertical-align: middle;
|
||||
-webkit-transform: perspective(1px) translateZ(0);
|
||||
transform: perspective(1px) translateZ(0);
|
||||
box-shadow: 0 0 1px rgba(0, 0, 0, 0);
|
||||
box-shadow: 0 1px 1px rgba(0, 0, 0, 0);
|
||||
}
|
||||
.hvr-pulse:hover, .hvr-pulse:focus, .hvr-pulse:active {
|
||||
-webkit-animation-name: hvr-pulse;
|
||||
51
Common/3dParty/html/css/tests/cssFiles/test.css
Normal file
51
Common/3dParty/html/css/tests/cssFiles/test.css
Normal file
@ -0,0 +1,51 @@
|
||||
/*!
|
||||
* Hover.css (http://ianlunn.github.io/Hover/)
|
||||
* Version: 2.3.2
|
||||
* Author: Ian Lunn @IanLunn
|
||||
* Author URL: http://ianlunn.co.uk/
|
||||
* Github: https://github.com/IanLunn/Hover
|
||||
|
||||
* Hover.css Copyright Ian Lunn 2017. Generated with Sass.
|
||||
*/
|
||||
/* 2D TRANSITIONS */
|
||||
/* Grow */
|
||||
|
||||
@charset 'iso-8859-15';
|
||||
h1
|
||||
{
|
||||
color : red;
|
||||
}
|
||||
.animate__animated.animate__faster {
|
||||
-webkit-animation-duration: calc(1s / 2);
|
||||
animation-duration: calc(1s / 2);
|
||||
-webkit-animation-duration: calc(var(--animate-duration) / 2);
|
||||
animation-duration: calc(var(--animate-duration) / 2);
|
||||
}
|
||||
.Author
|
||||
{
|
||||
color: green;
|
||||
text-decoration: underline;
|
||||
border-radius: 4.5px;
|
||||
}
|
||||
|
||||
#first
|
||||
{
|
||||
color: black;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4
|
||||
{
|
||||
color: black;
|
||||
text-decoration: overline;
|
||||
}
|
||||
#main .container article.post > header h1.giga
|
||||
{
|
||||
color: #777;
|
||||
}
|
||||
|
||||
*
|
||||
{
|
||||
background: black;
|
||||
}
|
||||
|
||||
|
||||
95
Common/3dParty/html/css/tests/test.cpp
Normal file
95
Common/3dParty/html/css/tests/test.cpp
Normal file
@ -0,0 +1,95 @@
|
||||
#include "../../../../../DesktopEditor/common/File.h"
|
||||
|
||||
#include "../src/CCssCalculator.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
std::vector<std::pair<std::wstring, std::pair<std::vector<std::string>, std::map<std::wstring, std::wstring>>>> arTestDatas;
|
||||
std::vector<std::string> arSelectors1 = {"#forkongithub"};
|
||||
std::pair<std::vector<std::string>, std::map<std::wstring, std::wstring>> pData1 = {arSelectors1,{{L"display", L"block"},
|
||||
{L"height", L"5.291667cm "},
|
||||
{L"overflow", L"hidden"},
|
||||
{L"position", L"absolute"},
|
||||
{L"right", L"0"},
|
||||
{L"top", L"0"},
|
||||
{L"width", L"5.291667cm "}}};
|
||||
|
||||
arTestDatas.push_back(std::make_pair(L"../../../../cssFiles/demo-page.css", pData1));
|
||||
|
||||
std::vector<std::string> arSelectors2 = {".animate__animated.animate__faster"};
|
||||
std::pair<std::vector<std::string>, std::map<std::wstring, std::wstring>> pData2 = {arSelectors2,{{L"-webkit-animation-duration", L"calc(1s / 2)"},
|
||||
{L"animation-duration", L"calc(1s / 2)"},
|
||||
{L"-webkit-animation-duration", L"calc(var(--animate-duration) / 2)"},
|
||||
{L"animation-duration", L"calc(var(--animate-duration) / 2)"},
|
||||
{L"background", L"black"}}};
|
||||
|
||||
arTestDatas.push_back(std::make_pair(L"../../../../cssFiles/test.css", pData2));
|
||||
|
||||
std::vector<std::string> arSelectors3 = {".hvr-pulse-grow:focus"};
|
||||
std::pair<std::vector<std::string>, std::map<std::wstring, std::wstring>> pData3 = {arSelectors3,{{L"-webkit-animation-name", L"hvr-pulse-grow"},
|
||||
{L"animation-name", L"hvr-pulse-grow"},
|
||||
{L"-webkit-animation-duration", L"0.3s"},
|
||||
{L"animation-duration", L"0.3s"},
|
||||
{L"-webkit-animation-timing-function", L"linear"},
|
||||
{L"animation-timing-function", L"linear"},
|
||||
{L"-webkit-animation-iteration-count", L"infinite"},
|
||||
{L"animation-iteration-count", L"infinite"},
|
||||
{L"-webkit-animation-direction", L"alternate"},
|
||||
{L"animation-direction", L"alternate"}}};
|
||||
|
||||
arTestDatas.push_back(std::make_pair(L"../../../../cssFiles/hover.css", pData3));
|
||||
|
||||
|
||||
for (size_t i = 0; i < arTestDatas.size(); i++)
|
||||
{
|
||||
std::wstring sFilePath = NSFile::GetProcessDirectory() + arTestDatas[i].first;
|
||||
|
||||
CCssCalculator oCSS;
|
||||
oCSS.AddStyles(sFilePath);
|
||||
|
||||
std::map<std::wstring, std::wstring> mDecl = oCSS.GetCompiledStyleW(arTestDatas[i].second.first, Cantimeter);
|
||||
|
||||
bool bError = false;
|
||||
|
||||
if (mDecl.size() == arTestDatas[i].second.second.size())
|
||||
{
|
||||
auto iter2 = arTestDatas[i].second.second.begin();
|
||||
for (auto iter1 = mDecl.begin(); iter1 != mDecl.end(); iter1++)
|
||||
{
|
||||
if (iter1->first != iter2->first ||
|
||||
iter1->second != iter2->second)
|
||||
{
|
||||
bError = true;
|
||||
break;
|
||||
}
|
||||
iter2++;
|
||||
}
|
||||
}
|
||||
else
|
||||
bError = true;
|
||||
|
||||
std::string arSels;
|
||||
for (size_t j = 0; j < arTestDatas[i].second.first.size() - 1; j++)
|
||||
arSels += arTestDatas[i].second.first[j] + ',';
|
||||
arSels += arTestDatas[i].second.first[arTestDatas[i].second.first.size() - 1];
|
||||
|
||||
std::wcout << arTestDatas[i].first;
|
||||
std::cout << " - " << arSels << " - ";
|
||||
|
||||
if (bError)
|
||||
std::cout << "FALSE";
|
||||
else
|
||||
std::cout << "TRUE";
|
||||
std::cout << std::endl;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
20
Common/3dParty/html/css/tests/test.pro
Normal file
20
Common/3dParty/html/css/tests/test.pro
Normal file
@ -0,0 +1,20 @@
|
||||
QT -= core
|
||||
QT -= gui
|
||||
|
||||
TARGET = test
|
||||
TEMPLATE = app
|
||||
CONFIG += console
|
||||
CONFIG -= app_bundle
|
||||
|
||||
DEFINES += CSSCALCULATOR_USE_DYNAMIC_LIBRARY
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/../../../../..
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
include($$CORE_ROOT_DIR/Common/base.pri)
|
||||
|
||||
DESTDIR = $$PWD_ROOT_DIR/build/$$CORE_BUILDS_PLATFORM_PREFIX/$$CORE_BUILDS_CONFIGURATION_PREFIX
|
||||
|
||||
ADD_DEPENDENCY(CssCalculator, kernel)
|
||||
|
||||
SOURCES += \
|
||||
test.cpp
|
||||
4
Common/3dParty/html/katana.pri
Normal file
4
Common/3dParty/html/katana.pri
Normal file
@ -0,0 +1,4 @@
|
||||
core_windows:INCLUDEPATH += $$PWD/katana-parser/visualc/include
|
||||
|
||||
HEADERS += $$files($$PWD/katana-parser/src/*.h, true)
|
||||
SOURCES += $$files($$PWD/katana-parser/src/*.c, true)
|
||||
@ -1,18 +0,0 @@
|
||||
QT -= core
|
||||
QT -= gui
|
||||
|
||||
VERSION = 1.0.0.3
|
||||
TARGET = katana
|
||||
TEMPLATE = lib
|
||||
CONFIG += staticlib
|
||||
|
||||
CONFIG += core_static_link_libstd
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/../../..
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
include($$CORE_ROOT_DIR/Common/base.pri)
|
||||
|
||||
core_windows:INCLUDEPATH += $$PWD/katana-parser/visualc/include
|
||||
|
||||
HEADERS += $$files($$PWD/katana-parser/src/*.h, true)
|
||||
SOURCES += $$files($$PWD/katana-parser/src/*.c, true)
|
||||
@ -1,31 +0,0 @@
|
||||
h1
|
||||
{
|
||||
color : red;
|
||||
}
|
||||
|
||||
.Author
|
||||
{
|
||||
color: green;
|
||||
text-decoration: underline;
|
||||
border-radius: 4.5px;
|
||||
}
|
||||
|
||||
#first
|
||||
{
|
||||
color: black;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4
|
||||
{
|
||||
color: black;
|
||||
text-decoration: overline;
|
||||
}
|
||||
#main .container article.post > header h1.giga
|
||||
{
|
||||
color: #777;
|
||||
}
|
||||
|
||||
*
|
||||
{
|
||||
background: black;
|
||||
}
|
||||
@ -1,65 +0,0 @@
|
||||
#include "../gumbo-parser/src/gumbo.h"
|
||||
#include "../katana-parser/src/katana.h"
|
||||
|
||||
#include "../../../../DesktopEditor/common/File.h"
|
||||
|
||||
#include "CGetData.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// const char* filename = "C:/Users/kiril/Desktop/OnlyOffice/core/EpubFile/test/part1.xhtml";
|
||||
|
||||
// std::ifstream in(filename, std::ios::in | std::ios::binary);
|
||||
// if (!in)
|
||||
// {
|
||||
// std::cout << "File " << filename << " not found!\n";
|
||||
// exit(EXIT_FAILURE);
|
||||
// }
|
||||
|
||||
// {
|
||||
// std::string contents;
|
||||
// in.seekg(0, std::ios::end);
|
||||
// contents.resize(in.tellg());
|
||||
// in.seekg(0, std::ios::beg);
|
||||
// in.read(&contents[0], contents.size());
|
||||
// in.close();
|
||||
|
||||
// GumboOptions options = kGumboDefaultOptions;
|
||||
|
||||
// GumboOutput* output = gumbo_parse_with_options(&options, contents.data(), contents.length());
|
||||
// std::string indent_chars = " ";
|
||||
// std::cout << prettyprint(output->document, 0, indent_chars) << std::endl;
|
||||
// gumbo_destroy_output(&kGumboDefaultOptions, output);
|
||||
// return 0;
|
||||
// }
|
||||
std::wstring sFilePath = NSFile::GetProcessDirectory() + L"../../../../cssFiles/demo-page.css";
|
||||
|
||||
CCssCalculator oCSS;
|
||||
oCSS.AddStyles(sFilePath);
|
||||
oCSS.AddStyle("h1 {color : red;}"
|
||||
".Author{"
|
||||
"color: green;"
|
||||
"text-decoration: underline;"
|
||||
"border-radius: 4.5px;}");
|
||||
|
||||
// oCSS.Print();
|
||||
std::wcout << oCSS.GetEncoding() << std::endl;
|
||||
|
||||
std::vector<std::string> arSelectors;
|
||||
arSelectors.push_back("#forkongithub");
|
||||
|
||||
std::map<std::wstring, std::wstring> mDecl;
|
||||
|
||||
mDecl = oCSS.GetCompiledStyleW(arSelectors, Cantimeter);
|
||||
|
||||
for (auto iter = mDecl.begin(); iter != mDecl.end(); iter++)
|
||||
{
|
||||
std::wcout << iter->first << " : " << iter->second << std::endl;
|
||||
}
|
||||
}
|
||||
@ -1,28 +0,0 @@
|
||||
QT -= core
|
||||
QT -= gui
|
||||
|
||||
TARGET = test
|
||||
TEMPLATE = app
|
||||
CONFIG += console
|
||||
CONFIG -= app_bundle
|
||||
|
||||
DEFINES += EPUBFORMAT_USE_DYNAMIC_LIBRARY
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/../../../..
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
include($$CORE_ROOT_DIR/Common/base.pri)
|
||||
|
||||
core_windows:INCLUDEPATH += $$PWD/../gumbo-parser/visualc/include
|
||||
core_windows:INCLUDEPATH += $$PWD/../katana-parser/visualc/include
|
||||
|
||||
DESTDIR = $$PWD_ROOT_DIR/build/$$CORE_BUILDS_PLATFORM_PREFIX/$$CORE_BUILDS_CONFIGURATION_PREFIX
|
||||
|
||||
ADD_DEPENDENCY(gumbo, katana, kernel)
|
||||
|
||||
SOURCES += main.cpp \
|
||||
CElement.cpp \
|
||||
CGetData.cpp
|
||||
|
||||
HEADERS += \
|
||||
CElement.h \
|
||||
CGetData.h
|
||||
Reference in New Issue
Block a user