mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
fix bug #66798
This commit is contained in:
@ -30,6 +30,7 @@
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
#include <string>
|
||||
|
||||
struct _shape_converter
|
||||
{
|
||||
|
||||
104
OdfFile/DataTypes/referenceformat.cpp
Normal file
104
OdfFile/DataTypes/referenceformat.cpp
Normal file
@ -0,0 +1,104 @@
|
||||
/*
|
||||
* (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 "referenceformat.h"
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <ostream>
|
||||
|
||||
namespace cpdoccore {
|
||||
namespace odf_types {
|
||||
std::wostream & operator << (std::wostream & _Wostream, const reference_format & _Val)
|
||||
{
|
||||
switch(_Val.get_type())
|
||||
{
|
||||
case reference_format::chapter:
|
||||
_Wostream << L"chapter";
|
||||
break;
|
||||
case reference_format::direction:
|
||||
_Wostream << L"direction";
|
||||
break;
|
||||
case reference_format::caption:
|
||||
_Wostream << L"caption";
|
||||
break;
|
||||
case reference_format::category_and_value:
|
||||
_Wostream << L"category-and-value";
|
||||
break;
|
||||
case reference_format::value:
|
||||
_Wostream << L"value";
|
||||
break;
|
||||
case reference_format::number:
|
||||
_Wostream << L"number";
|
||||
break;
|
||||
case reference_format::number_all_superior:
|
||||
_Wostream << L"number-all-superior";
|
||||
break;
|
||||
case reference_format::number_no_superior:
|
||||
_Wostream << L"number-no-superior";
|
||||
break;
|
||||
default:
|
||||
case reference_format::text:
|
||||
_Wostream << L"text";
|
||||
break;
|
||||
}
|
||||
return _Wostream;
|
||||
}
|
||||
|
||||
reference_format reference_format::parse(const std::wstring & Str)
|
||||
{
|
||||
std::wstring tmp = Str;
|
||||
boost::algorithm::to_lower(tmp);
|
||||
|
||||
if (tmp == L"chapter")
|
||||
return reference_format(chapter);
|
||||
else if (tmp == L"direction")
|
||||
return reference_format(direction);
|
||||
else if (tmp == L"text")
|
||||
return reference_format(text);
|
||||
else if (tmp == L"caption")
|
||||
return reference_format(caption);
|
||||
else if (tmp == L"category-and-value")
|
||||
return reference_format(category_and_value);
|
||||
else if (tmp == L"value")
|
||||
return reference_format(value);
|
||||
else if (tmp == L"number")
|
||||
return reference_format(number);
|
||||
else if (tmp == L"number-all-superior")
|
||||
return reference_format(number_all_superior);
|
||||
else if (tmp == L"number-no-superior")
|
||||
return reference_format(number_no_superior);
|
||||
else
|
||||
{
|
||||
return reference_format(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
76
OdfFile/DataTypes/referenceformat.h
Normal file
76
OdfFile/DataTypes/referenceformat.h
Normal file
@ -0,0 +1,76 @@
|
||||
/*
|
||||
* (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 reference_format
|
||||
{
|
||||
public:
|
||||
enum type
|
||||
{
|
||||
chapter,
|
||||
direction,
|
||||
text,
|
||||
caption,
|
||||
category_and_value,
|
||||
value,
|
||||
number,
|
||||
number_all_superior,
|
||||
number_no_superior
|
||||
};
|
||||
|
||||
reference_format() {}
|
||||
reference_format(type _Type) : type_(_Type)
|
||||
{}
|
||||
|
||||
type get_type() const
|
||||
{
|
||||
return type_;
|
||||
};
|
||||
static reference_format parse(const std::wstring & Str);
|
||||
|
||||
private:
|
||||
type type_;
|
||||
|
||||
};
|
||||
std::wostream & operator << (std::wostream & _Wostream, const reference_format& _Val);
|
||||
}
|
||||
APPLY_PARSE_XML_ATTRIBUTES(odf_types::reference_format);
|
||||
|
||||
}
|
||||
@ -40,7 +40,8 @@ SOURCES += \
|
||||
|
||||
core_debug {
|
||||
SOURCES += \
|
||||
../../DataTypes/mathvariant.cpp \
|
||||
../../DataTypes/referenceformat.cpp \
|
||||
../../DataTypes/mathvariant.cpp \
|
||||
../../DataTypes/anchortype.cpp \
|
||||
../../DataTypes/animation_attlists.cpp \
|
||||
../../DataTypes/backgroundcolor.cpp \
|
||||
@ -445,7 +446,8 @@ HEADERS += \
|
||||
../../Common/xml/xmlchar.h \
|
||||
../../Common/xml/xmlelement.h \
|
||||
\
|
||||
../../DataTypes/mathvariant.h \
|
||||
../../DataTypes/referenceformat.h \
|
||||
../../DataTypes/mathvariant.h \
|
||||
../../DataTypes/anchortype.h \
|
||||
../../DataTypes/animation_attlists.h \
|
||||
../../DataTypes/backgroundcolor.h \
|
||||
|
||||
@ -153,3 +153,4 @@
|
||||
#include "../../DataTypes/sparklines.cpp"
|
||||
#include "../../DataTypes/tabledatatype.cpp"
|
||||
#include "../../DataTypes/tableoperator.cpp"
|
||||
#include "../../DataTypes/referenceformat.cpp"
|
||||
|
||||
@ -253,6 +253,7 @@
|
||||
<ClInclude Include="..\..\DataTypes\presetclass.h" />
|
||||
<ClInclude Include="..\..\DataTypes\presetid.h" />
|
||||
<ClInclude Include="..\..\DataTypes\punctuationwrap.h" />
|
||||
<ClInclude Include="..\..\DataTypes\referenceformat.h" />
|
||||
<ClInclude Include="..\..\DataTypes\rotationalign.h" />
|
||||
<ClInclude Include="..\..\DataTypes\runthrough.h" />
|
||||
<ClInclude Include="..\..\DataTypes\scripttype.h" />
|
||||
@ -383,6 +384,7 @@
|
||||
<ClCompile Include="..\..\DataTypes\presetclass.cpp" />
|
||||
<ClCompile Include="..\..\DataTypes\presetid.cpp" />
|
||||
<ClCompile Include="..\..\DataTypes\punctuationwrap.cpp" />
|
||||
<ClCompile Include="..\..\DataTypes\referenceformat.cpp" />
|
||||
<ClCompile Include="..\..\DataTypes\rotationalign.cpp" />
|
||||
<ClCompile Include="..\..\DataTypes\runthrough.cpp" />
|
||||
<ClCompile Include="..\..\DataTypes\scripttype.cpp" />
|
||||
|
||||
@ -126,6 +126,10 @@
|
||||
<ClCompile Include="..\..\DataTypes\writingmode.cpp" />
|
||||
<ClCompile Include="..\..\DataTypes\xlink.cpp" />
|
||||
<ClCompile Include="..\..\DataTypes\animation_attlists.cpp" />
|
||||
<ClCompile Include="..\..\DataTypes\presentationvisibility.cpp" />
|
||||
<ClCompile Include="..\..\DataTypes\tabledatatype.cpp" />
|
||||
<ClCompile Include="..\..\DataTypes\tableoperator.cpp" />
|
||||
<ClCompile Include="..\..\DataTypes\referenceformat.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\Common\CPColorUtils.h" />
|
||||
@ -143,15 +147,133 @@
|
||||
<ClInclude Include="..\..\Common\utils.h" />
|
||||
<ClInclude Include="..\..\Common\writedocelement.h" />
|
||||
<ClInclude Include="..\..\Common\errors.h" />
|
||||
<ClInclude Include="..\..\DataTypes\sparklines.h">
|
||||
<Filter>datatypes odf</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\DataTypes\tabledatatype.h">
|
||||
<Filter>datatypes odf</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\DataTypes\tableoperator.h">
|
||||
<Filter>datatypes odf</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\DataTypes\anchortype.h" />
|
||||
<ClInclude Include="..\..\DataTypes\animation_attlists.h" />
|
||||
<ClInclude Include="..\..\DataTypes\backgroundcolor.h" />
|
||||
<ClInclude Include="..\..\DataTypes\bibliography.h" />
|
||||
<ClInclude Include="..\..\DataTypes\bool.h" />
|
||||
<ClInclude Include="..\..\DataTypes\bordermodel.h" />
|
||||
<ClInclude Include="..\..\DataTypes\borderstyle.h" />
|
||||
<ClInclude Include="..\..\DataTypes\borderwidths.h" />
|
||||
<ClInclude Include="..\..\DataTypes\calcext_type.h" />
|
||||
<ClInclude Include="..\..\DataTypes\chartclass.h" />
|
||||
<ClInclude Include="..\..\DataTypes\chartdatalabelnumber.h" />
|
||||
<ClInclude Include="..\..\DataTypes\charterrorcategory.h" />
|
||||
<ClInclude Include="..\..\DataTypes\chartinterpolation.h" />
|
||||
<ClInclude Include="..\..\DataTypes\chartlabelarrangement.h" />
|
||||
<ClInclude Include="..\..\DataTypes\chartlabelposition.h" />
|
||||
<ClInclude Include="..\..\DataTypes\chartregressiontype.h" />
|
||||
<ClInclude Include="..\..\DataTypes\chartseriessource.h" />
|
||||
<ClInclude Include="..\..\DataTypes\chartsolidtype.h" />
|
||||
<ClInclude Include="..\..\DataTypes\chartsymbol.h" />
|
||||
<ClInclude Include="..\..\DataTypes\charttimeunit.h" />
|
||||
<ClInclude Include="..\..\DataTypes\clockvalue.h" />
|
||||
<ClInclude Include="..\..\DataTypes\color.h" />
|
||||
<ClInclude Include="..\..\DataTypes\commandtype.h" />
|
||||
<ClInclude Include="..\..\DataTypes\common_attlists.h" />
|
||||
<ClInclude Include="..\..\DataTypes\custom_shape_types_convert.h" />
|
||||
<ClInclude Include="..\..\DataTypes\dategroup.h" />
|
||||
<ClInclude Include="..\..\DataTypes\direction.h" />
|
||||
<ClInclude Include="..\..\DataTypes\drawangle.h" />
|
||||
<ClInclude Include="..\..\DataTypes\drawfill.h" />
|
||||
<ClInclude Include="..\..\DataTypes\dropcaplength.h" />
|
||||
<ClInclude Include="..\..\DataTypes\errors.h" />
|
||||
<ClInclude Include="..\..\DataTypes\fillimagerefpoint.h" />
|
||||
<ClInclude Include="..\..\DataTypes\fobreak.h" />
|
||||
<ClInclude Include="..\..\DataTypes\fontfamilygeneric.h" />
|
||||
<ClInclude Include="..\..\DataTypes\fontpitch.h" />
|
||||
<ClInclude Include="..\..\DataTypes\fontrelief.h" />
|
||||
<ClInclude Include="..\..\DataTypes\fontsize.h" />
|
||||
<ClInclude Include="..\..\DataTypes\fontstretch.h" />
|
||||
<ClInclude Include="..\..\DataTypes\fontstyle.h" />
|
||||
<ClInclude Include="..\..\DataTypes\fontvariant.h" />
|
||||
<ClInclude Include="..\..\DataTypes\fontweight.h" />
|
||||
<ClInclude Include="..\..\DataTypes\gradientstyle.h" />
|
||||
<ClInclude Include="..\..\DataTypes\grandtotal.h" />
|
||||
<ClInclude Include="..\..\DataTypes\hatchstyle.h" />
|
||||
<ClInclude Include="..\..\DataTypes\hyphenationkeep.h" />
|
||||
<ClInclude Include="..\..\DataTypes\hyphenationladdercount.h" />
|
||||
<ClInclude Include="..\..\DataTypes\iconset_type.h" />
|
||||
<ClInclude Include="..\..\DataTypes\keeptogether.h" />
|
||||
<ClInclude Include="..\..\DataTypes\layoutgridmode.h" />
|
||||
<ClInclude Include="..\..\DataTypes\length.h" />
|
||||
<ClInclude Include="..\..\DataTypes\lengthorpercent.h" />
|
||||
<ClInclude Include="..\..\DataTypes\letterspacing.h" />
|
||||
<ClInclude Include="..\..\DataTypes\linebreak.h" />
|
||||
<ClInclude Include="..\..\DataTypes\linemode.h" />
|
||||
<ClInclude Include="..\..\DataTypes\linestyle.h" />
|
||||
<ClInclude Include="..\..\DataTypes\linetype.h" />
|
||||
<ClInclude Include="..\..\DataTypes\linewidth.h" />
|
||||
<ClInclude Include="..\..\DataTypes\markerstyle.h" />
|
||||
<ClInclude Include="..\..\DataTypes\mathvariant.h" />
|
||||
<ClInclude Include="..\..\DataTypes\membertype.h" />
|
||||
<ClInclude Include="..\..\DataTypes\messagetype.h" />
|
||||
<ClInclude Include="..\..\DataTypes\noteclass.h" />
|
||||
<ClInclude Include="..\..\DataTypes\odfattributes.h" />
|
||||
<ClInclude Include="..\..\DataTypes\officevaluetype.h" />
|
||||
<ClInclude Include="..\..\DataTypes\pageusage.h" />
|
||||
<ClInclude Include="..\..\DataTypes\percent.h" />
|
||||
<ClInclude Include="..\..\DataTypes\percentorscale.h" />
|
||||
<ClInclude Include="..\..\DataTypes\presentationclass.h" />
|
||||
<ClInclude Include="..\..\DataTypes\presentationnodetype.h" />
|
||||
<ClInclude Include="..\..\DataTypes\presentationvisibility.h" />
|
||||
<ClInclude Include="..\..\DataTypes\presetclass.h" />
|
||||
<ClInclude Include="..\..\DataTypes\presetid.h" />
|
||||
<ClInclude Include="..\..\DataTypes\punctuationwrap.h" />
|
||||
<ClInclude Include="..\..\DataTypes\rotationalign.h" />
|
||||
<ClInclude Include="..\..\DataTypes\runthrough.h" />
|
||||
<ClInclude Include="..\..\DataTypes\scripttype.h" />
|
||||
<ClInclude Include="..\..\DataTypes\shadowtype.h" />
|
||||
<ClInclude Include="..\..\DataTypes\smil_additive.h" />
|
||||
<ClInclude Include="..\..\DataTypes\smil_attributename.h" />
|
||||
<ClInclude Include="..\..\DataTypes\smil_fill.h" />
|
||||
<ClInclude Include="..\..\DataTypes\smil_keytimes.h" />
|
||||
<ClInclude Include="..\..\DataTypes\smil_transitiontype.h" />
|
||||
<ClInclude Include="..\..\DataTypes\smil_values.h" />
|
||||
<ClInclude Include="..\..\DataTypes\sparklines.h" />
|
||||
<ClInclude Include="..\..\DataTypes\stylecellprotect.h" />
|
||||
<ClInclude Include="..\..\DataTypes\stylefamily.h" />
|
||||
<ClInclude Include="..\..\DataTypes\stylehorizontalpos.h" />
|
||||
<ClInclude Include="..\..\DataTypes\stylehorizontalrel.h" />
|
||||
<ClInclude Include="..\..\DataTypes\styleleadercolor.h" />
|
||||
<ClInclude Include="..\..\DataTypes\stylenumformat.h" />
|
||||
<ClInclude Include="..\..\DataTypes\styleposition.h" />
|
||||
<ClInclude Include="..\..\DataTypes\styleprint.h" />
|
||||
<ClInclude Include="..\..\DataTypes\stylerepeat.h" />
|
||||
<ClInclude Include="..\..\DataTypes\styletype.h" />
|
||||
<ClInclude Include="..\..\DataTypes\styleverticalpos.h" />
|
||||
<ClInclude Include="..\..\DataTypes\styleverticalrel.h" />
|
||||
<ClInclude Include="..\..\DataTypes\stylewrap.h" />
|
||||
<ClInclude Include="..\..\DataTypes\stylewrapcontourmode.h" />
|
||||
<ClInclude Include="..\..\DataTypes\style_ref.h" />
|
||||
<ClInclude Include="..\..\DataTypes\svg_type.h" />
|
||||
<ClInclude Include="..\..\DataTypes\tablealign.h" />
|
||||
<ClInclude Include="..\..\DataTypes\tablecentering.h" />
|
||||
<ClInclude Include="..\..\DataTypes\tabledatatype.h" />
|
||||
<ClInclude Include="..\..\DataTypes\tablefunction.h" />
|
||||
<ClInclude Include="..\..\DataTypes\tablemode.h" />
|
||||
<ClInclude Include="..\..\DataTypes\tableoperator.h" />
|
||||
<ClInclude Include="..\..\DataTypes\tableorder.h" />
|
||||
<ClInclude Include="..\..\DataTypes\tableorientation.h" />
|
||||
<ClInclude Include="..\..\DataTypes\tabletype.h" />
|
||||
<ClInclude Include="..\..\DataTypes\tablevisibility.h" />
|
||||
<ClInclude Include="..\..\DataTypes\targetframename.h" />
|
||||
<ClInclude Include="..\..\DataTypes\textalign.h" />
|
||||
<ClInclude Include="..\..\DataTypes\textalignsource.h" />
|
||||
<ClInclude Include="..\..\DataTypes\textautospace.h" />
|
||||
<ClInclude Include="..\..\DataTypes\textcombine.h" />
|
||||
<ClInclude Include="..\..\DataTypes\textdisplay.h" />
|
||||
<ClInclude Include="..\..\DataTypes\textemphasize.h" />
|
||||
<ClInclude Include="..\..\DataTypes\textposition.h" />
|
||||
<ClInclude Include="..\..\DataTypes\textrotationscale.h" />
|
||||
<ClInclude Include="..\..\DataTypes\texttransform.h" />
|
||||
<ClInclude Include="..\..\DataTypes\timeperiod.h" />
|
||||
<ClInclude Include="..\..\DataTypes\underlinecolor.h" />
|
||||
<ClInclude Include="..\..\DataTypes\verticalalign.h" />
|
||||
<ClInclude Include="..\..\DataTypes\wrapoption.h" />
|
||||
<ClInclude Include="..\..\DataTypes\writingmode.h" />
|
||||
<ClInclude Include="..\..\DataTypes\xlink.h" />
|
||||
<ClInclude Include="..\..\DataTypes\referenceformat.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\Common\CPColorUtils.cpp" />
|
||||
@ -489,11 +611,5 @@
|
||||
<ClCompile Include="..\..\DataTypes\sparklines.cpp">
|
||||
<Filter>datatypes odf</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\DataTypes\tabledatatype.cpp">
|
||||
<Filter>datatypes odf</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\DataTypes\tableoperator.cpp">
|
||||
<Filter>datatypes odf</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@ -91,6 +91,31 @@ void paragraph_content_element::docx_serialize_field(const std::wstring & field_
|
||||
strm << L"<w:r><w:fldChar w:fldCharType=\"end\"/></w:r>";
|
||||
}
|
||||
}
|
||||
|
||||
void paragraph_content_element::docx_serialize_field(const std::wstring& field_name, office_element_ptr_array& content,
|
||||
oox::docx_conversion_context& Context, bool bLock)
|
||||
{
|
||||
std::wostream& strm = Context.output_stream();
|
||||
Context.finish_run();
|
||||
|
||||
if (false == field_name.empty())
|
||||
{
|
||||
strm << L"<w:r><w:fldChar w:fldCharType=\"begin\"";
|
||||
if (bLock)
|
||||
{
|
||||
strm << L" w:fldLock=\"1\"";
|
||||
}
|
||||
strm << L"/></w:r>";
|
||||
strm << L"<w:r><w:instrText>" << field_name << L"</w:instrText></w:r><w:r><w:fldChar w:fldCharType=\"separate\"/></w:r>";
|
||||
}
|
||||
|
||||
docx_serialize_run(content, Context);
|
||||
|
||||
if (false == field_name.empty())
|
||||
{
|
||||
strm << L"<w:r><w:fldChar w:fldCharType=\"end\"/></w:r>";
|
||||
}
|
||||
}
|
||||
void paragraph_content_element::docx_serialize_sdt_placeholder(const std::wstring & name, office_element_ptr & text, oox::docx_conversion_context & Context)
|
||||
{
|
||||
std::wostream & strm = Context.output_stream();
|
||||
@ -105,7 +130,20 @@ void paragraph_content_element::docx_serialize_sdt_placeholder(const std::wstrin
|
||||
|
||||
strm << L"</w:sdtContent></w:sdt>";
|
||||
}
|
||||
void paragraph_content_element::docx_serialize_sdt_placeholder(const std::wstring& name, office_element_ptr_array& content, oox::docx_conversion_context& Context)
|
||||
{
|
||||
std::wostream& strm = Context.output_stream();
|
||||
Context.finish_run();
|
||||
|
||||
strm << L"<w:sdt><w:sdtPr><w:alias w:val=\"";
|
||||
strm << name;
|
||||
strm << L"\"/><w:temporary/>";
|
||||
strm << L"<w:showingPlcHdr/><w:text/></w:sdtPr><w:sdtContent>";
|
||||
|
||||
docx_serialize_run(content, Context);
|
||||
|
||||
strm << L"</w:sdtContent></w:sdt>";
|
||||
}
|
||||
void paragraph_content_element::docx_serialize_run(office_element_ptr & text, oox::docx_conversion_context & Context)
|
||||
{
|
||||
Context.add_new_run();
|
||||
@ -115,6 +153,13 @@ void paragraph_content_element::docx_serialize_run(office_element_ptr & text, oo
|
||||
}
|
||||
Context.finish_run();
|
||||
}
|
||||
void paragraph_content_element::docx_serialize_run(office_element_ptr_array& content, oox::docx_conversion_context& Context)
|
||||
{
|
||||
for (size_t i = 0; i < content.size(); ++i)
|
||||
{
|
||||
docx_serialize_run(content[i], Context);
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------
|
||||
const wchar_t * text::ns = L"";
|
||||
@ -396,7 +441,26 @@ void bookmark_ref::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
}
|
||||
void bookmark_ref::add_text(const std::wstring & Text)
|
||||
{
|
||||
content_ = Text;
|
||||
office_element_ptr elm = text::create(Text);
|
||||
content_.push_back( elm );
|
||||
}
|
||||
void bookmark_ref::add_child_element(xml::sax* Reader, const std::wstring& Ns, const std::wstring& Name)
|
||||
{
|
||||
CP_CREATE_ELEMENT(content_);
|
||||
}
|
||||
void bookmark_ref::docx_convert(oox::docx_conversion_context& Context)
|
||||
{
|
||||
std::wstring field_name = (ref_name_ ? L"REF " + *ref_name_ : L"REF") + L" \\h";
|
||||
|
||||
if (reference_format_)
|
||||
{
|
||||
switch (reference_format_->get_type())
|
||||
{
|
||||
case reference_format::direction: field_name += L" \\p"; break;
|
||||
case reference_format::number: field_name += L" \\n"; break;
|
||||
}
|
||||
}
|
||||
docx_serialize_field(field_name, content_, Context);
|
||||
}
|
||||
// text:reference-ref
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -1088,30 +1152,32 @@ void chapter::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
const wchar_t * text_placeholder::ns = L"text";
|
||||
const wchar_t * text_placeholder::name = L"placeholder";
|
||||
|
||||
std::wostream & text_placeholder::text_to_stream(std::wostream & _Wostream, bool bXmlEncode) const
|
||||
{
|
||||
CP_SERIALIZE_TEXT(text_, bXmlEncode);
|
||||
return _Wostream;
|
||||
}
|
||||
|
||||
void text_placeholder::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
{
|
||||
}
|
||||
std::wostream & text_placeholder::text_to_stream(std::wostream & _Wostream, bool bXmlEncode) const
|
||||
{
|
||||
CP_SERIALIZE_TEXT(content_, bXmlEncode);
|
||||
return _Wostream;
|
||||
}
|
||||
void text_placeholder::add_child_element(xml::sax* Reader, const std::wstring& Ns, const std::wstring& Name)
|
||||
{
|
||||
CP_CREATE_ELEMENT(content_);
|
||||
}
|
||||
void text_placeholder::add_text(const std::wstring & Text)
|
||||
{
|
||||
text_ = text::create(Text) ;
|
||||
office_element_ptr text = text::create(Text) ;
|
||||
content_.push_back(text);
|
||||
}
|
||||
|
||||
void text_placeholder::docx_convert(oox::docx_conversion_context & Context)
|
||||
{
|
||||
docx_serialize_sdt_placeholder(L"Click placeholder and overwrite", text_, Context);
|
||||
docx_serialize_sdt_placeholder(L"Click placeholder and overwrite", content_, Context);
|
||||
}
|
||||
|
||||
void text_placeholder::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
{
|
||||
if (text_)
|
||||
for (size_t i = 0; i < content_.size(); ++i)
|
||||
{
|
||||
text_->pptx_convert(Context);
|
||||
content_[i]->pptx_convert(Context);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1424,18 +1490,18 @@ void sequence::add_attributes( const xml::attributes_wc_ptr & Attributes )
|
||||
}
|
||||
std::wostream & sequence::text_to_stream(std::wostream & _Wostream, bool bXmlEncode) const
|
||||
{
|
||||
CP_SERIALIZE_TEXT(text_, bXmlEncode);
|
||||
CP_SERIALIZE_TEXT(content_, bXmlEncode);
|
||||
return _Wostream;
|
||||
}
|
||||
void sequence::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
|
||||
{
|
||||
CP_CREATE_ELEMENT(text_);
|
||||
CP_CREATE_ELEMENT(content_);
|
||||
}
|
||||
|
||||
void sequence::add_text(const std::wstring & Text)
|
||||
{
|
||||
office_element_ptr elm = text::create(Text) ;
|
||||
text_.push_back( elm );
|
||||
content_.push_back( elm );
|
||||
}
|
||||
|
||||
void sequence::docx_convert(oox::docx_conversion_context & Context)
|
||||
@ -1485,9 +1551,9 @@ void sequence::docx_convert(oox::docx_conversion_context & Context)
|
||||
Context.start_bookmark(name);
|
||||
Context.output_stream() << L"<w:fldSimple w:instr=\" SEQ " << XmlUtils::EncodeXmlString(sequence) << L" \\* " << num_format << L" \">";
|
||||
Context.add_new_run();
|
||||
for (size_t i = 0; i < text_.size(); i++)
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
{
|
||||
text_[i]->docx_convert(Context);
|
||||
content_[i]->docx_convert(Context);
|
||||
}
|
||||
Context.finish_run();
|
||||
|
||||
@ -1502,9 +1568,9 @@ void sequence::docx_convert(oox::docx_conversion_context & Context)
|
||||
}
|
||||
void sequence::pptx_convert(oox::pptx_conversion_context & Context)
|
||||
{
|
||||
for (size_t i = 0; i < text_.size(); i++)
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
{
|
||||
text_[i]->pptx_convert(Context);
|
||||
content_[i]->pptx_convert(Context);
|
||||
}
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@ -42,6 +42,7 @@
|
||||
#include "../../DataTypes/noteclass.h"
|
||||
#include "../../DataTypes/bool.h"
|
||||
#include "../../DataTypes/bibliography.h"
|
||||
#include "../../DataTypes/referenceformat.h"
|
||||
|
||||
#include "../../Reader/Converter/docx_conversion_context.h"
|
||||
|
||||
@ -67,9 +68,14 @@ public:
|
||||
virtual void xlsx_convert(oox::xlsx_conversion_context & Context){}
|
||||
virtual void pptx_convert(oox::pptx_conversion_context & Context){}
|
||||
|
||||
virtual void docx_serialize_sdt_placeholder(const std::wstring & name, office_element_ptr & text, oox::docx_conversion_context & Context);
|
||||
virtual void docx_serialize_field(const std::wstring & field_name, office_element_ptr & text, oox::docx_conversion_context & Context, bool bLock = false);
|
||||
virtual void docx_serialize_run(office_element_ptr & text, oox::docx_conversion_context & Context);
|
||||
virtual void docx_serialize_sdt_placeholder(const std::wstring& name, office_element_ptr_array& content, oox::docx_conversion_context& Context);
|
||||
virtual void docx_serialize_sdt_placeholder(const std::wstring & name, office_element_ptr & text, oox::docx_conversion_context & Context);
|
||||
|
||||
virtual void docx_serialize_field(const std::wstring & field_name, office_element_ptr & content, oox::docx_conversion_context & Context, bool bLock = false);
|
||||
virtual void docx_serialize_field(const std::wstring& field_name, office_element_ptr_array& text, oox::docx_conversion_context& Context, bool bLock = false);
|
||||
|
||||
virtual void docx_serialize_run(office_element_ptr & text, oox::docx_conversion_context & Context);
|
||||
virtual void docx_serialize_run(office_element_ptr_array& content, oox::docx_conversion_context& Context);
|
||||
|
||||
virtual void xlsx_serialize(std::wostream & _Wostream, oox::xlsx_conversion_context & Context)
|
||||
{
|
||||
@ -245,7 +251,6 @@ private:
|
||||
virtual void add_text(const std::wstring & Text) {}
|
||||
|
||||
};
|
||||
|
||||
CP_REGISTER_OFFICE_ELEMENT2(bookmark);
|
||||
//-------------------------------------------------------------------------------------------------------------------
|
||||
// text:bookmark-start
|
||||
@ -314,12 +319,15 @@ public:
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
CPDOCCORE_OFFICE_DOCUMENT_IMPL_NAME_FUNCS_;
|
||||
|
||||
_CP_OPT(std::wstring) ref_name_;
|
||||
_CP_OPT(std::wstring) reference_format_;
|
||||
std::wstring content_;
|
||||
virtual void docx_convert(oox::docx_conversion_context& Context);
|
||||
|
||||
_CP_OPT(std::wstring) ref_name_;
|
||||
_CP_OPT(odf_types::reference_format) reference_format_;
|
||||
|
||||
office_element_ptr_array content_;
|
||||
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_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(bookmark_ref);
|
||||
@ -337,9 +345,10 @@ public:
|
||||
CPDOCCORE_DEFINE_VISITABLE();
|
||||
CPDOCCORE_OFFICE_DOCUMENT_IMPL_NAME_FUNCS_;
|
||||
|
||||
_CP_OPT(std::wstring) ref_name_;
|
||||
_CP_OPT(std::wstring) reference_format_;
|
||||
std::wstring content_;
|
||||
_CP_OPT(std::wstring) ref_name_;
|
||||
_CP_OPT(odf_types::reference_format) reference_format_;
|
||||
|
||||
std::wstring content_;
|
||||
|
||||
private:
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
@ -699,10 +708,10 @@ public:
|
||||
|
||||
_CP_OPT(std::wstring) text_description_;
|
||||
_CP_OPT(std::wstring) text_placeholder_type_;
|
||||
office_element_ptr text_;
|
||||
office_element_ptr_array content_;
|
||||
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_child_element(xml::sax* Reader, const std::wstring& Ns, const std::wstring& Name);
|
||||
virtual void add_text(const std::wstring & Text);
|
||||
};
|
||||
|
||||
@ -1007,7 +1016,7 @@ public:
|
||||
_CP_OPT(std::wstring) ref_name_;
|
||||
|
||||
_CP_OPT(std::wstring) template_;
|
||||
office_element_ptr_array text_;
|
||||
office_element_ptr_array content_;
|
||||
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);
|
||||
@ -1086,10 +1095,10 @@ public:
|
||||
|
||||
void docx_convert(oox::docx_conversion_context & Context);
|
||||
|
||||
_CP_OPT(std::wstring) reference_format_;//caption, category-and-value, value, chapter, direction, page, text, number, number-all-superior, number-no-superior
|
||||
_CP_OPT(std::wstring) ref_name_;
|
||||
_CP_OPT(odf_types::reference_format) reference_format_;
|
||||
_CP_OPT(std::wstring) ref_name_;
|
||||
|
||||
office_element_ptr text_;
|
||||
office_element_ptr text_;
|
||||
|
||||
private:
|
||||
virtual void add_attributes( const xml::attributes_wc_ptr & Attributes );
|
||||
|
||||
@ -602,6 +602,18 @@ bool odf_text_context::start_field(int type, const std::wstring& value, const st
|
||||
{
|
||||
create_element(L"text", L"text-input", elm, odf_context_);
|
||||
}break;
|
||||
case fieldRef:
|
||||
{
|
||||
create_element(L"text", L"bookmark-ref", elm, odf_context_);
|
||||
text_bookmark_ref* ref = dynamic_cast<text_bookmark_ref*>(elm.get());
|
||||
if (ref)
|
||||
{
|
||||
if (false == value.empty()) ref->ref_name_ = value;
|
||||
|
||||
ref->reference_format_ = odf_types::reference_format::parse(format.empty() ? L"text" : format);
|
||||
|
||||
}
|
||||
}break;
|
||||
}
|
||||
|
||||
if (elm)
|
||||
|
||||
@ -58,6 +58,7 @@ namespace odf_writer
|
||||
fieldDropDown,
|
||||
fieldDate,
|
||||
fieldTime,
|
||||
fieldRef,
|
||||
|
||||
fieldBibliography = 0xff + 1,
|
||||
fieldIndex,
|
||||
|
||||
@ -767,6 +767,33 @@ void odt_conversion_context::set_field_instr()
|
||||
if (instr.length() > 9)
|
||||
current_fields.back().value = instr.substr(9, instr.length() - 5);
|
||||
}
|
||||
res1 = instr.find(L"REF");
|
||||
if (std::wstring::npos != res1 && current_fields.back().type == 0)
|
||||
{
|
||||
current_fields.back().type = fieldRef;
|
||||
std::map<std::wstring, std::wstring> options = parse_instr_options(instr.substr(4));
|
||||
|
||||
for (std::map<std::wstring, std::wstring>::iterator it = options.begin(); it != options.end(); ++it)
|
||||
{
|
||||
if (it->first == L" ")//field-argument
|
||||
{
|
||||
current_fields.back().value = it->second;
|
||||
boost::algorithm::trim(current_fields.back().value);
|
||||
}
|
||||
else if (it->first == L"h")
|
||||
{
|
||||
current_fields.back().bHyperlinks = true;
|
||||
}
|
||||
else if (it->first == L"p")
|
||||
{
|
||||
current_fields.back().format = L"direction";
|
||||
}
|
||||
else if (it->first == L"r" || it->first == L"n")
|
||||
{
|
||||
current_fields.back().format = L"number";
|
||||
}
|
||||
}
|
||||
}
|
||||
res1 = instr.find(L"PAGE");
|
||||
if (std::wstring::npos != res1 && current_fields.back().type == 0)
|
||||
{
|
||||
|
||||
@ -188,6 +188,42 @@ void text_bookmark_end::serialize(std::wostream & _Wostream)
|
||||
}
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------------
|
||||
// text:bookmark-ref
|
||||
//----------------------------------------------------------------------------------
|
||||
const wchar_t* text_bookmark_ref::ns = L"text";
|
||||
const wchar_t* text_bookmark_ref::name = L"bookmark-ref";
|
||||
|
||||
void text_bookmark_ref::create_child_element(const std::wstring& Ns, const std::wstring& Name)
|
||||
{
|
||||
CP_CREATE_ELEMENT(content_);
|
||||
}
|
||||
void text_bookmark_ref::add_child_element(const office_element_ptr& child_element)
|
||||
{
|
||||
content_.push_back(child_element);
|
||||
}
|
||||
void text_bookmark_ref::add_text(const std::wstring& Text)
|
||||
{
|
||||
office_element_ptr elm = text_text::create(Text);
|
||||
content_.push_back(elm);
|
||||
}
|
||||
void text_bookmark_ref::serialize(std::wostream& _Wostream)
|
||||
{
|
||||
CP_XML_WRITER(_Wostream)
|
||||
{
|
||||
CP_XML_NODE_SIMPLE()
|
||||
{
|
||||
CP_XML_ATTR_OPT_ENCODE_STRING(L"text:ref-name", ref_name_);
|
||||
CP_XML_ATTR_OPT(L"text:reference-format", reference_format_);
|
||||
|
||||
for (size_t i = 0; i < content_.size(); i++)
|
||||
{
|
||||
content_[i]->serialize(CP_XML_STREAM());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// text:reference-mark
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
@ -42,6 +42,7 @@
|
||||
#include "../../DataTypes/targetframename.h"
|
||||
#include "../../DataTypes/noteclass.h"
|
||||
#include "../../DataTypes/bibliography.h"
|
||||
#include "../../DataTypes/referenceformat.h"
|
||||
|
||||
#include "../../DataTypes/common_attlists.h"
|
||||
|
||||
@ -211,7 +212,33 @@ public:
|
||||
std::wstring text_name_;
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(text_bookmark_end);
|
||||
//-------------------------------------------------------------------------------------------------------------------
|
||||
// text:bookmark-ref
|
||||
//-------------------------------------------------------------------------------------------------------------------
|
||||
class text_bookmark_ref : public office_element_impl<text_bookmark_ref>
|
||||
{
|
||||
public:
|
||||
static const wchar_t* ns;
|
||||
static const wchar_t* name;
|
||||
|
||||
static const ElementType type = typeTextBookmarkRef;
|
||||
|
||||
text_bookmark_ref() {};
|
||||
text_bookmark_ref(const std::wstring& Name) : ref_name_(Name) {};
|
||||
|
||||
virtual void create_child_element(const std::wstring& Ns, const std::wstring& Name);
|
||||
virtual void add_child_element(const office_element_ptr& child_element);
|
||||
virtual void add_text(const std::wstring& Text);
|
||||
|
||||
virtual void serialize(std::wostream& _Wostream);
|
||||
|
||||
_CP_OPT(std::wstring) ref_name_;
|
||||
_CP_OPT(odf_types::reference_format) reference_format_;
|
||||
|
||||
_CP_OPT(std::wstring) text_;
|
||||
office_element_ptr_array content_;
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(text_bookmark_ref);
|
||||
// text:reference-mark
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
class text_reference_mark : public office_element_impl<text_reference_mark>
|
||||
@ -920,18 +947,17 @@ public:
|
||||
static const wchar_t * ns;
|
||||
static const wchar_t * name;
|
||||
|
||||
static const ElementType type = typeTextSequenceRef;
|
||||
|
||||
static const ElementType type = typeTextSequenceRef;
|
||||
|
||||
virtual void create_child_element (const std::wstring & Ns, const std::wstring & Name){}
|
||||
virtual void add_child_element ( const office_element_ptr & child_element){}
|
||||
|
||||
virtual void serialize(std::wostream & _Wostream);
|
||||
|
||||
_CP_OPT(std::wstring) reference_format_;//caption, category-and-value, value, chapter, direction, page, text, number, number-all-superior, number-no-superior
|
||||
_CP_OPT(std::wstring) ref_name_;
|
||||
_CP_OPT(odf_types::reference_format) reference_format_;
|
||||
_CP_OPT(std::wstring) ref_name_;
|
||||
|
||||
std::wstring content_;
|
||||
std::wstring content_;
|
||||
};
|
||||
CP_REGISTER_OFFICE_ELEMENT2(text_sequence_ref);
|
||||
//-------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user