Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
onlyoffice_core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
onlyoffice_core
Commits
82dc7ab4
Commit
82dc7ab4
authored
Dec 09, 2016
by
ElenaSubbotina
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
OdfFormatReader - global settings for documents
parent
51c8ab54
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
305 additions
and
75 deletions
+305
-75
ASCOfficeOdfFile/src/docx/xlsx_table_state.cpp
ASCOfficeOdfFile/src/docx/xlsx_table_state.cpp
+15
-1
ASCOfficeOdfFile/src/docx/xlsx_utils.cpp
ASCOfficeOdfFile/src/docx/xlsx_utils.cpp
+7
-7
ASCOfficeOdfFile/src/docx/xlsxconversioncontext.cpp
ASCOfficeOdfFile/src/docx/xlsxconversioncontext.cpp
+56
-3
ASCOfficeOdfFile/src/docx/xlsxconversioncontext.h
ASCOfficeOdfFile/src/docx/xlsxconversioncontext.h
+4
-2
ASCOfficeOdfFile/src/odf/chart_build_oox.cpp
ASCOfficeOdfFile/src/odf/chart_build_oox.cpp
+10
-11
ASCOfficeOdfFile/src/odf/chart_build_oox.h
ASCOfficeOdfFile/src/odf/chart_build_oox.h
+1
-1
ASCOfficeOdfFile/src/odf/odf_document_impl.cpp
ASCOfficeOdfFile/src/odf/odf_document_impl.cpp
+32
-1
ASCOfficeOdfFile/src/odf/odfcontext.h
ASCOfficeOdfFile/src/odf/odfcontext.h
+8
-9
ASCOfficeOdfFile/src/odf/office_settings.cpp
ASCOfficeOdfFile/src/odf/office_settings.cpp
+2
-0
ASCOfficeOdfFile/src/odf/office_settings.h
ASCOfficeOdfFile/src/odf/office_settings.h
+8
-15
ASCOfficeOdfFile/src/odf/search_table_cell.cpp
ASCOfficeOdfFile/src/odf/search_table_cell.cpp
+8
-8
ASCOfficeOdfFile/src/odf/styles_lite_container.cpp
ASCOfficeOdfFile/src/odf/styles_lite_container.cpp
+129
-15
ASCOfficeOdfFile/src/odf/styles_lite_container.h
ASCOfficeOdfFile/src/odf/styles_lite_container.h
+25
-2
No files found.
ASCOfficeOdfFile/src/docx/xlsx_table_state.cpp
View file @
82dc7ab4
...
...
@@ -344,6 +344,7 @@ double charsToSize(unsigned int charsCount, double maxDigitSize)
void
xlsx_table_state
::
serialize_table_format
(
std
::
wostream
&
_Wostream
)
{
odf_reader
::
odf_read_context
&
odfContext
=
context_
->
root
()
->
odf_context
();
CP_XML_WRITER
(
_Wostream
)
{
odf_reader
::
style_table_properties
*
table_prop
=
NULL
;
...
...
@@ -367,9 +368,22 @@ void xlsx_table_state::serialize_table_format(std::wostream & _Wostream)
//<pageSetUpPr fitToPage="true"/>
}
}
//<dimension ref="B1:T65536"/>
int
columns
=
(
std
::
max
)(
current_table_column_
,
(
int
)
columns_count_
);
int
rows
=
(
std
::
max
)(
current_table_row_
,
1
);
if
(
columns
<
1024
&&
columns
>
1
&&
rows
<
1024
&&
rows
>
1
)
{
CP_XML_NODE
(
L"dimension"
)
{
std
::
wstring
ref2
=
getCellAddress
(
current_table_column_
,
current_table_row_
);
CP_XML_ATTR
(
L"ref"
,
L"A1:"
+
ref2
);
}
}
CP_XML_NODE
(
L"sheetView"
)
{
if
(
odfContext
.
Settings
().
get_views_count
()
>
0
)
CP_XML_ATTR
(
L"workbookViewId"
,
0
);
// -showGridLines
// -showRowColHeaders
// -rightToLeft
...
...
ASCOfficeOdfFile/src/docx/xlsx_utils.cpp
View file @
82dc7ab4
...
...
@@ -53,8 +53,8 @@ std::wstring getColAddress(size_t col)
if
(
r0
>
0
)
{
const
std
::
wstring
rest
=
getColAddress
(
col
-
r
*
r0
);
const
std
::
wstring
res
=
getColAddress
(
r0
-
1
)
+
rest
;
const
std
::
wstring
rest
=
getColAddress
(
col
-
r
*
r0
);
const
std
::
wstring
res
=
getColAddress
(
r0
-
1
)
+
rest
;
return
res
;
}
else
...
...
@@ -65,12 +65,12 @@ std::wstring getColAddress(size_t col)
std
::
wstring
getRowAddress
(
size_t
row
)
{
return
boost
::
lexical_cast
<
std
::
wstring
>
(
row
+
1
);
return
boost
::
lexical_cast
<
std
::
wstring
>
(
row
+
1
);
}
std
::
wstring
getCellAddress
(
size_t
col
,
size_t
row
)
{
return
getColAddress
(
col
)
+
getRowAddress
(
row
);
return
getColAddress
(
col
)
+
getRowAddress
(
row
);
}
//_ASSERTE(getColAddressInv(L"A") == 0);
...
...
@@ -148,11 +148,11 @@ void splitCellAddress(const std::wstring & a_, std::wstring & col, std::wstring
//_ASSERTE(rowS == 999);
void
getCellAddressInv
(
const
std
::
wstring
&
a_
,
size_t
&
col
,
size_t
&
row
)
{
std
::
wstring
colStr
=
L""
,
rowStr
=
L""
;
std
::
wstring
colStr
=
L""
,
rowStr
=
L""
;
splitCellAddress
(
a_
,
colStr
,
rowStr
);
col
=
getColAddressInv
(
colStr
);
row
=
getRowAdderssInv
(
rowStr
);
col
=
getColAddressInv
(
colStr
);
row
=
getRowAdderssInv
(
rowStr
);
}
bool
parseBoolVal
(
const
std
::
wstring
&
str
)
...
...
ASCOfficeOdfFile/src/docx/xlsxconversioncontext.cpp
View file @
82dc7ab4
...
...
@@ -41,6 +41,8 @@
#include "xlsx_package.h"
#include "xlsx_utils.h"
#include "xlsx_cell_format.h"
#include "../odf/odfcontext.h"
#include "../odf/calcs_styles.h"
#include "../../DesktopEditor/fontengine/ApplicationFonts.h"
...
...
@@ -136,7 +138,7 @@ void xlsx_conversion_context::end_document()
{
xlsx_xml_worksheet_ptr
&
sheet
=
sheets_
[
i
];
const
std
::
wstring
id
=
std
::
wstring
(
L"sId"
)
+
std
::
to_wstring
(
i
+
1
);
const
std
::
wstring
id
=
std
::
wstring
(
L"sId"
)
+
std
::
to_wstring
(
i
+
1
);
package
::
sheet_content_ptr
content
=
package
::
sheet_content
::
create
();
////////////////////////////////////////////////////////////////////////////////////////////
...
...
@@ -222,6 +224,8 @@ void xlsx_conversion_context::end_document()
CP_XML_ATTR
(
L"xmlns"
,
L"http://schemas.openxmlformats.org/spreadsheetml/2006/main"
);
CP_XML_ATTR
(
L"xmlns:r"
,
L"http://schemas.openxmlformats.org/officeDocument/2006/relationships"
);
serialize_bookViews
(
CP_XML_STREAM
());
CP_XML_NODE
(
L"sheets"
)
{
CP_XML_STREAM
()
<<
workbook_content
.
str
();
...
...
@@ -240,10 +244,59 @@ void xlsx_conversion_context::end_document()
output_document_
->
get_xl_files
().
set_drawings
(
drawings
);
package
::
xl_comments_ptr
comments
=
package
::
xl_comments
::
create
(
xlsx_comments_context_handle_
.
content
());
output_document_
->
get_xl_files
().
set_comments
(
comments
);
output_document_
->
get_xl_files
().
set_comments
(
comments
);
}
}
void
xlsx_conversion_context
::
serialize_bookViews
(
std
::
wostream
&
strm
)
{
odf_reader
::
settings_container
&
settings
=
odf_document_
->
odf_context
().
Settings
();
if
(
settings
.
get_views_count
()
<
1
)
return
;
CP_XML_WRITER
(
strm
)
{
CP_XML_NODE
(
L"bookViews"
)
{
for
(
int
i
=
0
;
i
<
settings
.
get_views_count
();
i
++
)
{
_CP_OPT
(
std
::
wstring
)
sActiveTable
=
settings
.
find_view_by_name
(
L"ActiveTable"
,
i
);
_CP_OPT
(
std
::
wstring
)
sAreaWidth
=
settings
.
find_view_by_name
(
L"VisibleAreaWidth"
,
i
);
_CP_OPT
(
std
::
wstring
)
sAreaHeight
=
settings
.
find_view_by_name
(
L"VisibleAreaHeight"
,
i
);
_CP_OPT
(
std
::
wstring
)
sAreaTop
=
settings
.
find_view_by_name
(
L"VisibleAreaTop"
,
i
);
_CP_OPT
(
std
::
wstring
)
sAreaLeft
=
settings
.
find_view_by_name
(
L"VisibleAreaLeft"
,
i
);
CP_XML_NODE
(
L"workbookView"
)
{
if
(
sActiveTable
)
{
for
(
int
i
=
0
;
i
<
sheets_
.
size
();
i
++
)
{
if
(
sheets_
[
i
]
->
name
()
==
*
sActiveTable
)
{
CP_XML_ATTR
(
L"activeTab"
,
i
);
}
}
}
if
(
sAreaWidth
)
CP_XML_ATTR
(
L"windowWidth"
,
*
sAreaWidth
);
if
(
sAreaHeight
)
CP_XML_ATTR
(
L"windowHeight"
,
*
sAreaHeight
);
if
(
sAreaTop
)
CP_XML_ATTR
(
L"yWindow"
,
*
sAreaTop
);
if
(
sAreaLeft
)
CP_XML_ATTR
(
L"xWindow"
,
*
sAreaLeft
);
CP_XML_ATTR
(
L"showSheetTabs"
,
true
);
CP_XML_ATTR
(
L"showVerticalScroll"
,
true
);
CP_XML_ATTR
(
L"showHorizontalScroll"
,
true
);
}
}
}
}
}
void
xlsx_conversion_context
::
serialize_calcPr
(
std
::
wostream
&
strm
)
{
}
void
xlsx_conversion_context
::
start_body
()
...
...
ASCOfficeOdfFile/src/docx/xlsxconversioncontext.h
View file @
82dc7ab4
...
...
@@ -177,7 +177,10 @@ public:
mediaitems
&
get_mediaitems
()
{
return
mediaitems_
;
}
private:
void
create_new_sheet
(
std
::
wstring
const
&
name
);
void
create_new_sheet
(
std
::
wstring
const
&
name
);
void
serialize_bookViews
(
std
::
wostream
&
strm
);
void
serialize_calcPr
(
std
::
wostream
&
strm
);
package
::
xlsx_document
*
output_document_
;
const
odf_reader
::
office_element
*
spreadsheet_
;
...
...
@@ -201,7 +204,6 @@ private:
math_context
math_context_
;
xlsx_drawing_context_handle
xlsx_drawing_context_handle_
;
xlsx_comments_context_handle
xlsx_comments_context_handle_
;
};
}
...
...
ASCOfficeOdfFile/src/odf/chart_build_oox.cpp
View file @
82dc7ab4
...
...
@@ -40,8 +40,6 @@
#include "style_chart_properties.h"
#include "style_text_properties.h"
#include "office_settings.h"
#include "draw_common.h"
#include "number_style.h"
...
...
@@ -137,11 +135,12 @@ void object_odf_context::add_grid(std::wstring const & className, std::wstring c
_CP_LOG
<<
"[warning] unexpected chart:grid"
<<
std
::
endl
;
}
}
void
object_odf_context
::
add_series
(
std
::
wstring
const
&
cellRangeAddress
,
std
::
wstring
const
&
labelCell
,
class_type
classType
,
std
::
wstring
const
&
attachedAxis
,
std
::
wstring
const
&
styleName
)
void
object_odf_context
::
add_series
(
std
::
wstring
const
&
cellRangeAddress
,
std
::
wstring
const
&
labelCell
,
class_type
classType
,
std
::
wstring
const
&
attachedAxis
,
std
::
wstring
const
&
styleName
)
{
if
(
class_
==
chart_ring
)
classType
=
chart_ring
;
//if (class_ == chart_stock) classType = chart_stock;
...
...
@@ -459,13 +458,13 @@ process_build_object::process_build_object(object_odf_context & object_odf, odf_
,
number_styles_
(
context
.
numberStyles
())
,
num_format_context_
(
context
)
{
office_element_ptr
sett_elm
=
settings_
.
find_by_style
_name
(
L"BaseFontHeight"
);
settings_config_item
*
sett
=
dynamic_cast
<
settings_config_item
*>
(
sett_elm
.
get
());
if
(
s
et
t
)
_CP_OPT
(
std
::
wstring
)
sFontHeight
=
settings_
.
find_by
_name
(
L"BaseFontHeight"
);
if
(
s
FontHeigh
t
)
{
try
{
object_odf_context_
.
baseFontHeight_
=
boost
::
lexical_cast
<
int
>
(
sett
->
content_
);
object_odf_context_
.
baseFontHeight_
=
boost
::
lexical_cast
<
int
>
(
*
sFontHeight
);
}
catch
(...)
{
...
...
ASCOfficeOdfFile/src/odf/chart_build_oox.h
View file @
82dc7ab4
...
...
@@ -340,7 +340,7 @@ private:
styles_container
&
styles_
;
s
tyles_lite_container
&
settings_
;
s
ettings_container
&
settings_
;
styles_lite_container
&
draw_styles_
;
styles_lite_container
&
number_styles_
;
...
...
ASCOfficeOdfFile/src/odf/odf_document_impl.cpp
View file @
82dc7ab4
...
...
@@ -294,7 +294,38 @@ void odf_document::Impl::parse_settings()
context_
->
Settings
().
add
(
sett
->
config_name_
,
elm_sett
);
}
}
}
else
if
(
item_set
->
config_name_
==
L"ooo:view-settings"
)
{
BOOST_FOREACH
(
office_element_ptr
&
elm_sett
,
item_set
->
content_
)
{
settings_config_item
*
sett
=
dynamic_cast
<
settings_config_item
*>
(
elm_sett
.
get
());
if
(
sett
)
context_
->
Settings
().
add_view
(
sett
->
config_name_
,
elm_sett
);
else
{
settings_config_item_map_indexed
*
map_sett
=
dynamic_cast
<
settings_config_item_map_indexed
*>
(
elm_sett
.
get
());
if
((
map_sett
)
&&
(
map_sett
->
config_name_
==
L"Views"
))
{
for
(
int
i
=
0
;
i
<
map_sett
->
content_
.
size
();
i
++
)
{
settings_config_item_map_entry
*
entry
=
dynamic_cast
<
settings_config_item_map_entry
*>
(
map_sett
->
content_
[
i
].
get
());
if
(
!
entry
)
continue
;
context_
->
Settings
().
start_view
();
for
(
int
j
=
0
;
(
entry
)
&&
(
j
<
entry
->
content_
.
size
());
j
++
)
{
settings_config_item
*
sett
=
dynamic_cast
<
settings_config_item
*>
(
entry
->
content_
[
j
].
get
());
if
(
!
sett
)
continue
;
context_
->
Settings
().
add_view
(
sett
->
config_name_
,
entry
->
content_
[
j
]);
}
context_
->
Settings
().
end_view
();
}
}
}
}
}
}
}
void
odf_document
::
Impl
::
parse_styles
()
...
...
ASCOfficeOdfFile/src/odf/odfcontext.h
View file @
82dc7ab4
...
...
@@ -280,8 +280,8 @@ class fonts_container
{
public:
typedef
std
::
vector
<
font_instance_ptr
>
instances_array
;
public:
font_instance
*
font_by_style_name
(
const
std
::
wstring
&
StyleName
);
font_instance
*
font_by_style_name
(
const
std
::
wstring
&
StyleName
);
font_instance
*
font_by_name
(
const
std
::
wstring
&
Name
);
instances_array
&
instances
()
{
return
instances_
;
}
void
add_font
(
font_instance_ptr
FontInstance
);
...
...
@@ -322,8 +322,7 @@ class list_style_container
public:
typedef
std
::
vector
<
list_style_instance_ptr
>
instances_array
;
public:
void
add_list_style
(
text_list_style
*
textListStyle
);
void
add_list_style
(
text_list_style
*
textListStyle
);
void
add_list_style
(
text_list_style
*
textListStyle
,
const
std
::
wstring
&
NewName
);
/// получить экземпляр по имени стиля
...
...
@@ -367,10 +366,10 @@ public:
notes_configuration
&
noteConfiguration
()
{
return
notes_configuration_
;
}
styles_lite_container
&
numberStyles
()
{
return
number_style_container_
;
}
styles_lite_container
&
drawStyles
()
{
return
draw_style_container_
;
}
styles_lite_container
&
Templates
()
{
return
template_container_
;
}
s
tyles_lite_container
&
Settings
()
{
return
settings_container_
;
}
styles_lite_container
&
numberStyles
()
{
return
number_style_container_
;
}
styles_lite_container
&
drawStyles
()
{
return
draw_style_container_
;
}
styles_lite_container
&
Templates
()
{
return
template_container_
;
}
s
ettings_container
&
Settings
()
{
return
settings_container_
;
}
private:
styles_container
major_style_container_
;
...
...
@@ -383,7 +382,7 @@ private:
styles_lite_container
draw_style_container_
;
styles_lite_container
template_container_
;
s
tyles_lite_container
settings_container_
;
s
ettings_container
settings_container_
;
};
...
...
ASCOfficeOdfFile/src/odf/office_settings.cpp
View file @
82dc7ab4
...
...
@@ -93,6 +93,7 @@ const wchar_t * settings_config_item_map_indexed::name = L"config-item-map-index
void
settings_config_item_map_indexed
::
add_attributes
(
const
xml
::
attributes_wc_ptr
&
Attributes
)
{
CP_APPLY_ATTR
(
L"config:name"
,
config_name_
,
std
::
wstring
(
L""
));
}
void
settings_config_item_map_indexed
::
add_child_element
(
xml
::
sax
*
Reader
,
const
std
::
wstring
&
Ns
,
const
std
::
wstring
&
Name
)
...
...
@@ -106,6 +107,7 @@ const wchar_t * settings_config_item_map_named::name = L"config-item-map-named";
void
settings_config_item_map_named
::
add_attributes
(
const
xml
::
attributes_wc_ptr
&
Attributes
)
{
CP_APPLY_ATTR
(
L"config:name"
,
config_name_
,
std
::
wstring
(
L""
));
}
void
settings_config_item_map_named
::
add_child_element
(
xml
::
sax
*
Reader
,
const
std
::
wstring
&
Ns
,
const
std
::
wstring
&
Name
)
...
...
ASCOfficeOdfFile/src/odf/office_settings.h
View file @
82dc7ab4
...
...
@@ -112,15 +112,13 @@ public:
static
const
ElementType
type
=
typeOfficeSettingsConfigItemMapIndexed
;
CPDOCCORE_DEFINE_VISITABLE
();
std
::
wstring
config_name_
;
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_text
(
const
std
::
wstring
&
Text
){}
private:
office_element_ptr_array
content_
;
};
CP_REGISTER_OFFICE_ELEMENT2
(
settings_config_item_map_indexed
);
...
...
@@ -134,15 +132,13 @@ public:
static
const
ElementType
type
=
typeOfficeSettingsConfigItemMapNamed
;
CPDOCCORE_DEFINE_VISITABLE
();
std
::
wstring
config_name_
;
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_text
(
const
std
::
wstring
&
Text
){}
private:
office_element_ptr_array
content_
;
};
CP_REGISTER_OFFICE_ELEMENT2
(
settings_config_item_map_named
);
...
...
@@ -156,15 +152,12 @@ public:
static
const
ElementType
type
=
typeOfficeSettingsConfigItemMapEntry
;
CPDOCCORE_DEFINE_VISITABLE
();
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_text
(
const
std
::
wstring
&
Text
){}
private:
office_element_ptr_array
content_
;
};
CP_REGISTER_OFFICE_ELEMENT2
(
settings_config_item_map_entry
);
...
...
ASCOfficeOdfFile/src/odf/search_table_cell.cpp
View file @
82dc7ab4
...
...
@@ -96,14 +96,14 @@ public:
typedef
boost
::
function
<
void
(
const
office_element
*
elm
,
std
::
wstring
defaultColumnStyle
,
std
::
wstring
defaultRowStyle
)
>
on_found_callback
;
table_round
(
std
::
wstring
const
&
targetTable
,
int
targetColumn
,
int
targetRow
,
on_found_callback
on_found
)
:
target_table_
(
targetTable
),
target_column_
(
targetColumn
),
target_row_
(
targetRow
),
on_found_
(
on_found
),
current_table_column_
(
0
),
current_table_row_
(
0
),
columns_spanned_num_
(
0
),
columns_count_
(
0
),
:
target_table_
(
targetTable
),
target_column_
(
targetColumn
),
target_row_
(
targetRow
),
on_found_
(
on_found
),
current_table_column_
(
0
),
current_table_row_
(
0
),
columns_spanned_num_
(
0
),
columns_count_
(
0
),
stop_
(
false
)
{}
...
...
ASCOfficeOdfFile/src/odf/styles_lite_container.cpp
View file @
82dc7ab4
...
...
@@ -34,23 +34,23 @@
#include <boost/unordered_map.hpp>
#include "styles_lite_container.h"
#include "office_settings.h"
namespace
cpdoccore
{
namespace
odf_reader
{
struct
style_ref_lite_container
struct
container_element
{
std
::
wstring
style_
name
;
office_element_ptr
style
;
std
::
wstring
name
;
office_element_ptr
elm
;
};
struct
styles_lite_container
::
Impl
{
typedef
std
::
vector
<
style_ref_lite_container
>
array_t
;
array_t
array_
;
typedef
boost
::
unordered_map
<
std
::
wstring
,
size_t
>
map_t
;
map_t
map_
;
std
::
vector
<
container_element
>
array_
;
boost
::
unordered_map
<
std
::
wstring
,
int
>
map_
;
};
styles_lite_container
::
styles_lite_container
()
:
impl_
(
new
styles_lite_container
::
Impl
()
)
...
...
@@ -61,25 +61,139 @@ styles_lite_container::~styles_lite_container()
{
}
void
styles_lite_container
::
add
(
const
std
::
wstring
&
style_
name
,
office_element_ptr
content
)
void
styles_lite_container
::
add
(
const
std
::
wstring
&
name
,
office_element_ptr
content
)
{
style_ref_lite_container
ref
=
{
style_name
,
content
};
impl_
->
array_
.
push_back
(
ref
);
impl_
->
map_
[
style_name
]
=
impl_
->
array_
.
size
()
-
1
;
container_element
ref
=
{
name
,
content
};
impl_
->
array_
.
push_back
(
ref
);
impl_
->
map_
[
name
]
=
impl_
->
array_
.
size
()
-
1
;
}
office_element_ptr
styles_lite_container
::
find_by_style_name
(
const
std
::
wstring
&
style_
name
)
office_element_ptr
styles_lite_container
::
find_by_style_name
(
const
std
::
wstring
&
name
)
{
styles_lite_container
::
Impl
::
map_t
::
const_iterator
i
=
impl_
->
map_
.
find
(
style_name
);
if
(
i
!=
impl_
->
map_
.
end
())
boost
::
unordered_map
<
std
::
wstring
,
int
>::
const_iterator
i
=
impl_
->
map_
.
find
(
name
);
if
(
i
!=
impl_
->
map_
.
end
())
{
return
impl_
->
array_
[
i
->
second
].
style
;
return
impl_
->
array_
[
i
->
second
].
elm
;
}
else
{
return
office_element_ptr
();
}
}
//----------------------------------------------------------------------------------
struct
settings_elm
{
std
::
vector
<
container_element
>
array_
;
boost
::
unordered_map
<
std
::
wstring
,
int
>
map_
;
};
class
settings_container
::
Impl
{
public:
settings_container
::
Impl
(){}
settings_elm
common
;
settings_elm
common_view
;
std
::
vector
<
settings_elm
>
views
;
};
settings_container
::
settings_container
()
:
impl_
(
new
settings_container
::
Impl
()
)
{
}
settings_container
::~
settings_container
()
{
}
void
settings_container
::
add
(
const
std
::
wstring
&
name
,
office_element_ptr
content
)
{
container_element
ref
=
{
name
,
content
};
impl_
->
common
.
array_
.
push_back
(
ref
);
impl_
->
common
.
map_
[
name
]
=
impl_
->
common
.
array_
.
size
()
-
1
;
}
void
settings_container
::
start_view
()
{
settings_elm
elm
;
impl_
->
views
.
push_back
(
elm
);
}
void
settings_container
::
end_view
()
{
}
int
settings_container
::
get_views_count
()
{
return
impl_
->
views
.
size
();
}
void
settings_container
::
add_view
(
const
std
::
wstring
&
name
,
office_element_ptr
content
)
{
container_element
ref
=
{
name
,
content
};
if
(
impl_
->
views
.
empty
())
{
impl_
->
common_view
.
array_
.
push_back
(
ref
);
impl_
->
common_view
.
map_
[
name
]
=
impl_
->
common_view
.
array_
.
size
()
-
1
;
}
else
{
impl_
->
views
.
back
().
array_
.
push_back
(
ref
);
impl_
->
views
.
back
().
map_
[
name
]
=
impl_
->
views
.
back
().
array_
.
size
()
-
1
;
}
}
_CP_OPT
(
std
::
wstring
)
settings_container
::
find_by_name
(
const
std
::
wstring
&
name
)
{
_CP_OPT
(
std
::
wstring
)
value
;
boost
::
unordered_map
<
std
::
wstring
,
int
>::
const_iterator
i
=
impl_
->
common
.
map_
.
find
(
name
);
if
(
i
!=
impl_
->
common
.
map_
.
end
())
{
office_element_ptr
&
elm
=
impl_
->
common
.
array_
[
i
->
second
].
elm
;
settings_config_item
*
sett
=
dynamic_cast
<
settings_config_item
*>
(
elm
.
get
());
if
(
sett
)
value
=
sett
->
content_
;
}
return
value
;
}
_CP_OPT
(
std
::
wstring
)
settings_container
::
find_view_by_name
(
const
std
::
wstring
&
name
,
int
ind
)
{
_CP_OPT
(
std
::
wstring
)
value
;
if
(
ind
<
0
||
ind
>=
impl_
->
views
.
size
())
{
boost
::
unordered_map
<
std
::
wstring
,
int
>::
const_iterator
i
=
impl_
->
common_view
.
map_
.
find
(
name
);
if
(
i
!=
impl_
->
common_view
.
map_
.
end
())
{
office_element_ptr
&
elm
=
impl_
->
common_view
.
array_
[
i
->
second
].
elm
;
settings_config_item
*
sett
=
dynamic_cast
<
settings_config_item
*>
(
elm
.
get
());
if
(
sett
)
value
=
sett
->
content_
;
}
}
else
{
boost
::
unordered_map
<
std
::
wstring
,
int
>::
const_iterator
i
=
impl_
->
views
[
ind
].
map_
.
find
(
name
);
if
(
i
!=
impl_
->
views
[
ind
].
map_
.
end
())
{
office_element_ptr
&
elm
=
impl_
->
views
[
ind
].
array_
[
i
->
second
].
elm
;
settings_config_item
*
sett
=
dynamic_cast
<
settings_config_item
*>
(
elm
.
get
());
if
(
sett
)
value
=
sett
->
content_
;
}
else
{
return
find_view_by_name
(
name
);
}
}
return
value
;
}
}
}
\ No newline at end of file
ASCOfficeOdfFile/src/odf/styles_lite_container.h
View file @
82dc7ab4
...
...
@@ -33,6 +33,7 @@
#include <cpdoccore/CPSharedPtr.h>
#include <cpdoccore/CPScopedPtr.h>
#include <cpdoccore/CPOptional.h>
namespace
cpdoccore
{
namespace
odf_reader
{
...
...
@@ -45,8 +46,8 @@ class styles_lite_container
public:
styles_lite_container
();
~
styles_lite_container
();
public:
void
add
(
const
std
::
wstring
&
style_name
,
office_element_ptr
content
);
void
add
(
const
std
::
wstring
&
style_name
,
office_element_ptr
content
);
office_element_ptr
find_by_style_name
(
const
std
::
wstring
&
style_name
);
private:
...
...
@@ -55,5 +56,27 @@ private:
};
class
settings_container
{
public:
settings_container
();
~
settings_container
();
_CP_OPT
(
std
::
wstring
)
find_by_name
(
const
std
::
wstring
&
name
);
_CP_OPT
(
std
::
wstring
)
find_view_by_name
(
const
std
::
wstring
&
name
,
int
index
=
-
1
);
//"-1" - common
int
get_views_count
();
void
add
(
const
std
::
wstring
&
name
,
office_element_ptr
content
);
void
start_view
();
void
end_view
();
void
add_view
(
const
std
::
wstring
&
name
,
office_element_ptr
content
);
private:
class
Impl
;
_CP_SCOPED_PTR
(
Impl
)
impl_
;
};
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment