mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
for bug #74280
This commit is contained in:
@ -58,7 +58,6 @@ namespace PPTX
|
||||
virtual void toPPTY(NSBinPptxRW::CBinaryFileWriter* pWriter) const;
|
||||
virtual void fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader);
|
||||
|
||||
public:
|
||||
nullable_int bright;
|
||||
nullable_int contrast;
|
||||
|
||||
|
||||
85
OdfFile/DataTypes/color_mode.cpp
Normal file
85
OdfFile/DataTypes/color_mode.cpp
Normal file
@ -0,0 +1,85 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
|
||||
#include "color_mode.h"
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <ostream>
|
||||
|
||||
namespace cpdoccore { namespace odf_types {
|
||||
|
||||
std::wostream & operator << (std::wostream & _Wostream, const color_mode& _Val)
|
||||
{
|
||||
switch(_Val.get_type())
|
||||
{
|
||||
case color_mode::greyscale:
|
||||
_Wostream << L"greyscale";
|
||||
break;
|
||||
case color_mode::mono:
|
||||
_Wostream << L"mono";
|
||||
break;
|
||||
case color_mode::standard:
|
||||
_Wostream << L"standard";
|
||||
break;
|
||||
case color_mode::watermark:
|
||||
_Wostream << L"watermark";
|
||||
break;
|
||||
case color_mode::separating:
|
||||
_Wostream << L"separating";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return _Wostream;
|
||||
}
|
||||
color_mode color_mode::parse(const std::wstring & Str)
|
||||
{
|
||||
std::wstring tmp = Str;
|
||||
boost::algorithm::to_lower(tmp);
|
||||
|
||||
if (tmp == L"greyscale")
|
||||
return color_mode(greyscale);
|
||||
else if (tmp == L"mono")
|
||||
return color_mode(mono);
|
||||
else if (tmp == L"standard")
|
||||
return color_mode(standard);
|
||||
else if (tmp == L"watermark")
|
||||
return color_mode(watermark);
|
||||
else if (tmp == L"separating")
|
||||
return color_mode(separating);
|
||||
else
|
||||
{
|
||||
return color_mode(standard);
|
||||
}
|
||||
}
|
||||
|
||||
} }
|
||||
72
OdfFile/DataTypes/color_mode.h
Normal file
72
OdfFile/DataTypes/color_mode.h
Normal file
@ -0,0 +1,72 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <iosfwd>
|
||||
#include <string>
|
||||
#include "odfattributes.h"
|
||||
|
||||
namespace cpdoccore { namespace odf_types {
|
||||
|
||||
class color_mode
|
||||
{
|
||||
public:
|
||||
enum type
|
||||
{
|
||||
standard,
|
||||
greyscale,
|
||||
mono,
|
||||
watermark,
|
||||
separating
|
||||
};
|
||||
|
||||
color_mode() {}
|
||||
color_mode(type _Type) : type_(_Type)
|
||||
{}
|
||||
|
||||
type get_type() const
|
||||
{
|
||||
return type_;
|
||||
};
|
||||
|
||||
static color_mode parse(const std::wstring & Str);
|
||||
|
||||
private:
|
||||
type type_;
|
||||
|
||||
};
|
||||
|
||||
std::wostream & operator << (std::wostream & _Wostream, const color_mode& _Val);
|
||||
}
|
||||
APPLY_PARSE_XML_ATTRIBUTES(odf_types::color_mode);
|
||||
|
||||
}
|
||||
@ -64,6 +64,7 @@
|
||||
#include "borderstyle.h"
|
||||
#include "mathvariant.h"
|
||||
#include "textdisplay.h"
|
||||
#include "color_mode.h"
|
||||
|
||||
#define _CP_APPLY_PROP(A, B) \
|
||||
if (B) \
|
||||
@ -113,7 +114,7 @@ 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(color_mode) draw_color_mode_;
|
||||
_CP_OPT(odf_types::percent) draw_contrast_;
|
||||
_CP_OPT(odf_types::percent) draw_luminance_;
|
||||
_CP_OPT(odf_types::percent) draw_gamma_;
|
||||
|
||||
@ -166,6 +166,7 @@ SOURCES += \
|
||||
../../DataTypes/messagetype.cpp \
|
||||
../../DataTypes/stylecellprotect.cpp \
|
||||
../../DataTypes/sparklines.cpp \
|
||||
../../DataTypes/color_mode.cpp \
|
||||
\
|
||||
../../Reader/Format/abstract_xml.cpp \
|
||||
../../Reader/Format/anim_elements.cpp \
|
||||
|
||||
@ -154,3 +154,4 @@
|
||||
#include "../../DataTypes/tabledatatype.cpp"
|
||||
#include "../../DataTypes/tableoperator.cpp"
|
||||
#include "../../DataTypes/referenceformat.cpp"
|
||||
#include "../../DataTypes/color_mode.cpp"
|
||||
|
||||
@ -202,6 +202,7 @@
|
||||
<ClInclude Include="..\..\DataTypes\charttimeunit.h" />
|
||||
<ClInclude Include="..\..\DataTypes\clockvalue.h" />
|
||||
<ClInclude Include="..\..\DataTypes\color.h" />
|
||||
<ClInclude Include="..\..\DataTypes\color_mode.h" />
|
||||
<ClInclude Include="..\..\DataTypes\commandtype.h" />
|
||||
<ClInclude Include="..\..\DataTypes\common_attlists.h" />
|
||||
<ClInclude Include="..\..\DataTypes\custom_shape_types_convert.h" />
|
||||
@ -336,6 +337,7 @@
|
||||
<ClCompile Include="..\..\DataTypes\charttimeunit.cpp" />
|
||||
<ClCompile Include="..\..\DataTypes\clockvalue.cpp" />
|
||||
<ClCompile Include="..\..\DataTypes\color.cpp" />
|
||||
<ClCompile Include="..\..\DataTypes\color_mode.cpp" />
|
||||
<ClCompile Include="..\..\DataTypes\commandtype.cpp" />
|
||||
<ClCompile Include="..\..\DataTypes\common_attlists.cpp" />
|
||||
<ClCompile Include="..\..\DataTypes\dategroup.cpp" />
|
||||
|
||||
@ -130,6 +130,7 @@
|
||||
<ClCompile Include="..\..\DataTypes\tabledatatype.cpp" />
|
||||
<ClCompile Include="..\..\DataTypes\tableoperator.cpp" />
|
||||
<ClCompile Include="..\..\DataTypes\referenceformat.cpp" />
|
||||
<ClCompile Include="..\..\DataTypes\color_mode.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\Common\CPColorUtils.h" />
|
||||
@ -274,6 +275,7 @@
|
||||
<ClInclude Include="..\..\DataTypes\writingmode.h" />
|
||||
<ClInclude Include="..\..\DataTypes\xlink.h" />
|
||||
<ClInclude Include="..\..\DataTypes\referenceformat.h" />
|
||||
<ClInclude Include="..\..\DataTypes\color_mode.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\Common\CPColorUtils.cpp" />
|
||||
|
||||
@ -37,7 +37,7 @@
|
||||
namespace cpdoccore {
|
||||
namespace oox {
|
||||
|
||||
oox_bitmap_fill::oox_bitmap_fill() : name_space(L"a"), bStretch(false), bCrop(false), bTile(false), isInternal(true), bGrayscale(false)
|
||||
oox_bitmap_fill::oox_bitmap_fill() : name_space(L"a"), bStretch(false), bCrop(false), bTile(false), isInternal(true)
|
||||
{
|
||||
memset(cropRect, 0, sizeof(double)*4);
|
||||
}
|
||||
@ -190,11 +190,37 @@ void oox_serialize_bitmap_fill(std::wostream & strm, const _oox_fill & val, cons
|
||||
CP_XML_ATTR2(ns_att + L"amt", (int)(*val.image_opacity * 1000));
|
||||
}
|
||||
}
|
||||
if (val.bitmap->bGrayscale)
|
||||
bool bSetLum = false;
|
||||
if (val.bitmap->color_mode)
|
||||
{
|
||||
CP_XML_NODE(ns + L":grayscl");
|
||||
switch (*val.bitmap->color_mode)
|
||||
{
|
||||
case 1: //greyscale
|
||||
{
|
||||
CP_XML_NODE(ns + L":grayscl");
|
||||
}break;
|
||||
case 2: //mono
|
||||
{
|
||||
CP_XML_NODE(ns + L":biLevel")
|
||||
{
|
||||
CP_XML_ATTR2(ns_att + L"thresh", 50000);
|
||||
}
|
||||
}break;
|
||||
case 3: //watermark
|
||||
{
|
||||
bSetLum = true;
|
||||
CP_XML_NODE(ns + L":lum")
|
||||
{
|
||||
CP_XML_ATTR2(L"bright", 70000);
|
||||
CP_XML_ATTR2(L"contrast", -70000);
|
||||
}
|
||||
}break;
|
||||
//case 4: //separating
|
||||
//{
|
||||
//}break;
|
||||
}
|
||||
}
|
||||
if (val.bitmap->luminance || val.bitmap->contrast)
|
||||
if ((val.bitmap->luminance || val.bitmap->contrast) && !bSetLum)
|
||||
{
|
||||
CP_XML_NODE(ns + L":lum")
|
||||
{
|
||||
|
||||
@ -69,12 +69,12 @@ namespace oox {
|
||||
|
||||
double cropRect[4];//0-left, 1 -top, 2- right, 3 - bottom
|
||||
|
||||
_CP_OPT(int) dpi;
|
||||
_CP_OPT(bool) rotate;
|
||||
_CP_OPT(int) dpi;
|
||||
_CP_OPT(bool) rotate;
|
||||
|
||||
bool bGrayscale;
|
||||
_CP_OPT(double) luminance;
|
||||
_CP_OPT(double) contrast;
|
||||
_CP_OPT(int) color_mode;
|
||||
};
|
||||
/////////////////////////////////////////////////////////
|
||||
class oox_hatch_fill;
|
||||
|
||||
@ -720,11 +720,11 @@ 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, sColorMode;
|
||||
_CP_OPT(std::wstring) sTextContent;
|
||||
_CP_OPT(double) dLuminance, dContrast;
|
||||
|
||||
GetProperty(obj.additional_, L"text-content", sTextContent);
|
||||
GetProperty(obj.additional_, L"color-mode", sColorMode);
|
||||
GetProperty(obj.additional_, L"color-mode", drawing.fill.bitmap->color_mode);
|
||||
GetProperty(obj.additional_, L"luminance", drawing.fill.bitmap->luminance);
|
||||
GetProperty(obj.additional_, L"contrast", drawing.fill.bitmap->contrast);
|
||||
|
||||
@ -737,9 +737,6 @@ void pptx_slide_context::Impl::process_image(drawing_object_description& obj, _p
|
||||
std::wstring fileName = odfPacket_ + FILE_SEPARATOR_STR + obj.xlink_href_;
|
||||
process_crop(obj, drawing, fileName);
|
||||
|
||||
if ((sColorMode) && (*sColorMode == L"greyscale"))
|
||||
drawing.fill.bitmap->luminance = true;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
std::wstring ref;/// это ссылка на выходной внешний объект
|
||||
bool isMediaInternal = false;
|
||||
|
||||
@ -652,10 +652,10 @@ 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, sColorMode;
|
||||
_CP_OPT(std::wstring) sTextContent;
|
||||
|
||||
GetProperty(obj.additional_, L"text-content", sTextContent);
|
||||
GetProperty(obj.additional_, L"color-mode", sColorMode);
|
||||
GetProperty(obj.additional_, L"color-mode", drawing.fill.bitmap->color_mode);
|
||||
GetProperty(obj.additional_, L"luminance", drawing.fill.bitmap->luminance);
|
||||
GetProperty(obj.additional_, L"contrast", drawing.fill.bitmap->contrast);
|
||||
|
||||
@ -669,9 +669,6 @@ void xlsx_drawing_context::process_image(drawing_object_description & obj, _xlsx
|
||||
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;
|
||||
|
||||
|
||||
@ -566,8 +566,6 @@ 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_)
|
||||
{
|
||||
|
||||
@ -1298,6 +1298,10 @@ void draw_image::docx_convert(oox::docx_conversion_context & Context)
|
||||
{
|
||||
drawing->fill.bitmap->contrast = properties->common_draw_fill_attlist_.draw_contrast_->get_value();
|
||||
}
|
||||
if (properties->common_draw_fill_attlist_.draw_color_mode_)
|
||||
{
|
||||
drawing->fill.bitmap->color_mode = properties->common_draw_fill_attlist_.draw_color_mode_->get_type();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -150,7 +150,7 @@ void graphic_format_properties::apply_to(std::vector<_property> & properties)
|
||||
|
||||
if (common_draw_fill_attlist_.draw_color_mode_)
|
||||
{
|
||||
properties.push_back(_property(L"color-mode", *common_draw_fill_attlist_.draw_color_mode_));
|
||||
properties.push_back(_property(L"color-mode", (int)common_draw_fill_attlist_.draw_color_mode_->get_type()));
|
||||
}
|
||||
if (common_draw_fill_attlist_.draw_luminance_)
|
||||
{
|
||||
|
||||
@ -1455,7 +1455,7 @@ void odf_drawing_context::set_grayscale()
|
||||
{
|
||||
if (!impl_->current_graphic_properties)return;
|
||||
|
||||
impl_->current_graphic_properties->common_draw_fill_attlist_.draw_color_mode_ = L"greyscale";
|
||||
impl_->current_graphic_properties->common_draw_fill_attlist_.draw_color_mode_ = color_mode(color_mode::greyscale);
|
||||
}
|
||||
void odf_drawing_context::set_white_balance(double red, double green, double blue)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user