Commit e465e33d authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov

XlsFormat - word art, расширение градиентных заливок, ...

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@67713 954022d7-b5bf-4e40-9824-e11837661b57
parent 3d525eef
......@@ -45,9 +45,10 @@ void OfficeArtFOPTE::load(XLS::CFRecord& record)
{
unsigned short flags;
record >> flags >> op;
opid = GETBITS(flags, 0, 13);
fBid = GETBIT(flags, 14);
fComplex = GETBIT(flags, 15);
opid = GETBITS(flags, 0, 13);
fBid = GETBIT(flags, 14);
fComplex = GETBIT(flags, 15);
// TODO: complex data shall be parsed here
}
......@@ -81,7 +82,6 @@ OfficeArtFOPTEPtr OfficeArtFOPTE::load_and_create(XLS::CFRecord& record)
case NSOfficeDrawing::gtextAlign:
case NSOfficeDrawing::gtextSize:
case NSOfficeDrawing::gtextSpacing:
case NSOfficeDrawing::gtextFont:
case NSOfficeDrawing::gtextCSSFont:
fopte = OfficeArtFOPTEPtr(new OfficeArtFOPTE);
break;
......@@ -89,8 +89,12 @@ OfficeArtFOPTEPtr OfficeArtFOPTE::load_and_create(XLS::CFRecord& record)
fopte = OfficeArtFOPTEPtr(new TextBooleanProperties);
break;
case NSOfficeDrawing::gtextUNICODE:
case NSOfficeDrawing::gtextFont:
fopte = OfficeArtFOPTEPtr(new anyString);
break;
case 0x00ff:
fopte = OfficeArtFOPTEPtr(new GeometryTextBooleanProperties);
break;
case 0x0100:
fopte = OfficeArtFOPTEPtr(new cropFromTop);
break;
......@@ -365,10 +369,49 @@ void TextBooleanProperties::load(XLS::CFRecord& record)
fFitShapeToText = GETBIT(op, 1);
fAutoTextMargin = GETBIT(op, 3);
fSelectText = GETBIT(op, 4);
fUsefFitShapeToText = GETBIT(op, 17);
fUsefAutoTextMargin = GETBIT(op, 19);
fUsefSelectText = GETBIT(op, 20);
}
void GeometryTextBooleanProperties::load(XLS::CFRecord& record)
{
OfficeArtFOPTE::load(record);
bool fUsegFReverseRows = GETBIT(op, 31);
bool fUsefGtext = GETBIT(op, 30);
bool fUsegFVertical = GETBIT(op, 29);
bool fUsegtextFKern = GETBIT(op, 28);
bool fUsegTight = GETBIT(op, 27);
bool fUsegFStretch = GETBIT(op, 26);
bool fUsegFShrinkFit = GETBIT(op, 25);
bool fUsegFBestFit = GETBIT(op, 24);
bool fUsegFNormalize = GETBIT(op, 23);
bool fUsegFDxMeasure = GETBIT(op, 22);
bool fUsegFBold = GETBIT(op, 21);
bool fUsegFItalic = GETBIT(op, 20);
bool fUsegFUnderline = GETBIT(op, 19);
bool fUsegFShadow = GETBIT(op, 18);
bool fUsegFSmallcaps = GETBIT(op, 17);
bool fUsegFStrikethrough= GETBIT(op, 16);
gFReverseRows = fUsegFReverseRows ? GETBIT(op, 15) : false;
fGtext = fUsefGtext ? GETBIT(op, 14) : false;
fVertical = fUsegFVertical ? GETBIT(op, 13) : false;
fKern = fUsegtextFKern ? GETBIT(op, 12) : false;
fTight = fUsegTight ? GETBIT(op, 11) : false;
fStretch = fUsegFStretch ? GETBIT(op, 10) : false;
fShrinkFit = fUsegFShrinkFit ? GETBIT(op, 9) : false;
fBestFit = fUsegFBestFit ? GETBIT(op, 8) : false;
fNormalize = fUsegFNormalize ? GETBIT(op, 7) : false;
fDxMeasure = fUsegFDxMeasure ? GETBIT(op, 6) : false;
fBold = fUsegFBold ? GETBIT(op, 5) : false;
fItalic = fUsegFItalic ? GETBIT(op, 4) : false;
fUnderline = fUsegFUnderline ? GETBIT(op, 3) : false;
fShadow = fUsegFShadow ? GETBIT(op, 2) : false;
fSmallcaps = fUsegFSmallcaps ? GETBIT(op, 1) : false;
fStrikethrough = fUsegFStrikethrough? GETBIT(op, 0) : false;
}
void FillStyleBooleanProperties::load(XLS::CFRecord& record)
{
......@@ -440,6 +483,7 @@ void ProtectionBooleanProperties::load(XLS::CFRecord& record)
fLockAspectRatio = GETBIT(op, 7);
fLockRotation = GETBIT(op, 8);
fLockAgainstUngrouping = GETBIT(op, 9);
fUsefLockAgainstGrouping = GETBIT(op, 16);
fUsefLockAdjustHandles = GETBIT(op, 17);
fUsefLockText = GETBIT(op, 18);
......
......@@ -109,6 +109,30 @@ class TextBooleanProperties : public OfficeArtFOPTE
bool fUsefSelectText;
};
class GeometryTextBooleanProperties : public OfficeArtFOPTE
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(TextBooleanProperties)
virtual void load(XLS::CFRecord& record);
bool gFReverseRows;
bool fGtext;
bool fVertical;
bool fKern;
bool fStretch;
bool fTight;
bool fBestFit;
bool fShrinkFit;
bool fNormalize;
bool fDxMeasure;
bool fBold;
bool fItalic;
bool fUnderline;
bool fShadow;
bool fSmallcaps;
bool fStrikethrough;
};
class lineColor : public OfficeArtFOPTE
{
BASE_STRUCTURE_DEFINE_CLASS_NAME(lineColor)
......
......@@ -683,7 +683,7 @@ void XlsConverter::convert_fill_style(std::vector<ODRAW::OfficeArtFOPTEPtr> & pr
{
switch(props[i]->opid)
{
case 0x0180:
case NSOfficeDrawing::fillType:
{
switch(props[i]->op)
{
......@@ -719,7 +719,7 @@ void XlsConverter::convert_fill_style(std::vector<ODRAW::OfficeArtFOPTEPtr> & pr
}break;
}
}break;
case 0x0181:
case NSOfficeDrawing::fillColor:
{
ODRAW::fillColor * fill = (ODRAW::fillColor *)(props[i].get());
ODRAW::OfficeArtCOLORREF color(fill->op);
......@@ -737,12 +737,12 @@ void XlsConverter::convert_fill_style(std::vector<ODRAW::OfficeArtFOPTEPtr> & pr
else
xlsx_context->get_drawing_context().set_fill_color(color.index, color.fSchemeIndex ? 1 : 3 );
}break;
case 0x0182:
case NSOfficeDrawing::fillOpacity:
{
ODRAW::FixedPoint * fixed_point = static_cast<ODRAW::FixedPoint *>(props[i].get());
xlsx_context->get_drawing_context().set_fill_opacity(fixed_point->dVal);
}break;
case 0x0183:
case NSOfficeDrawing::fillBackColor:
{
ODRAW::fillColor * fill = (ODRAW::fillColor *)(props[i].get());
ODRAW::OfficeArtCOLORREF color(fill->op);
......@@ -760,12 +760,12 @@ void XlsConverter::convert_fill_style(std::vector<ODRAW::OfficeArtFOPTEPtr> & pr
else
xlsx_context->get_drawing_context().set_fill_color(color.index, color.fSchemeIndex ? 1 : 3, true );
}break;
case 0x0184:
case NSOfficeDrawing::fillBackOpacity:
{
ODRAW::FixedPoint * fixed_point = static_cast<ODRAW::FixedPoint *>(props[i].get());
xlsx_context->get_drawing_context().set_fill_opacity(fixed_point->dVal, true);
}break;
case 0x0186:
case NSOfficeDrawing::fillBlip:
{
std::wstring target;
ODRAW::fillBlip *fillBlip = (ODRAW::fillBlip *)(props[i].get());
......@@ -780,12 +780,19 @@ void XlsConverter::convert_fill_style(std::vector<ODRAW::OfficeArtFOPTEPtr> & pr
}
xlsx_context->get_drawing_context().set_fill_texture(target);
}break;
case 0x018B:
case NSOfficeDrawing::fillAngle:
{
ODRAW::fillAngle * angle = (ODRAW::fillAngle *)(props[i].get());
xlsx_context->get_drawing_context().set_fill_angle(angle->dVal);
}break;
case 0x197:
case NSOfficeDrawing::fillFocus:
{
xlsx_context->get_drawing_context().set_fill_focus(props[i]->op);
}break;
case NSOfficeDrawing::fillShadePreset:
{
}break;
case NSOfficeDrawing::fillShadeColors:
{
ODRAW::fillShadeColors *shadeColors = (ODRAW::fillShadeColors *)(props[i].get());
......@@ -809,7 +816,10 @@ void XlsConverter::convert_fill_style(std::vector<ODRAW::OfficeArtFOPTEPtr> & pr
}
}
}break;
case 0x01BF:
case NSOfficeDrawing::fillShadeType:
{
}break;
case NSOfficeDrawing::fNoFillHitTest:
{
ODRAW::FillStyleBooleanProperties * fill = (ODRAW::FillStyleBooleanProperties *)(props[i].get());
if (fill)
......@@ -1005,29 +1015,41 @@ void XlsConverter::convert_geometry_text(std::vector<ODRAW::OfficeArtFOPTEPtr> &
case NSOfficeDrawing::gtextUNICODE://word art text
{
ODRAW::anyString *str = dynamic_cast<ODRAW::anyString*>(props[i].get());
xlsx_context->get_drawing_context().set_wordart_text(str->string_);
if (str) xlsx_context->get_drawing_context().set_wordart_text(str->string_);
}break;
case NSOfficeDrawing::gtextFont:
{
ODRAW::anyString *str = dynamic_cast<ODRAW::anyString*>(props[i].get());
//xlsx_context->get_drawing_context().set_text_font(str->string_);
if (str) xlsx_context->get_drawing_context().set_wordart_font(str->string_);
}break;
case NSOfficeDrawing::gtextSize:
//xlsx_context->get_drawing_context().set_text_font_size((INT)((props[i]->op >> 16) & 0x0000FFFF));
break;
{
xlsx_context->get_drawing_context().set_wordart_size((INT)((props[i]->op >> 16) & 0x0000FFFF));
}break;
case NSOfficeDrawing::gtextAlign:
{
//switch (props[i]->op)
//{
//case NSOfficeDrawing::alignTextLeft:
// pParentShape->m_oText.m_oAttributes.m_nTextAlignHorizontal = 0; break;
//case NSOfficeDrawing::alignTextCenter:
// pParentShape->m_oText.m_oAttributes.m_nTextAlignHorizontal = 1; break;
//case NSOfficeDrawing::alignTextRight:
// pParentShape->m_oText.m_oAttributes.m_nTextAlignHorizontal = 2; break;
//default:
// pParentShape->m_oText.m_oAttributes.m_nTextAlignHorizontal = 1;
//}
switch (props[i]->op)
{
case NSOfficeDrawing::alignTextLeft:
xlsx_context->get_drawing_context().set_wordart_align(0); break;
case NSOfficeDrawing::alignTextCenter:
xlsx_context->get_drawing_context().set_wordart_align(1); break;
case NSOfficeDrawing::alignTextRight:
xlsx_context->get_drawing_context().set_wordart_align(2); break;
default:
xlsx_context->get_drawing_context().set_wordart_align(1); break;
}
}break;
case 0xff:
{
ODRAW::GeometryTextBooleanProperties *bools = dynamic_cast<ODRAW::GeometryTextBooleanProperties*>(props[i].get());
if (bools)
{
if (bools->fBold) xlsx_context->get_drawing_context().set_wordart_bold (true);
if (bools->fItalic) xlsx_context->get_drawing_context().set_wordart_italic (true);
if (bools->fVertical) xlsx_context->get_drawing_context().set_wordart_vertical(true);
if (bools->fUnderline) xlsx_context->get_drawing_context().set_wordart_underline(true);
}
}break;
}
}
......@@ -1051,7 +1073,7 @@ void XlsConverter::convert_text(std::vector<ODRAW::OfficeArtFOPTEPtr> & props)
//pParentShape->m_dTextMarginBottom = (double)pProperty->m_lValue / EMU_MM; break;
case NSOfficeDrawing::WrapText:
{
int lWrapMode = props[i]->op;
xlsx_context->get_drawing_context().set_text_wrap(props[i]->op);
}break;
case NSOfficeDrawing::anchorText:
{
......@@ -1066,31 +1088,22 @@ void XlsConverter::convert_text(std::vector<ODRAW::OfficeArtFOPTEPtr> & props)
//case NSOfficeDrawing::anchorBottom:
//case NSOfficeDrawing::anchorBottomBaseline:
// {
// pParentShape->m_oText.m_oAttributes.m_nTextAlignHorizontal = 0;
// pParentShape->m_oText.m_oAttributes.m_nTextAlignVertical = 2;
// }break;
//case NSOfficeDrawing::anchorTopCentered:
//case NSOfficeDrawing::anchorTopCenteredBaseline:
// {
// pParentShape->m_oText.m_oAttributes.m_nTextAlignHorizontal = 1;
// pParentShape->m_oText.m_oAttributes.m_nTextAlignVertical = 0;
// }break;
//case NSOfficeDrawing::anchorMiddleCentered:
// {
// pParentShape->m_oText.m_oAttributes.m_nTextAlignHorizontal = 1;
// pParentShape->m_oText.m_oAttributes.m_nTextAlignVertical = 1;
// }break;
//case NSOfficeDrawing::anchorBottomCentered:
//case NSOfficeDrawing::anchorBottomCenteredBaseline:
// {
// pParentShape->m_oText.m_oAttributes.m_nTextAlignHorizontal = 1;
// pParentShape->m_oText.m_oAttributes.m_nTextAlignVertical = 2;
// }break;
//default:
// {
// pParentShape->m_oText.m_oAttributes.m_nTextAlignHorizontal = 1;
// pParentShape->m_oText.m_oAttributes.m_nTextAlignVertical = -1; // not set
// }break;
//}
}break;
}
......
......@@ -92,7 +92,11 @@ typedef _CP_PTR(_drawing_state) _drawing_state_ptr;
class _drawing_state
{
public:
_drawing_state() : isInternal(false), shape_id(msosptRectangle), flipH(false), flipV(false), bTextBox(false), bWordArt(false)
_drawing_state() : isInternal(false),
shape_id(msosptRectangle),
flipH(false), flipV(false),
text_wrap(2), //none
bTextBox(false)
{
id = -1;
rotation = 0;
......@@ -121,22 +125,25 @@ public:
std::wstring path;
_rect path_rect;
std::wstring text_content;
std::wstring text_content; //c
int text_wrap;
bool isInternal;
bool bTextBox;
bool bWordArt;
struct _line
struct _wordart
{
_line() {opacity = 0; type = fillSolid; style = L"simple"; width = 0; color.sRGB = L"000000"; typeDash = lineSolid;}
_color color;
int opacity;
_fill_type type;
std::wstring style;
int width;
_line_typeDash typeDash;
}line;
_wordart() : bEnabled(false), size(0), align(1), bold(false), italic(false), underline(false), vertical(false) {}
bool bEnabled;
std::wstring text;
std::wstring font;
int size;
int align;
bool bold;
bool italic;
bool underline;
bool vertical;
}wordart;
bool isInternal;
bool bTextBox;
struct _shadow
{
......@@ -150,7 +157,7 @@ public:
{
_fill()
{
angle = opacity = opacity2 = 0; type = fillSolid;
angle = opacity = opacity2 = focus = 0; type = fillSolid;
memset(texture_crop, 0, 4 * sizeof(int));
texture_crop_enabled = false;
}
......@@ -160,6 +167,7 @@ public:
double opacity2;
_fill_type type;
int focus;
double angle;
std::wstring texture_target;
......@@ -169,6 +177,14 @@ public:
std::vector<std::pair<double, _color>> colorsPosition;
}fill;
struct _line
{
std::wstring style;
int width;
_line_typeDash typeDash;
_fill fill;
}line;
//for group
std::vector<_drawing_state_ptr> drawing_states;
std::vector<_drawing_state_ptr>* parent_drawing_states;
......@@ -218,7 +234,8 @@ public:
void set_fill_texture_mode(int val);
void set_fill_texture (const std::wstring & str);
void add_fill_colors (double position, const std::wstring & color);
void add_fill_colors (double position, int index, int type);
void add_fill_colors (double position, int index, int type);
void set_fill_focus (int val);
void set_line_color (int nColor, const std::wstring & color);
void set_line_color (int index, int type);
......@@ -238,7 +255,16 @@ public:
void set_path (const std::wstring & path);
void set_text (const std::wstring & text);
void set_wordart_text(const std::wstring & text);
void set_text_wrap (int val);
void set_wordart_text (const std::wstring & text);
void set_wordart_font (const std::wstring & text);
void set_wordart_size (int val);
void set_wordart_align (int val);
void set_wordart_bold (bool val);
void set_wordart_italic (bool val);
void set_wordart_underline (bool val);
void set_wordart_vertical (bool val);
//------------------------------------------------------------------------------
void serialize_shape (_drawing_state_ptr & drawing_state);
......@@ -267,12 +293,16 @@ private:
std::vector<_drawing_state_ptr>* current_drawing_states;
void end_drawing (_drawing_state_ptr & drawing_state);
void reset_fill_pattern (_drawing_state_ptr & drawing_state);
void serialize_line (std::wostream & stream, _drawing_state_ptr & drawing_state);
void serialize_gradient_fill(std::wostream & stream, _drawing_state_ptr & drawing_state);
void serialize_bitmap_fill (std::wostream & stream, _drawing_state_ptr & drawing_state, std::wstring rId, const std::wstring ns = L"a:");
void serialize_line (std::wostream & stream, _drawing_state::_line & line);
void serialize_fill (std::wostream & stream, _drawing_state::_fill & fill);
void serialize_gradient_fill(std::wostream & stream, _drawing_state::_fill & fill);
void serialize_bitmap_fill (std::wostream & stream, _drawing_state::_fill & fill, std::wstring rId, const std::wstring ns = L"a:");
void serialize_solid_fill (std::wostream & stream, const _color &color, double opacity = 0);
void serialize_none_fill (std::wostream & stream);
void serialize_line (std::wostream & stream, _drawing_state_ptr & drawing_state);
void serialize_xfrm (std::wostream & stream, _drawing_state_ptr & drawing_state);
void serialize_text (std::wostream & stream, _drawing_state_ptr & drawing_state);
void serialize_color (std::wostream & stream, const _color &color, double opacity = 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment