styles.cpp 59.6 KB
Newer Older
Alexander.Trofimov's avatar
Alexander.Trofimov committed
1
/*
Alexander.Trofimov's avatar
Alexander.Trofimov committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
 * (c) Copyright Ascensio System SIA 2010-2016
 *
 * 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 Lubanas st. 125a-25, Riga, Latvia,
 * EU, LV-1021.
 *
 * 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
 *
 */
Elen.Subbotina's avatar
Elen.Subbotina committed
32

Elen.Subbotina's avatar
Elen.Subbotina committed
33

Alexey.Golubev's avatar
Alexey.Golubev committed
34 35
#include "styles.h"
#include <cpdoccore/xml/xmlchar.h>
36
#include <cpdoccore/xml/attributes.h>
Alexey.Golubev's avatar
Alexey.Golubev committed
37
#include <cpdoccore/xml/attributes.h>
Elen.Subbotina's avatar
Elen.Subbotina committed
38
#include <cpdoccore/xml/simple_xml_writer.h>
39 40 41

#include <cpdoccore/odf/odf_document.h>

Alexey.Golubev's avatar
Alexey.Golubev committed
42 43 44 45 46 47 48 49 50 51 52
#include <iostream>
#include <boost/foreach.hpp>

#include "office_elements.h"
#include "office_elements_create.h"

#include "style_text_properties.h"
#include "style_paragraph_properties.h"
#include "style_table_properties.h"
#include "style_graphic_properties.h"
#include "style_chart_properties.h"
53
#include "style_presentation.h"
Alexey.Golubev's avatar
Alexey.Golubev committed
54 55 56 57

#include "serialize_elements.h"
#include "odfcontext.h"

58 59
#include "draw_common.h"

Alexey.Golubev's avatar
Alexey.Golubev committed
60
namespace cpdoccore { 
61

62 63 64
	using namespace odf_types;

namespace odf_reader {
Alexey.Golubev's avatar
Alexey.Golubev committed
65

66 67
	namespace {

68 69 70 71 72
std::wstring process_border(const border_style	& borderStyle,
			const	_CP_OPT(border_widths)		& borderLineWidths,
					_CP_OPT(length)				& borderPadding, 
					_CP_OPT(length_or_percent)	& margin, 
			const	std::wstring				& Shadow = L"")
73 74 75 76 77 78 79 80 81 82 83 84 85
{
    std::wstring w_sz;
    std::wstring w_color;
    std::wstring w_val = L"single";
    std::wstring w_space;

    if (!borderStyle.initialized() || borderStyle.is_none())
    {
        w_val = L"none";
    }
    else if (borderStyle.initialized())
    {
        double width = borderStyle.get_length().get_value_unit(length::pt);
86 87 88 89 90 91 92 93 94 95 96
	
		if (borderLineWidths)
		{
			width = borderLineWidths->get_len1().get_value_unit(length::pt);
		}

        int szInt = (int)(0.5 + 8.0 * width); //eighths of a point (ST_EighthPointMeasure)
        if (szInt <= 0)      szInt = 1;

		w_sz = boost::lexical_cast<std::wstring>( szInt );
		w_color = boost::lexical_cast<std::wstring>( borderStyle.get_color().get_hex_value() );
97 98 99 100

        if (borderPadding)
            w_space = boost::lexical_cast<std::wstring>((int)(borderPadding->get_value_unit(length::pt) + 0.5) );

Elen.Subbotina's avatar
Elen.Subbotina committed
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
        switch(borderStyle.get_style())
        {
        case border_style::none:        w_val = L"none";    break;
        case border_style::solid:
        case border_style::single:
                                        w_val = L"single";  break;
        case border_style::double_:     w_val = L"double";  break;
        case border_style::dotted:      w_val = L"dotted";  break;
        case border_style::dashed:      w_val = L"dashed";  break;
        case border_style::groove:      w_val = L"thinThickMediumGap";  break;
        case border_style::ridge:       w_val = L"thickThinMediumGap";  break;
        case border_style::inset:       w_val = L"inset";  break;
        case border_style::outset:      w_val = L"outset";  break;
        case border_style::hidden:      w_val = L"nil";     break;
        }
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
    }
    std::wstring res;
    if (!w_val.empty())
        res += L" w:val=\"" + w_val + L"\" ";
    if (!w_sz.empty())
        res += L"w:sz=\"" + w_sz + L"\" ";
    if (!w_color.empty())
        res += L"w:color=\"" + w_color + L"\" ";
    if (!w_space.empty())
        res += L"w:space=\"" + w_space + L"\" ";
    if (!Shadow.empty())
        res += L"w:shadow=\"" + Shadow + L"\" ";

    return res;
}

std::wstring process_margin(const _CP_OPT(length_or_percent) & margin, double Mul)
{
    if (margin)
    {
        if (margin->get_type() == length_or_percent::Length)
        {
            int val = (int)(0.5 + Mul * margin->get_length().get_value_unit(length::pt));
            return boost::lexical_cast<std::wstring>( val );
        }
        else
        {
            _CP_LOG << L"[docx_convert] convert margin warning: invalid type (percent)\n";
        }       
    }
    return L"";
}

}


Alexey.Golubev's avatar
Alexey.Golubev committed
152 153 154 155 156 157 158 159 160 161 162 163 164 165
style_text_properties * style_content::get_style_text_properties() const
{
    return dynamic_cast<style_text_properties *>(style_text_properties_.get());    
}

style_paragraph_properties * style_content::get_style_paragraph_properties() const
{
    return dynamic_cast<style_paragraph_properties *>(style_paragraph_properties_.get());    
}

style_graphic_properties * style_content::get_style_graphic_properties() const
{
    return dynamic_cast<style_graphic_properties *>(style_graphic_properties_.get());    
}
166 167 168 169
style_table_properties * style_content::get_style_table_properties() const
{
    return dynamic_cast<style_table_properties *>(style_table_properties_.get());    
}
Alexey.Golubev's avatar
Alexey.Golubev committed
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194

style_section_properties * style_content::get_style_section_properties() const
{
    return dynamic_cast<style_section_properties *>(style_section_properties_.get());
}

style_table_cell_properties * style_content::get_style_table_cell_properties() const
{
    return dynamic_cast<style_table_cell_properties *>(style_table_cell_properties_.get());
}

style_table_row_properties * style_content::get_style_table_row_properties() const
{
    return dynamic_cast<style_table_row_properties *>(style_table_row_properties_.get());
}

style_table_column_properties * style_content::get_style_table_column_properties() const
{
    return dynamic_cast<style_table_column_properties *>(style_table_column_properties_.get());
}

style_chart_properties * style_content::get_style_chart_properties() const
{
    return dynamic_cast<style_chart_properties *>(style_chart_properties_.get());    
}
195 196 197 198
style_drawing_page_properties * style_content::get_style_drawing_page_properties() const
{
    return dynamic_cast<style_drawing_page_properties *>(style_drawing_page_properties_.get());
}
Alexey.Golubev's avatar
Alexey.Golubev committed
199 200 201 202 203 204 205 206 207 208 209 210 211 212

void style_content::xlsx_convert(oox::xlsx_conversion_context & Context)
{
    if (style_table_column_properties_)
        style_table_column_properties_->xlsx_convert(Context);

	if (style_table_cell_properties_)
		style_table_cell_properties_->xlsx_convert(Context);

    if (style_chart_properties_)
        style_chart_properties_->xlsx_convert(Context);

}

Elen.Subbotina's avatar
 
Elen.Subbotina committed
213
void style_content::docx_convert(oox::docx_conversion_context & Context, bool in_styles) 
Alexey.Golubev's avatar
Alexey.Golubev committed
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
{
    Context.start_process_style_content();

    if (style_text_properties_)
        style_text_properties_->docx_convert(Context);

    if (style_paragraph_properties_)
        style_paragraph_properties_->docx_convert(Context);

    if (style_table_properties_)
        style_table_properties_->docx_convert(Context);

    if (style_table_column_properties_)
        style_table_column_properties_->docx_convert(Context);

    if (style_table_row_properties_)
        style_table_row_properties_->docx_convert(Context);

    if (style_table_cell_properties_)
        style_table_cell_properties_->docx_convert(Context);        

Elen.Subbotina's avatar
 
Elen.Subbotina committed
235
    Context.end_process_style_content(in_styles);
Alexey.Golubev's avatar
Alexey.Golubev committed
236 237
}

ElenaSubbotina's avatar
ElenaSubbotina committed
238
void style_content::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name, document_context * Context)
Alexey.Golubev's avatar
Alexey.Golubev committed
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275
{   
    if CP_CHECK_NAME(L"style", L"text-properties")
    {
        CP_CREATE_ELEMENT_SIMPLE(style_text_properties_);    
    }
    else if CP_CHECK_NAME(L"style", L"paragraph-properties")
    {
        CP_CREATE_ELEMENT_SIMPLE(style_paragraph_properties_);
    }
    else if CP_CHECK_NAME(L"style", L"table-properties")
    {
        CP_CREATE_ELEMENT_SIMPLE(style_table_properties_);
    }
    else if CP_CHECK_NAME(L"style", L"table-column-properties")
    {
        CP_CREATE_ELEMENT_SIMPLE(style_table_column_properties_);
    }
    else if CP_CHECK_NAME(L"style", L"table-cell-properties")
    {
        CP_CREATE_ELEMENT_SIMPLE(style_table_cell_properties_);
    }
    else if CP_CHECK_NAME(L"style", L"table-row-properties")
    {
        CP_CREATE_ELEMENT_SIMPLE(style_table_row_properties_);
    }
    else if CP_CHECK_NAME(L"style", L"section-properties")
    {
        CP_CREATE_ELEMENT_SIMPLE(style_section_properties_);
    } 
    else if CP_CHECK_NAME(L"style", L"graphic-properties")
    {
        CP_CREATE_ELEMENT_SIMPLE(style_graphic_properties_);    
    }
    else if CP_CHECK_NAME(L"style", L"chart-properties")
    {
        CP_CREATE_ELEMENT_SIMPLE(style_chart_properties_);    
    }
276 277 278 279
	else if CP_CHECK_NAME(L"style", L"drawing-page-properties")
	{
		CP_CREATE_ELEMENT_SIMPLE(style_drawing_page_properties_);
	}
Alexey.Golubev's avatar
Alexey.Golubev committed
280 281 282 283 284 285 286 287 288 289 290
    else
    {
        not_applicable_element(L"style-content", Reader, Ns, Name);
    }
}

// style:default-style
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * default_style::ns = L"style";
const wchar_t * default_style::name = L"default-style";

ElenaSubbotina's avatar
ElenaSubbotina committed
291
std::wostream & default_style::text_to_stream(std::wostream & _Wostream) const
Alexey.Golubev's avatar
Alexey.Golubev committed
292 293 294 295 296 297 298 299 300
{
    return _Wostream;
}

void default_style::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
    CP_APPLY_ATTR(L"style:family", style_family_, style_family());
}

ElenaSubbotina's avatar
ElenaSubbotina committed
301
void default_style::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
Alexey.Golubev's avatar
Alexey.Golubev committed
302 303 304 305 306 307 308 309
{
    style_content_.add_child_element(Reader, Ns, Name, getContext());
}

void default_style::add_text(const std::wstring & Text)
{    
}

310 311 312 313 314 315 316 317 318 319
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * draw_fill_image::ns = L"draw";
const wchar_t * draw_fill_image::name = L"fill-image";

void draw_fill_image::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
	CP_APPLY_ATTR(L"draw:name",	draw_name_);
	xlink_attlist_.add_attributes(Attributes);
}

ElenaSubbotina's avatar
ElenaSubbotina committed
320
void draw_fill_image::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
321 322 323 324 325 326 327 328
{
    CP_NOT_APPLICABLE_ELM();
}
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * draw_gradient::ns = L"draw";
const wchar_t * draw_gradient::name = L"gradient";

void draw_gradient::add_attributes( const xml::attributes_wc_ptr & Attributes )
Alexey.Golubev's avatar
Alexey.Golubev committed
329
{
330 331
	CP_APPLY_ATTR(L"draw:name"				, draw_name_);
	CP_APPLY_ATTR(L"draw:display-name"		, draw_display_name_);
Alexey.Golubev's avatar
Alexey.Golubev committed
332

333 334
	CP_APPLY_ATTR(L"draw:start-color"		, draw_start_color_);
	CP_APPLY_ATTR(L"draw:end-color"			, draw_end_color_);
Alexey.Golubev's avatar
Alexey.Golubev committed
335

336 337
	CP_APPLY_ATTR(L"draw:end-intensity"		, draw_end_intensity_); 
	CP_APPLY_ATTR(L"draw:start-intensity"	, draw_start_intensity_);
Alexey.Golubev's avatar
Alexey.Golubev committed
338

339 340
	CP_APPLY_ATTR(L"draw:cy"				, draw_cy_);//%
	CP_APPLY_ATTR(L"draw:cx"				, draw_cx_);
Alexey.Golubev's avatar
Alexey.Golubev committed
341
	
342 343 344
	CP_APPLY_ATTR(L"draw:border"			, draw_border_);
	CP_APPLY_ATTR(L"draw:angle"				, draw_angle_);
	CP_APPLY_ATTR(L"draw:style"				, draw_style_);//"square" 
Alexey.Golubev's avatar
Alexey.Golubev committed
345 346 347

}

ElenaSubbotina's avatar
ElenaSubbotina committed
348
void draw_gradient::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
Alexey.Golubev's avatar
Alexey.Golubev committed
349 350 351
{
    CP_NOT_APPLICABLE_ELM();
}
352
//////////////////////////////////////////////////////////////////////////////////////////////////
353 354 355 356 357 358 359 360 361 362 363 364 365
const wchar_t * draw_hatch::ns = L"draw";
const wchar_t * draw_hatch::name = L"hatch";

void draw_hatch::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
	CP_APPLY_ATTR(L"draw:name",			draw_name_);
	CP_APPLY_ATTR(L"draw:display-name",	draw_display_name_);
	CP_APPLY_ATTR(L"draw:style",		draw_style_);
	CP_APPLY_ATTR(L"draw:color",		draw_color_);
	CP_APPLY_ATTR(L"draw:distance",		draw_distance_);
	CP_APPLY_ATTR(L"draw:rotation",		draw_rotation_);
}

ElenaSubbotina's avatar
ElenaSubbotina committed
366
void draw_hatch::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
367 368 369 370
{
    CP_NOT_APPLICABLE_ELM();
}
//////////////////////////////////////////////////////////////////////////////////////////////////
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388
const wchar_t * draw_opacity::ns = L"draw";
const wchar_t * draw_opacity::name = L"opacity";

void draw_opacity::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
	CP_APPLY_ATTR(L"draw:name",	draw_name_);
	CP_APPLY_ATTR(L"draw:display-name",	draw_display_name_);

	CP_APPLY_ATTR(L"draw:start",	draw_start_);
	CP_APPLY_ATTR(L"draw:end",		draw_end_);

	
	CP_APPLY_ATTR(L"draw:border",	draw_border_);
	CP_APPLY_ATTR(L"draw:angle",	draw_angle_);
	CP_APPLY_ATTR(L"draw:style",	draw_style_); 

}

ElenaSubbotina's avatar
ElenaSubbotina committed
389
void draw_opacity::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
390 391 392
{
    CP_NOT_APPLICABLE_ELM();
}
Alexey.Golubev's avatar
Alexey.Golubev committed
393 394 395 396 397
// style:style
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * style::ns = L"style";
const wchar_t * style::name = L"style";

ElenaSubbotina's avatar
ElenaSubbotina committed
398
std::wostream & style::text_to_stream(std::wostream & _Wostream) const
Alexey.Golubev's avatar
Alexey.Golubev committed
399 400 401 402 403 404
{
    return _Wostream;
}

void style::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
405 406 407 408 409 410 411 412 413 414
    CP_APPLY_ATTR(L"style:name"					, style_name_, std::wstring(L""));
    CP_APPLY_ATTR(L"style:display-name"			, style_display_name_);
    CP_APPLY_ATTR(L"style:family"				, style_family_, style_family());
    CP_APPLY_ATTR(L"style:parent-style-name"	, style_parent_style_name_);
    CP_APPLY_ATTR(L"style:next-style-name"		, style_next_style_name_);
    CP_APPLY_ATTR(L"style:list-style-name"		, style_list_style_name_);
    CP_APPLY_ATTR(L"style:master-page-name"		, style_master_page_name_);
    CP_APPLY_ATTR(L"style:auto-update"			, style_auto_update_, false);
    CP_APPLY_ATTR(L"style:data-style-name"		, style_data_style_name_);
    CP_APPLY_ATTR(L"style:class"				, style_class_);
Alexander.Trofimov's avatar
Alexander.Trofimov committed
415
    CP_APPLY_ATTR(L"style:default-outline-level", style_default_outline_level_);//было int .. error
416 417 418 419 420 421 422 423

	if (style_master_page_name_)
	{
		if (style_master_page_name_->empty())
		{
			style_master_page_name_.reset();
		}
	}
Alexey.Golubev's avatar
Alexey.Golubev committed
424 425
}

ElenaSubbotina's avatar
ElenaSubbotina committed
426
void style::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
Alexey.Golubev's avatar
Alexey.Golubev committed
427 428 429 430 431 432 433 434 435 436 437 438 439
{
    if CP_CHECK_NAME(L"style", L"map")
    {
        CP_CREATE_ELEMENT(style_map_);
    }
    else
        style_content_.add_child_element(Reader, Ns, Name, getContext());
}

void style::add_text(const std::wstring & Text)
{
}

440
// styles & draw_styles
Alexey.Golubev's avatar
Alexey.Golubev committed
441 442
//////////////////////////////////////////////////////////////////////////////////////////////////

ElenaSubbotina's avatar
ElenaSubbotina committed
443
void styles::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name, document_context * Context)
Alexey.Golubev's avatar
Alexey.Golubev committed
444 445 446 447 448 449 450 451 452 453
{
    if CP_CHECK_NAME(L"style", L"style")
    {
        CP_CREATE_ELEMENT_SIMPLE(style_style_);
    } 
    else if CP_CHECK_NAME(L"text", L"list-style")
    {
        CP_CREATE_ELEMENT_SIMPLE(text_list_style_);
    }
    else if (
454
        CP_CHECK_NAME(L"number", L"number-style")	||
Alexey.Golubev's avatar
Alexey.Golubev committed
455 456
        CP_CHECK_NAME(L"number", L"currency-style") ||
        CP_CHECK_NAME(L"number", L"percentage-style") ||
457 458 459
        CP_CHECK_NAME(L"number", L"date-style")		||
        CP_CHECK_NAME(L"number", L"time-style")		||
        CP_CHECK_NAME(L"number", L"text-style")		||
Alexey.Golubev's avatar
Alexey.Golubev committed
460 461 462 463 464 465 466 467 468 469 470
        CP_CHECK_NAME(L"number", L"number-boolean-style")
        )
    {
        CP_CREATE_ELEMENT_SIMPLE(number_styles_);
    }   
    else
    {
        CP_NOT_APPLICABLE_ELM_SIMPLE(L"styles");
    }
}

ElenaSubbotina's avatar
ElenaSubbotina committed
471
void templates::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name, document_context * Context)
472 473 474 475 476 477 478
{
    if CP_CHECK_NAME(L"table", L"table-template")
    {
        CP_CREATE_ELEMENT_SIMPLE(table_templates_);
    } 
}

ElenaSubbotina's avatar
ElenaSubbotina committed
479
void draw_styles::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name, document_context * Context)
480 481 482 483 484 485 486 487 488 489 490 491 492
{
    if CP_CHECK_NAME(L"draw", L"gradient")
    {
        CP_CREATE_ELEMENT_SIMPLE(draw_gradient_);
    } 
    else if CP_CHECK_NAME(L"draw", L"hatch")
    {
        CP_CREATE_ELEMENT_SIMPLE(draw_hatch_);
    }
    else if CP_CHECK_NAME(L"draw", L"fill-image")
    {
        CP_CREATE_ELEMENT_SIMPLE(draw_fill_image_);
    }
493 494 495 496 497 498 499 500 501 502 503 504
    else if CP_CHECK_NAME(L"draw", L"opacity")
	{
         CP_CREATE_ELEMENT_SIMPLE(draw_opacity_);  
	}
	else if CP_CHECK_NAME(L"draw", L"marker")
	{
         CP_CREATE_ELEMENT_SIMPLE(draw_marker_);
	}
    else if CP_CHECK_NAME(L"draw", L"stroke-dash")
	{
         CP_CREATE_ELEMENT_SIMPLE(draw_stroke_dash_);
	}
505 506 507 508 509 510 511
    else
    {
        CP_NOT_APPLICABLE_ELM_SIMPLE(L"draw_styles");
    }
}


Alexey.Golubev's avatar
Alexey.Golubev committed
512 513 514 515 516
// office:automatic-styles
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * office_automatic_styles::ns = L"office";
const wchar_t * office_automatic_styles::name = L"automatic-styles";

ElenaSubbotina's avatar
ElenaSubbotina committed
517
std::wostream & office_automatic_styles::text_to_stream(std::wostream & _Wostream) const
Alexey.Golubev's avatar
Alexey.Golubev committed
518 519 520 521 522 523 524
{
    return _Wostream;
}

void office_automatic_styles::add_attributes( const xml::attributes_wc_ptr & Attributes )
{}

ElenaSubbotina's avatar
ElenaSubbotina committed
525
void office_automatic_styles::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
Alexey.Golubev's avatar
Alexey.Golubev committed
526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544
{
    if (L"style" == Ns && L"page-layout" == Name)
    {
        CP_CREATE_ELEMENT(style_page_layout_);
    }
    else
    {
        styles_.add_child_element(Reader, Ns, Name, getContext());            
    }
}

void office_automatic_styles::add_text(const std::wstring & Text)
{}

// office:master-styles
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * office_master_styles::ns = L"office";
const wchar_t * office_master_styles::name = L"master-styles";

ElenaSubbotina's avatar
ElenaSubbotina committed
545
std::wostream & office_master_styles::text_to_stream(std::wostream & _Wostream) const
Alexey.Golubev's avatar
Alexey.Golubev committed
546 547 548 549 550 551 552 553
{
    return _Wostream;
}

void office_master_styles::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
}

ElenaSubbotina's avatar
ElenaSubbotina committed
554
void office_master_styles::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
Alexey.Golubev's avatar
Alexey.Golubev committed
555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581
{
    if (L"style" == Ns && L"master-page" == Name)
        CP_CREATE_ELEMENT(style_master_page_);
    else if (L"style" == Ns && L"handout-master" == Name)
        CP_CREATE_ELEMENT(style_handout_master_);
    else if (L"style" == Ns && L"draw-layer-set" == Name)
        CP_CREATE_ELEMENT(draw_layer_set_);
    else
    {
        CP_NOT_APPLICABLE_ELM();
    }
}

void office_master_styles::add_text(const std::wstring & Text)
{
}


// office:styles
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * office_styles::ns = L"office";
const wchar_t * office_styles::name = L"styles";

void office_styles::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
}

ElenaSubbotina's avatar
ElenaSubbotina committed
582
void office_styles::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
Alexey.Golubev's avatar
Alexey.Golubev committed
583
{
584 585 586 587 588 589 590 591
    if (CP_CHECK_NAME(L"style",		L"style") ||
        CP_CHECK_NAME(L"text",		L"list-style") ||
        
		CP_CHECK_NAME(L"number",	L"number-style") ||
        CP_CHECK_NAME(L"number",	L"currency-style") || 
        CP_CHECK_NAME(L"number",	L"text-style") ||
        CP_CHECK_NAME(L"number",	L"percentage-style") ||
        CP_CHECK_NAME(L"number",	L"date-style") ||
Elen.Subbotina's avatar
Elen.Subbotina committed
592 593
		CP_CHECK_NAME(L"number",	L"time-style") ||
		CP_CHECK_NAME(L"number",	L"boolean-style")
Alexey.Golubev's avatar
Alexey.Golubev committed
594 595 596 597 598 599
        )
    {
        styles_.add_child_element(Reader, Ns, Name, getContext());
    }
    else if (L"style" == Ns && L"default-style" == Name)
        CP_CREATE_ELEMENT(style_default_style_);
600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615

    else if (L"style" == Ns && L"presentation-page-layout" == Name)
        CP_CREATE_ELEMENT(style_presentation_page_layout_);

    else if(CP_CHECK_NAME(L"draw",		L"gradient") ||
			CP_CHECK_NAME(L"draw",		L"fill-image") ||
			CP_CHECK_NAME(L"draw",		L"hatch") ||
			CP_CHECK_NAME(L"draw",		L"marker") ||
			CP_CHECK_NAME(L"draw",		L"opacity") ||
			CP_CHECK_NAME(L"draw",		L"stroke-dash") ||
			CP_CHECK_NAME(L"svg",		L"linearGradient") ||
			CP_CHECK_NAME(L"svg",		L"radialGradient") 
			)
	{
        draw_styles_.add_child_element(Reader, Ns, Name, getContext());
	}
616 617 618 619 620
     else if(CP_CHECK_NAME(L"table",	L"table-template"))
	{
        templates_.add_child_element(Reader, Ns, Name, getContext());
	}
	 else if (L"text" == Ns && L"outline-style" == Name)
Alexey.Golubev's avatar
Alexey.Golubev committed
621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644
        CP_CREATE_ELEMENT(text_outline_style_);
    else if (L"text" == Ns && L"notes-configuration" == Name)
        CP_CREATE_ELEMENT(text_notes_configuration_);
    else if (L"text" == Ns && L"bibliography-configuration" == Name)
        CP_CREATE_ELEMENT(text_bibliography_configuration_);
    else if (L"text" == Ns && L"linenumbering-configuration" == Name)
        CP_CREATE_ELEMENT(text_linenumbering_configuration_);
    else
    {
        CP_NOT_APPLICABLE_ELM();
    }
}


// style:header
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * style_header::ns = L"style";
const wchar_t * style_header::name = L"header";

void style_header::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
    content().common_style_header_footer_attlist_.add_attributes(Attributes);
}

ElenaSubbotina's avatar
ElenaSubbotina committed
645
void style_header::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
Alexey.Golubev's avatar
Alexey.Golubev committed
646 647 648 649 650 651 652 653 654 655 656 657 658
{
    content().header_footer_content_.add_child_element(Reader, Ns, Name, getContext());
}

//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * style_footer::ns = L"style";
const wchar_t * style_footer::name = L"footer";

void style_footer::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
    content().common_style_header_footer_attlist_.add_attributes(Attributes);
}

ElenaSubbotina's avatar
ElenaSubbotina committed
659
void style_footer::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
Alexey.Golubev's avatar
Alexey.Golubev committed
660 661 662 663 664 665 666 667 668 669 670 671 672
{
    content().header_footer_content_.add_child_element(Reader, Ns, Name, getContext());
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * style_header_first::ns = L"style";
const wchar_t * style_header_first::name = L"header-first";

void style_header_first::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
    content().common_style_header_footer_attlist_.add_attributes(Attributes);
}

ElenaSubbotina's avatar
ElenaSubbotina committed
673
void style_header_first::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
Alexey.Golubev's avatar
Alexey.Golubev committed
674 675 676 677 678 679 680 681 682 683 684 685 686
{
    content().header_footer_content_.add_child_element(Reader, Ns, Name, getContext());
}

//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * style_footer_first::ns = L"style";
const wchar_t * style_footer_first::name = L"footer-first";

void style_footer_first::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
    content().common_style_header_footer_attlist_.add_attributes(Attributes);
}

ElenaSubbotina's avatar
ElenaSubbotina committed
687
void style_footer_first::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
Alexey.Golubev's avatar
Alexey.Golubev committed
688 689 690 691 692 693 694 695 696 697 698 699 700
{
    content().header_footer_content_.add_child_element(Reader, Ns, Name, getContext());
}

//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * style_header_left::ns = L"style";
const wchar_t * style_header_left::name = L"header-left";

void style_header_left::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
    content().common_style_header_footer_attlist_.add_attributes(Attributes);
}

ElenaSubbotina's avatar
ElenaSubbotina committed
701
void style_header_left::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
Alexey.Golubev's avatar
Alexey.Golubev committed
702 703 704 705 706 707 708 709 710 711 712 713 714
{
    content().header_footer_content_.add_child_element(Reader, Ns, Name, getContext());
}

//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * style_footer_left::ns = L"style";
const wchar_t * style_footer_left::name = L"footer-left";

void style_footer_left::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
    content().common_style_header_footer_attlist_.add_attributes(Attributes);
}

ElenaSubbotina's avatar
ElenaSubbotina committed
715
void style_footer_left::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
Alexey.Golubev's avatar
Alexey.Golubev committed
716 717 718 719 720 721 722 723 724 725 726 727 728 729 730
{
    content().header_footer_content_.add_child_element(Reader, Ns, Name, getContext());
}

/// style:columns
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * style_columns::ns = L"style";
const wchar_t * style_columns::name = L"columns";

void style_columns::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
    CP_APPLY_ATTR(L"fo:column-count", fo_column_count_);
    CP_APPLY_ATTR(L"fo:column-gap", fo_column_gap_);
}

ElenaSubbotina's avatar
ElenaSubbotina committed
731
void style_columns::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
Alexey.Golubev's avatar
Alexey.Golubev committed
732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749
{
    if (L"style" == Ns && L"column" == Name)
        CP_CREATE_ELEMENT(style_column_);
    else if (L"style" == Ns && L"column-sep" == Name)
        CP_CREATE_ELEMENT(style_column_sep_);
    else
    {
        CP_NOT_APPLICABLE_ELM();
    }
}

/// style:column
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * style_column::ns = L"style";
const wchar_t * style_column::name = L"column";

void style_column::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
750 751 752 753 754
    CP_APPLY_ATTR(L"style:rel-width",	style_rel_width_);
    CP_APPLY_ATTR(L"fo:start-indent",	fo_start_indent_,	length(0.0, length::cm));
    CP_APPLY_ATTR(L"fo:end-indent",		fo_end_indent_,		length(0.0, length::cm));
    CP_APPLY_ATTR(L"fo:space-before",	fo_space_before_,	length(0.0, length::cm));
    CP_APPLY_ATTR(L"fo:space-after",	fo_space_after_,	length(0.0, length::cm));
Alexey.Golubev's avatar
Alexey.Golubev committed
755 756 757
    
}

ElenaSubbotina's avatar
ElenaSubbotina committed
758
void style_column::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
Alexey.Golubev's avatar
Alexey.Golubev committed
759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776
{
    CP_NOT_APPLICABLE_ELM();
}

/// style:column-sep
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * style_column_sep::ns = L"style";
const wchar_t * style_column_sep::name = L":column-sep";

void style_column_sep::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
    CP_APPLY_ATTR(L"style:style", style_style_, std::wstring(L"solid")); // default solid
    CP_APPLY_ATTR(L"style:width", style_width_);
    CP_APPLY_ATTR(L"style:height", style_height_, percent(100.0)); // default 100
    CP_APPLY_ATTR(L"style:vertical-align", style_vertical_align_, vertical_align(vertical_align::Top)); 
    CP_APPLY_ATTR(L"style:color", style_color_, color(L"#000000"));  
}

ElenaSubbotina's avatar
ElenaSubbotina committed
777
void style_column_sep::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
Alexey.Golubev's avatar
Alexey.Golubev committed
778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796
{
    CP_NOT_APPLICABLE_ELM();
}


/// style:section-properties
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * style_section_properties::ns = L"style";
const wchar_t * style_section_properties::name = L"section-properties";

void style_section_properties::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
    common_background_color_attlist_.add_attributes(Attributes);
    common_horizontal_margin_attlist_.add_attributes(Attributes);
    CP_APPLY_ATTR(L"style:protect", style_protect_, false); // default false
    CP_APPLY_ATTR(L"text:dont-balance-text-columns", text_dont_balance_text_columns_);
    common_writing_mode_attlist_.add_attributes(Attributes);
}

ElenaSubbotina's avatar
ElenaSubbotina committed
797
void style_section_properties::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
Alexey.Golubev's avatar
Alexey.Golubev committed
798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813
{
    if (L"style" == Ns && L"background-image" == Name)
        CP_CREATE_ELEMENT(style_background_image_);    
    else if (L"style" == Ns && L"columns" == Name)
        CP_CREATE_ELEMENT(style_columns_);        
    else
    {
        CP_NOT_APPLICABLE_ELM();
    }
}

/// style:header-style
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * style_header_style::ns = L"style";
const wchar_t * style_header_style::name = L"header-style";

ElenaSubbotina's avatar
ElenaSubbotina committed
814
std::wostream & style_header_style::text_to_stream(std::wostream & _Wostream) const
Alexey.Golubev's avatar
Alexey.Golubev committed
815 816 817 818 819 820 821 822
{
    return _Wostream;
}

void style_header_style::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
}

ElenaSubbotina's avatar
ElenaSubbotina committed
823
void style_header_style::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
Alexey.Golubev's avatar
Alexey.Golubev committed
824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839
{
    if (L"style" == Ns && L"header-footer-properties" == Name)
    {
        CP_CREATE_ELEMENT(style_header_footer_properties_);        
    } 
    else
    {
        CP_NOT_APPLICABLE_ELM();
    }
}

/// style:footer-style
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * style_footer_style::ns = L"style";
const wchar_t * style_footer_style::name = L"footer-style";

ElenaSubbotina's avatar
ElenaSubbotina committed
840
std::wostream & style_footer_style::text_to_stream(std::wostream & _Wostream) const
Alexey.Golubev's avatar
Alexey.Golubev committed
841 842 843 844 845 846 847 848
{
    return _Wostream;
}

void style_footer_style::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
}

ElenaSubbotina's avatar
ElenaSubbotina committed
849
void style_footer_style::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
Alexey.Golubev's avatar
Alexey.Golubev committed
850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873
{
    if (L"style" == Ns && L"header-footer-properties" == Name)
    {
        CP_CREATE_ELEMENT(style_header_footer_properties_);        
    } 
    else
    {
        CP_NOT_APPLICABLE_ELM();
    }
}


/// style-page-layout-attlist
void style_page_layout_attlist::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
    CP_APPLY_ATTR(L"style:name", style_name_, std::wstring(L""));
    CP_APPLY_ATTR(L"style:page-usage", style_page_usage_, page_usage(page_usage::All));    
}

/// style:page-layout
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * style_page_layout::ns = L"style";
const wchar_t * style_page_layout::name = L"page-layout";

ElenaSubbotina's avatar
ElenaSubbotina committed
874
std::wostream & style_page_layout::text_to_stream(std::wostream & _Wostream) const
Alexey.Golubev's avatar
Alexey.Golubev committed
875 876 877 878 879 880 881 882 883
{
    return _Wostream;    
}

void style_page_layout::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
    style_page_layout_attlist_.add_attributes(Attributes);
}

ElenaSubbotina's avatar
ElenaSubbotina committed
884
void style_page_layout::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
Alexey.Golubev's avatar
Alexey.Golubev committed
885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912
{
    if (L"style" == Ns && L"header-style" == Name)
    {
        CP_CREATE_ELEMENT(style_header_style_);        
    } 
    else if (L"style" == Ns && L"footer-style" == Name)
    {
        CP_CREATE_ELEMENT(style_footer_style_);
    }
    else if (L"style" == Ns && L"page-layout-properties" == Name)
    {
        CP_CREATE_ELEMENT(style_page_layout_properties_);
    }
    else
    {
        CP_NOT_APPLICABLE_ELM();
    }
}

// style-page-layout-properties-attlist
void style_page_layout_properties_attlist::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
    CP_APPLY_ATTR(L"fo:page-width", fo_page_width_);
    CP_APPLY_ATTR(L"fo:page-height", fo_page_height_);
    common_num_format_attlist_.add_attributes(Attributes);
    common_num_format_prefix_suffix_attlist_.add_attributes(Attributes);
    CP_APPLY_ATTR(L"style:paper-tray-name", style_paper_tray_name_);
    CP_APPLY_ATTR(L"style:print-orientation", style_print_orientation_);
913 914
   
	common_horizontal_margin_attlist_.add_attributes(Attributes);
Alexey.Golubev's avatar
Alexey.Golubev committed
915 916 917 918 919 920 921
    common_vertical_margin_attlist_.add_attributes(Attributes);
    common_margin_attlist_.add_attributes(Attributes);
    common_border_attlist_.add_attributes(Attributes);
    common_border_line_width_attlist_.add_attributes(Attributes);
    common_padding_attlist_.add_attributes(Attributes);
    common_shadow_attlist_.add_attributes(Attributes);
    common_background_color_attlist_.add_attributes(Attributes);
922 923 924 925 926 927 928 929 930 931 932 933 934
    
	CP_APPLY_ATTR(L"style:register-truth-ref-style-name", style_register_truth_ref_style_name_);
    CP_APPLY_ATTR(L"style:print",					style_print_);
    CP_APPLY_ATTR(L"style:print-page-order",		style_print_page_order_);
    CP_APPLY_ATTR(L"style:first-page-number",		style_first_page_number_);
    CP_APPLY_ATTR(L"style:scale-to",				style_scale_to_);
    CP_APPLY_ATTR(L"style:scale-to_pages",			style_scale_to_pages_);
    CP_APPLY_ATTR(L"style:table-centering",			style_table_centering_);
    CP_APPLY_ATTR(L"style:footnote-max-height",		style_footnote_max_height_);
    
	common_writing_mode_attlist_.add_attributes(Attributes);
    
	CP_APPLY_ATTR(L"style:layout-grid-mode",		style_layout_grid_mode_);
Alexey.Golubev's avatar
Alexey.Golubev committed
935 936
    CP_APPLY_ATTR(L"style:layout-grid-base-height", style_layout_grid_base_height_);
    CP_APPLY_ATTR(L"style:layout-grid-ruby-height", style_layout_grid_ruby_height_);
937 938 939 940 941
    CP_APPLY_ATTR(L"style:layout-grid-lines",		style_layout_grid_lines_);
    CP_APPLY_ATTR(L"style:layout-grid-color",		style_layout_grid_color_);
    CP_APPLY_ATTR(L"style:layout-grid-ruby-below",	style_layout_grid_ruby_below_);  
    CP_APPLY_ATTR(L"style:layout-grid-print",		style_layout_grid_print_);
    CP_APPLY_ATTR(L"style:layout-grid-display",		style_layout_grid_display_);
Alexey.Golubev's avatar
Alexey.Golubev committed
942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973
}

/*
Choice [0..6]
[ ] w:headerReference     Header Reference
[ ] w:footerReference     Footer Reference
[ ] from group w:EG_SectPrContents  
[ ] Sequence 
[ ] w:footnotePr     Section-Wide Footnote Properties
[ ] w:endnotePr     Section-Wide Endnote Properties
[ ] w:type     Section Type
[x] w:pgSz     Page Size
[ ] w:pgMar     Page Margins
[ ] w:paperSrc     Paper Source Information
[ ] w:pgBorders     Page Borders
[ ] w:lnNumType     Line Numbering Settings
[ ] w:pgNumType     Page Numbering Settings
[ ] w:cols     Column Definitions
[ ] w:formProt     Only Allow Editing of Form Fields
[ ] w:vAlign     Vertical Text Alignment on Page
[ ] w:noEndnote     Suppress Endnotes In Document
[ ] w:titlePg     Different First Page Headers and Footers
[ ] w:textDirection     Text Flow Direction
[ ] w:bidi     Right to Left Section Layout
[ ] w:rtlGutter     Gutter on Right Side of Page
[ ] w:docGrid     Document Grid
[ ] w:printerSettings     Reference to Printer Settings Data
[ ] w:sectPrChange     Revision Information for Section Properties
*/

namespace {

974 975
std::wstring process_page_margin(const _CP_OPT(length_or_percent)	& Val, 
								 const _CP_OPT(length)				& AddVal = _CP_OPT(length)())
Alexey.Golubev's avatar
Alexey.Golubev committed
976
{
977 978
    //if ((!Val) || (Val->get_type() == length_or_percent::Percent))
    //    return L"0";
Alexey.Golubev's avatar
Alexey.Golubev committed
979

980 981
    double v = (!Val || Val->get_type() == length_or_percent::Percent) ? 0 :
						(20.0 * Val->get_length().get_value_unit(length::pt));
Alexey.Golubev's avatar
Alexey.Golubev committed
982

983
    double dAddVal = 20.0 * AddVal.get_value_or(length(0, length::pt)).get_value_unit(length::pt) + 0.5;
984 985

	if (dAddVal < 0 ) dAddVal = 0;
986
    return boost::lexical_cast<std::wstring>( (int)( v + dAddVal));
Alexey.Golubev's avatar
Alexey.Golubev committed
987 988 989 990
}

}

991 992
void style_page_layout_properties_attlist::docx_convert_serialize(std::wostream & strm, oox::docx_conversion_context & Context, _CP_OPT(length_or_percent) margin_left, 
																								_CP_OPT(length_or_percent) margin_right) 
Alexey.Golubev's avatar
Alexey.Golubev committed
993
{
994 995 996 997 998
	double height_page = 0;
	
	if (fo_page_width_ || fo_page_height_ || style_print_orientation_)
	{
		std::wstring w_w = L"";
Alexey.Golubev's avatar
Alexey.Golubev committed
999 1000 1001 1002 1003 1004 1005
		std::wstring w_h = L"";
		
		if (fo_page_width_)
		{
			int val =  0.5 + 20.0 * fo_page_width_->get_value_unit(length::pt);
			if (val > 31680)
			{
1006
				//Context.set_settings_property(odf_reader::_property(L"UnormalWidthPage",val));
Alexey.Golubev's avatar
Alexey.Golubev committed
1007 1008 1009 1010
				val =31680;//22"
			}
			w_w = boost::lexical_cast<std::wstring>(val);
		}
1011
		if (fo_page_height_)
Alexey.Golubev's avatar
Alexey.Golubev committed
1012 1013 1014 1015
		{
			int val = 0.5 + 20.0 * fo_page_height_->get_value_unit(length::pt);
			if (val > 31680) val =31680;//22"
			w_h = boost::lexical_cast<std::wstring>(val);
1016 1017

			height_page = val;
Alexey.Golubev's avatar
Alexey.Golubev committed
1018 1019
		}
                
1020 1021 1022 1023 1024 1025 1026 1027
		std::wstring w_orient;
		if (style_print_orientation_)
		{
			if (L"landscape" == *style_print_orientation_)
				w_orient = L"landscape";
			else if (L"portrait" == *style_print_orientation_)
				w_orient = L"portrait";
		}
Alexey.Golubev's avatar
Alexey.Golubev committed
1028
        
1029 1030 1031
		strm << L"<w:pgSz ";
		if (!w_h.empty())
			strm << L"w:h=\"" << w_h << L"\" ";
Alexey.Golubev's avatar
Alexey.Golubev committed
1032

1033 1034
		if (!w_w.empty())
			strm << L"w:w=\"" << w_w << L"\" ";
Alexey.Golubev's avatar
Alexey.Golubev committed
1035

1036 1037
		if (!w_orient.empty())
			strm << L"w:orient=\"" << w_orient << L"\" ";
Alexey.Golubev's avatar
Alexey.Golubev committed
1038

1039 1040
		strm << L"/>";
	}
1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066
	if (!common_padding_attlist_.fo_padding_top_)
		common_padding_attlist_.fo_padding_top_		= common_padding_attlist_.fo_padding_;
	if (!common_padding_attlist_.fo_padding_bottom_)
		common_padding_attlist_.fo_padding_bottom_	= common_padding_attlist_.fo_padding_;
	if (!common_padding_attlist_.fo_padding_left_)
		common_padding_attlist_.fo_padding_left_	= common_padding_attlist_.fo_padding_;
	if (!common_padding_attlist_.fo_padding_right_)
		common_padding_attlist_.fo_padding_right_	= common_padding_attlist_.fo_padding_;

	if (!common_horizontal_margin_attlist_.fo_margin_left_)
		common_horizontal_margin_attlist_.fo_margin_left_	= common_margin_attlist_.fo_margin_;
	if (!common_horizontal_margin_attlist_.fo_margin_right_)
		common_horizontal_margin_attlist_.fo_margin_right_	= common_margin_attlist_.fo_margin_;
	if (!common_vertical_margin_attlist_.fo_margin_top_)
		common_vertical_margin_attlist_.fo_margin_top_		= common_margin_attlist_.fo_margin_;
	if (!common_vertical_margin_attlist_.fo_margin_bottom_)
		common_vertical_margin_attlist_.fo_margin_bottom_	= common_margin_attlist_.fo_margin_;

//hange offset border from text to from page
	if (common_padding_attlist_.fo_padding_left_ && common_horizontal_margin_attlist_.fo_margin_left_)
	{
	}
	if (common_padding_attlist_.fo_padding_right_ && common_horizontal_margin_attlist_.fo_margin_right_)
	{
	}	
	if (common_padding_attlist_.fo_padding_top_ && common_vertical_margin_attlist_.fo_margin_top_)
1067 1068
	{
	}
1069 1070 1071 1072 1073
	if (common_padding_attlist_.fo_padding_bottom_ && common_vertical_margin_attlist_.fo_margin_bottom_)
	{
	}
			
	if (common_border_attlist_.fo_border_ || common_border_attlist_.fo_border_top_ || common_border_attlist_.fo_border_bottom_ ||
1074 1075 1076 1077 1078 1079 1080
			common_border_attlist_.fo_border_left_ || common_border_attlist_.fo_border_right_ )
	{
		std::wstring w_top, w_left, w_right, w_bottom, w_shadow;
	
		if (common_shadow_attlist_.style_shadow_)
			w_shadow = common_shadow_attlist_.style_shadow_->get_type() != shadow_type::None ? L"1" : L"0";

1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113
		if (common_border_attlist_.fo_border_ || common_border_attlist_.fo_border_top_)
		{
			w_top = process_border (	common_border_attlist_.fo_border_top_ ? *common_border_attlist_.fo_border_top_ : *common_border_attlist_.fo_border_ 
										, common_border_line_width_attlist_.style_border_line_width_top_
										, common_padding_attlist_.fo_padding_top_
										, common_vertical_margin_attlist_.fo_margin_top_
										, w_shadow);
		}
		if (common_border_attlist_.fo_border_ || common_border_attlist_.fo_border_bottom_)
		{
			w_bottom = process_border (	common_border_attlist_.fo_border_bottom_ ? *common_border_attlist_.fo_border_bottom_ : *common_border_attlist_.fo_border_
										, common_border_line_width_attlist_.style_border_line_width_bottom_ 
										, common_padding_attlist_.fo_padding_bottom_
										, common_vertical_margin_attlist_.fo_margin_bottom_
										, w_shadow);
		}
		if (common_border_attlist_.fo_border_ || common_border_attlist_.fo_border_left_)
		{
			w_left = process_border (	common_border_attlist_.fo_border_left_ ? *common_border_attlist_.fo_border_left_ : *common_border_attlist_.fo_border_ 
										, common_border_line_width_attlist_.style_border_line_width_left_
										, common_padding_attlist_.fo_padding_left_
										, common_horizontal_margin_attlist_.fo_margin_left_
										, w_shadow);
		}
		if (common_border_attlist_.fo_border_ || common_border_attlist_.fo_border_right_)
		{
			w_right = process_border (	common_border_attlist_.fo_border_right_ ? *common_border_attlist_.fo_border_right_ : *common_border_attlist_.fo_border_ 
										, common_border_line_width_attlist_.style_border_line_width_right_
										, common_padding_attlist_.fo_padding_right_
										, common_horizontal_margin_attlist_.fo_margin_right_
										, w_shadow);
		}
		 strm << L"<w:pgBorders w:offsetFrom=\"text\">";
1114 1115 1116 1117 1118 1119 1120
			if (!w_top.empty())			strm << L"<w:top "		<< w_top	<< L" />";
			if (!w_left.empty())		strm << L"<w:left "		<< w_left	<< L" />";
			if (!w_right.empty())		strm << L"<w:right "	<< w_right	<< L" />";
			if (!w_bottom.empty())		strm << L"<w:bottom "	<< w_bottom << L" />";
		 strm << L"</w:pgBorders>";
	}
   
1121 1122
	CP_XML_WRITER(strm)
	{
1123 1124 1125 1126 1127
		if (common_horizontal_margin_attlist_.fo_margin_left_	||
			common_horizontal_margin_attlist_.fo_margin_right_	||
			common_vertical_margin_attlist_.fo_margin_top_		||
			common_vertical_margin_attlist_.fo_margin_bottom_	||
			margin_right || margin_left
1128 1129 1130 1131
			)
		{
			_CP_OPT(odf_types::length)  margin_left_length, margin_right_length;

1132
			if (margin_left)	margin_left_length	= margin_left->get_length();
1133 1134 1135 1136
			if (margin_right)	margin_right_length = margin_right->get_length();

			CP_XML_NODE(L"w:pgMar")
			{
1137 1138 1139 1140
				CP_XML_ATTR(L"w:left"	, process_page_margin(common_horizontal_margin_attlist_.fo_margin_left_	, margin_left_length) );
				CP_XML_ATTR(L"w:right"	, process_page_margin(common_horizontal_margin_attlist_.fo_margin_right_, margin_right_length) );
				CP_XML_ATTR(L"w:top"	, process_page_margin(common_vertical_margin_attlist_.fo_margin_top_	, Context.get_header_footer_context().header()) );
				CP_XML_ATTR(L"w:bottom"	, process_page_margin(common_vertical_margin_attlist_.fo_margin_bottom_	, Context.get_header_footer_context().footer()) );
ElenaSubbotina's avatar
ElenaSubbotina committed
1141 1142 1143 1144
				
				CP_XML_ATTR(L"w:header"	, process_page_margin(common_vertical_margin_attlist_.fo_margin_top_	) );
				CP_XML_ATTR(L"w:footer"	, process_page_margin(common_vertical_margin_attlist_.fo_margin_bottom_ ) );
				CP_XML_ATTR(L"w:gutter"	, 0 );
1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171
			}
		}

		if ((style_layout_grid_mode_) && (style_layout_grid_mode_->get_type() != odf_types::layout_grid_mode::None))
		{
			CP_XML_NODE(L"w:docGrid")
			{
				if (style_layout_grid_mode_->get_type() == odf_types::layout_grid_mode::Line)
					CP_XML_ATTR(L"w:type", L"lines");
				if (style_layout_grid_mode_->get_type() == odf_types::layout_grid_mode::Both)	
					CP_XML_ATTR(L"w:type", L"linesAndChars");

				int val_step = 0;
				if (style_layout_grid_base_height_ && style_layout_grid_ruby_height_)
				{
					val_step = 0.5	+ 20. * style_layout_grid_ruby_height_->get_value_unit(odf_types::length::pt) 
									+ 20. * style_layout_grid_base_height_->get_value_unit(odf_types::length::pt);
				}
				else  if (style_layout_grid_lines_ && height_page > 0)
				{
					val_step = height_page / (*style_layout_grid_lines_);
				}
				
				if (val_step > 0)CP_XML_ATTR(L"w:linePitch", val_step);
			}			
		}
	}
Alexey.Golubev's avatar
Alexey.Golubev committed
1172 1173
}

Elen.Subbotina's avatar
Elen.Subbotina committed
1174 1175 1176 1177 1178 1179
void style_page_layout_properties_attlist::pptx_convert(oox::pptx_conversion_context & Context) 
{
    std::wostream & strm = Context.current_presentation().slidesProperties();

    if (fo_page_width_ || fo_page_height_ || style_print_orientation_)
    {
1180
        std::wstring w_w, w_h;
Elen.Subbotina's avatar
Elen.Subbotina committed
1181

1182
		_INT64 h = 0, w = 0;
Elen.Subbotina's avatar
Elen.Subbotina committed
1183 1184 1185 1186
		
		if (fo_page_width_)
		{
			w =  fo_page_width_->get_value_unit(length::emu);
1187
			if (w < 914400) w = 914400;
Elen.Subbotina's avatar
Elen.Subbotina committed
1188

1189
			w_w = std::to_wstring(w);
Elen.Subbotina's avatar
Elen.Subbotina committed
1190 1191 1192 1193
		}
        if (fo_page_height_)
		{
			h = fo_page_height_->get_value_unit(length::emu);
1194 1195 1196
			if (h < 914400) h = 914400;

			w_h = std::to_wstring(h);
Elen.Subbotina's avatar
Elen.Subbotina committed
1197 1198 1199 1200
		}
                
        std::wstring w_orient = L"custom";

1201 1202 1203 1204 1205 1206
		//if (w && h)
		//{
		//	double ratio = (double)w/(double)h;
		//	if (abs(ratio - 16./9.)<0.01)	w_orient = L"screen16x9";
		//	if (abs(ratio - 4./3.)<0.01)	w_orient = L"screen4x3";
		//}
Elen.Subbotina's avatar
Elen.Subbotina committed
1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221
        
        strm << L"<p:sldSz ";
        if (!w_h.empty())
            strm << L"cy=\"" << w_h << L"\" ";

        if (!w_w.empty())
            strm << L"cx=\"" << w_w << L"\" ";
	
		strm << L"type=\"" << w_orient << L"\" ";

        strm << L"/>";
    }

}

Alexey.Golubev's avatar
Alexey.Golubev committed
1222 1223 1224
// style-footnote-sep-attlist
void style_footnote_sep_attlist::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
1225 1226 1227 1228 1229 1230 1231
    CP_APPLY_ATTR(L"style:width",					style_width_);
    CP_APPLY_ATTR(L"style:rel-width",				style_rel_width_);
    CP_APPLY_ATTR(L"style:color",					style_color_);
    CP_APPLY_ATTR(L"style:line-style",				style_line_style_);
    CP_APPLY_ATTR(L"style:type",					style_adjustment_, style_type(style_type::Left)); // default Left
    CP_APPLY_ATTR(L"style:distance-before-sep",		style_distance_before_sep_);
    CP_APPLY_ATTR(L"style:distance-after-sep",		style_distance_after_sep_);
Alexey.Golubev's avatar
Alexey.Golubev committed
1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243
}

/// style:footnote-sep
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * style_footnote_sep::ns = L"style";
const wchar_t * style_footnote_sep::name = L"footnote-sep";

void style_footnote_sep::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
    style_footnote_sep_attlist_.add_attributes( Attributes );
}

ElenaSubbotina's avatar
ElenaSubbotina committed
1244
void style_footnote_sep::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
Alexey.Golubev's avatar
Alexey.Golubev committed
1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258
{
    CP_NOT_APPLICABLE_ELM();
}

/// style:page-layout-properties
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * style_page_layout_properties::ns = L"style";
const wchar_t * style_page_layout_properties::name = L"page-layout-properties";

void style_page_layout_properties::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
    style_page_layout_properties_attlist_.add_attributes(Attributes);
}

ElenaSubbotina's avatar
ElenaSubbotina committed
1259
void style_page_layout_properties::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
Alexey.Golubev's avatar
Alexey.Golubev committed
1260 1261 1262
{
    style_page_layout_properties_elements_.add_child_element(Reader, Ns, Name, getContext());
}
1263 1264
bool style_page_layout_properties::docx_back_serialize(std::wostream & strm, oox::docx_conversion_context & Context)
{
1265
	if (!style_page_layout_properties_attlist_.common_background_color_attlist_.fo_background_color_)return false;
Elen.Subbotina's avatar
Elen.Subbotina committed
1266

1267
    if (style_page_layout_properties_attlist_.common_background_color_attlist_.fo_background_color_->get_type() == background_color::Transparent) return true;
Alexander.Trofimov's avatar
Alexander.Trofimov committed
1268
    //прозрачный фон
1269 1270 1271 1272
	CP_XML_WRITER(strm)
	{
		CP_XML_NODE(L"w:background")
		{
1273
			std::wstring color = style_page_layout_properties_attlist_.common_background_color_attlist_.fo_background_color_->get_color().get_hex_value();
1274 1275 1276 1277 1278
			CP_XML_ATTR(L"w:color",color);
		}
	}
	return true;
}
Elen.Subbotina's avatar
Elen.Subbotina committed
1279
void style_page_layout_properties::docx_convert_serialize(std::wostream & strm, oox::docx_conversion_context & Context)
Alexey.Golubev's avatar
Alexey.Golubev committed
1280
{
1281
	style_columns * columns = dynamic_cast<style_columns *>( style_page_layout_properties_elements_.style_columns_.get());
1282

Elen.Subbotina's avatar
Elen.Subbotina committed
1283 1284 1285
	CP_XML_WRITER(strm)
	{
		CP_XML_NODE(L"w:sectPr")
Alexey.Golubev's avatar
Alexey.Golubev committed
1286
		{
1287
			Context.process_section( CP_XML_STREAM(), columns);
1288
			
ElenaSubbotina's avatar
ElenaSubbotina committed
1289 1290
			bool next_page = Context.is_next_dump_page_properties();
			
1291 1292
			CP_XML_NODE(L"w:type")
			{				
ElenaSubbotina's avatar
ElenaSubbotina committed
1293 1294
				if (next_page)	CP_XML_ATTR(L"w:val", L"nextPage");
				else			CP_XML_ATTR(L"w:val", L"continuous");
1295
			}			
1296

1297
			std::wstring masterPageName = Context.get_master_page_name();
ElenaSubbotina's avatar
ElenaSubbotina committed
1298 1299
			bool res = Context.get_headers_footers().write_sectPr(masterPageName, next_page, strm);
			
1300
			if (res == false)
Elen.Subbotina's avatar
Elen.Subbotina committed
1301
			{
1302 1303 1304 1305 1306 1307 1308
				// default???
				masterPageName = L"Standard";
				const std::wstring masterPageNameLayout = Context.root()->odf_context().pageLayoutContainer().page_layout_name_by_style(masterPageName);
				
				Context.remove_page_properties();
				Context.add_page_properties(masterPageNameLayout);
				
ElenaSubbotina's avatar
ElenaSubbotina committed
1309
				bool res = Context.get_headers_footers().write_sectPr(masterPageName, next_page, strm);
Elen.Subbotina's avatar
Elen.Subbotina committed
1310
			}
1311 1312
	
			oox::section_context::_section & section = Context.get_section_context().get();
1313

1314
			style_page_layout_properties_attlist_.docx_convert_serialize(strm, Context, section.margin_left_, section.margin_right_);
Alexander.Trofimov's avatar
Alexander.Trofimov committed
1315
			//todooo при появлении еще накладок - переписать !!
Alexey.Golubev's avatar
Alexey.Golubev committed
1316 1317 1318
		}
	}
}
Elen.Subbotina's avatar
Elen.Subbotina committed
1319 1320 1321 1322
void style_page_layout_properties::pptx_convert(oox::pptx_conversion_context & Context)
{
    style_page_layout_properties_attlist_.pptx_convert(Context);        
}
Alexey.Golubev's avatar
Alexey.Golubev committed
1323

Elen.Subbotina's avatar
Elen.Subbotina committed
1324

Alexey.Golubev's avatar
Alexey.Golubev committed
1325 1326 1327
// style-page-layout-properties-elements
//////////////////////////////////////////////////////////////////////////////////////////////////

ElenaSubbotina's avatar
ElenaSubbotina committed
1328
void style_page_layout_properties_elements::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name, document_context * Context )
Alexey.Golubev's avatar
Alexey.Golubev committed
1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363
{
    if (L"style" == Ns && L"background-image" == Name)
    {
        CP_CREATE_ELEMENT_SIMPLE(style_background_image_);            
    }
    else if (L"style" == Ns && L"columns" == Name)
    {
        CP_CREATE_ELEMENT_SIMPLE(style_columns_);            
    }
    else if (L"style" == Ns && L"footnote-sep" == Name)
    {
        CP_CREATE_ELEMENT_SIMPLE(style_footnote_sep_);            
    }
    else
    {
        not_applicable_element(L"style-page-layout-properties-elements", Reader, Ns, Name);
    }
}

// style-master-page-attlist
////////////////////////////////////////////////////////////////////////////////////////////////// 
void style_master_page_attlist::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
    CP_APPLY_ATTR(L"style:name", style_name_);
    CP_APPLY_ATTR(L"style:display-name", style_display_name_);
    CP_APPLY_ATTR(L"style:page-layout-name", style_page_layout_name_);
    CP_APPLY_ATTR(L"draw:style-name", draw_style_name_);
    CP_APPLY_ATTR(L"style:next-style-name", style_next_style_name_);
}

/// style:master-page
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * style_master_page::ns = L"style";
const wchar_t * style_master_page::name = L"master-page";

ElenaSubbotina's avatar
ElenaSubbotina committed
1364
std::wostream & style_master_page::text_to_stream(std::wostream & _Wostream) const
Alexey.Golubev's avatar
Alexey.Golubev committed
1365 1366 1367 1368 1369 1370 1371 1372 1373
{
    return _Wostream;
}

void style_master_page::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
    style_master_page_attlist_.add_attributes(Attributes);
}

ElenaSubbotina's avatar
ElenaSubbotina committed
1374
void style_master_page::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
Alexey.Golubev's avatar
Alexey.Golubev committed
1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397
{
    if (L"style" == Ns && L"header" == Name)
        CP_CREATE_ELEMENT(style_header_);
	else if (L"style" == Ns && L"header-first" == Name)
        CP_CREATE_ELEMENT(style_header_first_);
	else if (L"style" == Ns && L"header-left" == Name)
        CP_CREATE_ELEMENT(style_header_left_);

	else if (L"style" == Ns && L"footer" == Name)
        CP_CREATE_ELEMENT(style_footer_);
	else if (L"style" == Ns && L"footer-first" == Name)
        CP_CREATE_ELEMENT(style_footer_first_);
	else if (L"style" == Ns && L"footer-left" == Name)
        CP_CREATE_ELEMENT(style_footer_left_);

    else if (L"office" == Ns && L"forms" == Name)
        CP_CREATE_ELEMENT(office_forms_);
    else if (L"style" == Ns && L"style" == Name)
        CP_CREATE_ELEMENT(style_style_);
    else if (L"presentation" == Ns && L"notes" == Name)
        CP_CREATE_ELEMENT(presentation_notes_); 
    else
    {
Elen.Subbotina's avatar
Elen.Subbotina committed
1398
        CP_CREATE_ELEMENT(content_);   
Alexey.Golubev's avatar
Alexey.Golubev committed
1399 1400 1401
    }
}

1402
int style_master_page::find_placeHolderIndex(presentation_class::type placeHolder,int & last_idx)
1403 1404 1405 1406 1407 1408 1409 1410 1411
{
	int idx = -1;

	int i=0;
	int size = content_.size();
	
	while(true)
    {
		if (i>=size)break;
1412
		if (content_[i]->get_type() == odf_reader::typeDrawFrame)
1413 1414 1415
		{
			draw_frame* frame = dynamic_cast<draw_frame *>(content_[i].get());

1416
			if (frame->idx_in_owner<0)frame->idx_in_owner = last_idx++;
1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428

			if ((frame) && (frame->common_presentation_attlist_.presentation_class_) && 
						   (frame->common_presentation_attlist_.presentation_class_->get_type()== placeHolder))
			{
				idx = frame->idx_in_owner;
				break;
			}
		}
		i++;
    }
	return idx;
}
Alexey.Golubev's avatar
Alexey.Golubev committed
1429

Elen.Subbotina's avatar
Elen.Subbotina committed
1430 1431
void style_master_page::pptx_convert(oox::pptx_conversion_context & Context)
{
1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443
	if (style_master_page_attlist_.draw_style_name_)
	{
		std::wstring style_name = style_master_page_attlist_.draw_style_name_.get();
		style_instance * style_inst = Context.root()->odf_context().styleContainer().style_by_name(style_name,style_family::DrawingPage,true);
		
		if ((style_inst) && (style_inst->content()))
		{
			const style_drawing_page_properties * properties = style_inst->content()->get_style_drawing_page_properties();

			if (properties)
			{				
				oox::_oox_fill fill;
1444 1445
				Compute_GraphicFill(properties->content().common_draw_fill_attlist_, office_element_ptr(), 
																			Context.root()->odf_context().drawStyles() ,fill);
1446 1447 1448 1449 1450 1451
				Context.get_slide_context().add_background(fill);
			}
		}
	}
	
	BOOST_FOREACH(office_element_ptr elm, content_)
Elen.Subbotina's avatar
Elen.Subbotina committed
1452 1453 1454 1455
    {
		elm->pptx_convert(Context);
	}
}
Alexey.Golubev's avatar
Alexey.Golubev committed
1456 1457 1458
////////////////

const wchar_t * hdrHeader = L"<w:hdr \
1459 1460
xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" \
xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" \
1461 1462
xmlns:o=\"urn:schemas-microsoft-com:office:office\" \
xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" \
1463 1464 1465 1466
xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" \
xmlns:v=\"urn:schemas-microsoft-com:vml\" \
xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" \
xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" \
1467
xmlns:w10=\"urn:schemas-microsoft-com:office:word\" \
1468
xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" \
1469 1470
xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" \
xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" \
1471
xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" \
1472
xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" \
1473
xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" \
1474 1475
xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" \
mc:Ignorable=\"w14 wp14\">";
1476

1477

Alexey.Golubev's avatar
Alexey.Golubev committed
1478
const wchar_t * ftrHeader = L"<w:ftr \
1479 1480
xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" \
xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" \
1481 1482
xmlns:o=\"urn:schemas-microsoft-com:office:office\" \
xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" \
1483 1484 1485 1486
xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" \
xmlns:v=\"urn:schemas-microsoft-com:vml\" \
xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" \
xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" \
1487
xmlns:w10=\"urn:schemas-microsoft-com:office:word\" \
1488
xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" \
1489 1490
xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" \
xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" \
1491
xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" \
1492
xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" \
1493
xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\" \
1494 1495
xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" \
mc:Ignorable=\"w14 wp14\">";
Alexey.Golubev's avatar
Alexey.Golubev committed
1496 1497 1498 1499 1500 1501 1502

void style_header::docx_convert(oox::docx_conversion_context & Context)
{
    std::wostream & strm = Context.output_stream();

    strm << hdrHeader;
    header_footer_impl::docx_convert(Context);
ElenaSubbotina's avatar
ElenaSubbotina committed
1503 1504
    
	strm << L"</w:hdr>";
Alexey.Golubev's avatar
Alexey.Golubev committed
1505 1506 1507 1508 1509 1510 1511
}

void style_footer::docx_convert(oox::docx_conversion_context & Context)
{
    std::wostream & strm = Context.output_stream();
    strm << ftrHeader;
    header_footer_impl::docx_convert(Context);
ElenaSubbotina's avatar
ElenaSubbotina committed
1512 1513
    
	strm << L"</w:ftr>";
Alexey.Golubev's avatar
Alexey.Golubev committed
1514 1515 1516 1517 1518 1519 1520 1521
}

void style_header_first::docx_convert(oox::docx_conversion_context & Context)
{
    std::wostream & strm = Context.output_stream();

    strm << hdrHeader;
    header_footer_impl::docx_convert(Context);
ElenaSubbotina's avatar
ElenaSubbotina committed
1522 1523
    
	strm << L"</w:hdr>";
Alexey.Golubev's avatar
Alexey.Golubev committed
1524 1525 1526 1527 1528 1529 1530
}

void style_footer_first::docx_convert(oox::docx_conversion_context & Context)
{
    std::wostream & strm = Context.output_stream();
    strm << ftrHeader;
    header_footer_impl::docx_convert(Context);
ElenaSubbotina's avatar
ElenaSubbotina committed
1531 1532
    
	strm << L"</w:ftr>";
Alexey.Golubev's avatar
Alexey.Golubev committed
1533 1534 1535 1536 1537 1538 1539 1540
}


void style_header_left::docx_convert(oox::docx_conversion_context & Context) 
{
    std::wostream & strm = Context.output_stream();
    strm << hdrHeader;
    header_footer_impl::docx_convert(Context);
ElenaSubbotina's avatar
ElenaSubbotina committed
1541 1542
    
	strm << L"</w:hdr>";
Alexey.Golubev's avatar
Alexey.Golubev committed
1543 1544 1545 1546 1547 1548 1549
}

void style_footer_left::docx_convert(oox::docx_conversion_context & Context)
{
    std::wostream & strm = Context.output_stream();
    strm << ftrHeader;
    header_footer_impl::docx_convert(Context);
ElenaSubbotina's avatar
ElenaSubbotina committed
1550 1551
    
	strm << L"</w:ftr>";
Alexey.Golubev's avatar
Alexey.Golubev committed
1552 1553 1554 1555
}

void header_footer_impl::docx_convert(oox::docx_conversion_context & Context)
{
ElenaSubbotina's avatar
ElenaSubbotina committed
1556 1557 1558 1559
	if (content_.header_footer_content_.tracked_changes_)
		content_.header_footer_content_.tracked_changes_->docx_convert(Context);

    for (int i=0; i < content_.header_footer_content_.content_.size(); i++)
Alexey.Golubev's avatar
Alexey.Golubev committed
1560
    {
ElenaSubbotina's avatar
ElenaSubbotina committed
1561
        content_.header_footer_content_.content_[i]->docx_convert(Context);
Alexey.Golubev's avatar
Alexey.Golubev committed
1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585
    }
}

/// text:notes-configuration
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * text_notes_configuration::ns = L"text";
const wchar_t * text_notes_configuration::name = L"notes-configuration";

void text_notes_configuration::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
    CP_APPLY_ATTR(L"text:note-class", noteclass_, noteclass(noteclass::Footnote));
    CP_APPLY_ATTR(L"text:citation-style-name", text_citation_style_name_);
    CP_APPLY_ATTR(L"text:citation-body-style-name", text_citation_body_style_name_);
    CP_APPLY_ATTR(L"text:default-style-name", text_default_style_name_);
    CP_APPLY_ATTR(L"text:master-page-name", text_master_page_name_);
    CP_APPLY_ATTR(L"text:start-value", text_start_value_);
    common_num_format_prefix_suffix_attlist_.add_attributes(Attributes);
    common_num_format_attlist_.add_attributes(Attributes);
    
    CP_APPLY_ATTR(L"text:start-numbering-at", text_start_numbering_at_);   
    CP_APPLY_ATTR(L"text:footnotes-position", text_footnotes_position_);

}

ElenaSubbotina's avatar
ElenaSubbotina committed
1586
void text_notes_configuration::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
Alexey.Golubev's avatar
Alexey.Golubev committed
1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600
{
    
    if CP_CHECK_NAME(L"text", L"note-continuation-notice-forward")
        CP_CREATE_ELEMENT(text_note_continuation_notice_forward_);
    else if CP_CHECK_NAME(L"text", L"note-continuation-notice-backward")
        CP_CREATE_ELEMENT(text_note_continuation_notice_backward_);
    else
        CP_NOT_APPLICABLE_ELM();    
}

void text_notes_configuration::add_text(const std::wstring & Text)
{
}

Elen.Subbotina's avatar
Elen.Subbotina committed
1601 1602 1603 1604 1605
/// style:presentation-page-layout
//////////////////////////////////////////////////////////////////////////////////////////////////
const wchar_t * style_presentation_page_layout::ns = L"style";
const wchar_t * style_presentation_page_layout::name = L"presentation-page-layout";

ElenaSubbotina's avatar
ElenaSubbotina committed
1606
std::wostream & style_presentation_page_layout::text_to_stream(std::wostream & _Wostream) const
Elen.Subbotina's avatar
Elen.Subbotina committed
1607 1608 1609 1610 1611 1612 1613 1614 1615 1616
{
    return _Wostream;    
} 

void style_presentation_page_layout::add_attributes( const xml::attributes_wc_ptr & Attributes )
{
	CP_APPLY_ATTR(L"style:name", style_name_);
	//style:display-name
}

ElenaSubbotina's avatar
ElenaSubbotina committed
1617
void style_presentation_page_layout::add_child_element( xml::sax * Reader, const std::wstring & Ns, const std::wstring & Name)
Elen.Subbotina's avatar
Elen.Subbotina committed
1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635
{
    if (L"presentation" == Ns && L"placeholder" == Name)
    {
        CP_CREATE_ELEMENT(content_);        
    } 
    else
    {
        CP_NOT_APPLICABLE_ELM();
    }
}
void style_presentation_page_layout::pptx_convert(oox::pptx_conversion_context & Context)
{
    BOOST_FOREACH(office_element_ptr elm, content_)
    {
		elm->pptx_convert(Context);
	}
}

Alexey.Golubev's avatar
Alexey.Golubev committed
1636 1637
}
}