From 6b958fd1779e1882dbd91f714719cfae08752f67 Mon Sep 17 00:00:00 2001 From: Denis Declara Date: Mon, 26 Mar 2012 17:30:27 +0200 Subject: Added anchor-selection widget, it doesn't do much at the moment, next step will be to wire everything together, btw, you can see the widget in the 'rows and columns' panel (bzr r11073.1.3) --- src/ui/CMakeLists.txt | 2 + src/ui/dialog/tile.cpp | 1 + src/ui/dialog/tile.h | 3 + src/ui/widget/anchor-selector.cpp | 123 ++++++++++++++++++++++++++++++++++++++ src/ui/widget/anchor-selector.h | 37 ++++++++++++ 5 files changed, 166 insertions(+) create mode 100644 src/ui/widget/anchor-selector.cpp create mode 100644 src/ui/widget/anchor-selector.h (limited to 'src') diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 484edc6e2..e21c3795f 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -72,6 +72,7 @@ set(ui_SRC # dialog/whiteboard-sharewithchat.cpp # dialog/whiteboard-sharewithuser.cpp + widget/anchor-selector.cpp widget/button.cpp widget/color-picker.cpp widget/color-preview.cpp @@ -200,6 +201,7 @@ set(ui_SRC view/view-widget.h view/view.h + widget/anchor-selector.h widget/attr-widget.h widget/button.h widget/color-picker.h diff --git a/src/ui/dialog/tile.cpp b/src/ui/dialog/tile.cpp index 77dae056f..5ce41c716 100644 --- a/src/ui/dialog/tile.cpp +++ b/src/ui/dialog/tile.cpp @@ -796,6 +796,7 @@ TileDialog::TileDialog() SpinsHBox.pack_start(NoOfColsBox, false, false, MARGIN); TileBox.pack_start(SpinsHBox, false, false, MARGIN); + TileBox.pack_start(anchorSelector); { /*#### Radio buttons to control spacing manually or to fit selection bbox ####*/ diff --git a/src/ui/dialog/tile.h b/src/ui/dialog/tile.h index f9e9d9842..f1493664d 100644 --- a/src/ui/dialog/tile.h +++ b/src/ui/dialog/tile.h @@ -20,6 +20,7 @@ #include #include +#include "ui/widget/anchor-selector.h" #include "ui/widget/panel.h" #include "ui/widget/spinbutton.h" #include "ui/widget/scalar-unit.h" @@ -78,6 +79,8 @@ private: bool userHidden; bool updating; + AnchorSelector anchorSelector; + Gtk::Notebook notebook; Gtk::VBox TileBox; diff --git a/src/ui/widget/anchor-selector.cpp b/src/ui/widget/anchor-selector.cpp new file mode 100644 index 000000000..f32346436 --- /dev/null +++ b/src/ui/widget/anchor-selector.cpp @@ -0,0 +1,123 @@ +/* + * anchor-selector.cpp + * + * Created on: Mar 22, 2012 + * Author: denis + */ + +#include +#include "widgets/icon.h" +#include "ui/icon-names.h" +#include "ui/widget/anchor-selector.h" + +void AnchorSelector::setupButton(const Glib::ustring& icon, Gtk::ToggleButton& button) { + Gtk::Widget* buttonIcon = Gtk::manage(sp_icon_get_icon(icon, Inkscape::ICON_SIZE_LARGE_TOOLBAR)); + buttonIcon->show(); + + button.set_relief(Gtk::RELIEF_NONE); + button.show(); + button.add(*buttonIcon); + button.set_can_focus(false); +} + +AnchorSelector::AnchorSelector() + : Gtk::Alignment(0.5, 0, 0, 0), + _container(3, 3, true) +{ + setupButton(INKSCAPE_ICON("boundingbox_top_left"), _buttons[0]); + setupButton(INKSCAPE_ICON("boundingbox_top"), _buttons[1]); + setupButton(INKSCAPE_ICON("boundingbox_top_right"), _buttons[2]); + setupButton(INKSCAPE_ICON("boundingbox_left"), _buttons[3]); + setupButton(INKSCAPE_ICON("boundingbox_center"), _buttons[4]); + setupButton(INKSCAPE_ICON("boundingbox_right"), _buttons[5]); + setupButton(INKSCAPE_ICON("boundingbox_bottom_left"), _buttons[6]); + setupButton(INKSCAPE_ICON("boundingbox_bottom"), _buttons[7]); + setupButton(INKSCAPE_ICON("boundingbox_bottom_right"), _buttons[8]); + + _buttons[0].signal_clicked().connect(sigc::mem_fun(*this, &AnchorSelector::btn_tl_activated)); + _buttons[1].signal_clicked().connect(sigc::mem_fun(*this, &AnchorSelector::btn_t_activated)); + _buttons[2].signal_clicked().connect(sigc::mem_fun(*this, &AnchorSelector::btn_tr_activated)); + _buttons[3].signal_clicked().connect(sigc::mem_fun(*this, &AnchorSelector::btn_l_activated)); + _buttons[4].signal_clicked().connect(sigc::mem_fun(*this, &AnchorSelector::btn_c_activated)); + _buttons[5].signal_clicked().connect(sigc::mem_fun(*this, &AnchorSelector::btn_r_activated)); + _buttons[6].signal_clicked().connect(sigc::mem_fun(*this, &AnchorSelector::btn_bl_activated)); + _buttons[7].signal_clicked().connect(sigc::mem_fun(*this, &AnchorSelector::btn_b_activated)); + _buttons[8].signal_clicked().connect(sigc::mem_fun(*this, &AnchorSelector::btn_br_activated)); + + for(int i = 0; i < 9; ++i) { + _container.attach(_buttons[i], i % 3, i % 3+1, i / 3, i / 3+1, Gtk::FILL, Gtk::FILL); + } + _selection = 4; + _buttons[4].set_active(); + + this->add(_container); +} + +AnchorSelector::~AnchorSelector() +{ + // TODO Auto-generated destructor stub +} + +void AnchorSelector::btn_activated(int index) +{ + if(_buttons[index].get_active()) + { + std::cout << "btn_activated(" << index << ", old=" << _selection << ");" << std::endl; + if(index != _selection) + { + _buttons[_selection].set_active(false); + _buttons[index].set_active(); + _selection = index; + } else { + _buttons[index].set_active(); + } + } +} + +void AnchorSelector::btn_tl_activated() +{ + btn_activated(0); +} + +void AnchorSelector::btn_t_activated() +{ + btn_activated(1); +} + +void AnchorSelector::btn_tr_activated() +{ + btn_activated(2); +} + +void AnchorSelector::btn_l_activated() +{ + btn_activated(3); +} + +void AnchorSelector::btn_c_activated() +{ + btn_activated(4); +} + +void AnchorSelector::btn_r_activated() +{ + btn_activated(5); +} + +void AnchorSelector::btn_bl_activated() +{ + btn_activated(6); +} + +void AnchorSelector::btn_b_activated() +{ + btn_activated(7); +} + +void AnchorSelector::btn_br_activated() +{ + btn_activated(8); +} + + + diff --git a/src/ui/widget/anchor-selector.h b/src/ui/widget/anchor-selector.h new file mode 100644 index 000000000..c852a1a5d --- /dev/null +++ b/src/ui/widget/anchor-selector.h @@ -0,0 +1,37 @@ +/* + * anchor-selector.h + * + * Created on: Mar 22, 2012 + * Author: denis + */ + +#ifndef ANCHOR_SELECTOR_H_ +#define ANCHOR_SELECTOR_H_ + +#include + +class AnchorSelector : public Gtk::Alignment +{ +private: + Gtk::ToggleButton _buttons[9]; + int _selection; + Gtk::Table _container; + + void setupButton(const Glib::ustring &icon, Gtk::ToggleButton &button); + void btn_activated(int index); + void btn_tl_activated(); + void btn_t_activated(); + void btn_tr_activated(); + void btn_l_activated(); + void btn_c_activated(); + void btn_r_activated(); + void btn_bl_activated(); + void btn_b_activated(); + void btn_br_activated(); + +public: + AnchorSelector(); + virtual ~AnchorSelector(); +}; + +#endif /* ANCHOR_SELECTOR_H_ */ -- cgit v1.2.3 From 3f7eff8696693c9b946fe47c2831c8706bffb68d Mon Sep 17 00:00:00 2001 From: Denis Declara Date: Wed, 28 Mar 2012 17:44:47 +0200 Subject: Integrated the newly created Anchor-Selection-Widget with the existing "Rows and Columns" panel. Code still needs documentation and cleenup however. (bzr r11073.1.5) --- src/ui/dialog/tile.cpp | 56 +++++++++----------------- src/ui/dialog/tile.h | 25 ++---------- src/ui/widget/anchor-selector.cpp | 82 +++++++-------------------------------- src/ui/widget/anchor-selector.h | 19 ++++----- 4 files changed, 47 insertions(+), 135 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/tile.cpp b/src/ui/dialog/tile.cpp index 5ce41c716..4a5e9785f 100644 --- a/src/ui/dialog/tile.cpp +++ b/src/ui/dialog/tile.cpp @@ -517,39 +517,15 @@ void TileDialog::Spacing_button_changed() } /** - * changed Radio button in Vertical Align group. + * changed Anchor selection widget. */ -void TileDialog::VertAlign_changed() +void TileDialog::Align_changed() { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - if (VertTopRadioButton.get_active()) { - VertAlign = 0; - prefs->setInt("/dialogs/gridtiler/VertAlign", 0); - } else if (VertCentreRadioButton.get_active()){ - VertAlign = 1; - prefs->setInt("/dialogs/gridtiler/VertAlign", 1); - } else if (VertBotRadioButton.get_active()){ - VertAlign = 2; - prefs->setInt("/dialogs/gridtiler/VertAlign", 2); - } -} - -/** - * changed Radio button in Vertical Align group. - */ -void TileDialog::HorizAlign_changed() -{ - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - if (HorizLeftRadioButton.get_active()) { - HorizAlign = 0; - prefs->setInt("/dialogs/gridtiler/HorizAlign", 0); - } else if (HorizCentreRadioButton.get_active()){ - HorizAlign = 1; - prefs->setInt("/dialogs/gridtiler/HorizAlign", 1); - } else if (HorizRightRadioButton.get_active()){ - HorizAlign = 2; - prefs->setInt("/dialogs/gridtiler/HorizAlign", 2); - } + VertAlign = AlignmentSelector.getVerticalAlignment(); + prefs->setInt("/dialogs/gridtiler/VertAlign", VertAlign); + HorizAlign = AlignmentSelector.getHorizontalAlignment(); + prefs->setInt("/dialogs/gridtiler/HorizAlign", HorizAlign); } /** @@ -685,8 +661,8 @@ TileDialog::TileDialog() RowHeightButton.set_tooltip_text(_("If not set, each row has the height of the tallest object in it")); RowHeightButton.signal_toggled().connect(sigc::mem_fun(*this, &TileDialog::on_RowSize_checkbutton_changed)); - { - /*#### Radio buttons to control vertical alignment ####*/ +/* { + /*#### Radio buttons to control vertical alignment ####*//* VertAlignLabel.set_label(_("Align:")); VertAlignHBox.pack_start(VertAlignLabel, false, false, MARGIN); @@ -715,7 +691,7 @@ TileDialog::TileDialog() } VertAlignHBox.pack_start(VertAlignVBox, false, false, MARGIN); NoOfRowsBox.pack_start(VertAlignHBox, false, false, MARGIN); - } + }*/ SpinsHBox.pack_start(NoOfRowsBox, false, false, MARGIN); @@ -757,8 +733,8 @@ TileDialog::TileDialog() ColumnWidthButton.signal_toggled().connect(sigc::mem_fun(*this, &TileDialog::on_ColSize_checkbutton_changed)); - { - /*#### Radio buttons to control horizontal alignment ####*/ + /*{ + /*#### Radio buttons to control horizontal alignment ####*//* HorizAlignLabel.set_label(_("Align:")); HorizAlignVBox.pack_start(HorizAlignLabel, false, false, MARGIN); @@ -791,12 +767,18 @@ TileDialog::TileDialog() } HorizAlignVBox.pack_start(HorizAlignHBox, false, false, MARGIN); NoOfColsBox.pack_start(HorizAlignVBox, false, false, MARGIN); - } + }*/ SpinsHBox.pack_start(NoOfColsBox, false, false, MARGIN); TileBox.pack_start(SpinsHBox, false, false, MARGIN); - TileBox.pack_start(anchorSelector); + + + // Anchor selection widget + AlignLabel.set_label("Alignment:"); + AlignmentSelector.on_selectionChanged().connect(sigc::mem_fun(*this, &TileDialog::Align_changed)); + TileBox.pack_start(AlignLabel, false, false, MARGIN); + TileBox.pack_start(AlignmentSelector, true, false, MARGIN); { /*#### Radio buttons to control spacing manually or to fit selection bbox ####*/ diff --git a/src/ui/dialog/tile.h b/src/ui/dialog/tile.h index f1493664d..b3bf390b6 100644 --- a/src/ui/dialog/tile.h +++ b/src/ui/dialog/tile.h @@ -67,8 +67,7 @@ public: void on_rowSize_spinbutton_changed(); void on_colSize_spinbutton_changed(); void Spacing_button_changed(); - void VertAlign_changed(); - void HorizAlign_changed(); + void Align_changed(); static TileDialog& getInstance() { return *new TileDialog(); } @@ -79,8 +78,6 @@ private: bool userHidden; bool updating; - AnchorSelector anchorSelector; - Gtk::Notebook notebook; Gtk::VBox TileBox; @@ -112,24 +109,10 @@ private: bool AutoColSize; Gtk::CheckButton ColumnWidthButton; - // Vertical align - Gtk::Label VertAlignLabel; - Gtk::HBox VertAlignHBox; - Gtk::VBox VertAlignVBox; - Gtk::RadioButtonGroup VertAlignGroup; - Gtk::RadioButton VertCentreRadioButton; - Gtk::RadioButton VertTopRadioButton; - Gtk::RadioButton VertBotRadioButton; + // Alignment + Gtk::Label AlignLabel; + AnchorSelector AlignmentSelector; double VertAlign; - - // Horizontal align - Gtk::Label HorizAlignLabel; - Gtk::VBox HorizAlignVBox; - Gtk::HBox HorizAlignHBox; - Gtk::RadioButtonGroup HorizAlignGroup; - Gtk::RadioButton HorizCentreRadioButton; - Gtk::RadioButton HorizLeftRadioButton; - Gtk::RadioButton HorizRightRadioButton; double HorizAlign; Inkscape::UI::Widget::ScalarUnit XPadding; diff --git a/src/ui/widget/anchor-selector.cpp b/src/ui/widget/anchor-selector.cpp index f32346436..aa173e0a0 100644 --- a/src/ui/widget/anchor-selector.cpp +++ b/src/ui/widget/anchor-selector.cpp @@ -3,6 +3,8 @@ * * Created on: Mar 22, 2012 * Author: denis + * + * Released under GNU GPL. Read the file 'COPYING' for more information. */ #include @@ -34,17 +36,9 @@ AnchorSelector::AnchorSelector() setupButton(INKSCAPE_ICON("boundingbox_bottom"), _buttons[7]); setupButton(INKSCAPE_ICON("boundingbox_bottom_right"), _buttons[8]); - _buttons[0].signal_clicked().connect(sigc::mem_fun(*this, &AnchorSelector::btn_tl_activated)); - _buttons[1].signal_clicked().connect(sigc::mem_fun(*this, &AnchorSelector::btn_t_activated)); - _buttons[2].signal_clicked().connect(sigc::mem_fun(*this, &AnchorSelector::btn_tr_activated)); - _buttons[3].signal_clicked().connect(sigc::mem_fun(*this, &AnchorSelector::btn_l_activated)); - _buttons[4].signal_clicked().connect(sigc::mem_fun(*this, &AnchorSelector::btn_c_activated)); - _buttons[5].signal_clicked().connect(sigc::mem_fun(*this, &AnchorSelector::btn_r_activated)); - _buttons[6].signal_clicked().connect(sigc::mem_fun(*this, &AnchorSelector::btn_bl_activated)); - _buttons[7].signal_clicked().connect(sigc::mem_fun(*this, &AnchorSelector::btn_b_activated)); - _buttons[8].signal_clicked().connect(sigc::mem_fun(*this, &AnchorSelector::btn_br_activated)); - for(int i = 0; i < 9; ++i) { + _buttons[i].signal_clicked().connect( + sigc::bind(sigc::mem_fun(*this, &AnchorSelector::btn_activated), i)); _container.attach(_buttons[i], i % 3, i % 3+1, i / 3, i / 3+1, Gtk::FILL, Gtk::FILL); } _selection = 4; @@ -60,64 +54,16 @@ AnchorSelector::~AnchorSelector() void AnchorSelector::btn_activated(int index) { - if(_buttons[index].get_active()) + + if(_selection == index && _buttons[index].get_active() == false) { - std::cout << "btn_activated(" << index << ", old=" << _selection << ");" << std::endl; - if(index != _selection) - { - _buttons[_selection].set_active(false); - _buttons[index].set_active(); - _selection = index; - } else { - _buttons[index].set_active(); - } + _buttons[index].set_active(true); + } + else if(_selection != index && _buttons[index].get_active()) + { + int old_selection = _selection; + _selection = index; + _buttons[old_selection].set_active(false); + _selectionChanged.emit(); } } - -void AnchorSelector::btn_tl_activated() -{ - btn_activated(0); -} - -void AnchorSelector::btn_t_activated() -{ - btn_activated(1); -} - -void AnchorSelector::btn_tr_activated() -{ - btn_activated(2); -} - -void AnchorSelector::btn_l_activated() -{ - btn_activated(3); -} - -void AnchorSelector::btn_c_activated() -{ - btn_activated(4); -} - -void AnchorSelector::btn_r_activated() -{ - btn_activated(5); -} - -void AnchorSelector::btn_bl_activated() -{ - btn_activated(6); -} - -void AnchorSelector::btn_b_activated() -{ - btn_activated(7); -} - -void AnchorSelector::btn_br_activated() -{ - btn_activated(8); -} - - - diff --git a/src/ui/widget/anchor-selector.h b/src/ui/widget/anchor-selector.h index c852a1a5d..ad20bf063 100644 --- a/src/ui/widget/anchor-selector.h +++ b/src/ui/widget/anchor-selector.h @@ -3,6 +3,8 @@ * * Created on: Mar 22, 2012 * Author: denis + * + * Released under GNU GPL. Read the file 'COPYING' for more information. */ #ifndef ANCHOR_SELECTOR_H_ @@ -17,19 +19,18 @@ private: int _selection; Gtk::Table _container; + sigc::signal _selectionChanged; + void setupButton(const Glib::ustring &icon, Gtk::ToggleButton &button); void btn_activated(int index); - void btn_tl_activated(); - void btn_t_activated(); - void btn_tr_activated(); - void btn_l_activated(); - void btn_c_activated(); - void btn_r_activated(); - void btn_bl_activated(); - void btn_b_activated(); - void btn_br_activated(); public: + + int getHorizontalAlignment() { return _selection % 3; } + int getVerticalAlignment() { return _selection / 3; } + + sigc::signal &on_selectionChanged() { return _selectionChanged; } + AnchorSelector(); virtual ~AnchorSelector(); }; -- cgit v1.2.3 From f31125febfcaf661ffb7227081b72da399440730 Mon Sep 17 00:00:00 2001 From: Denis Declara Date: Thu, 29 Mar 2012 18:31:07 +0200 Subject: Removed some commented code, which i replaced, and is therefore no longer used. (bzr r11073.1.7) --- src/ui/dialog/tile.cpp | 69 -------------------------------------------------- 1 file changed, 69 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/tile.cpp b/src/ui/dialog/tile.cpp index 4a5e9785f..4c83c7be0 100644 --- a/src/ui/dialog/tile.cpp +++ b/src/ui/dialog/tile.cpp @@ -661,38 +661,6 @@ TileDialog::TileDialog() RowHeightButton.set_tooltip_text(_("If not set, each row has the height of the tallest object in it")); RowHeightButton.signal_toggled().connect(sigc::mem_fun(*this, &TileDialog::on_RowSize_checkbutton_changed)); -/* { - /*#### Radio buttons to control vertical alignment ####*//* - - VertAlignLabel.set_label(_("Align:")); - VertAlignHBox.pack_start(VertAlignLabel, false, false, MARGIN); - - VertTopRadioButton.signal_toggled().connect(sigc::mem_fun(*this, &TileDialog::VertAlign_changed)); - VertAlignGroup = VertTopRadioButton.get_group(); - VertAlignVBox.pack_start(VertTopRadioButton, false, false, 0); - - VertCentreRadioButton.set_group(VertAlignGroup); - VertCentreRadioButton.signal_toggled().connect(sigc::mem_fun(*this, &TileDialog::VertAlign_changed)); - VertAlignVBox.pack_start(VertCentreRadioButton, false, false, 0); - - VertBotRadioButton.set_group(VertAlignGroup); - VertBotRadioButton.signal_toggled().connect(sigc::mem_fun(*this, &TileDialog::VertAlign_changed)); - VertAlignVBox.pack_start(VertBotRadioButton, false, false, 0); - - VertAlign = prefs->getInt("/dialogs/gridtiler/VertAlign", 1); - if (VertAlign == 0) { - VertTopRadioButton.set_active(TRUE); - } - else if (VertAlign == 1) { - VertCentreRadioButton.set_active(TRUE); - } - else if (VertAlign == 2){ - VertBotRadioButton.set_active(TRUE); - } - VertAlignHBox.pack_start(VertAlignVBox, false, false, MARGIN); - NoOfRowsBox.pack_start(VertAlignHBox, false, false, MARGIN); - }*/ - SpinsHBox.pack_start(NoOfRowsBox, false, false, MARGIN); @@ -732,43 +700,6 @@ TileDialog::TileDialog() ColumnWidthButton.set_tooltip_text(_("If not set, each column has the width of the widest object in it")); ColumnWidthButton.signal_toggled().connect(sigc::mem_fun(*this, &TileDialog::on_ColSize_checkbutton_changed)); - - /*{ - /*#### Radio buttons to control horizontal alignment ####*//* - - HorizAlignLabel.set_label(_("Align:")); - HorizAlignVBox.pack_start(HorizAlignLabel, false, false, MARGIN); - - HorizAlignHBox.pack_start(*(new Gtk::HBox()), true, true, 0); // centering strut - - HorizLeftRadioButton.signal_toggled().connect(sigc::mem_fun(*this, &TileDialog::HorizAlign_changed)); - HorizAlignGroup = HorizLeftRadioButton.get_group(); - HorizAlignHBox.pack_start(HorizLeftRadioButton, false, false, 0); - - HorizCentreRadioButton.set_group(HorizAlignGroup); - HorizCentreRadioButton.signal_toggled().connect(sigc::mem_fun(*this, &TileDialog::HorizAlign_changed)); - HorizAlignHBox.pack_start(HorizCentreRadioButton, false, false, 0); - - HorizRightRadioButton.set_group(HorizAlignGroup); - HorizRightRadioButton.signal_toggled().connect(sigc::mem_fun(*this, &TileDialog::HorizAlign_changed)); - HorizAlignHBox.pack_start(HorizRightRadioButton, false, false, 0); - - HorizAlignHBox.pack_start(*(new Gtk::HBox()), true, true, 0); // centering strut - - HorizAlign = prefs->getInt("/dialogs/gridtiler/HorizAlign", 1); - if (HorizAlign == 0) { - HorizLeftRadioButton.set_active(TRUE); - } - else if (HorizAlign == 1) { - HorizCentreRadioButton.set_active(TRUE); - } - else if (HorizAlign == 2) { - HorizRightRadioButton.set_active(TRUE); - } - HorizAlignVBox.pack_start(HorizAlignHBox, false, false, MARGIN); - NoOfColsBox.pack_start(HorizAlignVBox, false, false, MARGIN); - }*/ - SpinsHBox.pack_start(NoOfColsBox, false, false, MARGIN); TileBox.pack_start(SpinsHBox, false, false, MARGIN); -- cgit v1.2.3 From dc6fcf4ec96d4f4345ad86b1940d4b31d6771a0f Mon Sep 17 00:00:00 2001 From: Denis Declara Date: Sat, 31 Mar 2012 15:20:19 +0200 Subject: Brought old code, "Rows and Columns" in it's own class. Added a separate class for the panel. Still some cleanup to do. (bzr r11073.1.8) --- src/ui/dialog/dialog-manager.cpp | 4 +- src/ui/dialog/tile.cpp | 98 ++++++++++++++++++++++++++-------------- src/ui/dialog/tile.h | 56 +++++++++++++++++++---- 3 files changed, 112 insertions(+), 46 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/dialog-manager.cpp b/src/ui/dialog/dialog-manager.cpp index 60011ca9d..746cfc1b4 100644 --- a/src/ui/dialog/dialog-manager.cpp +++ b/src/ui/dialog/dialog-manager.cpp @@ -121,7 +121,7 @@ DialogManager::DialogManager() { registerFactory("SvgFontsDialog", &create); #endif registerFactory("Swatches", &create); - registerFactory("TileDialog", &create); + registerFactory("TileDialog", &create); registerFactory("Trace", &create); registerFactory("Transformation", &create); registerFactory("UndoHistory", &create); @@ -156,7 +156,7 @@ DialogManager::DialogManager() { registerFactory("SvgFontsDialog", &create); #endif registerFactory("Swatches", &create); - registerFactory("TileDialog", &create); + registerFactory("TileDialog", &create); registerFactory("Trace", &create); registerFactory("Transformation", &create); registerFactory("UndoHistory", &create); diff --git a/src/ui/dialog/tile.cpp b/src/ui/dialog/tile.cpp index 4c83c7be0..9297b5154 100644 --- a/src/ui/dialog/tile.cpp +++ b/src/ui/dialog/tile.cpp @@ -109,6 +109,34 @@ namespace Inkscape { namespace UI { namespace Dialog { +ArrangeDialog::ArrangeDialog() + : UI::Widget::Panel("", "/dialogs/gridtiler", SP_VERB_SELECTION_GRIDTILE), + _gridArrangeTab(new GridArrangeTab(this)) +{ + Gtk::Box *contents = this->_getContents(); + + _notebook.append_page(*_gridArrangeTab, C_("Arrange dialog", "Rectangular grid")); + _arrangeBox.pack_start(_notebook); + + _arrangeButton = this->addResponseButton(C_("Arrange dialog","_Arrange"), GTK_RESPONSE_APPLY); + _arrangeButton->set_use_underline(true); + _arrangeButton->set_tooltip_text(_("Arrange selected objects")); + _arrangeBox.pack_start(*_arrangeButton); + contents->pack_start(_arrangeBox); + show_all_children(); +} + +void ArrangeDialog::_apply() +{ + switch(_notebook.get_current_page()) + { + case 0: + _gridArrangeTab->arrange(); + break; + } +} + + //######################################################################### //## E V E N T S @@ -120,7 +148,7 @@ namespace Dialog { * */ -void TileDialog::Grid_Arrange () +void GridArrangeTab::arrange() { int cnt,row_cnt,col_cnt,a,row,col; @@ -159,7 +187,7 @@ void TileDialog::Grid_Arrange () grid_left = 99999; grid_top = 99999; - SPDesktop *desktop = getDesktop(); + SPDesktop *desktop = Parent->getDesktop(); sp_desktop_document(desktop)->ensureUpToDate(); Inkscape::Selection *selection = sp_desktop_selection (desktop); @@ -356,16 +384,16 @@ g_print("\n row = %f col = %f selection x= %f selection y = %f", total_row_h //######################################################################### -void TileDialog::_apply() +void GridArrangeTab::_apply() { - Grid_Arrange(); + arrange(); } /** * changed value in # of columns spinbox. */ -void TileDialog::on_row_spinbutton_changed() +void GridArrangeTab::on_row_spinbutton_changed() { // quit if run by the attr_changed listener if (updating) { @@ -374,7 +402,7 @@ void TileDialog::on_row_spinbutton_changed() // in turn, prevent listener from responding updating = true; - SPDesktop *desktop = getDesktop(); + SPDesktop *desktop = Parent->getDesktop(); Inkscape::Selection *selection = desktop ? desktop->selection : 0; g_return_if_fail( selection ); @@ -392,7 +420,7 @@ void TileDialog::on_row_spinbutton_changed() /** * changed value in # of rows spinbox. */ -void TileDialog::on_col_spinbutton_changed() +void GridArrangeTab::on_col_spinbutton_changed() { // quit if run by the attr_changed listener if (updating) { @@ -401,7 +429,7 @@ void TileDialog::on_col_spinbutton_changed() // in turn, prevent listener from responding updating = true; - SPDesktop *desktop = getDesktop(); + SPDesktop *desktop = Parent->getDesktop(); Inkscape::Selection *selection = desktop ? desktop->selection : 0; g_return_if_fail(selection); @@ -419,7 +447,7 @@ void TileDialog::on_col_spinbutton_changed() /** * changed value in x padding spinbox. */ -void TileDialog::on_xpad_spinbutton_changed() +void GridArrangeTab::on_xpad_spinbutton_changed() { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setDouble("/dialogs/gridtiler/XPad", XPadding.getValue("px")); @@ -429,7 +457,7 @@ void TileDialog::on_xpad_spinbutton_changed() /** * changed value in y padding spinbox. */ -void TileDialog::on_ypad_spinbutton_changed() +void GridArrangeTab::on_ypad_spinbutton_changed() { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setDouble("/dialogs/gridtiler/YPad", YPadding.getValue("px")); @@ -439,7 +467,7 @@ void TileDialog::on_ypad_spinbutton_changed() /** * checked/unchecked autosize Rows button. */ -void TileDialog::on_RowSize_checkbutton_changed() +void GridArrangeTab::on_RowSize_checkbutton_changed() { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (RowHeightButton.get_active()) { @@ -453,7 +481,7 @@ void TileDialog::on_RowSize_checkbutton_changed() /** * checked/unchecked autosize Rows button. */ -void TileDialog::on_ColSize_checkbutton_changed() +void GridArrangeTab::on_ColSize_checkbutton_changed() { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (ColumnWidthButton.get_active()) { @@ -467,7 +495,7 @@ void TileDialog::on_ColSize_checkbutton_changed() /** * changed value in columns spinbox. */ -void TileDialog::on_rowSize_spinbutton_changed() +void GridArrangeTab::on_rowSize_spinbutton_changed() { // quit if run by the attr_changed listener if (updating) { @@ -485,7 +513,7 @@ void TileDialog::on_rowSize_spinbutton_changed() /** * changed value in rows spinbox. */ -void TileDialog::on_colSize_spinbutton_changed() +void GridArrangeTab::on_colSize_spinbutton_changed() { // quit if run by the attr_changed listener if (updating) { @@ -503,7 +531,7 @@ void TileDialog::on_colSize_spinbutton_changed() /** * changed Radio button in Spacing group. */ -void TileDialog::Spacing_button_changed() +void GridArrangeTab::Spacing_button_changed() { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (SpaceManualRadioButton.get_active()) { @@ -519,7 +547,7 @@ void TileDialog::Spacing_button_changed() /** * changed Anchor selection widget. */ -void TileDialog::Align_changed() +void GridArrangeTab::Align_changed() { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); VertAlign = AlignmentSelector.getVerticalAlignment(); @@ -531,7 +559,7 @@ void TileDialog::Align_changed() /** * Desktop selection changed */ -void TileDialog::updateSelection() +void GridArrangeTab::updateSelection() { // quit if run by the attr_changed listener if (updating) { @@ -541,7 +569,7 @@ void TileDialog::updateSelection() Inkscape::Preferences *prefs = Inkscape::Preferences::get(); // in turn, prevent listener from responding updating = true; - SPDesktop *desktop = getDesktop(); + SPDesktop *desktop = Parent->getDesktop(); Inkscape::Selection *selection = desktop ? desktop->selection : 0; GSList const *items = selection ? selection->itemList() : 0; @@ -577,7 +605,7 @@ void TileDialog::updateSelection() ## Experimental ##########################*/ -static void updateSelectionCallback(Inkscape::Application */*inkscape*/, Inkscape::Selection */*selection*/, TileDialog *dlg) +static void updateSelectionCallback(Inkscape::Application */*inkscape*/, Inkscape::Selection */*selection*/, GridArrangeTab *dlg) { dlg->updateSelection(); } @@ -589,8 +617,8 @@ static void updateSelectionCallback(Inkscape::Application */*inkscape*/, Inkscap /** * Constructor */ -TileDialog::TileDialog() - : UI::Widget::Panel("", "/dialogs/gridtiler", SP_VERB_SELECTION_GRIDTILE), +GridArrangeTab::GridArrangeTab(ArrangeDialog *parent) + : Parent(parent), XPadding(_("X:"), _("Horizontal spacing between columns."), UNIT_TYPE_LINEAR, "", "object-columns"), YPadding(_("Y:"), _("Vertical spacing between rows."), XPadding, "", "object-rows") { @@ -608,13 +636,13 @@ TileDialog::TileDialog() g_signal_connect ( G_OBJECT (INKSCAPE), "change_selection", G_CALLBACK (updateSelectionCallback), this); } - Gtk::Box *contents = _getContents(); + Gtk::Box *contents = this; #define MARGIN 2 //##Set up the panel - SPDesktop *desktop = getDesktop(); + SPDesktop *desktop = Parent->getDesktop(); Inkscape::Selection *selection = desktop ? desktop->selection : 0; g_return_if_fail( selection ); @@ -642,7 +670,7 @@ TileDialog::TileDialog() NoOfRowsSpinner.set_increments(1, 0); NoOfRowsSpinner.set_range(1.0, 10000.0); NoOfRowsSpinner.set_value(PerCol); - NoOfRowsSpinner.signal_changed().connect(sigc::mem_fun(*this, &TileDialog::on_col_spinbutton_changed)); + NoOfRowsSpinner.signal_changed().connect(sigc::mem_fun(*this, &GridArrangeTab::on_col_spinbutton_changed)); NoOfRowsSpinner.set_tooltip_text(_("Number of rows")); NoOfRowsBox.pack_start(NoOfRowsSpinner, false, false, MARGIN); gtk_size_group_add_widget(_col1, (GtkWidget *) NoOfRowsBox.gobj()); @@ -659,7 +687,7 @@ TileDialog::TileDialog() NoOfRowsBox.pack_start(RowHeightButton, false, false, MARGIN); RowHeightButton.set_tooltip_text(_("If not set, each row has the height of the tallest object in it")); - RowHeightButton.signal_toggled().connect(sigc::mem_fun(*this, &TileDialog::on_RowSize_checkbutton_changed)); + RowHeightButton.signal_toggled().connect(sigc::mem_fun(*this, &GridArrangeTab::on_RowSize_checkbutton_changed)); SpinsHBox.pack_start(NoOfRowsBox, false, false, MARGIN); @@ -682,7 +710,7 @@ TileDialog::TileDialog() NoOfColsSpinner.set_increments(1, 0); NoOfColsSpinner.set_range(1.0, 10000.0); NoOfColsSpinner.set_value(PerRow); - NoOfColsSpinner.signal_changed().connect(sigc::mem_fun(*this, &TileDialog::on_row_spinbutton_changed)); + NoOfColsSpinner.signal_changed().connect(sigc::mem_fun(*this, &GridArrangeTab::on_row_spinbutton_changed)); NoOfColsSpinner.set_tooltip_text(_("Number of columns")); NoOfColsBox.pack_start(NoOfColsSpinner, false, false, MARGIN); gtk_size_group_add_widget(_col3, (GtkWidget *) NoOfColsBox.gobj()); @@ -698,7 +726,7 @@ TileDialog::TileDialog() NoOfColsBox.pack_start(ColumnWidthButton, false, false, MARGIN); ColumnWidthButton.set_tooltip_text(_("If not set, each column has the width of the widest object in it")); - ColumnWidthButton.signal_toggled().connect(sigc::mem_fun(*this, &TileDialog::on_ColSize_checkbutton_changed)); + ColumnWidthButton.signal_toggled().connect(sigc::mem_fun(*this, &GridArrangeTab::on_ColSize_checkbutton_changed)); SpinsHBox.pack_start(NoOfColsBox, false, false, MARGIN); @@ -707,7 +735,7 @@ TileDialog::TileDialog() // Anchor selection widget AlignLabel.set_label("Alignment:"); - AlignmentSelector.on_selectionChanged().connect(sigc::mem_fun(*this, &TileDialog::Align_changed)); + AlignmentSelector.on_selectionChanged().connect(sigc::mem_fun(*this, &GridArrangeTab::Align_changed)); TileBox.pack_start(AlignLabel, false, false, MARGIN); TileBox.pack_start(AlignmentSelector, true, false, MARGIN); @@ -715,7 +743,7 @@ TileDialog::TileDialog() /*#### Radio buttons to control spacing manually or to fit selection bbox ####*/ SpaceByBBoxRadioButton.set_label(_("_Fit into selection box")); SpaceByBBoxRadioButton.set_use_underline (true); - SpaceByBBoxRadioButton.signal_toggled().connect(sigc::mem_fun(*this, &TileDialog::Spacing_button_changed)); + SpaceByBBoxRadioButton.signal_toggled().connect(sigc::mem_fun(*this, &GridArrangeTab::Spacing_button_changed)); SpacingGroup = SpaceByBBoxRadioButton.get_group(); SpacingVBox.pack_start(SpaceByBBoxRadioButton, false, false, MARGIN); @@ -723,7 +751,7 @@ TileDialog::TileDialog() SpaceManualRadioButton.set_label(_("_Set spacing:")); SpaceManualRadioButton.set_use_underline (true); SpaceManualRadioButton.set_group(SpacingGroup); - SpaceManualRadioButton.signal_toggled().connect(sigc::mem_fun(*this, &TileDialog::Spacing_button_changed)); + SpaceManualRadioButton.signal_toggled().connect(sigc::mem_fun(*this, &GridArrangeTab::Spacing_button_changed)); SpacingVBox.pack_start(SpaceManualRadioButton, false, false, MARGIN); TileBox.pack_start(SpacingVBox, false, false, MARGIN); @@ -737,7 +765,7 @@ TileDialog::TileDialog() YPadding.setRange(-10000, 10000); double yPad = prefs->getDouble("/dialogs/gridtiler/YPad", 15); YPadding.setValue(yPad, "px"); - YPadding.signal_value_changed().connect(sigc::mem_fun(*this, &TileDialog::on_ypad_spinbutton_changed)); + YPadding.signal_value_changed().connect(sigc::mem_fun(*this, &GridArrangeTab::on_ypad_spinbutton_changed)); XPadding.setDigits(5); XPadding.setIncrements(0.2, 0); @@ -745,7 +773,7 @@ TileDialog::TileDialog() double xPad = prefs->getDouble("/dialogs/gridtiler/XPad", 15); XPadding.setValue(xPad, "px"); - XPadding.signal_value_changed().connect(sigc::mem_fun(*this, &TileDialog::on_xpad_spinbutton_changed)); + XPadding.signal_value_changed().connect(sigc::mem_fun(*this, &GridArrangeTab::on_xpad_spinbutton_changed)); } TileBox.pack_start(XPadding, false, false, MARGIN); TileBox.pack_start(YPadding, false, false, MARGIN); @@ -763,10 +791,10 @@ TileDialog::TileDialog() XPadding.set_sensitive (ManualSpacing); YPadding.set_sensitive (ManualSpacing); - //## The OK button - TileOkButton = addResponseButton(C_("Rows and columns dialog","_Arrange"), GTK_RESPONSE_APPLY); + //## The OK button FIXME + /*TileOkButton = addResponseButton(C_("Rows and columns dialog","_Arrange"), GTK_RESPONSE_APPLY); TileOkButton->set_use_underline(true); - TileOkButton->set_tooltip_text(_("Arrange selected objects")); + TileOkButton->set_tooltip_text(_("Arrange selected objects"));*/ show_all_children(); } diff --git a/src/ui/dialog/tile.h b/src/ui/dialog/tile.h index b3bf390b6..657841ad0 100644 --- a/src/ui/dialog/tile.h +++ b/src/ui/dialog/tile.h @@ -33,19 +33,58 @@ namespace Inkscape { namespace UI { namespace Dialog { +/** + * This interface should be implemented by each arrange mode. + * The class is a Gtk::VBox and will be displayed as a tab in + * the dialog + */ +class ArrangeTab : public Gtk::VBox +{ +public: + ArrangeTab() {}; + virtual ~ArrangeTab() {}; + + /** + * Do the actual work! + */ + virtual void arrange() = 0; +}; + +class GridArrangeTab; + +class ArrangeDialog : public UI::Widget::Panel { +private: + Gtk::VBox _arrangeBox; + Gtk::Notebook _notebook; + + GridArrangeTab *_gridArrangeTab; + + Gtk::Button *_arrangeButton; + +public: + ArrangeDialog(); + virtual ~ArrangeDialog() {}; + + /** + * Callback from Apply + */ + virtual void _apply(); + + static ArrangeDialog& getInstance() { return *new ArrangeDialog(); } +}; /** * Dialog for tiling an object */ -class TileDialog : public UI::Widget::Panel { +class GridArrangeTab : public ArrangeTab { public: - TileDialog() ; - virtual ~TileDialog() {}; + GridArrangeTab(ArrangeDialog *parent); + virtual ~GridArrangeTab() {}; /** * Do the actual work */ - void Grid_Arrange(); + virtual void arrange(); /** * Respond to selection change @@ -69,17 +108,16 @@ public: void Spacing_button_changed(); void Align_changed(); - static TileDialog& getInstance() { return *new TileDialog(); } private: - TileDialog(TileDialog const &d); // no copy - void operator=(TileDialog const &d); // no assign + GridArrangeTab(GridArrangeTab const &d); // no copy + void operator=(GridArrangeTab const &d); // no assign + + ArrangeDialog *Parent; bool userHidden; bool updating; - Gtk::Notebook notebook; - Gtk::VBox TileBox; Gtk::Button *TileOkButton; Gtk::Button *TileCancelButton; -- cgit v1.2.3 From 13a67ac44b1120308c2fc607715ddf0cf3d516e9 Mon Sep 17 00:00:00 2001 From: Denis Declara Date: Mon, 2 Apr 2012 12:08:22 +0200 Subject: Anchor widget now reads the last alignment from the settings. Anchor selection widget is also smaller now. (bzr r11073.1.10) --- src/ui/dialog/dialog-manager.cpp | 2 +- src/ui/dialog/tile.cpp | 4 ++++ src/ui/widget/anchor-selector.cpp | 11 ++++++++++- src/ui/widget/anchor-selector.h | 2 ++ 4 files changed, 17 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/dialog-manager.cpp b/src/ui/dialog/dialog-manager.cpp index 746cfc1b4..528ddf5b3 100644 --- a/src/ui/dialog/dialog-manager.cpp +++ b/src/ui/dialog/dialog-manager.cpp @@ -121,7 +121,7 @@ DialogManager::DialogManager() { registerFactory("SvgFontsDialog", &create); #endif registerFactory("Swatches", &create); - registerFactory("TileDialog", &create); + registerFactory("TileDialog", &create); registerFactory("Trace", &create); registerFactory("Transformation", &create); registerFactory("UndoHistory", &create); diff --git a/src/ui/dialog/tile.cpp b/src/ui/dialog/tile.cpp index 9297b5154..ab3781630 100644 --- a/src/ui/dialog/tile.cpp +++ b/src/ui/dialog/tile.cpp @@ -732,9 +732,13 @@ GridArrangeTab::GridArrangeTab(ArrangeDialog *parent) TileBox.pack_start(SpinsHBox, false, false, MARGIN); + VertAlign = prefs->getInt("/dialogs/gridtiler/VertAlign", 1); + HorizAlign = prefs->getInt("/dialogs/gridtiler/HorizAlign", 1); // Anchor selection widget AlignLabel.set_label("Alignment:"); + AlignLabel.set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER); + AlignmentSelector.setAlignment(HorizAlign, VertAlign); AlignmentSelector.on_selectionChanged().connect(sigc::mem_fun(*this, &GridArrangeTab::Align_changed)); TileBox.pack_start(AlignLabel, false, false, MARGIN); TileBox.pack_start(AlignmentSelector, true, false, MARGIN); diff --git a/src/ui/widget/anchor-selector.cpp b/src/ui/widget/anchor-selector.cpp index aa173e0a0..49387fc34 100644 --- a/src/ui/widget/anchor-selector.cpp +++ b/src/ui/widget/anchor-selector.cpp @@ -13,7 +13,7 @@ #include "ui/widget/anchor-selector.h" void AnchorSelector::setupButton(const Glib::ustring& icon, Gtk::ToggleButton& button) { - Gtk::Widget* buttonIcon = Gtk::manage(sp_icon_get_icon(icon, Inkscape::ICON_SIZE_LARGE_TOOLBAR)); + Gtk::Widget* buttonIcon = Gtk::manage(sp_icon_get_icon(icon, Inkscape::ICON_SIZE_SMALL_TOOLBAR)); buttonIcon->show(); button.set_relief(Gtk::RELIEF_NONE); @@ -67,3 +67,12 @@ void AnchorSelector::btn_activated(int index) _selectionChanged.emit(); } } + +void AnchorSelector::setAlignment(int horizontal, int vertical) +{ + int index = 3 * vertical + horizontal; + if(index >= 0 && index < 9) + { + _buttons[index].set_active(!_buttons[index].get_active()); + } +} diff --git a/src/ui/widget/anchor-selector.h b/src/ui/widget/anchor-selector.h index ad20bf063..361528d11 100644 --- a/src/ui/widget/anchor-selector.h +++ b/src/ui/widget/anchor-selector.h @@ -31,6 +31,8 @@ public: sigc::signal &on_selectionChanged() { return _selectionChanged; } + void setAlignment(int horizontal, int vertical); + AnchorSelector(); virtual ~AnchorSelector(); }; -- cgit v1.2.3 From 591b007232d0806995bc24c7dd93babdec283834 Mon Sep 17 00:00:00 2001 From: Denis Declara Date: Wed, 4 Apr 2012 08:42:22 +0200 Subject: Changed enum used for alignment, which hopefully will fix daily deb builds. (bzr r11073.1.11) --- src/ui/dialog/tile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/dialog/tile.cpp b/src/ui/dialog/tile.cpp index ab3781630..2e5e3f822 100644 --- a/src/ui/dialog/tile.cpp +++ b/src/ui/dialog/tile.cpp @@ -737,7 +737,7 @@ GridArrangeTab::GridArrangeTab(ArrangeDialog *parent) // Anchor selection widget AlignLabel.set_label("Alignment:"); - AlignLabel.set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER); + AlignLabel.set_alignment(Gtk::ALIGN_START, Gtk::ALIGN_CENTER); AlignmentSelector.setAlignment(HorizAlign, VertAlign); AlignmentSelector.on_selectionChanged().connect(sigc::mem_fun(*this, &GridArrangeTab::Align_changed)); TileBox.pack_start(AlignLabel, false, false, MARGIN); -- cgit v1.2.3 From e3102d923b09da811953f791fdaa1d0a01e13032 Mon Sep 17 00:00:00 2001 From: Denis Declara Date: Wed, 4 Apr 2012 11:08:28 +0200 Subject: Changed makefile (bzr r11073.1.12) --- src/ui/widget/Makefile_insert | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/ui/widget/Makefile_insert b/src/ui/widget/Makefile_insert index 4dc83a81d..718d95979 100644 --- a/src/ui/widget/Makefile_insert +++ b/src/ui/widget/Makefile_insert @@ -1,6 +1,8 @@ ## Makefile.am fragment sourced by src/Makefile.am. ink_common_sources += \ + ui/widget/anchor-selector.h \ + ui/widget/anchor-selector.cpp \ ui/widget/attr-widget.h \ ui/widget/button.h \ ui/widget/button.cpp \ -- cgit v1.2.3 From d35a809b15aa11aa5ee3c0a035710683e8c76eaa Mon Sep 17 00:00:00 2001 From: Denis Declara Date: Mon, 9 Apr 2012 22:12:58 +0200 Subject: Added initial gui for polar arrangement tab (bzr r11073.1.13) --- src/ui/dialog/tile.cpp | 53 ++++++++++++++++++++++++++++++++++++++++-------- src/ui/dialog/tile.h | 55 +++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 91 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/tile.cpp b/src/ui/dialog/tile.cpp index 2e5e3f822..0e3b24f7c 100644 --- a/src/ui/dialog/tile.cpp +++ b/src/ui/dialog/tile.cpp @@ -111,11 +111,13 @@ namespace Dialog { ArrangeDialog::ArrangeDialog() : UI::Widget::Panel("", "/dialogs/gridtiler", SP_VERB_SELECTION_GRIDTILE), - _gridArrangeTab(new GridArrangeTab(this)) + _gridArrangeTab(new GridArrangeTab(this)), + _polarArrangeTab(new PolarArrangeTab(this)) { Gtk::Box *contents = this->_getContents(); _notebook.append_page(*_gridArrangeTab, C_("Arrange dialog", "Rectangular grid")); + _notebook.append_page(*_polarArrangeTab, C_("Arrange dialog", "Polar Coordinates")); _arrangeBox.pack_start(_notebook); _arrangeButton = this->addResponseButton(C_("Arrange dialog","_Arrange"), GTK_RESPONSE_APPLY); @@ -133,9 +135,51 @@ void ArrangeDialog::_apply() case 0: _gridArrangeTab->arrange(); break; + case 1: + _polarArrangeTab->arrange(); + break; } } +PolarArrangeTab::PolarArrangeTab(ArrangeDialog *parent_) + : parent(parent_) +{ + anchorPointLabel.set_text("Anchor point:"); + anchorPointLabel.set_alignment(Gtk::ALIGN_START); + pack_start(anchorPointLabel, false, false); + + anchorBoundingBoxRadio.set_label("Object's bounding box:"); + anchorBoundingBoxRadio.set_group(anchorRadioGroup); + pack_start(anchorBoundingBoxRadio, false, false); + + pack_start(anchorSelector, false, false); + + anchorObjectPivotRadio.set_label("Object's rotational center"); + anchorObjectPivotRadio.set_group(anchorRadioGroup); + pack_start(anchorObjectPivotRadio, false, false); + + arrangeOnLabel.set_text("Arrange on:"); + arrangeOnLabel.set_alignment(Gtk::ALIGN_START); + pack_start(arrangeOnLabel, false, false); + + arrangeOnCircleRadio.set_label("Last selected circle/ellipse/arc"); + anchorObjectPivotRadio.set_group(arrangeRadioGroup); + pack_start(arrangeOnCircleRadio, false, false); + + arrangeOnParametersRadio.set_label("Parameterized:"); + anchorObjectPivotRadio.set_group(arrangeRadioGroup); + pack_start(arrangeOnParametersRadio, false, false); +} + +void PolarArrangeTab::arrange() +{ + std::cout << "PolarArrangeTab::arrange()" << std::endl; +} + +void PolarArrangeTab::updateSelection() +{ + +} //######################################################################### @@ -383,13 +427,6 @@ g_print("\n row = %f col = %f selection x= %f selection y = %f", total_row_h //## E V E N T S //######################################################################### - -void GridArrangeTab::_apply() -{ - arrange(); -} - - /** * changed value in # of columns spinbox. */ diff --git a/src/ui/dialog/tile.h b/src/ui/dialog/tile.h index 657841ad0..ab075fb28 100644 --- a/src/ui/dialog/tile.h +++ b/src/ui/dialog/tile.h @@ -51,15 +51,17 @@ public: }; class GridArrangeTab; +class PolarArrangeTab; class ArrangeDialog : public UI::Widget::Panel { private: - Gtk::VBox _arrangeBox; - Gtk::Notebook _notebook; + Gtk::VBox _arrangeBox; + Gtk::Notebook _notebook; - GridArrangeTab *_gridArrangeTab; + GridArrangeTab *_gridArrangeTab; + PolarArrangeTab *_polarArrangeTab; - Gtk::Button *_arrangeButton; + Gtk::Button *_arrangeButton; public: ArrangeDialog(); @@ -91,11 +93,6 @@ public: */ void updateSelection(); - /** - * Callback from Apply - */ - virtual void _apply(); - // Callbacks from spinbuttons void on_row_spinbutton_changed(); void on_col_spinbutton_changed(); @@ -176,6 +173,46 @@ private: Inkscape::UI::Widget::SpinButton ColumnWidthSpinner; }; +class PolarArrangeTab : public ArrangeTab { +public: + PolarArrangeTab(ArrangeDialog *parent_); + virtual ~PolarArrangeTab() {}; + + /** + * Do the actual work + */ + virtual void arrange(); + + /** + * Respond to selection change + */ + void updateSelection(); + +private: + PolarArrangeTab(PolarArrangeTab const &d); // no copy + void operator=(PolarArrangeTab const &d); // no assign + + ArrangeDialog *parent; + + Gtk::Label anchorPointLabel; + + Gtk::RadioButtonGroup anchorRadioGroup; + Gtk::RadioButton anchorBoundingBoxRadio; + Gtk::RadioButton anchorObjectPivotRadio; + AnchorSelector anchorSelector; + + Gtk::Label arrangeOnLabel; + + Gtk::RadioButtonGroup arrangeRadioGroup; + Gtk::RadioButton arrangeOnCircleRadio; + Gtk::RadioButton arrangeOnParametersRadio; + + Inkscape::UI::Widget::SpinButton centerXSpin; + Inkscape::UI::Widget::SpinButton centerYSpin; + + +}; + } //namespace Dialog } //namespace UI -- cgit v1.2.3 From ffef031f0c930b63abe89386ad7edfcff0469029 Mon Sep 17 00:00:00 2001 From: Denis Declara Date: Sun, 15 Apr 2012 14:27:18 +0200 Subject: Improved User interface. Added controls for Center, Radius and Angles. Note that none of them actually do something yet (bzr r11073.1.14) --- src/ui/dialog/tile.cpp | 31 +++++++++++++++++++++++++++---- src/ui/dialog/tile.h | 15 +++++++++++++-- 2 files changed, 40 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/tile.cpp b/src/ui/dialog/tile.cpp index 0e3b24f7c..dd49ac9eb 100644 --- a/src/ui/dialog/tile.cpp +++ b/src/ui/dialog/tile.cpp @@ -142,14 +142,21 @@ void ArrangeDialog::_apply() } PolarArrangeTab::PolarArrangeTab(ArrangeDialog *parent_) - : parent(parent_) + : parent(parent_), + parametersTable(3, 3, false), + centerY("", "Y coordinate of the center", UNIT_TYPE_LINEAR), + centerX("", "X coordinate of the center", centerY), + radiusY("", "Y coordinate of the radius", UNIT_TYPE_LINEAR), + radiusX("", "X coordinate of the radius", radiusY), + angleY("", "Starting angle", UNIT_TYPE_RADIAL), + angleX("", "End angle", angleY) { anchorPointLabel.set_text("Anchor point:"); anchorPointLabel.set_alignment(Gtk::ALIGN_START); pack_start(anchorPointLabel, false, false); anchorBoundingBoxRadio.set_label("Object's bounding box:"); - anchorBoundingBoxRadio.set_group(anchorRadioGroup); + anchorRadioGroup = anchorBoundingBoxRadio.get_group(); pack_start(anchorBoundingBoxRadio, false, false); pack_start(anchorSelector, false, false); @@ -163,12 +170,28 @@ PolarArrangeTab::PolarArrangeTab(ArrangeDialog *parent_) pack_start(arrangeOnLabel, false, false); arrangeOnCircleRadio.set_label("Last selected circle/ellipse/arc"); - anchorObjectPivotRadio.set_group(arrangeRadioGroup); + arrangeRadioGroup = arrangeOnCircleRadio.get_group(); pack_start(arrangeOnCircleRadio, false, false); arrangeOnParametersRadio.set_label("Parameterized:"); - anchorObjectPivotRadio.set_group(arrangeRadioGroup); + arrangeOnParametersRadio.set_group(arrangeRadioGroup); pack_start(arrangeOnParametersRadio, false, false); + + centerLabel.set_text("Center X/Y:"); + parametersTable.attach(centerLabel, 0, 1, 0, 1); + parametersTable.attach(centerX, 1, 2, 0, 1, Gtk::EXPAND); + parametersTable.attach(centerY, 2, 3, 0, 1, Gtk::EXPAND); + + radiusLabel.set_text("Radius X/Y:"); + parametersTable.attach(radiusLabel, 0, 1, 1, 2); + parametersTable.attach(radiusX, 1, 2, 1, 2, Gtk::EXPAND); + parametersTable.attach(radiusY, 2, 3, 1, 2, Gtk::EXPAND); + + angleLabel.set_text("Center X/Y:"); + parametersTable.attach(angleLabel, 0, 1, 2, 3); + parametersTable.attach(angleX, 1, 2, 2, 3, Gtk::EXPAND); + parametersTable.attach(angleY, 2, 3, 2, 3, Gtk::EXPAND); + pack_start(parametersTable, false, false); } void PolarArrangeTab::arrange() diff --git a/src/ui/dialog/tile.h b/src/ui/dialog/tile.h index ab075fb28..40352f90d 100644 --- a/src/ui/dialog/tile.h +++ b/src/ui/dialog/tile.h @@ -207,8 +207,19 @@ private: Gtk::RadioButton arrangeOnCircleRadio; Gtk::RadioButton arrangeOnParametersRadio; - Inkscape::UI::Widget::SpinButton centerXSpin; - Inkscape::UI::Widget::SpinButton centerYSpin; + Gtk::Table parametersTable; + + Gtk::Label centerLabel; + Inkscape::UI::Widget::ScalarUnit centerY; + Inkscape::UI::Widget::ScalarUnit centerX; + + Gtk::Label radiusLabel; + Inkscape::UI::Widget::ScalarUnit radiusY; + Inkscape::UI::Widget::ScalarUnit radiusX; + + Gtk::Label angleLabel; + Inkscape::UI::Widget::ScalarUnit angleY; + Inkscape::UI::Widget::ScalarUnit angleX; }; -- cgit v1.2.3 From 35b3c61da544c8e771078a015690d4311203bf84 Mon Sep 17 00:00:00 2001 From: Denis Declara Date: Sun, 15 Apr 2012 22:21:15 +0200 Subject: Added some POC code to move objects around (bzr r11073.1.16) --- src/ui/dialog/tile.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src') diff --git a/src/ui/dialog/tile.cpp b/src/ui/dialog/tile.cpp index dd49ac9eb..af2319411 100644 --- a/src/ui/dialog/tile.cpp +++ b/src/ui/dialog/tile.cpp @@ -197,6 +197,18 @@ PolarArrangeTab::PolarArrangeTab(ArrangeDialog *parent_) void PolarArrangeTab::arrange() { std::cout << "PolarArrangeTab::arrange()" << std::endl; + Inkscape::Selection *selection = sp_desktop_selection(parent->getDesktop()); + const GSList *items = selection->itemList(); + int i = 0; + while(items) + { + SPItem *item = SP_ITEM(items->data); + Geom::Point move = Geom::Point(100 * i, -100 * i); + Geom::Affine const affine = Geom::Affine(Geom::Translate(move)); + item->set_i2d_affine(affine); + items = items->next; + ++i; + } } void PolarArrangeTab::updateSelection() -- cgit v1.2.3 From 88a55277617ed0a8ded158fb212669e45f19ff1c Mon Sep 17 00:00:00 2001 From: Denis Declara Date: Mon, 16 Apr 2012 15:27:44 +0200 Subject: Edited include order (putting gtkmm in first place) in the hope that it will fix the compilation issues on launchpad. (bzr r11073.1.17) --- src/ui/widget/anchor-selector.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/widget/anchor-selector.cpp b/src/ui/widget/anchor-selector.cpp index 49387fc34..87f50cf5f 100644 --- a/src/ui/widget/anchor-selector.cpp +++ b/src/ui/widget/anchor-selector.cpp @@ -7,10 +7,10 @@ * Released under GNU GPL. Read the file 'COPYING' for more information. */ +#include "ui/widget/anchor-selector.h" #include #include "widgets/icon.h" #include "ui/icon-names.h" -#include "ui/widget/anchor-selector.h" void AnchorSelector::setupButton(const Glib::ustring& icon, Gtk::ToggleButton& button) { Gtk::Widget* buttonIcon = Gtk::manage(sp_icon_get_icon(icon, Inkscape::ICON_SIZE_SMALL_TOOLBAR)); -- cgit v1.2.3 From 610dc4491aefb2afc144cad45893bf5435168648 Mon Sep 17 00:00:00 2001 From: Denis Declara Date: Thu, 19 Apr 2012 16:12:26 +0200 Subject: Improved UI of PolarArrangement Tab and connected some widgets to events (now parts of the GUI disable themselves when needed) (bzr r11073.1.18) --- src/ui/dialog/tile.cpp | 78 ++++++++++++++++++++++++++++++++++++++++++++++---- src/ui/dialog/tile.h | 5 ++++ 2 files changed, 77 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/tile.cpp b/src/ui/dialog/tile.cpp index af2319411..9e2ba71c4 100644 --- a/src/ui/dialog/tile.cpp +++ b/src/ui/dialog/tile.cpp @@ -157,12 +157,14 @@ PolarArrangeTab::PolarArrangeTab(ArrangeDialog *parent_) anchorBoundingBoxRadio.set_label("Object's bounding box:"); anchorRadioGroup = anchorBoundingBoxRadio.get_group(); + anchorBoundingBoxRadio.signal_toggled().connect(sigc::mem_fun(*this, &PolarArrangeTab::on_anchor_radio_changed)); pack_start(anchorBoundingBoxRadio, false, false); pack_start(anchorSelector, false, false); anchorObjectPivotRadio.set_label("Object's rotational center"); anchorObjectPivotRadio.set_group(anchorRadioGroup); + anchorObjectPivotRadio.signal_toggled().connect(sigc::mem_fun(*this, &PolarArrangeTab::on_anchor_radio_changed)); pack_start(anchorObjectPivotRadio, false, false); arrangeOnLabel.set_text("Arrange on:"); @@ -171,27 +173,71 @@ PolarArrangeTab::PolarArrangeTab(ArrangeDialog *parent_) arrangeOnCircleRadio.set_label("Last selected circle/ellipse/arc"); arrangeRadioGroup = arrangeOnCircleRadio.get_group(); + arrangeOnCircleRadio.signal_toggled().connect(sigc::mem_fun(*this, &PolarArrangeTab::on_arrange_radio_changed)); pack_start(arrangeOnCircleRadio, false, false); arrangeOnParametersRadio.set_label("Parameterized:"); arrangeOnParametersRadio.set_group(arrangeRadioGroup); + arrangeOnParametersRadio.signal_toggled().connect(sigc::mem_fun(*this, &PolarArrangeTab::on_arrange_radio_changed)); pack_start(arrangeOnParametersRadio, false, false); + //FIXME: Objects in grid do not line up properly! centerLabel.set_text("Center X/Y:"); parametersTable.attach(centerLabel, 0, 1, 0, 1); - parametersTable.attach(centerX, 1, 2, 0, 1, Gtk::EXPAND); - parametersTable.attach(centerY, 2, 3, 0, 1, Gtk::EXPAND); + centerX.setDigits(2); + centerX.set_size_request(60, -1); + centerX.setIncrements(0.2, 0); + centerX.setRange(-10000, 10000); + centerX.setValue(0, "px"); + centerY.setDigits(2); + centerY.set_size_request(120, -1); + centerY.setIncrements(0.2, 0); + centerY.setRange(-10000, 10000); + centerY.setValue(0, "px"); + parametersTable.attach(centerX, 1, 2, 0, 1); + parametersTable.attach(centerY, 2, 3, 0, 1); radiusLabel.set_text("Radius X/Y:"); parametersTable.attach(radiusLabel, 0, 1, 1, 2); - parametersTable.attach(radiusX, 1, 2, 1, 2, Gtk::EXPAND); - parametersTable.attach(radiusY, 2, 3, 1, 2, Gtk::EXPAND); + radiusX.setDigits(2); + radiusX.set_size_request(60, -1); + radiusX.setIncrements(0.2, 0); + radiusX.setRange(-10000, 10000); + radiusX.setValue(0, "px"); + radiusY.setDigits(2); + radiusY.set_size_request(120, -1); + radiusY.setIncrements(0.2, 0); + radiusY.setRange(-10000, 10000); + radiusY.setValue(0, "px"); + parametersTable.attach(radiusX, 1, 2, 1, 2); + parametersTable.attach(radiusY, 2, 3, 1, 2); angleLabel.set_text("Center X/Y:"); parametersTable.attach(angleLabel, 0, 1, 2, 3); - parametersTable.attach(angleX, 1, 2, 2, 3, Gtk::EXPAND); - parametersTable.attach(angleY, 2, 3, 2, 3, Gtk::EXPAND); + angleX.setDigits(2); + angleX.set_size_request(60, -1); + angleX.setIncrements(0.2, 0); + angleX.setRange(-10000, 10000); + angleX.setValue(0, "°"); + angleY.setDigits(2); + angleY.set_size_request(120, -1); + angleY.setIncrements(0.2, 0); + angleY.setRange(-10000, 10000); + angleY.setValue(0, "°"); + parametersTable.attach(angleX, 1, 2, 2, 3); + parametersTable.attach(angleY, 2, 3, 2, 3); pack_start(parametersTable, false, false); + + rotateObjectsCheckBox.set_label("Rotate objects"); + rotateObjectsCheckBox.set_active(true); + pack_start(rotateObjectsCheckBox, false, false); + + centerX.set_sensitive(false); + centerY.set_sensitive(false); + angleX.set_sensitive(false); + angleY.set_sensitive(false); + radiusX.set_sensitive(false); + radiusY.set_sensitive(false); } void PolarArrangeTab::arrange() @@ -213,7 +259,27 @@ void PolarArrangeTab::arrange() void PolarArrangeTab::updateSelection() { +} + +void PolarArrangeTab::on_arrange_radio_changed() +{ + bool arrangeParametric = !arrangeOnCircleRadio.get_active(); + + centerX.set_sensitive(arrangeParametric); + centerY.set_sensitive(arrangeParametric); + + angleX.set_sensitive(arrangeParametric); + angleY.set_sensitive(arrangeParametric); + + radiusX.set_sensitive(arrangeParametric); + radiusY.set_sensitive(arrangeParametric); +} + +void PolarArrangeTab::on_anchor_radio_changed() +{ + bool anchorBoundingBox = anchorBoundingBoxRadio.get_active(); + anchorSelector.set_sensitive(anchorBoundingBox); } diff --git a/src/ui/dialog/tile.h b/src/ui/dialog/tile.h index 40352f90d..b09416d04 100644 --- a/src/ui/dialog/tile.h +++ b/src/ui/dialog/tile.h @@ -188,6 +188,9 @@ public: */ void updateSelection(); + void on_anchor_radio_changed(); + void on_arrange_radio_changed(); + private: PolarArrangeTab(PolarArrangeTab const &d); // no copy void operator=(PolarArrangeTab const &d); // no assign @@ -221,6 +224,8 @@ private: Inkscape::UI::Widget::ScalarUnit angleY; Inkscape::UI::Widget::ScalarUnit angleX; + Gtk::CheckButton rotateObjectsCheckBox; + }; -- cgit v1.2.3 From 64d1318049350136ae837f74c56bc5ad9a3c363c Mon Sep 17 00:00:00 2001 From: Denis Declara Date: Tue, 24 Apr 2012 22:24:04 +0200 Subject: Added first support for elliptical arrangements (bzr r11073.1.19) --- src/ui/dialog/tile.cpp | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/tile.cpp b/src/ui/dialog/tile.cpp index 9e2ba71c4..d4c597b84 100644 --- a/src/ui/dialog/tile.cpp +++ b/src/ui/dialog/tile.cpp @@ -34,6 +34,7 @@ #include "sp-item.h" #include "widgets/icon.h" #include "desktop.h" +#include "sp-item-transform.h" /* * Sort items by their x co-ordinates, taking account of y (keeps rows intact) @@ -249,9 +250,29 @@ void PolarArrangeTab::arrange() while(items) { SPItem *item = SP_ITEM(items->data); - Geom::Point move = Geom::Point(100 * i, -100 * i); - Geom::Affine const affine = Geom::Affine(Geom::Translate(move)); - item->set_i2d_affine(affine); + + float centerx = 1000; + float centery = 2000; + + float radiusx = 1000; + float radiusy = 2000; + + float objectx = - item->documentVisualBounds()->min()[Geom::X]; + float objecty = item->documentVisualBounds()->min()[Geom::Y]; + + float angle = M_PI / 36 * i; + + float r = (radiusx * radiusy) / + sqrtf(powf(radiusy * cos(angle), 2) + powf(radiusx * sin(angle), 2)); + float calcx = cos(angle) * r; + float calcy = sin(angle) * r; + + sp_item_move_rel(item, Geom::Translate(objectx + calcx, objecty + calcy)); + sp_item_rotate_rel(item, Geom::Rotate(angle)); + + //item->set_i2d_affine(item->i2dt_affine() * toOrigin * rotation); + //item->doWriteTransform(item->getRepr(), item->transform, NULL); + items = items->next; ++i; } -- cgit v1.2.3 From 3b4367f104ffcb7e07664dc711b8a879d1122dec Mon Sep 17 00:00:00 2001 From: Denis Declara Date: Fri, 27 Apr 2012 23:43:11 +0200 Subject: Code Refactoreing. Moved parts of the code from tile.cpp tile.h to arrangetab.h, gridarrangetab(.cpp|.h), polararrangetab(.cpp|.h) Also modified the name of the verb used by the "Rows and Columns" dialog to SP_VERB_SELECTION_ARRANGE (bzr r11073.1.21) --- src/desktop.cpp | 2 +- src/menus-skeleton.h | 2 +- src/ui/CMakeLists.txt | 5 + src/ui/dialog/arrangetab.h | 54 +++ src/ui/dialog/gridarrangetab.cpp | 786 ++++++++++++++++++++++++++++++++ src/ui/dialog/gridarrangetab.h | 147 ++++++ src/ui/dialog/polararrangetab.cpp | 206 +++++++++ src/ui/dialog/polararrangetab.h | 86 ++++ src/ui/dialog/tile.cpp | 914 +------------------------------------- src/ui/dialog/tile.h | 177 +------- src/verbs.cpp | 8 +- src/verbs.h | 2 +- 12 files changed, 1298 insertions(+), 1091 deletions(-) create mode 100644 src/ui/dialog/arrangetab.h create mode 100644 src/ui/dialog/gridarrangetab.cpp create mode 100644 src/ui/dialog/gridarrangetab.h create mode 100644 src/ui/dialog/polararrangetab.cpp create mode 100644 src/ui/dialog/polararrangetab.h (limited to 'src') diff --git a/src/desktop.cpp b/src/desktop.cpp index 7aabb1245..f7a060670 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -1827,7 +1827,7 @@ SPDesktop::show_dialogs() mapVerbPreference.insert(std::make_pair ((int)SP_VERB_DIALOG_SVG_FONTS, "/dialogs/svgfonts") ); mapVerbPreference.insert(std::make_pair ((int)SP_VERB_DIALOG_INPUT, "/dialogs/inputdevices") ); mapVerbPreference.insert(std::make_pair ((int)SP_VERB_DIALOG_DISPLAY, "/dialogs/preferences") ); - mapVerbPreference.insert(std::make_pair ((int)SP_VERB_SELECTION_GRIDTILE, "/dialogs/gridtiler") ); + mapVerbPreference.insert(std::make_pair ((int)SP_VERB_SELECTION_ARRANGE, "/dialogs/gridtiler") ); //FIXME: denis: change also preferences? mapVerbPreference.insert(std::make_pair ((int)SP_VERB_SELECTION_TRACE, "/dialogs/trace") ); mapVerbPreference.insert(std::make_pair ((int)SP_VERB_DIALOG_TEXT, "/dialogs/textandfont") ); mapVerbPreference.insert(std::make_pair ((int)SP_VERB_DIALOG_EXPORT, "/dialogs/export") ); diff --git a/src/menus-skeleton.h b/src/menus-skeleton.h index 84ecc83ea..459b3d378 100644 --- a/src/menus-skeleton.h +++ b/src/menus-skeleton.h @@ -210,7 +210,7 @@ static char const menus_skeleton[] = " \n" " \n" " \n" -" \n" +" \n" " \n" " \n" " \n" diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 2c6a68569..b244b7349 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -42,6 +42,7 @@ set(ui_SRC dialog/find.cpp dialog/floating-behavior.cpp dialog/glyphs.cpp + dialog/gridarrangetab.cpp dialog/guides.cpp dialog/icon-preview.cpp dialog/inkscape-preferences.cpp @@ -55,6 +56,7 @@ set(ui_SRC dialog/object-attributes.cpp dialog/object-properties.cpp dialog/ocaldialogs.cpp + dialog/polararrangetab.cpp dialog/print-colors-preview-dialog.cpp dialog/print.cpp dialog/scriptdialog.cpp @@ -132,6 +134,7 @@ set(ui_SRC dialog/aboutbox.h dialog/align-and-distribute.h + dialog/arrangetab.h dialog/behavior.h dialog/calligraphic-profile-rename.h dialog/color-item.h @@ -155,6 +158,7 @@ set(ui_SRC dialog/floating-behavior.h dialog/glyphs.h dialog/guides.h + dialog/gridarrangetab.h dialog/icon-preview.h dialog/inkscape-preferences.h dialog/input.h @@ -168,6 +172,7 @@ set(ui_SRC dialog/object-properties.h dialog/ocaldialogs.h dialog/panel-dialog.h + dialog/polararrangetab.h dialog/print-colors-preview-dialog.h dialog/print.h dialog/scriptdialog.h diff --git a/src/ui/dialog/arrangetab.h b/src/ui/dialog/arrangetab.h new file mode 100644 index 000000000..3ffe1ef4c --- /dev/null +++ b/src/ui/dialog/arrangetab.h @@ -0,0 +1,54 @@ +/** + * @brief Arrange tools base class + */ +/* Authors: + * * Declara Denis + * Copyright (C) 2012 Authors + * + * Released under GNU GPL. Read the file 'COPYING' for more information. + */ + +#ifndef INKSCAPE_UI_DIALOG_ARRANGE_TAB_H +#define INKSCAPE_UI_DIALOG_ARRANGE_TAB_H + +#include + +namespace Inkscape { +namespace UI { +namespace Dialog { + +/** + * This interface should be implemented by each arrange mode. + * The class is a Gtk::VBox and will be displayed as a tab in + * the dialog + */ +class ArrangeTab : public Gtk::VBox +{ +public: + ArrangeTab() {}; + virtual ~ArrangeTab() {}; + + /** + * Do the actual work! This method is invoked to actually arrange the + * selection + */ + virtual void arrange() = 0; +}; + +} //namespace Dialog +} //namespace UI +} //namespace Inkscape + + +#endif /* INKSCAPE_UI_DIALOG_ARRANGE_TAB_H */ + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/dialog/gridarrangetab.cpp b/src/ui/dialog/gridarrangetab.cpp new file mode 100644 index 000000000..fca7c5b0e --- /dev/null +++ b/src/ui/dialog/gridarrangetab.cpp @@ -0,0 +1,786 @@ +/* + * A simple dialog for creating grid type arrangements of selected objects + * + * Authors: + * Bob Jamison ( based off trace dialog) + * John Cliff + * Other dudes from The Inkscape Organization + * Abhishek Sharma + * Declara Denis + * + * Copyright (C) 2004 Bob Jamison + * Copyright (C) 2004 John Cliff + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ +//#define DEBUG_GRID_ARRANGE 1 + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include "ui/dialog/gridarrangetab.h" +#include //for GTK_RESPONSE* types +#include +#include +#include <2geom/transforms.h> + +#include "verbs.h" +#include "preferences.h" +#include "inkscape.h" +#include "desktop-handles.h" +#include "selection.h" +#include "document.h" +#include "document-undo.h" +#include "sp-item.h" +#include "widgets/icon.h" +#include "desktop.h" +//#include "sp-item-transform.h" FIXME +#include "ui/dialog/tile.h" // for Inkscape::UI::Dialog::ArrangeDialog + +/* + * Sort items by their x co-ordinates, taking account of y (keeps rows intact) + * + * <0 *elem1 goes before *elem2 + * 0 *elem1 == *elem2 + * >0 *elem1 goes after *elem2 + */ +int sp_compare_x_position(SPItem *first, SPItem *second) +{ + using Geom::X; + using Geom::Y; + + Geom::OptRect a = first->documentVisualBounds(); + Geom::OptRect b = second->documentVisualBounds(); + + if ( !a || !b ) { + // FIXME? + return 0; + } + + double const a_height = a->dimensions()[Y]; + double const b_height = b->dimensions()[Y]; + + bool a_in_b_vert = false; + if ((a->min()[Y] < b->min()[Y] + 0.1) && (a->min()[Y] > b->min()[Y] - b_height)) { + a_in_b_vert = true; + } else if ((b->min()[Y] < a->min()[Y] + 0.1) && (b->min()[Y] > a->min()[Y] - a_height)) { + a_in_b_vert = true; + } else if (b->min()[Y] == a->min()[Y]) { + a_in_b_vert = true; + } else { + a_in_b_vert = false; + } + + if (!a_in_b_vert) { + return -1; + } + if (a_in_b_vert && a->min()[X] > b->min()[X]) { + return 1; + } + if (a_in_b_vert && a->min()[X] < b->min()[X]) { + return -1; + } + return 0; +} + +/* + * Sort items by their y co-ordinates. + */ +int sp_compare_y_position(SPItem *first, SPItem *second) +{ + Geom::OptRect a = first->documentVisualBounds(); + Geom::OptRect b = second->documentVisualBounds(); + + if ( !a || !b ) { + // FIXME? + return 0; + } + + if (a->min()[Geom::Y] > b->min()[Geom::Y]) { + return 1; + } + if (a->min()[Geom::Y] < b->min()[Geom::Y]) { + return -1; + } + + return 0; +} + +namespace Inkscape { +namespace UI { +namespace Dialog { + + +//######################################################################### +//## E V E N T S +//######################################################################### + +/* + * + * This arranges the selection in a grid pattern. + * + */ + +void GridArrangeTab::arrange() +{ + + int cnt,row_cnt,col_cnt,a,row,col; + double grid_left,grid_top,col_width,row_height,paddingx,paddingy,width, height, new_x, new_y,cx,cy; + double total_col_width,total_row_height; + col_width = 0; + row_height = 0; + total_col_width=0; + total_row_height=0; + + // check for correct numbers in the row- and col-spinners + on_col_spinbutton_changed(); + on_row_spinbutton_changed(); + + // set padding to manual values + paddingx = XPadding.getValue("px"); + paddingy = YPadding.getValue("px"); + + std::vector row_heights; + std::vector col_widths; + std::vector row_ys; + std::vector col_xs; + + int NoOfCols = NoOfColsSpinner.get_value_as_int(); + int NoOfRows = NoOfRowsSpinner.get_value_as_int(); + + width = 0; + for (a=0;agetDesktop(); + sp_desktop_document(desktop)->ensureUpToDate(); + + Inkscape::Selection *selection = sp_desktop_selection (desktop); + const GSList *items = selection ? selection->itemList() : 0; + cnt=0; + for (; items != NULL; items = items->next) { + SPItem *item = SP_ITEM(items->data); + Geom::OptRect b = item->documentVisualBounds(); + if (!b) { + continue; + } + + width = b->dimensions()[Geom::X]; + height = b->dimensions()[Geom::Y]; + + cx = b->midpoint()[Geom::X]; + cy = b->midpoint()[Geom::Y]; + + if (b->min()[Geom::X] < grid_left) { + grid_left = b->min()[Geom::X]; + } + if (b->min()[Geom::Y] < grid_top) { + grid_top = b->min()[Geom::Y]; + } + if (width > col_width) { + col_width = width; + } + if (height > row_height) { + row_height = height; + } + } + + + // require the sorting done before we can calculate row heights etc. + + g_return_if_fail(selection); + const GSList *items2 = selection->itemList(); + GSList *rev = g_slist_copy((GSList *) items2); + GSList *sorted = NULL; + rev = g_slist_sort(rev, (GCompareFunc) sp_compare_y_position); + sorted = g_slist_sort(rev, (GCompareFunc) sp_compare_x_position); + + + // Calculate individual Row and Column sizes if necessary + + + cnt=0; + const GSList *sizes = sorted; + for (; sizes != NULL; sizes = sizes->next) { + SPItem *item = SP_ITEM(sizes->data); + Geom::OptRect b = item->documentVisualBounds(); + if (b) { + width = b->dimensions()[Geom::X]; + height = b->dimensions()[Geom::Y]; + if (width > col_widths[(cnt % NoOfCols)]) { + col_widths[(cnt % NoOfCols)] = width; + } + if (height > row_heights[(cnt / NoOfCols)]) { + row_heights[(cnt / NoOfCols)] = height; + } + } + + cnt++; + } + + + /// Make sure the top and left of the grid dont move by compensating for align values. + if (RowHeightButton.get_active()){ + grid_top = grid_top - (((row_height - row_heights[0]) / 2)*(VertAlign)); + } + if (ColumnWidthButton.get_active()){ + grid_left = grid_left - (((col_width - col_widths[0]) /2)*(HorizAlign)); + } + + #ifdef DEBUG_GRID_ARRANGE + g_print("\n cx = %f cy= %f gridleft=%f",cx,cy,grid_left); + #endif + + // Calculate total widths and heights, allowing for columns and rows non uniformly sized. + + if (ColumnWidthButton.get_active()){ + total_col_width = col_width * NoOfCols; + col_widths.clear(); + for (a=0;avisualBounds(); + // Fit to bbox, calculate padding between rows accordingly. + if ( sel_bbox && !SpaceManualRadioButton.get_active() ){ +#ifdef DEBUG_GRID_ARRANGE +g_print("\n row = %f col = %f selection x= %f selection y = %f", total_row_height,total_col_width, b.extent(Geom::X), b.extent(Geom::Y)); +#endif + paddingx = (sel_bbox->width() - total_col_width) / (NoOfCols -1); + paddingy = (sel_bbox->height() - total_row_height) / (NoOfRows -1); + } + +/* + Horizontal align - Left = 0 + Centre = 1 + Right = 2 + + Vertical align - Top = 0 + Middle = 1 + Bottom = 2 + + X position is calculated by taking the grids left co-ord, adding the distance to the column, + then adding 1/2 the spacing multiplied by the align variable above, + Y position likewise, takes the top of the grid, adds the y to the current row then adds the padding in to align it. + +*/ + + // Calculate row and column x and y coords required to allow for columns and rows which are non uniformly sized. + + for (a=0;adata); + sorted = sorted->next; + } + + for (; current_row != NULL; current_row = current_row->next) { + SPItem *item=SP_ITEM(current_row->data); + Inkscape::XML::Node *repr = item->getRepr(); + Geom::OptRect b = item->documentVisualBounds(); + Geom::Point min; + if (b) { + width = b->dimensions()[Geom::X]; + height = b->dimensions()[Geom::Y]; + min = b->min(); + } else { + width = height = 0; + min = Geom::Point(0, 0); + } + + row = cnt / NoOfCols; + col = cnt % NoOfCols; + + new_x = grid_left + (((col_widths[col] - width)/2)*HorizAlign) + col_xs[col]; + new_y = grid_top + (((row_heights[row] - height)/2)*VertAlign) + row_ys[row]; + + // signs are inverted between x and y due to y inversion + Geom::Point move = Geom::Point(new_x - min[Geom::X], min[Geom::Y] - new_y); + Geom::Affine const affine = Geom::Affine(Geom::Translate(move)); + item->set_i2d_affine(item->i2dt_affine() * affine); + item->doWriteTransform(repr, item->transform, NULL); + SP_OBJECT (current_row->data)->updateRepr(); + cnt +=1; + } + g_slist_free (current_row); + } + + DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_SELECTION_ARRANGE, + _("Arrange in a grid")); + +} + + +//######################################################################### +//## E V E N T S +//######################################################################### + +/** + * changed value in # of columns spinbox. + */ +void GridArrangeTab::on_row_spinbutton_changed() +{ + // quit if run by the attr_changed listener + if (updating) { + return; + } + + // in turn, prevent listener from responding + updating = true; + SPDesktop *desktop = Parent->getDesktop(); + + Inkscape::Selection *selection = desktop ? desktop->selection : 0; + g_return_if_fail( selection ); + + GSList const *items = selection->itemList(); + int selcount = g_slist_length((GSList *)items); + + double PerCol = ceil(selcount / NoOfColsSpinner.get_value()); + NoOfRowsSpinner.set_value(PerCol); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setDouble("/dialogs/gridtiler/NoOfCols", NoOfColsSpinner.get_value()); + updating=false; +} + +/** + * changed value in # of rows spinbox. + */ +void GridArrangeTab::on_col_spinbutton_changed() +{ + // quit if run by the attr_changed listener + if (updating) { + return; + } + + // in turn, prevent listener from responding + updating = true; + SPDesktop *desktop = Parent->getDesktop(); + Inkscape::Selection *selection = desktop ? desktop->selection : 0; + g_return_if_fail(selection); + + GSList const *items = selection->itemList(); + int selcount = g_slist_length((GSList *)items); + + double PerRow = ceil(selcount / NoOfRowsSpinner.get_value()); + NoOfColsSpinner.set_value(PerRow); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setDouble("/dialogs/gridtiler/NoOfCols", PerRow); + + updating=false; +} + +/** + * changed value in x padding spinbox. + */ +void GridArrangeTab::on_xpad_spinbutton_changed() +{ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setDouble("/dialogs/gridtiler/XPad", XPadding.getValue("px")); + +} + +/** + * changed value in y padding spinbox. + */ +void GridArrangeTab::on_ypad_spinbutton_changed() +{ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setDouble("/dialogs/gridtiler/YPad", YPadding.getValue("px")); +} + + +/** + * checked/unchecked autosize Rows button. + */ +void GridArrangeTab::on_RowSize_checkbutton_changed() +{ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + if (RowHeightButton.get_active()) { + prefs->setDouble("/dialogs/gridtiler/AutoRowSize", 20); + } else { + prefs->setDouble("/dialogs/gridtiler/AutoRowSize", -20); + } + RowHeightBox.set_sensitive ( !RowHeightButton.get_active()); +} + +/** + * checked/unchecked autosize Rows button. + */ +void GridArrangeTab::on_ColSize_checkbutton_changed() +{ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + if (ColumnWidthButton.get_active()) { + prefs->setDouble("/dialogs/gridtiler/AutoColSize", 20); + } else { + prefs->setDouble("/dialogs/gridtiler/AutoColSize", -20); + } + ColumnWidthBox.set_sensitive ( !ColumnWidthButton.get_active()); +} + +/** + * changed value in columns spinbox. + */ +void GridArrangeTab::on_rowSize_spinbutton_changed() +{ + // quit if run by the attr_changed listener + if (updating) { + return; + } + + // in turn, prevent listener from responding + updating = true; + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setDouble("/dialogs/gridtiler/RowHeight", RowHeightSpinner.get_value()); + updating=false; + +} + +/** + * changed value in rows spinbox. + */ +void GridArrangeTab::on_colSize_spinbutton_changed() +{ + // quit if run by the attr_changed listener + if (updating) { + return; + } + + // in turn, prevent listener from responding + updating = true; + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setDouble("/dialogs/gridtiler/ColWidth", ColumnWidthSpinner.get_value()); + updating=false; + +} + +/** + * changed Radio button in Spacing group. + */ +void GridArrangeTab::Spacing_button_changed() +{ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + if (SpaceManualRadioButton.get_active()) { + prefs->setDouble("/dialogs/gridtiler/SpacingType", 20); + } else { + prefs->setDouble("/dialogs/gridtiler/SpacingType", -20); + } + + XPadding.set_sensitive ( SpaceManualRadioButton.get_active()); + YPadding.set_sensitive ( SpaceManualRadioButton.get_active()); +} + +/** + * changed Anchor selection widget. + */ +void GridArrangeTab::Align_changed() +{ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + VertAlign = AlignmentSelector.getVerticalAlignment(); + prefs->setInt("/dialogs/gridtiler/VertAlign", VertAlign); + HorizAlign = AlignmentSelector.getHorizontalAlignment(); + prefs->setInt("/dialogs/gridtiler/HorizAlign", HorizAlign); +} + +/** + * Desktop selection changed + */ +void GridArrangeTab::updateSelection() +{ + // quit if run by the attr_changed listener + if (updating) { + return; + } + + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + // in turn, prevent listener from responding + updating = true; + SPDesktop *desktop = Parent->getDesktop(); + Inkscape::Selection *selection = desktop ? desktop->selection : 0; + GSList const *items = selection ? selection->itemList() : 0; + + if (items) { + int selcount = g_slist_length((GSList *)items); + + if (NoOfColsSpinner.get_value() > 1 && NoOfRowsSpinner.get_value() > 1){ + // Update the number of rows assuming number of columns wanted remains same. + double NoOfRows = ceil(selcount / NoOfColsSpinner.get_value()); + NoOfRowsSpinner.set_value(NoOfRows); + + // if the selection has less than the number set for one row, reduce it appropriately + if (selcount < NoOfColsSpinner.get_value()) { + double NoOfCols = ceil(selcount / NoOfRowsSpinner.get_value()); + NoOfColsSpinner.set_value(NoOfCols); + prefs->setInt("/dialogs/gridtiler/NoOfCols", NoOfCols); + } + } else { + double PerRow = ceil(sqrt(selcount)); + double PerCol = ceil(sqrt(selcount)); + NoOfRowsSpinner.set_value(PerRow); + NoOfColsSpinner.set_value(PerCol); + prefs->setInt("/dialogs/gridtiler/NoOfCols", static_cast(PerCol)); + } + } + + updating = false; +} + + + +/*########################## +## Experimental +##########################*/ + +static void updateSelectionCallback(Inkscape::Application */*inkscape*/, Inkscape::Selection */*selection*/, GridArrangeTab *dlg) +{ + dlg->updateSelection(); +} + + +//######################################################################### +//## C O N S T R U C T O R / D E S T R U C T O R +//######################################################################### +/** + * Constructor + */ +GridArrangeTab::GridArrangeTab(ArrangeDialog *parent) + : Parent(parent), + XPadding(_("X:"), _("Horizontal spacing between columns."), UNIT_TYPE_LINEAR, "", "object-columns"), + YPadding(_("Y:"), _("Vertical spacing between rows."), XPadding, "", "object-rows") +{ + // bool used by spin button callbacks to stop loops where they change each other. + updating = false; + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + + // could not do this in gtkmm - there's no Gtk::SizeGroup public constructor (!) + GtkSizeGroup *_col1 = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); + GtkSizeGroup *_col2 = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); + GtkSizeGroup *_col3 = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); + + { + // Selection Change signal + g_signal_connect ( G_OBJECT (INKSCAPE), "change_selection", G_CALLBACK (updateSelectionCallback), this); + } + + Gtk::Box *contents = this; + +#define MARGIN 2 + + //##Set up the panel + + SPDesktop *desktop = Parent->getDesktop(); + + Inkscape::Selection *selection = desktop ? desktop->selection : 0; + g_return_if_fail( selection ); + int selcount = 1; + if (!selection->isEmpty()) { + GSList const *items = selection->itemList(); + selcount = g_slist_length((GSList *)items); + } + + + /*#### Number of Rows ####*/ + + double PerRow = ceil(sqrt(selcount)); + double PerCol = ceil(sqrt(selcount)); + + #ifdef DEBUG_GRID_ARRANGE + g_print("/n PerRox = %f PerCol = %f selcount = %d",PerRow,PerCol,selcount); + #endif + + NoOfRowsLabel.set_text_with_mnemonic(_("_Rows:")); + NoOfRowsLabel.set_mnemonic_widget(NoOfRowsSpinner); + NoOfRowsBox.pack_start(NoOfRowsLabel, false, false, MARGIN); + + NoOfRowsSpinner.set_digits(0); + NoOfRowsSpinner.set_increments(1, 0); + NoOfRowsSpinner.set_range(1.0, 10000.0); + NoOfRowsSpinner.set_value(PerCol); + NoOfRowsSpinner.signal_changed().connect(sigc::mem_fun(*this, &GridArrangeTab::on_col_spinbutton_changed)); + NoOfRowsSpinner.set_tooltip_text(_("Number of rows")); + NoOfRowsBox.pack_start(NoOfRowsSpinner, false, false, MARGIN); + gtk_size_group_add_widget(_col1, (GtkWidget *) NoOfRowsBox.gobj()); + + RowHeightButton.set_label(_("Equal _height")); + RowHeightButton.set_use_underline(true); + double AutoRow = prefs->getDouble("/dialogs/gridtiler/AutoRowSize", 15); + if (AutoRow>0) + AutoRowSize=true; + else + AutoRowSize=false; + RowHeightButton.set_active(AutoRowSize); + + NoOfRowsBox.pack_start(RowHeightButton, false, false, MARGIN); + + RowHeightButton.set_tooltip_text(_("If not set, each row has the height of the tallest object in it")); + RowHeightButton.signal_toggled().connect(sigc::mem_fun(*this, &GridArrangeTab::on_RowSize_checkbutton_changed)); + + SpinsHBox.pack_start(NoOfRowsBox, false, false, MARGIN); + + + /*#### Label for X ####*/ + padXByYLabel.set_label(" "); + XByYLabelVBox.pack_start(padXByYLabel, false, false, MARGIN); + XByYLabel.set_markup(" × "); + XByYLabelVBox.pack_start(XByYLabel, false, false, MARGIN); + SpinsHBox.pack_start(XByYLabelVBox, false, false, MARGIN); + gtk_size_group_add_widget(_col2, (GtkWidget *) XByYLabelVBox.gobj()); + + /*#### Number of columns ####*/ + + NoOfColsLabel.set_text_with_mnemonic(_("_Columns:")); + NoOfColsLabel.set_mnemonic_widget(NoOfColsSpinner); + NoOfColsBox.pack_start(NoOfColsLabel, false, false, MARGIN); + + NoOfColsSpinner.set_digits(0); + NoOfColsSpinner.set_increments(1, 0); + NoOfColsSpinner.set_range(1.0, 10000.0); + NoOfColsSpinner.set_value(PerRow); + NoOfColsSpinner.signal_changed().connect(sigc::mem_fun(*this, &GridArrangeTab::on_row_spinbutton_changed)); + NoOfColsSpinner.set_tooltip_text(_("Number of columns")); + NoOfColsBox.pack_start(NoOfColsSpinner, false, false, MARGIN); + gtk_size_group_add_widget(_col3, (GtkWidget *) NoOfColsBox.gobj()); + + ColumnWidthButton.set_label(_("Equal _width")); + ColumnWidthButton.set_use_underline(true); + double AutoCol = prefs->getDouble("/dialogs/gridtiler/AutoColSize", 15); + if (AutoCol>0) + AutoColSize=true; + else + AutoColSize=false; + ColumnWidthButton.set_active(AutoColSize); + NoOfColsBox.pack_start(ColumnWidthButton, false, false, MARGIN); + + ColumnWidthButton.set_tooltip_text(_("If not set, each column has the width of the widest object in it")); + ColumnWidthButton.signal_toggled().connect(sigc::mem_fun(*this, &GridArrangeTab::on_ColSize_checkbutton_changed)); + + SpinsHBox.pack_start(NoOfColsBox, false, false, MARGIN); + + TileBox.pack_start(SpinsHBox, false, false, MARGIN); + + VertAlign = prefs->getInt("/dialogs/gridtiler/VertAlign", 1); + HorizAlign = prefs->getInt("/dialogs/gridtiler/HorizAlign", 1); + + // Anchor selection widget + AlignLabel.set_label("Alignment:"); + AlignLabel.set_alignment(Gtk::ALIGN_START, Gtk::ALIGN_CENTER); + AlignmentSelector.setAlignment(HorizAlign, VertAlign); + AlignmentSelector.on_selectionChanged().connect(sigc::mem_fun(*this, &GridArrangeTab::Align_changed)); + TileBox.pack_start(AlignLabel, false, false, MARGIN); + TileBox.pack_start(AlignmentSelector, true, false, MARGIN); + + { + /*#### Radio buttons to control spacing manually or to fit selection bbox ####*/ + SpaceByBBoxRadioButton.set_label(_("_Fit into selection box")); + SpaceByBBoxRadioButton.set_use_underline (true); + SpaceByBBoxRadioButton.signal_toggled().connect(sigc::mem_fun(*this, &GridArrangeTab::Spacing_button_changed)); + SpacingGroup = SpaceByBBoxRadioButton.get_group(); + + SpacingVBox.pack_start(SpaceByBBoxRadioButton, false, false, MARGIN); + + SpaceManualRadioButton.set_label(_("_Set spacing:")); + SpaceManualRadioButton.set_use_underline (true); + SpaceManualRadioButton.set_group(SpacingGroup); + SpaceManualRadioButton.signal_toggled().connect(sigc::mem_fun(*this, &GridArrangeTab::Spacing_button_changed)); + SpacingVBox.pack_start(SpaceManualRadioButton, false, false, MARGIN); + + TileBox.pack_start(SpacingVBox, false, false, MARGIN); + } + + { + /*#### Padding ####*/ + + YPadding.setDigits(5); + YPadding.setIncrements(0.2, 0); + YPadding.setRange(-10000, 10000); + double yPad = prefs->getDouble("/dialogs/gridtiler/YPad", 15); + YPadding.setValue(yPad, "px"); + YPadding.signal_value_changed().connect(sigc::mem_fun(*this, &GridArrangeTab::on_ypad_spinbutton_changed)); + + XPadding.setDigits(5); + XPadding.setIncrements(0.2, 0); + XPadding.setRange(-10000, 10000); + double xPad = prefs->getDouble("/dialogs/gridtiler/XPad", 15); + XPadding.setValue(xPad, "px"); + + XPadding.signal_value_changed().connect(sigc::mem_fun(*this, &GridArrangeTab::on_xpad_spinbutton_changed)); + } + TileBox.pack_start(XPadding, false, false, MARGIN); + TileBox.pack_start(YPadding, false, false, MARGIN); + + contents->pack_start(TileBox); + + double SpacingType = prefs->getDouble("/dialogs/gridtiler/SpacingType", 15); + if (SpacingType>0) { + ManualSpacing=true; + } else { + ManualSpacing=false; + } + SpaceManualRadioButton.set_active(ManualSpacing); + SpaceByBBoxRadioButton.set_active(!ManualSpacing); + XPadding.set_sensitive (ManualSpacing); + YPadding.set_sensitive (ManualSpacing); + + //## The OK button FIXME + /*TileOkButton = addResponseButton(C_("Rows and columns dialog","_Arrange"), GTK_RESPONSE_APPLY); + TileOkButton->set_use_underline(true); + TileOkButton->set_tooltip_text(_("Arrange selected objects"));*/ + + show_all_children(); +} + +} //namespace Dialog +} //namespace UI +} //namespace Inkscape + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/dialog/gridarrangetab.h b/src/ui/dialog/gridarrangetab.h new file mode 100644 index 000000000..bc82258b8 --- /dev/null +++ b/src/ui/dialog/gridarrangetab.h @@ -0,0 +1,147 @@ +/** + * @brief Arranges Objects into a Grid + */ +/* Authors: + * Bob Jamison ( based off trace dialog) + * John Cliff + * Other dudes from The Inkscape Organization + * Abhishek Sharma + * Declara Denis + * + * Copyright (C) 2004 Bob Jamison + * Copyright (C) 2004 John Cliff + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifndef INKSCAPE_UI_DIALOG_GRID_ARRANGE_TAB_H +#define INKSCAPE_UI_DIALOG_GRID_ARRANGE_TAB_H + +#include + +#include "ui/dialog/arrangetab.h" + +#include "ui/widget/anchor-selector.h" +#include "ui/widget/scalar-unit.h" +#include "ui/widget/spinbutton.h" + +namespace Inkscape { +namespace UI { +namespace Dialog { + +class ArrangeDialog; + +/** + * Dialog for tiling an object + */ +class GridArrangeTab : public ArrangeTab { +public: + GridArrangeTab(ArrangeDialog *parent); + virtual ~GridArrangeTab() {}; + + /** + * Do the actual work + */ + virtual void arrange(); + + /** + * Respond to selection change + */ + void updateSelection(); + + // Callbacks from spinbuttons + void on_row_spinbutton_changed(); + void on_col_spinbutton_changed(); + void on_xpad_spinbutton_changed(); + void on_ypad_spinbutton_changed(); + void on_RowSize_checkbutton_changed(); + void on_ColSize_checkbutton_changed(); + void on_rowSize_spinbutton_changed(); + void on_colSize_spinbutton_changed(); + void Spacing_button_changed(); + void Align_changed(); + + +private: + GridArrangeTab(GridArrangeTab const &d); // no copy + void operator=(GridArrangeTab const &d); // no assign + + ArrangeDialog *Parent; + + bool userHidden; + bool updating; + + Gtk::VBox TileBox; + Gtk::Button *TileOkButton; + Gtk::Button *TileCancelButton; + + // Number selected label + Gtk::Label SelectionContentsLabel; + + + Gtk::HBox AlignHBox; + Gtk::HBox SpinsHBox; + + // Number per Row + Gtk::VBox NoOfColsBox; + Gtk::Label NoOfColsLabel; + Inkscape::UI::Widget::SpinButton NoOfColsSpinner; + bool AutoRowSize; + Gtk::CheckButton RowHeightButton; + + Gtk::VBox XByYLabelVBox; + Gtk::Label padXByYLabel; + Gtk::Label XByYLabel; + + // Number per Column + Gtk::VBox NoOfRowsBox; + Gtk::Label NoOfRowsLabel; + Inkscape::UI::Widget::SpinButton NoOfRowsSpinner; + bool AutoColSize; + Gtk::CheckButton ColumnWidthButton; + + // Alignment + Gtk::Label AlignLabel; + AnchorSelector AlignmentSelector; + double VertAlign; + double HorizAlign; + + Inkscape::UI::Widget::ScalarUnit XPadding; + Inkscape::UI::Widget::ScalarUnit YPadding; + + // BBox or manual spacing + Gtk::VBox SpacingVBox; + Gtk::RadioButtonGroup SpacingGroup; + Gtk::RadioButton SpaceByBBoxRadioButton; + Gtk::RadioButton SpaceManualRadioButton; + bool ManualSpacing; + + // Row height + Gtk::VBox RowHeightVBox; + Gtk::HBox RowHeightBox; + Gtk::Label RowHeightLabel; + Inkscape::UI::Widget::SpinButton RowHeightSpinner; + + // Column width + Gtk::VBox ColumnWidthVBox; + Gtk::HBox ColumnWidthBox; + Gtk::Label ColumnWidthLabel; + Inkscape::UI::Widget::SpinButton ColumnWidthSpinner; +}; + +} //namespace Dialog +} //namespace UI +} //namespace Inkscape + +#endif /* INKSCAPE_UI_DIALOG_GRID_ARRANGE_TAB_H */ + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/dialog/polararrangetab.cpp b/src/ui/dialog/polararrangetab.cpp new file mode 100644 index 000000000..d36a78759 --- /dev/null +++ b/src/ui/dialog/polararrangetab.cpp @@ -0,0 +1,206 @@ +/** + * @brief Arranges Objects into a Circle/Ellipse + */ +/* Authors: + * Declara Denis + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include <2geom/transforms.h> +#include + +#include "ui/dialog/polararrangetab.h" +#include "ui/dialog/tile.h" + +#include "verbs.h" +#include "preferences.h" +#include "inkscape.h" +#include "desktop-handles.h" +#include "selection.h" +#include "document.h" +#include "document-undo.h" +#include "sp-item.h" +#include "widgets/icon.h" +#include "desktop.h" +#include "sp-item-transform.h" + +namespace Inkscape { +namespace UI { +namespace Dialog { + +PolarArrangeTab::PolarArrangeTab(ArrangeDialog *parent_) + : parent(parent_), + parametersTable(3, 3, false), + centerY("", "Y coordinate of the center", UNIT_TYPE_LINEAR), + centerX("", "X coordinate of the center", centerY), + radiusY("", "Y coordinate of the radius", UNIT_TYPE_LINEAR), + radiusX("", "X coordinate of the radius", radiusY), + angleY("", "Starting angle", UNIT_TYPE_RADIAL), + angleX("", "End angle", angleY) +{ + anchorPointLabel.set_text("Anchor point:"); + anchorPointLabel.set_alignment(Gtk::ALIGN_START); + pack_start(anchorPointLabel, false, false); + + anchorBoundingBoxRadio.set_label("Object's bounding box:"); + anchorRadioGroup = anchorBoundingBoxRadio.get_group(); + anchorBoundingBoxRadio.signal_toggled().connect(sigc::mem_fun(*this, &PolarArrangeTab::on_anchor_radio_changed)); + pack_start(anchorBoundingBoxRadio, false, false); + + pack_start(anchorSelector, false, false); + + anchorObjectPivotRadio.set_label("Object's rotational center"); + anchorObjectPivotRadio.set_group(anchorRadioGroup); + anchorObjectPivotRadio.signal_toggled().connect(sigc::mem_fun(*this, &PolarArrangeTab::on_anchor_radio_changed)); + pack_start(anchorObjectPivotRadio, false, false); + + arrangeOnLabel.set_text("Arrange on:"); + arrangeOnLabel.set_alignment(Gtk::ALIGN_START); + pack_start(arrangeOnLabel, false, false); + + arrangeOnCircleRadio.set_label("Last selected circle/ellipse/arc"); + arrangeRadioGroup = arrangeOnCircleRadio.get_group(); + arrangeOnCircleRadio.signal_toggled().connect(sigc::mem_fun(*this, &PolarArrangeTab::on_arrange_radio_changed)); + pack_start(arrangeOnCircleRadio, false, false); + + arrangeOnParametersRadio.set_label("Parameterized:"); + arrangeOnParametersRadio.set_group(arrangeRadioGroup); + arrangeOnParametersRadio.signal_toggled().connect(sigc::mem_fun(*this, &PolarArrangeTab::on_arrange_radio_changed)); + pack_start(arrangeOnParametersRadio, false, false); + + //FIXME: Objects in grid do not line up properly! + centerLabel.set_text("Center X/Y:"); + parametersTable.attach(centerLabel, 0, 1, 0, 1); + centerX.setDigits(2); + centerX.set_size_request(60, -1); + centerX.setIncrements(0.2, 0); + centerX.setRange(-10000, 10000); + centerX.setValue(0, "px"); + centerY.setDigits(2); + centerY.set_size_request(120, -1); + centerY.setIncrements(0.2, 0); + centerY.setRange(-10000, 10000); + centerY.setValue(0, "px"); + parametersTable.attach(centerX, 1, 2, 0, 1); + parametersTable.attach(centerY, 2, 3, 0, 1); + + radiusLabel.set_text("Radius X/Y:"); + parametersTable.attach(radiusLabel, 0, 1, 1, 2); + radiusX.setDigits(2); + radiusX.set_size_request(60, -1); + radiusX.setIncrements(0.2, 0); + radiusX.setRange(-10000, 10000); + radiusX.setValue(0, "px"); + radiusY.setDigits(2); + radiusY.set_size_request(120, -1); + radiusY.setIncrements(0.2, 0); + radiusY.setRange(-10000, 10000); + radiusY.setValue(0, "px"); + parametersTable.attach(radiusX, 1, 2, 1, 2); + parametersTable.attach(radiusY, 2, 3, 1, 2); + + angleLabel.set_text("Center X/Y:"); + parametersTable.attach(angleLabel, 0, 1, 2, 3); + angleX.setDigits(2); + angleX.set_size_request(60, -1); + angleX.setIncrements(0.2, 0); + angleX.setRange(-10000, 10000); + angleX.setValue(0, "°"); + angleY.setDigits(2); + angleY.set_size_request(120, -1); + angleY.setIncrements(0.2, 0); + angleY.setRange(-10000, 10000); + angleY.setValue(0, "°"); + parametersTable.attach(angleX, 1, 2, 2, 3); + parametersTable.attach(angleY, 2, 3, 2, 3); + pack_start(parametersTable, false, false); + + rotateObjectsCheckBox.set_label("Rotate objects"); + rotateObjectsCheckBox.set_active(true); + pack_start(rotateObjectsCheckBox, false, false); + + centerX.set_sensitive(false); + centerY.set_sensitive(false); + angleX.set_sensitive(false); + angleY.set_sensitive(false); + radiusX.set_sensitive(false); + radiusY.set_sensitive(false); +} + +void PolarArrangeTab::arrange() +{ + std::cout << "PolarArrangeTab::arrange()" << std::endl; + Inkscape::Selection *selection = sp_desktop_selection(parent->getDesktop()); + const GSList *items = selection->itemList(); + int i = 0; + while(items) + { + SPItem *item = SP_ITEM(items->data); + + float centerx = 1000; + float centery = 2000; + + float radiusx = 1000; + float radiusy = 2000; + + float objectx = - item->documentVisualBounds()->min()[Geom::X]; + float objecty = item->documentVisualBounds()->min()[Geom::Y]; + + float angle = M_PI / 36 * i; + + float r = (radiusx * radiusy) / + sqrtf(powf(radiusy * cos(angle), 2) + powf(radiusx * sin(angle), 2)); + float calcx = cos(angle) * r; + float calcy = sin(angle) * r; + + sp_item_move_rel(item, Geom::Translate(objectx + calcx, objecty + calcy)); + sp_item_rotate_rel(item, Geom::Rotate(angle)); + + //item->set_i2d_affine(item->i2dt_affine() * toOrigin * rotation); + //item->doWriteTransform(item->getRepr(), item->transform, NULL); + + items = items->next; + ++i; + } +} + +void PolarArrangeTab::updateSelection() +{ +} + +void PolarArrangeTab::on_arrange_radio_changed() +{ + bool arrangeParametric = !arrangeOnCircleRadio.get_active(); + + centerX.set_sensitive(arrangeParametric); + centerY.set_sensitive(arrangeParametric); + + angleX.set_sensitive(arrangeParametric); + angleY.set_sensitive(arrangeParametric); + + radiusX.set_sensitive(arrangeParametric); + radiusY.set_sensitive(arrangeParametric); +} + +void PolarArrangeTab::on_anchor_radio_changed() +{ + bool anchorBoundingBox = anchorBoundingBoxRadio.get_active(); + + anchorSelector.set_sensitive(anchorBoundingBox); +} + +} //namespace Dialog +} //namespace UI +} //namespace Inkscape + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/dialog/polararrangetab.h b/src/ui/dialog/polararrangetab.h new file mode 100644 index 000000000..81b7de4d9 --- /dev/null +++ b/src/ui/dialog/polararrangetab.h @@ -0,0 +1,86 @@ +/** + * @brief Arranges Objects into a Circle/Ellipse + */ +/* Authors: + * Declara Denis + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifndef INKSCAPE_UI_DIALOG_POLAR_ARRANGE_TAB_H +#define INKSCAPE_UI_DIALOG_POLAR_ARRANGE_TAB_H + +#include + +#include "ui/dialog/arrangetab.h" + +#include "ui/widget/anchor-selector.h" +#include "ui/widget/scalar-unit.h" + +namespace Inkscape { +namespace UI { +namespace Dialog { + +class ArrangeDialog; + +class PolarArrangeTab : public ArrangeTab { +public: + PolarArrangeTab(ArrangeDialog *parent_); + virtual ~PolarArrangeTab() {}; + + /** + * Do the actual work + */ + virtual void arrange(); + + /** + * Respond to selection change + */ + void updateSelection(); + + void on_anchor_radio_changed(); + void on_arrange_radio_changed(); + +private: + PolarArrangeTab(PolarArrangeTab const &d); // no copy + void operator=(PolarArrangeTab const &d); // no assign + + ArrangeDialog *parent; + + Gtk::Label anchorPointLabel; + + Gtk::RadioButtonGroup anchorRadioGroup; + Gtk::RadioButton anchorBoundingBoxRadio; + Gtk::RadioButton anchorObjectPivotRadio; + AnchorSelector anchorSelector; + + Gtk::Label arrangeOnLabel; + + Gtk::RadioButtonGroup arrangeRadioGroup; + Gtk::RadioButton arrangeOnCircleRadio; + Gtk::RadioButton arrangeOnParametersRadio; + + Gtk::Table parametersTable; + + Gtk::Label centerLabel; + Inkscape::UI::Widget::ScalarUnit centerY; + Inkscape::UI::Widget::ScalarUnit centerX; + + Gtk::Label radiusLabel; + Inkscape::UI::Widget::ScalarUnit radiusY; + Inkscape::UI::Widget::ScalarUnit radiusX; + + Gtk::Label angleLabel; + Inkscape::UI::Widget::ScalarUnit angleY; + Inkscape::UI::Widget::ScalarUnit angleX; + + Gtk::CheckButton rotateObjectsCheckBox; + + +}; + +} //namespace Dialog +} //namespace UI +} //namespace Inkscape + +#endif /* INKSCAPE_UI_DIALOG_POLAR_ARRANGE_TAB_H */ diff --git a/src/ui/dialog/tile.cpp b/src/ui/dialog/tile.cpp index d4c597b84..879c9182f 100644 --- a/src/ui/dialog/tile.cpp +++ b/src/ui/dialog/tile.cpp @@ -6,112 +6,28 @@ * John Cliff * Other dudes from The Inkscape Organization * Abhishek Sharma + * Declara Denis * * Copyright (C) 2004 Bob Jamison * Copyright (C) 2004 John Cliff * * Released under GNU GPL, read the file 'COPYING' for more information */ -//#define DEBUG_GRID_ARRANGE 1 -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "tile.h" -#include //for GTK_RESPONSE* types #include -#include -#include <2geom/transforms.h> +#include "tile.h" #include "verbs.h" -#include "preferences.h" -#include "inkscape.h" -#include "desktop-handles.h" -#include "selection.h" -#include "document.h" -#include "document-undo.h" -#include "sp-item.h" -#include "widgets/icon.h" -#include "desktop.h" -#include "sp-item-transform.h" - -/* - * Sort items by their x co-ordinates, taking account of y (keeps rows intact) - * - * <0 *elem1 goes before *elem2 - * 0 *elem1 == *elem2 - * >0 *elem1 goes after *elem2 - */ -int sp_compare_x_position(SPItem *first, SPItem *second) -{ - using Geom::X; - using Geom::Y; - - Geom::OptRect a = first->documentVisualBounds(); - Geom::OptRect b = second->documentVisualBounds(); - - if ( !a || !b ) { - // FIXME? - return 0; - } - - double const a_height = a->dimensions()[Y]; - double const b_height = b->dimensions()[Y]; - - bool a_in_b_vert = false; - if ((a->min()[Y] < b->min()[Y] + 0.1) && (a->min()[Y] > b->min()[Y] - b_height)) { - a_in_b_vert = true; - } else if ((b->min()[Y] < a->min()[Y] + 0.1) && (b->min()[Y] > a->min()[Y] - a_height)) { - a_in_b_vert = true; - } else if (b->min()[Y] == a->min()[Y]) { - a_in_b_vert = true; - } else { - a_in_b_vert = false; - } - - if (!a_in_b_vert) { - return -1; - } - if (a_in_b_vert && a->min()[X] > b->min()[X]) { - return 1; - } - if (a_in_b_vert && a->min()[X] < b->min()[X]) { - return -1; - } - return 0; -} - -/* - * Sort items by their y co-ordinates. - */ -int -sp_compare_y_position(SPItem *first, SPItem *second) -{ - Geom::OptRect a = first->documentVisualBounds(); - Geom::OptRect b = second->documentVisualBounds(); - - if ( !a || !b ) { - // FIXME? - return 0; - } - if (a->min()[Geom::Y] > b->min()[Geom::Y]) { - return 1; - } - if (a->min()[Geom::Y] < b->min()[Geom::Y]) { - return -1; - } - - return 0; -} +#include "ui/dialog/gridarrangetab.h" +#include "ui/dialog/polararrangetab.h" namespace Inkscape { namespace UI { namespace Dialog { ArrangeDialog::ArrangeDialog() - : UI::Widget::Panel("", "/dialogs/gridtiler", SP_VERB_SELECTION_GRIDTILE), + : UI::Widget::Panel("", "/dialogs/gridtiler", SP_VERB_SELECTION_ARRANGE), _gridArrangeTab(new GridArrangeTab(this)), _polarArrangeTab(new PolarArrangeTab(this)) { @@ -142,826 +58,6 @@ void ArrangeDialog::_apply() } } -PolarArrangeTab::PolarArrangeTab(ArrangeDialog *parent_) - : parent(parent_), - parametersTable(3, 3, false), - centerY("", "Y coordinate of the center", UNIT_TYPE_LINEAR), - centerX("", "X coordinate of the center", centerY), - radiusY("", "Y coordinate of the radius", UNIT_TYPE_LINEAR), - radiusX("", "X coordinate of the radius", radiusY), - angleY("", "Starting angle", UNIT_TYPE_RADIAL), - angleX("", "End angle", angleY) -{ - anchorPointLabel.set_text("Anchor point:"); - anchorPointLabel.set_alignment(Gtk::ALIGN_START); - pack_start(anchorPointLabel, false, false); - - anchorBoundingBoxRadio.set_label("Object's bounding box:"); - anchorRadioGroup = anchorBoundingBoxRadio.get_group(); - anchorBoundingBoxRadio.signal_toggled().connect(sigc::mem_fun(*this, &PolarArrangeTab::on_anchor_radio_changed)); - pack_start(anchorBoundingBoxRadio, false, false); - - pack_start(anchorSelector, false, false); - - anchorObjectPivotRadio.set_label("Object's rotational center"); - anchorObjectPivotRadio.set_group(anchorRadioGroup); - anchorObjectPivotRadio.signal_toggled().connect(sigc::mem_fun(*this, &PolarArrangeTab::on_anchor_radio_changed)); - pack_start(anchorObjectPivotRadio, false, false); - - arrangeOnLabel.set_text("Arrange on:"); - arrangeOnLabel.set_alignment(Gtk::ALIGN_START); - pack_start(arrangeOnLabel, false, false); - - arrangeOnCircleRadio.set_label("Last selected circle/ellipse/arc"); - arrangeRadioGroup = arrangeOnCircleRadio.get_group(); - arrangeOnCircleRadio.signal_toggled().connect(sigc::mem_fun(*this, &PolarArrangeTab::on_arrange_radio_changed)); - pack_start(arrangeOnCircleRadio, false, false); - - arrangeOnParametersRadio.set_label("Parameterized:"); - arrangeOnParametersRadio.set_group(arrangeRadioGroup); - arrangeOnParametersRadio.signal_toggled().connect(sigc::mem_fun(*this, &PolarArrangeTab::on_arrange_radio_changed)); - pack_start(arrangeOnParametersRadio, false, false); - - //FIXME: Objects in grid do not line up properly! - centerLabel.set_text("Center X/Y:"); - parametersTable.attach(centerLabel, 0, 1, 0, 1); - centerX.setDigits(2); - centerX.set_size_request(60, -1); - centerX.setIncrements(0.2, 0); - centerX.setRange(-10000, 10000); - centerX.setValue(0, "px"); - centerY.setDigits(2); - centerY.set_size_request(120, -1); - centerY.setIncrements(0.2, 0); - centerY.setRange(-10000, 10000); - centerY.setValue(0, "px"); - parametersTable.attach(centerX, 1, 2, 0, 1); - parametersTable.attach(centerY, 2, 3, 0, 1); - - radiusLabel.set_text("Radius X/Y:"); - parametersTable.attach(radiusLabel, 0, 1, 1, 2); - radiusX.setDigits(2); - radiusX.set_size_request(60, -1); - radiusX.setIncrements(0.2, 0); - radiusX.setRange(-10000, 10000); - radiusX.setValue(0, "px"); - radiusY.setDigits(2); - radiusY.set_size_request(120, -1); - radiusY.setIncrements(0.2, 0); - radiusY.setRange(-10000, 10000); - radiusY.setValue(0, "px"); - parametersTable.attach(radiusX, 1, 2, 1, 2); - parametersTable.attach(radiusY, 2, 3, 1, 2); - - angleLabel.set_text("Center X/Y:"); - parametersTable.attach(angleLabel, 0, 1, 2, 3); - angleX.setDigits(2); - angleX.set_size_request(60, -1); - angleX.setIncrements(0.2, 0); - angleX.setRange(-10000, 10000); - angleX.setValue(0, "°"); - angleY.setDigits(2); - angleY.set_size_request(120, -1); - angleY.setIncrements(0.2, 0); - angleY.setRange(-10000, 10000); - angleY.setValue(0, "°"); - parametersTable.attach(angleX, 1, 2, 2, 3); - parametersTable.attach(angleY, 2, 3, 2, 3); - pack_start(parametersTable, false, false); - - rotateObjectsCheckBox.set_label("Rotate objects"); - rotateObjectsCheckBox.set_active(true); - pack_start(rotateObjectsCheckBox, false, false); - - centerX.set_sensitive(false); - centerY.set_sensitive(false); - angleX.set_sensitive(false); - angleY.set_sensitive(false); - radiusX.set_sensitive(false); - radiusY.set_sensitive(false); -} - -void PolarArrangeTab::arrange() -{ - std::cout << "PolarArrangeTab::arrange()" << std::endl; - Inkscape::Selection *selection = sp_desktop_selection(parent->getDesktop()); - const GSList *items = selection->itemList(); - int i = 0; - while(items) - { - SPItem *item = SP_ITEM(items->data); - - float centerx = 1000; - float centery = 2000; - - float radiusx = 1000; - float radiusy = 2000; - - float objectx = - item->documentVisualBounds()->min()[Geom::X]; - float objecty = item->documentVisualBounds()->min()[Geom::Y]; - - float angle = M_PI / 36 * i; - - float r = (radiusx * radiusy) / - sqrtf(powf(radiusy * cos(angle), 2) + powf(radiusx * sin(angle), 2)); - float calcx = cos(angle) * r; - float calcy = sin(angle) * r; - - sp_item_move_rel(item, Geom::Translate(objectx + calcx, objecty + calcy)); - sp_item_rotate_rel(item, Geom::Rotate(angle)); - - //item->set_i2d_affine(item->i2dt_affine() * toOrigin * rotation); - //item->doWriteTransform(item->getRepr(), item->transform, NULL); - - items = items->next; - ++i; - } -} - -void PolarArrangeTab::updateSelection() -{ -} - -void PolarArrangeTab::on_arrange_radio_changed() -{ - bool arrangeParametric = !arrangeOnCircleRadio.get_active(); - - centerX.set_sensitive(arrangeParametric); - centerY.set_sensitive(arrangeParametric); - - angleX.set_sensitive(arrangeParametric); - angleY.set_sensitive(arrangeParametric); - - radiusX.set_sensitive(arrangeParametric); - radiusY.set_sensitive(arrangeParametric); -} - -void PolarArrangeTab::on_anchor_radio_changed() -{ - bool anchorBoundingBox = anchorBoundingBoxRadio.get_active(); - - anchorSelector.set_sensitive(anchorBoundingBox); -} - - -//######################################################################### -//## E V E N T S -//######################################################################### - -/* - * - * This arranges the selection in a grid pattern. - * - */ - -void GridArrangeTab::arrange() -{ - - int cnt,row_cnt,col_cnt,a,row,col; - double grid_left,grid_top,col_width,row_height,paddingx,paddingy,width, height, new_x, new_y,cx,cy; - double total_col_width,total_row_height; - col_width = 0; - row_height = 0; - total_col_width=0; - total_row_height=0; - - // check for correct numbers in the row- and col-spinners - on_col_spinbutton_changed(); - on_row_spinbutton_changed(); - - // set padding to manual values - paddingx = XPadding.getValue("px"); - paddingy = YPadding.getValue("px"); - - std::vector row_heights; - std::vector col_widths; - std::vector row_ys; - std::vector col_xs; - - int NoOfCols = NoOfColsSpinner.get_value_as_int(); - int NoOfRows = NoOfRowsSpinner.get_value_as_int(); - - width = 0; - for (a=0;agetDesktop(); - sp_desktop_document(desktop)->ensureUpToDate(); - - Inkscape::Selection *selection = sp_desktop_selection (desktop); - const GSList *items = selection ? selection->itemList() : 0; - cnt=0; - for (; items != NULL; items = items->next) { - SPItem *item = SP_ITEM(items->data); - Geom::OptRect b = item->documentVisualBounds(); - if (!b) { - continue; - } - - width = b->dimensions()[Geom::X]; - height = b->dimensions()[Geom::Y]; - - cx = b->midpoint()[Geom::X]; - cy = b->midpoint()[Geom::Y]; - - if (b->min()[Geom::X] < grid_left) { - grid_left = b->min()[Geom::X]; - } - if (b->min()[Geom::Y] < grid_top) { - grid_top = b->min()[Geom::Y]; - } - if (width > col_width) { - col_width = width; - } - if (height > row_height) { - row_height = height; - } - } - - - // require the sorting done before we can calculate row heights etc. - - g_return_if_fail(selection); - const GSList *items2 = selection->itemList(); - GSList *rev = g_slist_copy((GSList *) items2); - GSList *sorted = NULL; - rev = g_slist_sort(rev, (GCompareFunc) sp_compare_y_position); - sorted = g_slist_sort(rev, (GCompareFunc) sp_compare_x_position); - - - // Calculate individual Row and Column sizes if necessary - - - cnt=0; - const GSList *sizes = sorted; - for (; sizes != NULL; sizes = sizes->next) { - SPItem *item = SP_ITEM(sizes->data); - Geom::OptRect b = item->documentVisualBounds(); - if (b) { - width = b->dimensions()[Geom::X]; - height = b->dimensions()[Geom::Y]; - if (width > col_widths[(cnt % NoOfCols)]) { - col_widths[(cnt % NoOfCols)] = width; - } - if (height > row_heights[(cnt / NoOfCols)]) { - row_heights[(cnt / NoOfCols)] = height; - } - } - - cnt++; - } - - - /// Make sure the top and left of the grid dont move by compensating for align values. - if (RowHeightButton.get_active()){ - grid_top = grid_top - (((row_height - row_heights[0]) / 2)*(VertAlign)); - } - if (ColumnWidthButton.get_active()){ - grid_left = grid_left - (((col_width - col_widths[0]) /2)*(HorizAlign)); - } - - #ifdef DEBUG_GRID_ARRANGE - g_print("\n cx = %f cy= %f gridleft=%f",cx,cy,grid_left); - #endif - - // Calculate total widths and heights, allowing for columns and rows non uniformly sized. - - if (ColumnWidthButton.get_active()){ - total_col_width = col_width * NoOfCols; - col_widths.clear(); - for (a=0;avisualBounds(); - // Fit to bbox, calculate padding between rows accordingly. - if ( sel_bbox && !SpaceManualRadioButton.get_active() ){ -#ifdef DEBUG_GRID_ARRANGE -g_print("\n row = %f col = %f selection x= %f selection y = %f", total_row_height,total_col_width, b.extent(Geom::X), b.extent(Geom::Y)); -#endif - paddingx = (sel_bbox->width() - total_col_width) / (NoOfCols -1); - paddingy = (sel_bbox->height() - total_row_height) / (NoOfRows -1); - } - -/* - Horizontal align - Left = 0 - Centre = 1 - Right = 2 - - Vertical align - Top = 0 - Middle = 1 - Bottom = 2 - - X position is calculated by taking the grids left co-ord, adding the distance to the column, - then adding 1/2 the spacing multiplied by the align variable above, - Y position likewise, takes the top of the grid, adds the y to the current row then adds the padding in to align it. - -*/ - - // Calculate row and column x and y coords required to allow for columns and rows which are non uniformly sized. - - for (a=0;adata); - sorted = sorted->next; - } - - for (; current_row != NULL; current_row = current_row->next) { - SPItem *item=SP_ITEM(current_row->data); - Inkscape::XML::Node *repr = item->getRepr(); - Geom::OptRect b = item->documentVisualBounds(); - Geom::Point min; - if (b) { - width = b->dimensions()[Geom::X]; - height = b->dimensions()[Geom::Y]; - min = b->min(); - } else { - width = height = 0; - min = Geom::Point(0, 0); - } - - row = cnt / NoOfCols; - col = cnt % NoOfCols; - - new_x = grid_left + (((col_widths[col] - width)/2)*HorizAlign) + col_xs[col]; - new_y = grid_top + (((row_heights[row] - height)/2)*VertAlign) + row_ys[row]; - - // signs are inverted between x and y due to y inversion - Geom::Point move = Geom::Point(new_x - min[Geom::X], min[Geom::Y] - new_y); - Geom::Affine const affine = Geom::Affine(Geom::Translate(move)); - item->set_i2d_affine(item->i2dt_affine() * affine); - item->doWriteTransform(repr, item->transform, NULL); - SP_OBJECT (current_row->data)->updateRepr(); - cnt +=1; - } - g_slist_free (current_row); - } - - DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_SELECTION_GRIDTILE, - _("Arrange in a grid")); - -} - - -//######################################################################### -//## E V E N T S -//######################################################################### - -/** - * changed value in # of columns spinbox. - */ -void GridArrangeTab::on_row_spinbutton_changed() -{ - // quit if run by the attr_changed listener - if (updating) { - return; - } - - // in turn, prevent listener from responding - updating = true; - SPDesktop *desktop = Parent->getDesktop(); - - Inkscape::Selection *selection = desktop ? desktop->selection : 0; - g_return_if_fail( selection ); - - GSList const *items = selection->itemList(); - int selcount = g_slist_length((GSList *)items); - - double PerCol = ceil(selcount / NoOfColsSpinner.get_value()); - NoOfRowsSpinner.set_value(PerCol); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setDouble("/dialogs/gridtiler/NoOfCols", NoOfColsSpinner.get_value()); - updating=false; -} - -/** - * changed value in # of rows spinbox. - */ -void GridArrangeTab::on_col_spinbutton_changed() -{ - // quit if run by the attr_changed listener - if (updating) { - return; - } - - // in turn, prevent listener from responding - updating = true; - SPDesktop *desktop = Parent->getDesktop(); - Inkscape::Selection *selection = desktop ? desktop->selection : 0; - g_return_if_fail(selection); - - GSList const *items = selection->itemList(); - int selcount = g_slist_length((GSList *)items); - - double PerRow = ceil(selcount / NoOfRowsSpinner.get_value()); - NoOfColsSpinner.set_value(PerRow); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setDouble("/dialogs/gridtiler/NoOfCols", PerRow); - - updating=false; -} - -/** - * changed value in x padding spinbox. - */ -void GridArrangeTab::on_xpad_spinbutton_changed() -{ - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setDouble("/dialogs/gridtiler/XPad", XPadding.getValue("px")); - -} - -/** - * changed value in y padding spinbox. - */ -void GridArrangeTab::on_ypad_spinbutton_changed() -{ - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setDouble("/dialogs/gridtiler/YPad", YPadding.getValue("px")); -} - - -/** - * checked/unchecked autosize Rows button. - */ -void GridArrangeTab::on_RowSize_checkbutton_changed() -{ - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - if (RowHeightButton.get_active()) { - prefs->setDouble("/dialogs/gridtiler/AutoRowSize", 20); - } else { - prefs->setDouble("/dialogs/gridtiler/AutoRowSize", -20); - } - RowHeightBox.set_sensitive ( !RowHeightButton.get_active()); -} - -/** - * checked/unchecked autosize Rows button. - */ -void GridArrangeTab::on_ColSize_checkbutton_changed() -{ - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - if (ColumnWidthButton.get_active()) { - prefs->setDouble("/dialogs/gridtiler/AutoColSize", 20); - } else { - prefs->setDouble("/dialogs/gridtiler/AutoColSize", -20); - } - ColumnWidthBox.set_sensitive ( !ColumnWidthButton.get_active()); -} - -/** - * changed value in columns spinbox. - */ -void GridArrangeTab::on_rowSize_spinbutton_changed() -{ - // quit if run by the attr_changed listener - if (updating) { - return; - } - - // in turn, prevent listener from responding - updating = true; - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setDouble("/dialogs/gridtiler/RowHeight", RowHeightSpinner.get_value()); - updating=false; - -} - -/** - * changed value in rows spinbox. - */ -void GridArrangeTab::on_colSize_spinbutton_changed() -{ - // quit if run by the attr_changed listener - if (updating) { - return; - } - - // in turn, prevent listener from responding - updating = true; - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setDouble("/dialogs/gridtiler/ColWidth", ColumnWidthSpinner.get_value()); - updating=false; - -} - -/** - * changed Radio button in Spacing group. - */ -void GridArrangeTab::Spacing_button_changed() -{ - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - if (SpaceManualRadioButton.get_active()) { - prefs->setDouble("/dialogs/gridtiler/SpacingType", 20); - } else { - prefs->setDouble("/dialogs/gridtiler/SpacingType", -20); - } - - XPadding.set_sensitive ( SpaceManualRadioButton.get_active()); - YPadding.set_sensitive ( SpaceManualRadioButton.get_active()); -} - -/** - * changed Anchor selection widget. - */ -void GridArrangeTab::Align_changed() -{ - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - VertAlign = AlignmentSelector.getVerticalAlignment(); - prefs->setInt("/dialogs/gridtiler/VertAlign", VertAlign); - HorizAlign = AlignmentSelector.getHorizontalAlignment(); - prefs->setInt("/dialogs/gridtiler/HorizAlign", HorizAlign); -} - -/** - * Desktop selection changed - */ -void GridArrangeTab::updateSelection() -{ - // quit if run by the attr_changed listener - if (updating) { - return; - } - - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - // in turn, prevent listener from responding - updating = true; - SPDesktop *desktop = Parent->getDesktop(); - Inkscape::Selection *selection = desktop ? desktop->selection : 0; - GSList const *items = selection ? selection->itemList() : 0; - - if (items) { - int selcount = g_slist_length((GSList *)items); - - if (NoOfColsSpinner.get_value() > 1 && NoOfRowsSpinner.get_value() > 1){ - // Update the number of rows assuming number of columns wanted remains same. - double NoOfRows = ceil(selcount / NoOfColsSpinner.get_value()); - NoOfRowsSpinner.set_value(NoOfRows); - - // if the selection has less than the number set for one row, reduce it appropriately - if (selcount < NoOfColsSpinner.get_value()) { - double NoOfCols = ceil(selcount / NoOfRowsSpinner.get_value()); - NoOfColsSpinner.set_value(NoOfCols); - prefs->setInt("/dialogs/gridtiler/NoOfCols", NoOfCols); - } - } else { - double PerRow = ceil(sqrt(selcount)); - double PerCol = ceil(sqrt(selcount)); - NoOfRowsSpinner.set_value(PerRow); - NoOfColsSpinner.set_value(PerCol); - prefs->setInt("/dialogs/gridtiler/NoOfCols", static_cast(PerCol)); - } - } - - updating = false; -} - - - -/*########################## -## Experimental -##########################*/ - -static void updateSelectionCallback(Inkscape::Application */*inkscape*/, Inkscape::Selection */*selection*/, GridArrangeTab *dlg) -{ - dlg->updateSelection(); -} - - -//######################################################################### -//## C O N S T R U C T O R / D E S T R U C T O R -//######################################################################### -/** - * Constructor - */ -GridArrangeTab::GridArrangeTab(ArrangeDialog *parent) - : Parent(parent), - XPadding(_("X:"), _("Horizontal spacing between columns."), UNIT_TYPE_LINEAR, "", "object-columns"), - YPadding(_("Y:"), _("Vertical spacing between rows."), XPadding, "", "object-rows") -{ - // bool used by spin button callbacks to stop loops where they change each other. - updating = false; - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - - // could not do this in gtkmm - there's no Gtk::SizeGroup public constructor (!) - GtkSizeGroup *_col1 = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); - GtkSizeGroup *_col2 = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); - GtkSizeGroup *_col3 = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); - - { - // Selection Change signal - g_signal_connect ( G_OBJECT (INKSCAPE), "change_selection", G_CALLBACK (updateSelectionCallback), this); - } - - Gtk::Box *contents = this; - -#define MARGIN 2 - - //##Set up the panel - - SPDesktop *desktop = Parent->getDesktop(); - - Inkscape::Selection *selection = desktop ? desktop->selection : 0; - g_return_if_fail( selection ); - int selcount = 1; - if (!selection->isEmpty()) { - GSList const *items = selection->itemList(); - selcount = g_slist_length((GSList *)items); - } - - - /*#### Number of Rows ####*/ - - double PerRow = ceil(sqrt(selcount)); - double PerCol = ceil(sqrt(selcount)); - - #ifdef DEBUG_GRID_ARRANGE - g_print("/n PerRox = %f PerCol = %f selcount = %d",PerRow,PerCol,selcount); - #endif - - NoOfRowsLabel.set_text_with_mnemonic(_("_Rows:")); - NoOfRowsLabel.set_mnemonic_widget(NoOfRowsSpinner); - NoOfRowsBox.pack_start(NoOfRowsLabel, false, false, MARGIN); - - NoOfRowsSpinner.set_digits(0); - NoOfRowsSpinner.set_increments(1, 0); - NoOfRowsSpinner.set_range(1.0, 10000.0); - NoOfRowsSpinner.set_value(PerCol); - NoOfRowsSpinner.signal_changed().connect(sigc::mem_fun(*this, &GridArrangeTab::on_col_spinbutton_changed)); - NoOfRowsSpinner.set_tooltip_text(_("Number of rows")); - NoOfRowsBox.pack_start(NoOfRowsSpinner, false, false, MARGIN); - gtk_size_group_add_widget(_col1, (GtkWidget *) NoOfRowsBox.gobj()); - - RowHeightButton.set_label(_("Equal _height")); - RowHeightButton.set_use_underline(true); - double AutoRow = prefs->getDouble("/dialogs/gridtiler/AutoRowSize", 15); - if (AutoRow>0) - AutoRowSize=true; - else - AutoRowSize=false; - RowHeightButton.set_active(AutoRowSize); - - NoOfRowsBox.pack_start(RowHeightButton, false, false, MARGIN); - - RowHeightButton.set_tooltip_text(_("If not set, each row has the height of the tallest object in it")); - RowHeightButton.signal_toggled().connect(sigc::mem_fun(*this, &GridArrangeTab::on_RowSize_checkbutton_changed)); - - SpinsHBox.pack_start(NoOfRowsBox, false, false, MARGIN); - - - /*#### Label for X ####*/ - padXByYLabel.set_label(" "); - XByYLabelVBox.pack_start(padXByYLabel, false, false, MARGIN); - XByYLabel.set_markup(" × "); - XByYLabelVBox.pack_start(XByYLabel, false, false, MARGIN); - SpinsHBox.pack_start(XByYLabelVBox, false, false, MARGIN); - gtk_size_group_add_widget(_col2, (GtkWidget *) XByYLabelVBox.gobj()); - - /*#### Number of columns ####*/ - - NoOfColsLabel.set_text_with_mnemonic(_("_Columns:")); - NoOfColsLabel.set_mnemonic_widget(NoOfColsSpinner); - NoOfColsBox.pack_start(NoOfColsLabel, false, false, MARGIN); - - NoOfColsSpinner.set_digits(0); - NoOfColsSpinner.set_increments(1, 0); - NoOfColsSpinner.set_range(1.0, 10000.0); - NoOfColsSpinner.set_value(PerRow); - NoOfColsSpinner.signal_changed().connect(sigc::mem_fun(*this, &GridArrangeTab::on_row_spinbutton_changed)); - NoOfColsSpinner.set_tooltip_text(_("Number of columns")); - NoOfColsBox.pack_start(NoOfColsSpinner, false, false, MARGIN); - gtk_size_group_add_widget(_col3, (GtkWidget *) NoOfColsBox.gobj()); - - ColumnWidthButton.set_label(_("Equal _width")); - ColumnWidthButton.set_use_underline(true); - double AutoCol = prefs->getDouble("/dialogs/gridtiler/AutoColSize", 15); - if (AutoCol>0) - AutoColSize=true; - else - AutoColSize=false; - ColumnWidthButton.set_active(AutoColSize); - NoOfColsBox.pack_start(ColumnWidthButton, false, false, MARGIN); - - ColumnWidthButton.set_tooltip_text(_("If not set, each column has the width of the widest object in it")); - ColumnWidthButton.signal_toggled().connect(sigc::mem_fun(*this, &GridArrangeTab::on_ColSize_checkbutton_changed)); - - SpinsHBox.pack_start(NoOfColsBox, false, false, MARGIN); - - TileBox.pack_start(SpinsHBox, false, false, MARGIN); - - VertAlign = prefs->getInt("/dialogs/gridtiler/VertAlign", 1); - HorizAlign = prefs->getInt("/dialogs/gridtiler/HorizAlign", 1); - - // Anchor selection widget - AlignLabel.set_label("Alignment:"); - AlignLabel.set_alignment(Gtk::ALIGN_START, Gtk::ALIGN_CENTER); - AlignmentSelector.setAlignment(HorizAlign, VertAlign); - AlignmentSelector.on_selectionChanged().connect(sigc::mem_fun(*this, &GridArrangeTab::Align_changed)); - TileBox.pack_start(AlignLabel, false, false, MARGIN); - TileBox.pack_start(AlignmentSelector, true, false, MARGIN); - - { - /*#### Radio buttons to control spacing manually or to fit selection bbox ####*/ - SpaceByBBoxRadioButton.set_label(_("_Fit into selection box")); - SpaceByBBoxRadioButton.set_use_underline (true); - SpaceByBBoxRadioButton.signal_toggled().connect(sigc::mem_fun(*this, &GridArrangeTab::Spacing_button_changed)); - SpacingGroup = SpaceByBBoxRadioButton.get_group(); - - SpacingVBox.pack_start(SpaceByBBoxRadioButton, false, false, MARGIN); - - SpaceManualRadioButton.set_label(_("_Set spacing:")); - SpaceManualRadioButton.set_use_underline (true); - SpaceManualRadioButton.set_group(SpacingGroup); - SpaceManualRadioButton.signal_toggled().connect(sigc::mem_fun(*this, &GridArrangeTab::Spacing_button_changed)); - SpacingVBox.pack_start(SpaceManualRadioButton, false, false, MARGIN); - - TileBox.pack_start(SpacingVBox, false, false, MARGIN); - } - - { - /*#### Padding ####*/ - - YPadding.setDigits(5); - YPadding.setIncrements(0.2, 0); - YPadding.setRange(-10000, 10000); - double yPad = prefs->getDouble("/dialogs/gridtiler/YPad", 15); - YPadding.setValue(yPad, "px"); - YPadding.signal_value_changed().connect(sigc::mem_fun(*this, &GridArrangeTab::on_ypad_spinbutton_changed)); - - XPadding.setDigits(5); - XPadding.setIncrements(0.2, 0); - XPadding.setRange(-10000, 10000); - double xPad = prefs->getDouble("/dialogs/gridtiler/XPad", 15); - XPadding.setValue(xPad, "px"); - - XPadding.signal_value_changed().connect(sigc::mem_fun(*this, &GridArrangeTab::on_xpad_spinbutton_changed)); - } - TileBox.pack_start(XPadding, false, false, MARGIN); - TileBox.pack_start(YPadding, false, false, MARGIN); - - contents->pack_start(TileBox); - - double SpacingType = prefs->getDouble("/dialogs/gridtiler/SpacingType", 15); - if (SpacingType>0) { - ManualSpacing=true; - } else { - ManualSpacing=false; - } - SpaceManualRadioButton.set_active(ManualSpacing); - SpaceByBBoxRadioButton.set_active(!ManualSpacing); - XPadding.set_sensitive (ManualSpacing); - YPadding.set_sensitive (ManualSpacing); - - //## The OK button FIXME - /*TileOkButton = addResponseButton(C_("Rows and columns dialog","_Arrange"), GTK_RESPONSE_APPLY); - TileOkButton->set_use_underline(true); - TileOkButton->set_tooltip_text(_("Arrange selected objects"));*/ - - show_all_children(); -} - } //namespace Dialog } //namespace UI } //namespace Inkscape diff --git a/src/ui/dialog/tile.h b/src/ui/dialog/tile.h index b09416d04..d42dd7f65 100644 --- a/src/ui/dialog/tile.h +++ b/src/ui/dialog/tile.h @@ -5,6 +5,7 @@ * Bob Jamison ( based off trace dialog) * John Cliff * Other dudes from The Inkscape Organization + * Declara Denis * * Copyright (C) 2004 Bob Jamison * Copyright (C) 2004 John Cliff @@ -20,10 +21,7 @@ #include #include -#include "ui/widget/anchor-selector.h" #include "ui/widget/panel.h" -#include "ui/widget/spinbutton.h" -#include "ui/widget/scalar-unit.h" namespace Gtk { class Button; @@ -33,23 +31,7 @@ namespace Inkscape { namespace UI { namespace Dialog { -/** - * This interface should be implemented by each arrange mode. - * The class is a Gtk::VBox and will be displayed as a tab in - * the dialog - */ -class ArrangeTab : public Gtk::VBox -{ -public: - ArrangeTab() {}; - virtual ~ArrangeTab() {}; - - /** - * Do the actual work! - */ - virtual void arrange() = 0; -}; - +class ArrangeTab; class GridArrangeTab; class PolarArrangeTab; @@ -75,161 +57,6 @@ public: static ArrangeDialog& getInstance() { return *new ArrangeDialog(); } }; -/** - * Dialog for tiling an object - */ -class GridArrangeTab : public ArrangeTab { -public: - GridArrangeTab(ArrangeDialog *parent); - virtual ~GridArrangeTab() {}; - - /** - * Do the actual work - */ - virtual void arrange(); - - /** - * Respond to selection change - */ - void updateSelection(); - - // Callbacks from spinbuttons - void on_row_spinbutton_changed(); - void on_col_spinbutton_changed(); - void on_xpad_spinbutton_changed(); - void on_ypad_spinbutton_changed(); - void on_RowSize_checkbutton_changed(); - void on_ColSize_checkbutton_changed(); - void on_rowSize_spinbutton_changed(); - void on_colSize_spinbutton_changed(); - void Spacing_button_changed(); - void Align_changed(); - - -private: - GridArrangeTab(GridArrangeTab const &d); // no copy - void operator=(GridArrangeTab const &d); // no assign - - ArrangeDialog *Parent; - - bool userHidden; - bool updating; - - Gtk::VBox TileBox; - Gtk::Button *TileOkButton; - Gtk::Button *TileCancelButton; - - // Number selected label - Gtk::Label SelectionContentsLabel; - - - Gtk::HBox AlignHBox; - Gtk::HBox SpinsHBox; - - // Number per Row - Gtk::VBox NoOfColsBox; - Gtk::Label NoOfColsLabel; - Inkscape::UI::Widget::SpinButton NoOfColsSpinner; - bool AutoRowSize; - Gtk::CheckButton RowHeightButton; - - Gtk::VBox XByYLabelVBox; - Gtk::Label padXByYLabel; - Gtk::Label XByYLabel; - - // Number per Column - Gtk::VBox NoOfRowsBox; - Gtk::Label NoOfRowsLabel; - Inkscape::UI::Widget::SpinButton NoOfRowsSpinner; - bool AutoColSize; - Gtk::CheckButton ColumnWidthButton; - - // Alignment - Gtk::Label AlignLabel; - AnchorSelector AlignmentSelector; - double VertAlign; - double HorizAlign; - - Inkscape::UI::Widget::ScalarUnit XPadding; - Inkscape::UI::Widget::ScalarUnit YPadding; - - // BBox or manual spacing - Gtk::VBox SpacingVBox; - Gtk::RadioButtonGroup SpacingGroup; - Gtk::RadioButton SpaceByBBoxRadioButton; - Gtk::RadioButton SpaceManualRadioButton; - bool ManualSpacing; - - // Row height - Gtk::VBox RowHeightVBox; - Gtk::HBox RowHeightBox; - Gtk::Label RowHeightLabel; - Inkscape::UI::Widget::SpinButton RowHeightSpinner; - - // Column width - Gtk::VBox ColumnWidthVBox; - Gtk::HBox ColumnWidthBox; - Gtk::Label ColumnWidthLabel; - Inkscape::UI::Widget::SpinButton ColumnWidthSpinner; -}; - -class PolarArrangeTab : public ArrangeTab { -public: - PolarArrangeTab(ArrangeDialog *parent_); - virtual ~PolarArrangeTab() {}; - - /** - * Do the actual work - */ - virtual void arrange(); - - /** - * Respond to selection change - */ - void updateSelection(); - - void on_anchor_radio_changed(); - void on_arrange_radio_changed(); - -private: - PolarArrangeTab(PolarArrangeTab const &d); // no copy - void operator=(PolarArrangeTab const &d); // no assign - - ArrangeDialog *parent; - - Gtk::Label anchorPointLabel; - - Gtk::RadioButtonGroup anchorRadioGroup; - Gtk::RadioButton anchorBoundingBoxRadio; - Gtk::RadioButton anchorObjectPivotRadio; - AnchorSelector anchorSelector; - - Gtk::Label arrangeOnLabel; - - Gtk::RadioButtonGroup arrangeRadioGroup; - Gtk::RadioButton arrangeOnCircleRadio; - Gtk::RadioButton arrangeOnParametersRadio; - - Gtk::Table parametersTable; - - Gtk::Label centerLabel; - Inkscape::UI::Widget::ScalarUnit centerY; - Inkscape::UI::Widget::ScalarUnit centerX; - - Gtk::Label radiusLabel; - Inkscape::UI::Widget::ScalarUnit radiusY; - Inkscape::UI::Widget::ScalarUnit radiusX; - - Gtk::Label angleLabel; - Inkscape::UI::Widget::ScalarUnit angleY; - Inkscape::UI::Widget::ScalarUnit angleX; - - Gtk::CheckButton rotateObjectsCheckBox; - - -}; - - } //namespace Dialog } //namespace UI } //namespace Inkscape diff --git a/src/verbs.cpp b/src/verbs.cpp index 1b57ad4ff..5d5414213 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -1127,9 +1127,9 @@ void SelectionVerb::perform(SPAction *action, void *data) case SP_VERB_SELECTION_BREAK_APART: sp_selected_path_break_apart(dt); break; - case SP_VERB_SELECTION_GRIDTILE: + case SP_VERB_SELECTION_ARRANGE: inkscape_dialogs_unhide(); - dt->_dlg_mgr->showDialog("TileDialog"); + dt->_dlg_mgr->showDialog("TileDialog"); //FIXME: denis: What's this string (to be changed) break; default: break; @@ -2412,8 +2412,8 @@ Verb *Verb::_base_verbs[] = { // Advanced tutorial for more info new SelectionVerb(SP_VERB_SELECTION_BREAK_APART, "SelectionBreakApart", N_("Break _Apart"), N_("Break selected paths into subpaths"), INKSCAPE_ICON("path-break-apart")), - new SelectionVerb(SP_VERB_SELECTION_GRIDTILE, "DialogGridArrange", N_("Ro_ws and Columns..."), - N_("Arrange selected objects in a table"), INKSCAPE_ICON("dialog-rows-and-columns")), + new SelectionVerb(SP_VERB_SELECTION_ARRANGE, "DialogArrange", N_("_Arrange..."), + N_("Arrange selected objects in a table or circle"), INKSCAPE_ICON("dialog-rows-and-columns")), // Layer new LayerVerb(SP_VERB_LAYER_NEW, "LayerNew", N_("_Add Layer..."), N_("Create a new layer"), INKSCAPE_ICON("layer-new")), diff --git a/src/verbs.h b/src/verbs.h index 1a9efdb81..b666ec92b 100644 --- a/src/verbs.h +++ b/src/verbs.h @@ -130,7 +130,7 @@ enum { SP_VERB_SELECTION_CREATE_BITMAP, SP_VERB_SELECTION_COMBINE, SP_VERB_SELECTION_BREAK_APART, - SP_VERB_SELECTION_GRIDTILE, + SP_VERB_SELECTION_ARRANGE, // Former SP_VERB_SELECTION_GRIDTILE /* Layer */ SP_VERB_LAYER_NEW, SP_VERB_LAYER_RENAME, -- cgit v1.2.3 From 06b0c9af0d579d4c9005bc8acf456288d7bea196 Mon Sep 17 00:00:00 2001 From: Denis Declara Date: Sat, 28 Apr 2012 18:17:05 +0200 Subject: Changed Makefile plus some minor tab vs. spaces fixes (bzr r11073.1.22) --- src/ui/dialog/Makefile_insert | 5 +++++ src/ui/dialog/gridarrangetab.h | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/dialog/Makefile_insert b/src/ui/dialog/Makefile_insert index f8b95247a..34cceae54 100644 --- a/src/ui/dialog/Makefile_insert +++ b/src/ui/dialog/Makefile_insert @@ -5,6 +5,7 @@ ink_common_sources += \ ui/dialog/aboutbox.h \ ui/dialog/align-and-distribute.cpp \ ui/dialog/align-and-distribute.h \ + ui/dialog/arrangetab.h \ ui/dialog/behavior.h \ ui/dialog/calligraphic-profile-rename.h \ ui/dialog/calligraphic-profile-rename.cpp \ @@ -48,6 +49,8 @@ ink_common_sources += \ ui/dialog/floating-behavior.h \ ui/dialog/glyphs.cpp \ ui/dialog/glyphs.h \ + ui/dialog/gridarrangetab.h \ + ui/dialog/gridarrangetab.cpp \ ui/dialog/guides.cpp \ ui/dialog/guides.h \ ui/dialog/icon-preview.cpp \ @@ -75,6 +78,8 @@ ink_common_sources += \ ui/dialog/object-properties.cpp \ ui/dialog/object-properties.h \ ui/dialog/panel-dialog.h \ + ui/dialog/polararrangetab.cpp \ + ui/dialog/polararrangetab.h \ ui/dialog/print.cpp \ ui/dialog/print.h \ ui/dialog/print-colors-preview-dialog.cpp \ diff --git a/src/ui/dialog/gridarrangetab.h b/src/ui/dialog/gridarrangetab.h index bc82258b8..16780e55f 100644 --- a/src/ui/dialog/gridarrangetab.h +++ b/src/ui/dialog/gridarrangetab.h @@ -36,7 +36,7 @@ class ArrangeDialog; */ class GridArrangeTab : public ArrangeTab { public: - GridArrangeTab(ArrangeDialog *parent); + GridArrangeTab(ArrangeDialog *parent); virtual ~GridArrangeTab() {}; /** -- cgit v1.2.3 From d1cc21d52c7800015a3713603cc0eb0ade15549d Mon Sep 17 00:00:00 2001 From: Denis Declara Date: Tue, 1 May 2012 14:16:34 +0200 Subject: Added translation support code (_(), C_()) to the polar arrange tab. (bzr r11073.1.23) --- src/ui/dialog/polararrangetab.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/polararrangetab.cpp b/src/ui/dialog/polararrangetab.cpp index d36a78759..26a163b1c 100644 --- a/src/ui/dialog/polararrangetab.cpp +++ b/src/ui/dialog/polararrangetab.cpp @@ -39,38 +39,38 @@ PolarArrangeTab::PolarArrangeTab(ArrangeDialog *parent_) angleY("", "Starting angle", UNIT_TYPE_RADIAL), angleX("", "End angle", angleY) { - anchorPointLabel.set_text("Anchor point:"); + anchorPointLabel.set_text(C_("Polar arrange tab", "Anchor point:")); anchorPointLabel.set_alignment(Gtk::ALIGN_START); pack_start(anchorPointLabel, false, false); - anchorBoundingBoxRadio.set_label("Object's bounding box:"); + anchorBoundingBoxRadio.set_label(C_("Polar arrange tab", "Object's bounding box:")); anchorRadioGroup = anchorBoundingBoxRadio.get_group(); anchorBoundingBoxRadio.signal_toggled().connect(sigc::mem_fun(*this, &PolarArrangeTab::on_anchor_radio_changed)); pack_start(anchorBoundingBoxRadio, false, false); pack_start(anchorSelector, false, false); - anchorObjectPivotRadio.set_label("Object's rotational center"); + anchorObjectPivotRadio.set_label(C_("Polar arrange tab", "Object's rotational center")); anchorObjectPivotRadio.set_group(anchorRadioGroup); anchorObjectPivotRadio.signal_toggled().connect(sigc::mem_fun(*this, &PolarArrangeTab::on_anchor_radio_changed)); pack_start(anchorObjectPivotRadio, false, false); - arrangeOnLabel.set_text("Arrange on:"); + arrangeOnLabel.set_text(C_("Polar arrange tab", "Arrange on:")); arrangeOnLabel.set_alignment(Gtk::ALIGN_START); pack_start(arrangeOnLabel, false, false); - arrangeOnCircleRadio.set_label("Last selected circle/ellipse/arc"); + arrangeOnCircleRadio.set_label(C_("Polar arrange tab", "Last selected circle/ellipse/arc")); arrangeRadioGroup = arrangeOnCircleRadio.get_group(); arrangeOnCircleRadio.signal_toggled().connect(sigc::mem_fun(*this, &PolarArrangeTab::on_arrange_radio_changed)); pack_start(arrangeOnCircleRadio, false, false); - arrangeOnParametersRadio.set_label("Parameterized:"); + arrangeOnParametersRadio.set_label(C_("Polar arrange tab", "Parameterized:")); arrangeOnParametersRadio.set_group(arrangeRadioGroup); arrangeOnParametersRadio.signal_toggled().connect(sigc::mem_fun(*this, &PolarArrangeTab::on_arrange_radio_changed)); pack_start(arrangeOnParametersRadio, false, false); //FIXME: Objects in grid do not line up properly! - centerLabel.set_text("Center X/Y:"); + centerLabel.set_text(_("Center X/Y:")); parametersTable.attach(centerLabel, 0, 1, 0, 1); centerX.setDigits(2); centerX.set_size_request(60, -1); @@ -85,7 +85,7 @@ PolarArrangeTab::PolarArrangeTab(ArrangeDialog *parent_) parametersTable.attach(centerX, 1, 2, 0, 1); parametersTable.attach(centerY, 2, 3, 0, 1); - radiusLabel.set_text("Radius X/Y:"); + radiusLabel.set_text(_("Radius X/Y:")); parametersTable.attach(radiusLabel, 0, 1, 1, 2); radiusX.setDigits(2); radiusX.set_size_request(60, -1); @@ -100,7 +100,7 @@ PolarArrangeTab::PolarArrangeTab(ArrangeDialog *parent_) parametersTable.attach(radiusX, 1, 2, 1, 2); parametersTable.attach(radiusY, 2, 3, 1, 2); - angleLabel.set_text("Center X/Y:"); + angleLabel.set_text(_("Center X/Y:")); parametersTable.attach(angleLabel, 0, 1, 2, 3); angleX.setDigits(2); angleX.set_size_request(60, -1); @@ -116,7 +116,7 @@ PolarArrangeTab::PolarArrangeTab(ArrangeDialog *parent_) parametersTable.attach(angleY, 2, 3, 2, 3); pack_start(parametersTable, false, false); - rotateObjectsCheckBox.set_label("Rotate objects"); + rotateObjectsCheckBox.set_label(_("Rotate objects")); rotateObjectsCheckBox.set_active(true); pack_start(rotateObjectsCheckBox, false, false); -- cgit v1.2.3 From d5ff00bb49276d55c53060770d7e79e4950b3906 Mon Sep 17 00:00:00 2001 From: Denis Declara Date: Tue, 1 May 2012 16:46:32 +0200 Subject: Got parametrized arrangement to work (bzr r11073.1.25) --- src/ui/dialog/polararrangetab.cpp | 198 ++++++++++++++++++++++++++++++-------- 1 file changed, 156 insertions(+), 42 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/polararrangetab.cpp b/src/ui/dialog/polararrangetab.cpp index 26a163b1c..faad5493b 100644 --- a/src/ui/dialog/polararrangetab.cpp +++ b/src/ui/dialog/polararrangetab.cpp @@ -71,49 +71,49 @@ PolarArrangeTab::PolarArrangeTab(ArrangeDialog *parent_) //FIXME: Objects in grid do not line up properly! centerLabel.set_text(_("Center X/Y:")); - parametersTable.attach(centerLabel, 0, 1, 0, 1); + parametersTable.attach(centerLabel, 0, 1, 0, 1, Gtk::FILL); centerX.setDigits(2); - centerX.set_size_request(60, -1); + //centerX.set_size_request(60, -1); centerX.setIncrements(0.2, 0); centerX.setRange(-10000, 10000); centerX.setValue(0, "px"); centerY.setDigits(2); - centerY.set_size_request(120, -1); + //centerY.set_size_request(120, -1); centerY.setIncrements(0.2, 0); centerY.setRange(-10000, 10000); centerY.setValue(0, "px"); - parametersTable.attach(centerX, 1, 2, 0, 1); - parametersTable.attach(centerY, 2, 3, 0, 1); + parametersTable.attach(centerX, 1, 2, 0, 1, Gtk::FILL); + parametersTable.attach(centerY, 2, 3, 0, 1, Gtk::FILL); radiusLabel.set_text(_("Radius X/Y:")); - parametersTable.attach(radiusLabel, 0, 1, 1, 2); + parametersTable.attach(radiusLabel, 0, 1, 1, 2, Gtk::FILL); radiusX.setDigits(2); - radiusX.set_size_request(60, -1); + //radiusX.set_size_request(60, -1); radiusX.setIncrements(0.2, 0); - radiusX.setRange(-10000, 10000); - radiusX.setValue(0, "px"); + radiusX.setRange(0.001, 10000); + radiusX.setValue(100, "px"); radiusY.setDigits(2); - radiusY.set_size_request(120, -1); + //radiusY.set_size_request(120, -1); radiusY.setIncrements(0.2, 0); - radiusY.setRange(-10000, 10000); - radiusY.setValue(0, "px"); - parametersTable.attach(radiusX, 1, 2, 1, 2); - parametersTable.attach(radiusY, 2, 3, 1, 2); + radiusY.setRange(0.001, 10000); + radiusY.setValue(100, "px"); + parametersTable.attach(radiusX, 1, 2, 1, 2, Gtk::FILL); + parametersTable.attach(radiusY, 2, 3, 1, 2, Gtk::FILL); - angleLabel.set_text(_("Center X/Y:")); - parametersTable.attach(angleLabel, 0, 1, 2, 3); + angleLabel.set_text(_("Angle X/Y:")); + parametersTable.attach(angleLabel, 0, 1, 2, 3, Gtk::FILL); angleX.setDigits(2); - angleX.set_size_request(60, -1); + //angleX.set_size_request(60, -1); angleX.setIncrements(0.2, 0); angleX.setRange(-10000, 10000); angleX.setValue(0, "°"); angleY.setDigits(2); - angleY.set_size_request(120, -1); + //angleY.set_size_request(120, -1); angleY.setIncrements(0.2, 0); angleY.setRange(-10000, 10000); - angleY.setValue(0, "°"); - parametersTable.attach(angleX, 1, 2, 2, 3); - parametersTable.attach(angleY, 2, 3, 2, 3); + angleY.setValue(180, "°"); + parametersTable.attach(angleX, 1, 2, 2, 3, Gtk::FILL); + parametersTable.attach(angleY, 2, 3, 2, 3, Gtk::FILL); pack_start(parametersTable, false, false); rotateObjectsCheckBox.set_label(_("Rotate objects")); @@ -128,39 +128,153 @@ PolarArrangeTab::PolarArrangeTab(ArrangeDialog *parent_) radiusY.set_sensitive(false); } +void rotateAround(SPItem *item, Geom::Point center, Geom::Rotate const &rotation) +{ + Geom::Translate const s(center); + Geom::Affine affine = Geom::Affine(s).inverse() * Geom::Affine(rotation) * Geom::Affine(s); + + // Save old center + center = item->getCenter(); + + item->set_i2d_affine(item->i2dt_affine() * affine); + item->doWriteTransform(item->getRepr(), item->transform); + + if(item->isCenterSet()) + { + item->setCenter(center * affine); + item->updateRepr(); + } +} + +float calcAngle(float arcBegin, float arcEnd, int count, int n) +{ + float arcLength = arcEnd - arcBegin; + if(abs(abs(arcLength) - 2*M_PI) > 0.0001) count--; // If not a complete circle, put an object also at the extremes of the arc; + + float angle = n / (float)count; + // Normalize for arcLength: + angle = angle * arcLength; + angle += arcBegin; + + return angle; +} + +Geom::Point calcPoint(float cx, float cy, float rx, float ry, float angle) +{ + // Parameters for radius equation + float a = ry * cos(angle); + float b = rx * sin(angle); + + float radius = (rx * ry) / sqrtf((a*a) + (b*b)); + + return Geom::Point(cos(angle) * radius + cx, sin(angle) * radius + cy); +} + +Geom::Point getAnchorPoint(int anchor, SPItem *item) +{ + Geom::Point source; + + Geom::OptRect bbox = item->documentVisualBounds(); + + switch(anchor) + { + case 0: // Top - Left + case 3: // Middle - Left + case 6: // Bottom - Left + source[0] = bbox->min()[Geom::X]; + break; + case 1: // Top - Middle + case 4: // Middle - Middle + case 7: // Bottom - Middle + source[0] = (bbox->min()[Geom::X] + bbox->max()[Geom::X]) / 2.0f; + break; + case 2: // Top - Right + case 5: // Middle - Right + case 8: // Bottom - Right + source[0] = bbox->max()[Geom::X]; + break; + }; + + switch(anchor) + { + case 0: // Top - Left + case 1: // Top - Middle + case 2: // Top - Right + source[1] = bbox->min()[Geom::Y]; + break; + case 3: // Middle - Left + case 4: // Middle - Middle + case 5: // Middle - Right + source[1] = (bbox->min()[Geom::Y] + bbox->max()[Geom::Y]) / 2.0f; + break; + case 6: // Bottom - Left + case 7: // Bottom - Middle + case 8: // Bottom - Right + source[1] = bbox->max()[Geom::Y]; + break; + }; + + // If using center + if(anchor == 9) + source = item->getCenter(); + else + { + source[1] -= item->document->getHeight(); + source[1] *= -1; + } + + return source; +} + +void moveToPoint(int anchor, SPItem *item, Geom::Point p) +{ + sp_item_move_rel(item, Geom::Translate(p - getAnchorPoint(anchor, item))); +} + void PolarArrangeTab::arrange() { std::cout << "PolarArrangeTab::arrange()" << std::endl; Inkscape::Selection *selection = sp_desktop_selection(parent->getDesktop()); - const GSList *items = selection->itemList(); - int i = 0; - while(items) - { - SPItem *item = SP_ITEM(items->data); + const GSList *items, *tmp; + tmp = items = selection->itemList(); - float centerx = 1000; - float centery = 2000; + int count = 0; + while(tmp) + { + tmp = tmp->next; + ++count; + } - float radiusx = 1000; - float radiusy = 2000; + // Read options from UI + float cx = centerX.getValue("px"); + float cy = centerY.getValue("px"); + float rx = radiusX.getValue("px"); + float ry = radiusY.getValue("px"); + float arcBeg = angleX.getValue("rad"); + float arcEnd = angleY.getValue("rad"); - float objectx = - item->documentVisualBounds()->min()[Geom::X]; - float objecty = item->documentVisualBounds()->min()[Geom::Y]; + int anchor = 9; + if(anchorBoundingBoxRadio.get_active()) + { + anchor = anchorSelector.getHorizontalAlignment() + + anchorSelector.getVerticalAlignment() * 3; + } - float angle = M_PI / 36 * i; + tmp = items; + int i = 0; + while(tmp) + { + SPItem *item = SP_ITEM(tmp->data); - float r = (radiusx * radiusy) / - sqrtf(powf(radiusy * cos(angle), 2) + powf(radiusx * sin(angle), 2)); - float calcx = cos(angle) * r; - float calcy = sin(angle) * r; + float angle = calcAngle(arcBeg, arcEnd, count, i); + Geom::Point newLocation = calcPoint(cx, cy, rx, ry, angle); - sp_item_move_rel(item, Geom::Translate(objectx + calcx, objecty + calcy)); - sp_item_rotate_rel(item, Geom::Rotate(angle)); + moveToPoint(anchor, item, newLocation); - //item->set_i2d_affine(item->i2dt_affine() * toOrigin * rotation); - //item->doWriteTransform(item->getRepr(), item->transform, NULL); + if(rotateObjectsCheckBox.get_active()) + rotateAround(item, newLocation, Geom::Rotate(angle)); - items = items->next; + tmp = tmp->next; ++i; } } -- cgit v1.2.3 From ad72a653c9ae867201bb36fc41a4e8eb2459d0d5 Mon Sep 17 00:00:00 2001 From: Denis Declara Date: Tue, 1 May 2012 17:19:13 +0200 Subject: Added undo support for polar arrangement as well as some minor fixes (bzr r11073.1.26) --- src/ui/dialog/polararrangetab.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/dialog/polararrangetab.cpp b/src/ui/dialog/polararrangetab.cpp index faad5493b..afb2ce680 100644 --- a/src/ui/dialog/polararrangetab.cpp +++ b/src/ui/dialog/polararrangetab.cpp @@ -149,7 +149,8 @@ void rotateAround(SPItem *item, Geom::Point center, Geom::Rotate const &rotation float calcAngle(float arcBegin, float arcEnd, int count, int n) { float arcLength = arcEnd - arcBegin; - if(abs(abs(arcLength) - 2*M_PI) > 0.0001) count--; // If not a complete circle, put an object also at the extremes of the arc; + float delta = std::abs(std::abs(arcLength) - 2*M_PI); + if(delta > 0.01) count--; // If not a complete circle, put an object also at the extremes of the arc; float angle = n / (float)count; // Normalize for arcLength: @@ -277,6 +278,9 @@ void PolarArrangeTab::arrange() tmp = tmp->next; ++i; } + + DocumentUndo::done(sp_desktop_document(parent->getDesktop()), SP_VERB_SELECTION_ARRANGE, + _("Arrange on ellipse")); } void PolarArrangeTab::updateSelection() -- cgit v1.2.3 From eb9d9b2480d4549f7887b1dc2a75339062f78895 Mon Sep 17 00:00:00 2001 From: Denis Declara Date: Thu, 3 May 2012 16:36:41 +0200 Subject: Now also the "Arrange on last selected circle" option of the polar arrangement works. (bzr r11073.1.27) --- src/ui/dialog/polararrangetab.cpp | 92 +++++++++++++++++++++++++++++++++------ 1 file changed, 79 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/polararrangetab.cpp b/src/ui/dialog/polararrangetab.cpp index afb2ce680..ce78e43a4 100644 --- a/src/ui/dialog/polararrangetab.cpp +++ b/src/ui/dialog/polararrangetab.cpp @@ -23,6 +23,7 @@ #include "sp-item.h" #include "widgets/icon.h" #include "desktop.h" +#include "sp-ellipse.h" #include "sp-item-transform.h" namespace Inkscape { @@ -128,6 +129,12 @@ PolarArrangeTab::PolarArrangeTab(ArrangeDialog *parent_) radiusY.set_sensitive(false); } +/** + * This function rotates an item around a given point by a given amount + * @param item item to rotate + * @param center center of the rotation to perform + * @param rotation amount to rotate the object by + */ void rotateAround(SPItem *item, Geom::Point center, Geom::Rotate const &rotation) { Geom::Translate const s(center); @@ -146,6 +153,15 @@ void rotateAround(SPItem *item, Geom::Point center, Geom::Rotate const &rotation } } +/** + * Calculates the angle at which to put an object given the total amount + * of objects, the index of the objects as well as the arc start and end + * points + * @param arcBegin angle at which the arc begins + * @param arcEnd angle at which the arc ends + * @param count number of objects in the selection + * @param n index of the object in the selection + */ float calcAngle(float arcBegin, float arcEnd, int count, int n) { float arcLength = arcEnd - arcBegin; @@ -160,6 +176,10 @@ float calcAngle(float arcBegin, float arcEnd, int count, int n) return angle; } +/** + * Calculates the point at which the object needs to be, given the center of the ellipse, + * it's radius (x and y), as well as the angle + */ Geom::Point calcPoint(float cx, float cy, float rx, float ry, float angle) { // Parameters for radius equation @@ -220,6 +240,7 @@ Geom::Point getAnchorPoint(int anchor, SPItem *item) source = item->getCenter(); else { + // FIXME: source[1] -= item->document->getHeight(); source[1] *= -1; } @@ -235,24 +256,64 @@ void moveToPoint(int anchor, SPItem *item, Geom::Point p) void PolarArrangeTab::arrange() { std::cout << "PolarArrangeTab::arrange()" << std::endl; + Inkscape::Selection *selection = sp_desktop_selection(parent->getDesktop()); const GSList *items, *tmp; tmp = items = selection->itemList(); + SPGenericEllipse *referenceEllipse = NULL; // Last ellipse in selection int count = 0; while(tmp) { + SPItem *item = SP_ITEM(tmp->data); + + // The last selected ellipse is actually the first in list + if(SP_IS_GENERICELLIPSE(item) && referenceEllipse == NULL) + referenceEllipse = SP_GENERICELLIPSE(item); + tmp = tmp->next; ++count; } - // Read options from UI - float cx = centerX.getValue("px"); - float cy = centerY.getValue("px"); - float rx = radiusX.getValue("px"); - float ry = radiusY.getValue("px"); - float arcBeg = angleX.getValue("rad"); - float arcEnd = angleY.getValue("rad"); + float cx, cy; // Center of the ellipse + float rx, ry; // Radiuses of the ellipse in x and y direction + float arcBeg, arcEnd; // begin and end angles for arcs + Geom::Affine transformation; // Any additional transformation to apply to the objects + + if(arrangeOnCircleRadio.get_active()) + { + if(referenceEllipse == NULL) + { + Gtk::MessageDialog dialog(_("Couldn't find an ellipse in selection"), false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_CLOSE, true); + dialog.run(); + return; + } else { + cx = referenceEllipse->cx.value; + cy = referenceEllipse->cy.value; + rx = referenceEllipse->rx.value; + ry = referenceEllipse->ry.value; + arcBeg = referenceEllipse->start; + arcEnd = referenceEllipse->end; + transformation = referenceEllipse->i2dt_affine(); + + // We decrement the count by 1 as we are not going to lay + // out the reference ellipse + --count; + } + + } else { + // Read options from UI + cx = centerX.getValue("px"); + cy = centerY.getValue("px"); + rx = radiusX.getValue("px"); + ry = radiusY.getValue("px"); + arcBeg = angleX.getValue("rad"); + arcEnd = angleY.getValue("rad"); + transformation.setIdentity(); + referenceEllipse = NULL; + } + + int anchor = 9; if(anchorBoundingBoxRadio.get_active()) @@ -267,16 +328,21 @@ void PolarArrangeTab::arrange() { SPItem *item = SP_ITEM(tmp->data); - float angle = calcAngle(arcBeg, arcEnd, count, i); - Geom::Point newLocation = calcPoint(cx, cy, rx, ry, angle); + // Ignore the reference ellipse if any + if(item != referenceEllipse) + { + float angle = calcAngle(arcBeg, arcEnd, count, i); + Geom::Point newLocation = calcPoint(cx, cy, rx, ry, angle) * transformation; + + moveToPoint(anchor, item, newLocation); - moveToPoint(anchor, item, newLocation); + if(rotateObjectsCheckBox.get_active()) + rotateAround(item, newLocation, Geom::Rotate(angle)); - if(rotateObjectsCheckBox.get_active()) - rotateAround(item, newLocation, Geom::Rotate(angle)); + ++i; + } tmp = tmp->next; - ++i; } DocumentUndo::done(sp_desktop_document(parent->getDesktop()), SP_VERB_SELECTION_ARRANGE, -- cgit v1.2.3 From 822480f5f68d7a1cd6aea9f4031f98b33980215e Mon Sep 17 00:00:00 2001 From: Denis Declara Date: Sat, 5 May 2012 15:31:09 +0200 Subject: Fixed some math, so that the objects now line up correctly (bzr r11073.1.28) --- src/ui/dialog/polararrangetab.cpp | 70 ++++++++++++++++++++++++++------------- src/ui/dialog/polararrangetab.h | 3 +- 2 files changed, 49 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/polararrangetab.cpp b/src/ui/dialog/polararrangetab.cpp index ce78e43a4..6968be35a 100644 --- a/src/ui/dialog/polararrangetab.cpp +++ b/src/ui/dialog/polararrangetab.cpp @@ -60,10 +60,15 @@ PolarArrangeTab::PolarArrangeTab(ArrangeDialog *parent_) arrangeOnLabel.set_alignment(Gtk::ALIGN_START); pack_start(arrangeOnLabel, false, false); - arrangeOnCircleRadio.set_label(C_("Polar arrange tab", "Last selected circle/ellipse/arc")); - arrangeRadioGroup = arrangeOnCircleRadio.get_group(); - arrangeOnCircleRadio.signal_toggled().connect(sigc::mem_fun(*this, &PolarArrangeTab::on_arrange_radio_changed)); - pack_start(arrangeOnCircleRadio, false, false); + arrangeOnFirstCircleRadio.set_label(C_("Polar arrange tab", "First selected circle/ellipse/arc")); + arrangeRadioGroup = arrangeOnFirstCircleRadio.get_group(); + arrangeOnFirstCircleRadio.signal_toggled().connect(sigc::mem_fun(*this, &PolarArrangeTab::on_arrange_radio_changed)); + pack_start(arrangeOnFirstCircleRadio, false, false); + + arrangeOnLastCircleRadio.set_label(C_("Polar arrange tab", "Last selected circle/ellipse/arc")); + arrangeOnLastCircleRadio.set_group(arrangeRadioGroup); + arrangeOnLastCircleRadio.signal_toggled().connect(sigc::mem_fun(*this, &PolarArrangeTab::on_arrange_radio_changed)); + pack_start(arrangeOnLastCircleRadio, false, false); arrangeOnParametersRadio.set_label(C_("Polar arrange tab", "Parameterized:")); arrangeOnParametersRadio.set_group(arrangeRadioGroup); @@ -182,15 +187,16 @@ float calcAngle(float arcBegin, float arcEnd, int count, int n) */ Geom::Point calcPoint(float cx, float cy, float rx, float ry, float angle) { - // Parameters for radius equation - float a = ry * cos(angle); - float b = rx * sin(angle); - - float radius = (rx * ry) / sqrtf((a*a) + (b*b)); - - return Geom::Point(cos(angle) * radius + cx, sin(angle) * radius + cy); + return Geom::Point(cx + cos(angle) * rx, cy + sin(angle) * ry); } +/** + * Returns the selected anchor point in document coordinates. If anchor + * is 0 to 8, then a bounding box point has been choosen. If it is 9 however + * the rotational center is chosen. + * @todo still using a hack to get the real coordinate space (subtracting document height + * and inverting axes) + */ Geom::Point getAnchorPoint(int anchor, SPItem *item) { Geom::Point source; @@ -262,15 +268,27 @@ void PolarArrangeTab::arrange() tmp = items = selection->itemList(); SPGenericEllipse *referenceEllipse = NULL; // Last ellipse in selection + bool arrangeOnEllipse = !arrangeOnParametersRadio.get_active(); + bool arrangeOnFirstEllipse = arrangeOnEllipse && arrangeOnFirstCircleRadio.get_active(); + int count = 0; while(tmp) { - SPItem *item = SP_ITEM(tmp->data); - - // The last selected ellipse is actually the first in list - if(SP_IS_GENERICELLIPSE(item) && referenceEllipse == NULL) - referenceEllipse = SP_GENERICELLIPSE(item); - + if(arrangeOnEllipse) + { + SPItem *item = SP_ITEM(tmp->data); + + if(arrangeOnFirstEllipse) + { + // The first selected ellipse is actually the last one in the list + if(SP_IS_GENERICELLIPSE(item)) + referenceEllipse = SP_GENERICELLIPSE(item); + } else { + // The last selected ellipse is actually the first in list + if(SP_IS_GENERICELLIPSE(item) && referenceEllipse == NULL) + referenceEllipse = SP_GENERICELLIPSE(item); + } + } tmp = tmp->next; ++count; } @@ -280,7 +298,7 @@ void PolarArrangeTab::arrange() float arcBeg, arcEnd; // begin and end angles for arcs Geom::Affine transformation; // Any additional transformation to apply to the objects - if(arrangeOnCircleRadio.get_active()) + if(arrangeOnEllipse) { if(referenceEllipse == NULL) { @@ -294,6 +312,8 @@ void PolarArrangeTab::arrange() ry = referenceEllipse->ry.value; arcBeg = referenceEllipse->start; arcEnd = referenceEllipse->end; + + std::cout << "Arc: " << arcBeg << ", " << arcEnd << std::endl; transformation = referenceEllipse->i2dt_affine(); // We decrement the count by 1 as we are not going to lay @@ -313,8 +333,6 @@ void PolarArrangeTab::arrange() referenceEllipse = NULL; } - - int anchor = 9; if(anchorBoundingBoxRadio.get_active()) { @@ -322,6 +340,8 @@ void PolarArrangeTab::arrange() anchorSelector.getVerticalAlignment() * 3; } + Geom::Point realCenter = Geom::Point(cx, cy) * transformation; + tmp = items; int i = 0; while(tmp) @@ -336,12 +356,16 @@ void PolarArrangeTab::arrange() moveToPoint(anchor, item, newLocation); - if(rotateObjectsCheckBox.get_active()) + if(rotateObjectsCheckBox.get_active()) { + // Calculate the angle by which to rotate each object + angle = -atan2f(newLocation.x() - realCenter.x(), newLocation.y() - realCenter.y()); rotateAround(item, newLocation, Geom::Rotate(angle)); + } + + std::cout << "object " << i << " out of " << count << ": " << angle << std::endl; ++i; } - tmp = tmp->next; } @@ -355,7 +379,7 @@ void PolarArrangeTab::updateSelection() void PolarArrangeTab::on_arrange_radio_changed() { - bool arrangeParametric = !arrangeOnCircleRadio.get_active(); + bool arrangeParametric = arrangeOnParametersRadio.get_active(); centerX.set_sensitive(arrangeParametric); centerY.set_sensitive(arrangeParametric); diff --git a/src/ui/dialog/polararrangetab.h b/src/ui/dialog/polararrangetab.h index 81b7de4d9..24760a8bc 100644 --- a/src/ui/dialog/polararrangetab.h +++ b/src/ui/dialog/polararrangetab.h @@ -57,7 +57,8 @@ private: Gtk::Label arrangeOnLabel; Gtk::RadioButtonGroup arrangeRadioGroup; - Gtk::RadioButton arrangeOnCircleRadio; + Gtk::RadioButton arrangeOnFirstCircleRadio; + Gtk::RadioButton arrangeOnLastCircleRadio; Gtk::RadioButton arrangeOnParametersRadio; Gtk::Table parametersTable; -- cgit v1.2.3 From 71d330c244fa7da51136dee09c2132814e84fdcf Mon Sep 17 00:00:00 2001 From: Denis Declara Date: Wed, 9 May 2012 16:50:16 +0200 Subject: Fixed runtime assertion about Parent beeing Null (bzr r11073.1.30) --- src/ui/dialog/tile.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/ui/dialog/tile.cpp b/src/ui/dialog/tile.cpp index 879c9182f..917544d3d 100644 --- a/src/ui/dialog/tile.cpp +++ b/src/ui/dialog/tile.cpp @@ -40,7 +40,6 @@ ArrangeDialog::ArrangeDialog() _arrangeButton = this->addResponseButton(C_("Arrange dialog","_Arrange"), GTK_RESPONSE_APPLY); _arrangeButton->set_use_underline(true); _arrangeButton->set_tooltip_text(_("Arrange selected objects")); - _arrangeBox.pack_start(*_arrangeButton); contents->pack_start(_arrangeBox); show_all_children(); } -- cgit v1.2.3 From 2b693f8037ad4b25b368376274811f20f5864c1b Mon Sep 17 00:00:00 2001 From: Denis Declara Date: Wed, 9 May 2012 17:03:55 +0200 Subject: Renamed files to better match coding conventions (bzr r11073.1.31) --- src/ui/CMakeLists.txt | 8 +- src/ui/dialog/Makefile_insert | 8 +- src/ui/dialog/grid-arrange-tab.cpp | 786 ++++++++++++++++++++++++++++++++++++ src/ui/dialog/grid-arrange-tab.h | 147 +++++++ src/ui/dialog/gridarrangetab.cpp | 786 ------------------------------------ src/ui/dialog/gridarrangetab.h | 147 ------- src/ui/dialog/polar-arrange-tab.cpp | 414 +++++++++++++++++++ src/ui/dialog/polar-arrange-tab.h | 87 ++++ src/ui/dialog/polararrangetab.cpp | 414 ------------------- src/ui/dialog/polararrangetab.h | 87 ---- src/ui/dialog/tile.cpp | 4 +- src/ui/widget/anchor-selector.cpp | 19 + src/ui/widget/anchor-selector.h | 19 + 13 files changed, 1482 insertions(+), 1444 deletions(-) create mode 100644 src/ui/dialog/grid-arrange-tab.cpp create mode 100644 src/ui/dialog/grid-arrange-tab.h delete mode 100644 src/ui/dialog/gridarrangetab.cpp delete mode 100644 src/ui/dialog/gridarrangetab.h create mode 100644 src/ui/dialog/polar-arrange-tab.cpp create mode 100644 src/ui/dialog/polar-arrange-tab.h delete mode 100644 src/ui/dialog/polararrangetab.cpp delete mode 100644 src/ui/dialog/polararrangetab.h (limited to 'src') diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 22f6b2bab..7435720fd 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -43,7 +43,7 @@ set(ui_SRC dialog/find.cpp dialog/floating-behavior.cpp dialog/glyphs.cpp - dialog/gridarrangetab.cpp + dialog/grid-arrange-tab.cpp dialog/guides.cpp dialog/icon-preview.cpp dialog/inkscape-preferences.cpp @@ -57,7 +57,7 @@ set(ui_SRC dialog/object-attributes.cpp dialog/object-properties.cpp dialog/ocaldialogs.cpp - dialog/polararrangetab.cpp + dialog/polar-arrange-tab.cpp dialog/print-colors-preview-dialog.cpp dialog/print.cpp dialog/scriptdialog.cpp @@ -160,7 +160,7 @@ set(ui_SRC dialog/floating-behavior.h dialog/glyphs.h dialog/guides.h - dialog/gridarrangetab.h + dialog/grid-arrange-tab.h dialog/icon-preview.h dialog/inkscape-preferences.h dialog/input.h @@ -174,7 +174,7 @@ set(ui_SRC dialog/object-properties.h dialog/ocaldialogs.h dialog/panel-dialog.h - dialog/polararrangetab.h + dialog/polar-arrange-tab.h dialog/print-colors-preview-dialog.h dialog/print.h dialog/scriptdialog.h diff --git a/src/ui/dialog/Makefile_insert b/src/ui/dialog/Makefile_insert index 34cceae54..53533a08f 100644 --- a/src/ui/dialog/Makefile_insert +++ b/src/ui/dialog/Makefile_insert @@ -49,8 +49,8 @@ ink_common_sources += \ ui/dialog/floating-behavior.h \ ui/dialog/glyphs.cpp \ ui/dialog/glyphs.h \ - ui/dialog/gridarrangetab.h \ - ui/dialog/gridarrangetab.cpp \ + ui/dialog/grid-arrange-tab.h \ + ui/dialog/grid-arrange-tab.cpp \ ui/dialog/guides.cpp \ ui/dialog/guides.h \ ui/dialog/icon-preview.cpp \ @@ -78,8 +78,8 @@ ink_common_sources += \ ui/dialog/object-properties.cpp \ ui/dialog/object-properties.h \ ui/dialog/panel-dialog.h \ - ui/dialog/polararrangetab.cpp \ - ui/dialog/polararrangetab.h \ + ui/dialog/polar-arrange-tab.cpp \ + ui/dialog/polar-arrange-tab.h \ ui/dialog/print.cpp \ ui/dialog/print.h \ ui/dialog/print-colors-preview-dialog.cpp \ diff --git a/src/ui/dialog/grid-arrange-tab.cpp b/src/ui/dialog/grid-arrange-tab.cpp new file mode 100644 index 000000000..54b667ed9 --- /dev/null +++ b/src/ui/dialog/grid-arrange-tab.cpp @@ -0,0 +1,786 @@ +/* + * A simple dialog for creating grid type arrangements of selected objects + * + * Authors: + * Bob Jamison ( based off trace dialog) + * John Cliff + * Other dudes from The Inkscape Organization + * Abhishek Sharma + * Declara Denis + * + * Copyright (C) 2004 Bob Jamison + * Copyright (C) 2004 John Cliff + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ +//#define DEBUG_GRID_ARRANGE 1 + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include "ui/dialog/grid-arrange-tab.h" +#include //for GTK_RESPONSE* types +#include +#include +#include <2geom/transforms.h> + +#include "verbs.h" +#include "preferences.h" +#include "inkscape.h" +#include "desktop-handles.h" +#include "selection.h" +#include "document.h" +#include "document-undo.h" +#include "sp-item.h" +#include "widgets/icon.h" +#include "desktop.h" +//#include "sp-item-transform.h" FIXME +#include "ui/dialog/tile.h" // for Inkscape::UI::Dialog::ArrangeDialog + +/* + * Sort items by their x co-ordinates, taking account of y (keeps rows intact) + * + * <0 *elem1 goes before *elem2 + * 0 *elem1 == *elem2 + * >0 *elem1 goes after *elem2 + */ +int sp_compare_x_position(SPItem *first, SPItem *second) +{ + using Geom::X; + using Geom::Y; + + Geom::OptRect a = first->documentVisualBounds(); + Geom::OptRect b = second->documentVisualBounds(); + + if ( !a || !b ) { + // FIXME? + return 0; + } + + double const a_height = a->dimensions()[Y]; + double const b_height = b->dimensions()[Y]; + + bool a_in_b_vert = false; + if ((a->min()[Y] < b->min()[Y] + 0.1) && (a->min()[Y] > b->min()[Y] - b_height)) { + a_in_b_vert = true; + } else if ((b->min()[Y] < a->min()[Y] + 0.1) && (b->min()[Y] > a->min()[Y] - a_height)) { + a_in_b_vert = true; + } else if (b->min()[Y] == a->min()[Y]) { + a_in_b_vert = true; + } else { + a_in_b_vert = false; + } + + if (!a_in_b_vert) { + return -1; + } + if (a_in_b_vert && a->min()[X] > b->min()[X]) { + return 1; + } + if (a_in_b_vert && a->min()[X] < b->min()[X]) { + return -1; + } + return 0; +} + +/* + * Sort items by their y co-ordinates. + */ +int sp_compare_y_position(SPItem *first, SPItem *second) +{ + Geom::OptRect a = first->documentVisualBounds(); + Geom::OptRect b = second->documentVisualBounds(); + + if ( !a || !b ) { + // FIXME? + return 0; + } + + if (a->min()[Geom::Y] > b->min()[Geom::Y]) { + return 1; + } + if (a->min()[Geom::Y] < b->min()[Geom::Y]) { + return -1; + } + + return 0; +} + +namespace Inkscape { +namespace UI { +namespace Dialog { + + +//######################################################################### +//## E V E N T S +//######################################################################### + +/* + * + * This arranges the selection in a grid pattern. + * + */ + +void GridArrangeTab::arrange() +{ + + int cnt,row_cnt,col_cnt,a,row,col; + double grid_left,grid_top,col_width,row_height,paddingx,paddingy,width, height, new_x, new_y,cx,cy; + double total_col_width,total_row_height; + col_width = 0; + row_height = 0; + total_col_width=0; + total_row_height=0; + + // check for correct numbers in the row- and col-spinners + on_col_spinbutton_changed(); + on_row_spinbutton_changed(); + + // set padding to manual values + paddingx = XPadding.getValue("px"); + paddingy = YPadding.getValue("px"); + + std::vector row_heights; + std::vector col_widths; + std::vector row_ys; + std::vector col_xs; + + int NoOfCols = NoOfColsSpinner.get_value_as_int(); + int NoOfRows = NoOfRowsSpinner.get_value_as_int(); + + width = 0; + for (a=0;agetDesktop(); + sp_desktop_document(desktop)->ensureUpToDate(); + + Inkscape::Selection *selection = sp_desktop_selection (desktop); + const GSList *items = selection ? selection->itemList() : 0; + cnt=0; + for (; items != NULL; items = items->next) { + SPItem *item = SP_ITEM(items->data); + Geom::OptRect b = item->documentVisualBounds(); + if (!b) { + continue; + } + + width = b->dimensions()[Geom::X]; + height = b->dimensions()[Geom::Y]; + + cx = b->midpoint()[Geom::X]; + cy = b->midpoint()[Geom::Y]; + + if (b->min()[Geom::X] < grid_left) { + grid_left = b->min()[Geom::X]; + } + if (b->min()[Geom::Y] < grid_top) { + grid_top = b->min()[Geom::Y]; + } + if (width > col_width) { + col_width = width; + } + if (height > row_height) { + row_height = height; + } + } + + + // require the sorting done before we can calculate row heights etc. + + g_return_if_fail(selection); + const GSList *items2 = selection->itemList(); + GSList *rev = g_slist_copy((GSList *) items2); + GSList *sorted = NULL; + rev = g_slist_sort(rev, (GCompareFunc) sp_compare_y_position); + sorted = g_slist_sort(rev, (GCompareFunc) sp_compare_x_position); + + + // Calculate individual Row and Column sizes if necessary + + + cnt=0; + const GSList *sizes = sorted; + for (; sizes != NULL; sizes = sizes->next) { + SPItem *item = SP_ITEM(sizes->data); + Geom::OptRect b = item->documentVisualBounds(); + if (b) { + width = b->dimensions()[Geom::X]; + height = b->dimensions()[Geom::Y]; + if (width > col_widths[(cnt % NoOfCols)]) { + col_widths[(cnt % NoOfCols)] = width; + } + if (height > row_heights[(cnt / NoOfCols)]) { + row_heights[(cnt / NoOfCols)] = height; + } + } + + cnt++; + } + + + /// Make sure the top and left of the grid dont move by compensating for align values. + if (RowHeightButton.get_active()){ + grid_top = grid_top - (((row_height - row_heights[0]) / 2)*(VertAlign)); + } + if (ColumnWidthButton.get_active()){ + grid_left = grid_left - (((col_width - col_widths[0]) /2)*(HorizAlign)); + } + + #ifdef DEBUG_GRID_ARRANGE + g_print("\n cx = %f cy= %f gridleft=%f",cx,cy,grid_left); + #endif + + // Calculate total widths and heights, allowing for columns and rows non uniformly sized. + + if (ColumnWidthButton.get_active()){ + total_col_width = col_width * NoOfCols; + col_widths.clear(); + for (a=0;avisualBounds(); + // Fit to bbox, calculate padding between rows accordingly. + if ( sel_bbox && !SpaceManualRadioButton.get_active() ){ +#ifdef DEBUG_GRID_ARRANGE +g_print("\n row = %f col = %f selection x= %f selection y = %f", total_row_height,total_col_width, b.extent(Geom::X), b.extent(Geom::Y)); +#endif + paddingx = (sel_bbox->width() - total_col_width) / (NoOfCols -1); + paddingy = (sel_bbox->height() - total_row_height) / (NoOfRows -1); + } + +/* + Horizontal align - Left = 0 + Centre = 1 + Right = 2 + + Vertical align - Top = 0 + Middle = 1 + Bottom = 2 + + X position is calculated by taking the grids left co-ord, adding the distance to the column, + then adding 1/2 the spacing multiplied by the align variable above, + Y position likewise, takes the top of the grid, adds the y to the current row then adds the padding in to align it. + +*/ + + // Calculate row and column x and y coords required to allow for columns and rows which are non uniformly sized. + + for (a=0;adata); + sorted = sorted->next; + } + + for (; current_row != NULL; current_row = current_row->next) { + SPItem *item=SP_ITEM(current_row->data); + Inkscape::XML::Node *repr = item->getRepr(); + Geom::OptRect b = item->documentVisualBounds(); + Geom::Point min; + if (b) { + width = b->dimensions()[Geom::X]; + height = b->dimensions()[Geom::Y]; + min = b->min(); + } else { + width = height = 0; + min = Geom::Point(0, 0); + } + + row = cnt / NoOfCols; + col = cnt % NoOfCols; + + new_x = grid_left + (((col_widths[col] - width)/2)*HorizAlign) + col_xs[col]; + new_y = grid_top + (((row_heights[row] - height)/2)*VertAlign) + row_ys[row]; + + // signs are inverted between x and y due to y inversion + Geom::Point move = Geom::Point(new_x - min[Geom::X], min[Geom::Y] - new_y); + Geom::Affine const affine = Geom::Affine(Geom::Translate(move)); + item->set_i2d_affine(item->i2dt_affine() * affine); + item->doWriteTransform(repr, item->transform, NULL); + SP_OBJECT (current_row->data)->updateRepr(); + cnt +=1; + } + g_slist_free (current_row); + } + + DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_SELECTION_ARRANGE, + _("Arrange in a grid")); + +} + + +//######################################################################### +//## E V E N T S +//######################################################################### + +/** + * changed value in # of columns spinbox. + */ +void GridArrangeTab::on_row_spinbutton_changed() +{ + // quit if run by the attr_changed listener + if (updating) { + return; + } + + // in turn, prevent listener from responding + updating = true; + SPDesktop *desktop = Parent->getDesktop(); + + Inkscape::Selection *selection = desktop ? desktop->selection : 0; + g_return_if_fail( selection ); + + GSList const *items = selection->itemList(); + int selcount = g_slist_length((GSList *)items); + + double PerCol = ceil(selcount / NoOfColsSpinner.get_value()); + NoOfRowsSpinner.set_value(PerCol); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setDouble("/dialogs/gridtiler/NoOfCols", NoOfColsSpinner.get_value()); + updating=false; +} + +/** + * changed value in # of rows spinbox. + */ +void GridArrangeTab::on_col_spinbutton_changed() +{ + // quit if run by the attr_changed listener + if (updating) { + return; + } + + // in turn, prevent listener from responding + updating = true; + SPDesktop *desktop = Parent->getDesktop(); + Inkscape::Selection *selection = desktop ? desktop->selection : 0; + g_return_if_fail(selection); + + GSList const *items = selection->itemList(); + int selcount = g_slist_length((GSList *)items); + + double PerRow = ceil(selcount / NoOfRowsSpinner.get_value()); + NoOfColsSpinner.set_value(PerRow); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setDouble("/dialogs/gridtiler/NoOfCols", PerRow); + + updating=false; +} + +/** + * changed value in x padding spinbox. + */ +void GridArrangeTab::on_xpad_spinbutton_changed() +{ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setDouble("/dialogs/gridtiler/XPad", XPadding.getValue("px")); + +} + +/** + * changed value in y padding spinbox. + */ +void GridArrangeTab::on_ypad_spinbutton_changed() +{ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setDouble("/dialogs/gridtiler/YPad", YPadding.getValue("px")); +} + + +/** + * checked/unchecked autosize Rows button. + */ +void GridArrangeTab::on_RowSize_checkbutton_changed() +{ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + if (RowHeightButton.get_active()) { + prefs->setDouble("/dialogs/gridtiler/AutoRowSize", 20); + } else { + prefs->setDouble("/dialogs/gridtiler/AutoRowSize", -20); + } + RowHeightBox.set_sensitive ( !RowHeightButton.get_active()); +} + +/** + * checked/unchecked autosize Rows button. + */ +void GridArrangeTab::on_ColSize_checkbutton_changed() +{ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + if (ColumnWidthButton.get_active()) { + prefs->setDouble("/dialogs/gridtiler/AutoColSize", 20); + } else { + prefs->setDouble("/dialogs/gridtiler/AutoColSize", -20); + } + ColumnWidthBox.set_sensitive ( !ColumnWidthButton.get_active()); +} + +/** + * changed value in columns spinbox. + */ +void GridArrangeTab::on_rowSize_spinbutton_changed() +{ + // quit if run by the attr_changed listener + if (updating) { + return; + } + + // in turn, prevent listener from responding + updating = true; + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setDouble("/dialogs/gridtiler/RowHeight", RowHeightSpinner.get_value()); + updating=false; + +} + +/** + * changed value in rows spinbox. + */ +void GridArrangeTab::on_colSize_spinbutton_changed() +{ + // quit if run by the attr_changed listener + if (updating) { + return; + } + + // in turn, prevent listener from responding + updating = true; + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setDouble("/dialogs/gridtiler/ColWidth", ColumnWidthSpinner.get_value()); + updating=false; + +} + +/** + * changed Radio button in Spacing group. + */ +void GridArrangeTab::Spacing_button_changed() +{ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + if (SpaceManualRadioButton.get_active()) { + prefs->setDouble("/dialogs/gridtiler/SpacingType", 20); + } else { + prefs->setDouble("/dialogs/gridtiler/SpacingType", -20); + } + + XPadding.set_sensitive ( SpaceManualRadioButton.get_active()); + YPadding.set_sensitive ( SpaceManualRadioButton.get_active()); +} + +/** + * changed Anchor selection widget. + */ +void GridArrangeTab::Align_changed() +{ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + VertAlign = AlignmentSelector.getVerticalAlignment(); + prefs->setInt("/dialogs/gridtiler/VertAlign", VertAlign); + HorizAlign = AlignmentSelector.getHorizontalAlignment(); + prefs->setInt("/dialogs/gridtiler/HorizAlign", HorizAlign); +} + +/** + * Desktop selection changed + */ +void GridArrangeTab::updateSelection() +{ + // quit if run by the attr_changed listener + if (updating) { + return; + } + + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + // in turn, prevent listener from responding + updating = true; + SPDesktop *desktop = Parent->getDesktop(); + Inkscape::Selection *selection = desktop ? desktop->selection : 0; + GSList const *items = selection ? selection->itemList() : 0; + + if (items) { + int selcount = g_slist_length((GSList *)items); + + if (NoOfColsSpinner.get_value() > 1 && NoOfRowsSpinner.get_value() > 1){ + // Update the number of rows assuming number of columns wanted remains same. + double NoOfRows = ceil(selcount / NoOfColsSpinner.get_value()); + NoOfRowsSpinner.set_value(NoOfRows); + + // if the selection has less than the number set for one row, reduce it appropriately + if (selcount < NoOfColsSpinner.get_value()) { + double NoOfCols = ceil(selcount / NoOfRowsSpinner.get_value()); + NoOfColsSpinner.set_value(NoOfCols); + prefs->setInt("/dialogs/gridtiler/NoOfCols", NoOfCols); + } + } else { + double PerRow = ceil(sqrt(selcount)); + double PerCol = ceil(sqrt(selcount)); + NoOfRowsSpinner.set_value(PerRow); + NoOfColsSpinner.set_value(PerCol); + prefs->setInt("/dialogs/gridtiler/NoOfCols", static_cast(PerCol)); + } + } + + updating = false; +} + + + +/*########################## +## Experimental +##########################*/ + +static void updateSelectionCallback(Inkscape::Application */*inkscape*/, Inkscape::Selection */*selection*/, GridArrangeTab *dlg) +{ + dlg->updateSelection(); +} + + +//######################################################################### +//## C O N S T R U C T O R / D E S T R U C T O R +//######################################################################### +/** + * Constructor + */ +GridArrangeTab::GridArrangeTab(ArrangeDialog *parent) + : Parent(parent), + XPadding(_("X:"), _("Horizontal spacing between columns."), UNIT_TYPE_LINEAR, "", "object-columns"), + YPadding(_("Y:"), _("Vertical spacing between rows."), XPadding, "", "object-rows") +{ + // bool used by spin button callbacks to stop loops where they change each other. + updating = false; + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + + // could not do this in gtkmm - there's no Gtk::SizeGroup public constructor (!) + GtkSizeGroup *_col1 = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); + GtkSizeGroup *_col2 = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); + GtkSizeGroup *_col3 = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); + + { + // Selection Change signal + g_signal_connect ( G_OBJECT (INKSCAPE), "change_selection", G_CALLBACK (updateSelectionCallback), this); + } + + Gtk::Box *contents = this; + +#define MARGIN 2 + + //##Set up the panel + + SPDesktop *desktop = Parent->getDesktop(); + + Inkscape::Selection *selection = desktop ? desktop->selection : 0; + g_return_if_fail( selection ); + int selcount = 1; + if (!selection->isEmpty()) { + GSList const *items = selection->itemList(); + selcount = g_slist_length((GSList *)items); + } + + + /*#### Number of Rows ####*/ + + double PerRow = ceil(sqrt(selcount)); + double PerCol = ceil(sqrt(selcount)); + + #ifdef DEBUG_GRID_ARRANGE + g_print("/n PerRox = %f PerCol = %f selcount = %d",PerRow,PerCol,selcount); + #endif + + NoOfRowsLabel.set_text_with_mnemonic(_("_Rows:")); + NoOfRowsLabel.set_mnemonic_widget(NoOfRowsSpinner); + NoOfRowsBox.pack_start(NoOfRowsLabel, false, false, MARGIN); + + NoOfRowsSpinner.set_digits(0); + NoOfRowsSpinner.set_increments(1, 0); + NoOfRowsSpinner.set_range(1.0, 10000.0); + NoOfRowsSpinner.set_value(PerCol); + NoOfRowsSpinner.signal_changed().connect(sigc::mem_fun(*this, &GridArrangeTab::on_col_spinbutton_changed)); + NoOfRowsSpinner.set_tooltip_text(_("Number of rows")); + NoOfRowsBox.pack_start(NoOfRowsSpinner, false, false, MARGIN); + gtk_size_group_add_widget(_col1, (GtkWidget *) NoOfRowsBox.gobj()); + + RowHeightButton.set_label(_("Equal _height")); + RowHeightButton.set_use_underline(true); + double AutoRow = prefs->getDouble("/dialogs/gridtiler/AutoRowSize", 15); + if (AutoRow>0) + AutoRowSize=true; + else + AutoRowSize=false; + RowHeightButton.set_active(AutoRowSize); + + NoOfRowsBox.pack_start(RowHeightButton, false, false, MARGIN); + + RowHeightButton.set_tooltip_text(_("If not set, each row has the height of the tallest object in it")); + RowHeightButton.signal_toggled().connect(sigc::mem_fun(*this, &GridArrangeTab::on_RowSize_checkbutton_changed)); + + SpinsHBox.pack_start(NoOfRowsBox, false, false, MARGIN); + + + /*#### Label for X ####*/ + padXByYLabel.set_label(" "); + XByYLabelVBox.pack_start(padXByYLabel, false, false, MARGIN); + XByYLabel.set_markup(" × "); + XByYLabelVBox.pack_start(XByYLabel, false, false, MARGIN); + SpinsHBox.pack_start(XByYLabelVBox, false, false, MARGIN); + gtk_size_group_add_widget(_col2, (GtkWidget *) XByYLabelVBox.gobj()); + + /*#### Number of columns ####*/ + + NoOfColsLabel.set_text_with_mnemonic(_("_Columns:")); + NoOfColsLabel.set_mnemonic_widget(NoOfColsSpinner); + NoOfColsBox.pack_start(NoOfColsLabel, false, false, MARGIN); + + NoOfColsSpinner.set_digits(0); + NoOfColsSpinner.set_increments(1, 0); + NoOfColsSpinner.set_range(1.0, 10000.0); + NoOfColsSpinner.set_value(PerRow); + NoOfColsSpinner.signal_changed().connect(sigc::mem_fun(*this, &GridArrangeTab::on_row_spinbutton_changed)); + NoOfColsSpinner.set_tooltip_text(_("Number of columns")); + NoOfColsBox.pack_start(NoOfColsSpinner, false, false, MARGIN); + gtk_size_group_add_widget(_col3, (GtkWidget *) NoOfColsBox.gobj()); + + ColumnWidthButton.set_label(_("Equal _width")); + ColumnWidthButton.set_use_underline(true); + double AutoCol = prefs->getDouble("/dialogs/gridtiler/AutoColSize", 15); + if (AutoCol>0) + AutoColSize=true; + else + AutoColSize=false; + ColumnWidthButton.set_active(AutoColSize); + NoOfColsBox.pack_start(ColumnWidthButton, false, false, MARGIN); + + ColumnWidthButton.set_tooltip_text(_("If not set, each column has the width of the widest object in it")); + ColumnWidthButton.signal_toggled().connect(sigc::mem_fun(*this, &GridArrangeTab::on_ColSize_checkbutton_changed)); + + SpinsHBox.pack_start(NoOfColsBox, false, false, MARGIN); + + TileBox.pack_start(SpinsHBox, false, false, MARGIN); + + VertAlign = prefs->getInt("/dialogs/gridtiler/VertAlign", 1); + HorizAlign = prefs->getInt("/dialogs/gridtiler/HorizAlign", 1); + + // Anchor selection widget + AlignLabel.set_label("Alignment:"); + AlignLabel.set_alignment(Gtk::ALIGN_START, Gtk::ALIGN_CENTER); + AlignmentSelector.setAlignment(HorizAlign, VertAlign); + AlignmentSelector.on_selectionChanged().connect(sigc::mem_fun(*this, &GridArrangeTab::Align_changed)); + TileBox.pack_start(AlignLabel, false, false, MARGIN); + TileBox.pack_start(AlignmentSelector, true, false, MARGIN); + + { + /*#### Radio buttons to control spacing manually or to fit selection bbox ####*/ + SpaceByBBoxRadioButton.set_label(_("_Fit into selection box")); + SpaceByBBoxRadioButton.set_use_underline (true); + SpaceByBBoxRadioButton.signal_toggled().connect(sigc::mem_fun(*this, &GridArrangeTab::Spacing_button_changed)); + SpacingGroup = SpaceByBBoxRadioButton.get_group(); + + SpacingVBox.pack_start(SpaceByBBoxRadioButton, false, false, MARGIN); + + SpaceManualRadioButton.set_label(_("_Set spacing:")); + SpaceManualRadioButton.set_use_underline (true); + SpaceManualRadioButton.set_group(SpacingGroup); + SpaceManualRadioButton.signal_toggled().connect(sigc::mem_fun(*this, &GridArrangeTab::Spacing_button_changed)); + SpacingVBox.pack_start(SpaceManualRadioButton, false, false, MARGIN); + + TileBox.pack_start(SpacingVBox, false, false, MARGIN); + } + + { + /*#### Padding ####*/ + + YPadding.setDigits(5); + YPadding.setIncrements(0.2, 0); + YPadding.setRange(-10000, 10000); + double yPad = prefs->getDouble("/dialogs/gridtiler/YPad", 15); + YPadding.setValue(yPad, "px"); + YPadding.signal_value_changed().connect(sigc::mem_fun(*this, &GridArrangeTab::on_ypad_spinbutton_changed)); + + XPadding.setDigits(5); + XPadding.setIncrements(0.2, 0); + XPadding.setRange(-10000, 10000); + double xPad = prefs->getDouble("/dialogs/gridtiler/XPad", 15); + XPadding.setValue(xPad, "px"); + + XPadding.signal_value_changed().connect(sigc::mem_fun(*this, &GridArrangeTab::on_xpad_spinbutton_changed)); + } + TileBox.pack_start(XPadding, false, false, MARGIN); + TileBox.pack_start(YPadding, false, false, MARGIN); + + contents->pack_start(TileBox); + + double SpacingType = prefs->getDouble("/dialogs/gridtiler/SpacingType", 15); + if (SpacingType>0) { + ManualSpacing=true; + } else { + ManualSpacing=false; + } + SpaceManualRadioButton.set_active(ManualSpacing); + SpaceByBBoxRadioButton.set_active(!ManualSpacing); + XPadding.set_sensitive (ManualSpacing); + YPadding.set_sensitive (ManualSpacing); + + //## The OK button FIXME + /*TileOkButton = addResponseButton(C_("Rows and columns dialog","_Arrange"), GTK_RESPONSE_APPLY); + TileOkButton->set_use_underline(true); + TileOkButton->set_tooltip_text(_("Arrange selected objects"));*/ + + show_all_children(); +} + +} //namespace Dialog +} //namespace UI +} //namespace Inkscape + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/dialog/grid-arrange-tab.h b/src/ui/dialog/grid-arrange-tab.h new file mode 100644 index 000000000..7e90accf1 --- /dev/null +++ b/src/ui/dialog/grid-arrange-tab.h @@ -0,0 +1,147 @@ +/** + * @brief Arranges Objects into a Grid + */ +/* Authors: + * Bob Jamison ( based off trace dialog) + * John Cliff + * Other dudes from The Inkscape Organization + * Abhishek Sharma + * Declara Denis + * + * Copyright (C) 2004 Bob Jamison + * Copyright (C) 2004 John Cliff + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifndef INKSCAPE_UI_DIALOG_GRID_ARRANGE_TAB_H +#define INKSCAPE_UI_DIALOG_GRID_ARRANGE_TAB_H + +#include + +#include "ui/dialog/arrangetab.h" + +#include "ui/widget/anchor-selector.h" +#include "ui/widget/scalar-unit.h" +#include "ui/widget/spinbutton.h" + +namespace Inkscape { +namespace UI { +namespace Dialog { + +class ArrangeDialog; + +/** + * Dialog for tiling an object + */ +class GridArrangeTab : public ArrangeTab { +public: + GridArrangeTab(ArrangeDialog *parent); + virtual ~GridArrangeTab() {}; + + /** + * Do the actual work + */ + virtual void arrange(); + + /** + * Respond to selection change + */ + void updateSelection(); + + // Callbacks from spinbuttons + void on_row_spinbutton_changed(); + void on_col_spinbutton_changed(); + void on_xpad_spinbutton_changed(); + void on_ypad_spinbutton_changed(); + void on_RowSize_checkbutton_changed(); + void on_ColSize_checkbutton_changed(); + void on_rowSize_spinbutton_changed(); + void on_colSize_spinbutton_changed(); + void Spacing_button_changed(); + void Align_changed(); + + +private: + GridArrangeTab(GridArrangeTab const &d); // no copy + void operator=(GridArrangeTab const &d); // no assign + + ArrangeDialog *Parent; + + bool userHidden; + bool updating; + + Gtk::VBox TileBox; + Gtk::Button *TileOkButton; + Gtk::Button *TileCancelButton; + + // Number selected label + Gtk::Label SelectionContentsLabel; + + + Gtk::HBox AlignHBox; + Gtk::HBox SpinsHBox; + + // Number per Row + Gtk::VBox NoOfColsBox; + Gtk::Label NoOfColsLabel; + Inkscape::UI::Widget::SpinButton NoOfColsSpinner; + bool AutoRowSize; + Gtk::CheckButton RowHeightButton; + + Gtk::VBox XByYLabelVBox; + Gtk::Label padXByYLabel; + Gtk::Label XByYLabel; + + // Number per Column + Gtk::VBox NoOfRowsBox; + Gtk::Label NoOfRowsLabel; + Inkscape::UI::Widget::SpinButton NoOfRowsSpinner; + bool AutoColSize; + Gtk::CheckButton ColumnWidthButton; + + // Alignment + Gtk::Label AlignLabel; + Inkscape::UI::Widget::AnchorSelector AlignmentSelector; + double VertAlign; + double HorizAlign; + + Inkscape::UI::Widget::ScalarUnit XPadding; + Inkscape::UI::Widget::ScalarUnit YPadding; + + // BBox or manual spacing + Gtk::VBox SpacingVBox; + Gtk::RadioButtonGroup SpacingGroup; + Gtk::RadioButton SpaceByBBoxRadioButton; + Gtk::RadioButton SpaceManualRadioButton; + bool ManualSpacing; + + // Row height + Gtk::VBox RowHeightVBox; + Gtk::HBox RowHeightBox; + Gtk::Label RowHeightLabel; + Inkscape::UI::Widget::SpinButton RowHeightSpinner; + + // Column width + Gtk::VBox ColumnWidthVBox; + Gtk::HBox ColumnWidthBox; + Gtk::Label ColumnWidthLabel; + Inkscape::UI::Widget::SpinButton ColumnWidthSpinner; +}; + +} //namespace Dialog +} //namespace UI +} //namespace Inkscape + +#endif /* INKSCAPE_UI_DIALOG_GRID_ARRANGE_TAB_H */ + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/dialog/gridarrangetab.cpp b/src/ui/dialog/gridarrangetab.cpp deleted file mode 100644 index fca7c5b0e..000000000 --- a/src/ui/dialog/gridarrangetab.cpp +++ /dev/null @@ -1,786 +0,0 @@ -/* - * A simple dialog for creating grid type arrangements of selected objects - * - * Authors: - * Bob Jamison ( based off trace dialog) - * John Cliff - * Other dudes from The Inkscape Organization - * Abhishek Sharma - * Declara Denis - * - * Copyright (C) 2004 Bob Jamison - * Copyright (C) 2004 John Cliff - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ -//#define DEBUG_GRID_ARRANGE 1 - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include "ui/dialog/gridarrangetab.h" -#include //for GTK_RESPONSE* types -#include -#include -#include <2geom/transforms.h> - -#include "verbs.h" -#include "preferences.h" -#include "inkscape.h" -#include "desktop-handles.h" -#include "selection.h" -#include "document.h" -#include "document-undo.h" -#include "sp-item.h" -#include "widgets/icon.h" -#include "desktop.h" -//#include "sp-item-transform.h" FIXME -#include "ui/dialog/tile.h" // for Inkscape::UI::Dialog::ArrangeDialog - -/* - * Sort items by their x co-ordinates, taking account of y (keeps rows intact) - * - * <0 *elem1 goes before *elem2 - * 0 *elem1 == *elem2 - * >0 *elem1 goes after *elem2 - */ -int sp_compare_x_position(SPItem *first, SPItem *second) -{ - using Geom::X; - using Geom::Y; - - Geom::OptRect a = first->documentVisualBounds(); - Geom::OptRect b = second->documentVisualBounds(); - - if ( !a || !b ) { - // FIXME? - return 0; - } - - double const a_height = a->dimensions()[Y]; - double const b_height = b->dimensions()[Y]; - - bool a_in_b_vert = false; - if ((a->min()[Y] < b->min()[Y] + 0.1) && (a->min()[Y] > b->min()[Y] - b_height)) { - a_in_b_vert = true; - } else if ((b->min()[Y] < a->min()[Y] + 0.1) && (b->min()[Y] > a->min()[Y] - a_height)) { - a_in_b_vert = true; - } else if (b->min()[Y] == a->min()[Y]) { - a_in_b_vert = true; - } else { - a_in_b_vert = false; - } - - if (!a_in_b_vert) { - return -1; - } - if (a_in_b_vert && a->min()[X] > b->min()[X]) { - return 1; - } - if (a_in_b_vert && a->min()[X] < b->min()[X]) { - return -1; - } - return 0; -} - -/* - * Sort items by their y co-ordinates. - */ -int sp_compare_y_position(SPItem *first, SPItem *second) -{ - Geom::OptRect a = first->documentVisualBounds(); - Geom::OptRect b = second->documentVisualBounds(); - - if ( !a || !b ) { - // FIXME? - return 0; - } - - if (a->min()[Geom::Y] > b->min()[Geom::Y]) { - return 1; - } - if (a->min()[Geom::Y] < b->min()[Geom::Y]) { - return -1; - } - - return 0; -} - -namespace Inkscape { -namespace UI { -namespace Dialog { - - -//######################################################################### -//## E V E N T S -//######################################################################### - -/* - * - * This arranges the selection in a grid pattern. - * - */ - -void GridArrangeTab::arrange() -{ - - int cnt,row_cnt,col_cnt,a,row,col; - double grid_left,grid_top,col_width,row_height,paddingx,paddingy,width, height, new_x, new_y,cx,cy; - double total_col_width,total_row_height; - col_width = 0; - row_height = 0; - total_col_width=0; - total_row_height=0; - - // check for correct numbers in the row- and col-spinners - on_col_spinbutton_changed(); - on_row_spinbutton_changed(); - - // set padding to manual values - paddingx = XPadding.getValue("px"); - paddingy = YPadding.getValue("px"); - - std::vector row_heights; - std::vector col_widths; - std::vector row_ys; - std::vector col_xs; - - int NoOfCols = NoOfColsSpinner.get_value_as_int(); - int NoOfRows = NoOfRowsSpinner.get_value_as_int(); - - width = 0; - for (a=0;agetDesktop(); - sp_desktop_document(desktop)->ensureUpToDate(); - - Inkscape::Selection *selection = sp_desktop_selection (desktop); - const GSList *items = selection ? selection->itemList() : 0; - cnt=0; - for (; items != NULL; items = items->next) { - SPItem *item = SP_ITEM(items->data); - Geom::OptRect b = item->documentVisualBounds(); - if (!b) { - continue; - } - - width = b->dimensions()[Geom::X]; - height = b->dimensions()[Geom::Y]; - - cx = b->midpoint()[Geom::X]; - cy = b->midpoint()[Geom::Y]; - - if (b->min()[Geom::X] < grid_left) { - grid_left = b->min()[Geom::X]; - } - if (b->min()[Geom::Y] < grid_top) { - grid_top = b->min()[Geom::Y]; - } - if (width > col_width) { - col_width = width; - } - if (height > row_height) { - row_height = height; - } - } - - - // require the sorting done before we can calculate row heights etc. - - g_return_if_fail(selection); - const GSList *items2 = selection->itemList(); - GSList *rev = g_slist_copy((GSList *) items2); - GSList *sorted = NULL; - rev = g_slist_sort(rev, (GCompareFunc) sp_compare_y_position); - sorted = g_slist_sort(rev, (GCompareFunc) sp_compare_x_position); - - - // Calculate individual Row and Column sizes if necessary - - - cnt=0; - const GSList *sizes = sorted; - for (; sizes != NULL; sizes = sizes->next) { - SPItem *item = SP_ITEM(sizes->data); - Geom::OptRect b = item->documentVisualBounds(); - if (b) { - width = b->dimensions()[Geom::X]; - height = b->dimensions()[Geom::Y]; - if (width > col_widths[(cnt % NoOfCols)]) { - col_widths[(cnt % NoOfCols)] = width; - } - if (height > row_heights[(cnt / NoOfCols)]) { - row_heights[(cnt / NoOfCols)] = height; - } - } - - cnt++; - } - - - /// Make sure the top and left of the grid dont move by compensating for align values. - if (RowHeightButton.get_active()){ - grid_top = grid_top - (((row_height - row_heights[0]) / 2)*(VertAlign)); - } - if (ColumnWidthButton.get_active()){ - grid_left = grid_left - (((col_width - col_widths[0]) /2)*(HorizAlign)); - } - - #ifdef DEBUG_GRID_ARRANGE - g_print("\n cx = %f cy= %f gridleft=%f",cx,cy,grid_left); - #endif - - // Calculate total widths and heights, allowing for columns and rows non uniformly sized. - - if (ColumnWidthButton.get_active()){ - total_col_width = col_width * NoOfCols; - col_widths.clear(); - for (a=0;avisualBounds(); - // Fit to bbox, calculate padding between rows accordingly. - if ( sel_bbox && !SpaceManualRadioButton.get_active() ){ -#ifdef DEBUG_GRID_ARRANGE -g_print("\n row = %f col = %f selection x= %f selection y = %f", total_row_height,total_col_width, b.extent(Geom::X), b.extent(Geom::Y)); -#endif - paddingx = (sel_bbox->width() - total_col_width) / (NoOfCols -1); - paddingy = (sel_bbox->height() - total_row_height) / (NoOfRows -1); - } - -/* - Horizontal align - Left = 0 - Centre = 1 - Right = 2 - - Vertical align - Top = 0 - Middle = 1 - Bottom = 2 - - X position is calculated by taking the grids left co-ord, adding the distance to the column, - then adding 1/2 the spacing multiplied by the align variable above, - Y position likewise, takes the top of the grid, adds the y to the current row then adds the padding in to align it. - -*/ - - // Calculate row and column x and y coords required to allow for columns and rows which are non uniformly sized. - - for (a=0;adata); - sorted = sorted->next; - } - - for (; current_row != NULL; current_row = current_row->next) { - SPItem *item=SP_ITEM(current_row->data); - Inkscape::XML::Node *repr = item->getRepr(); - Geom::OptRect b = item->documentVisualBounds(); - Geom::Point min; - if (b) { - width = b->dimensions()[Geom::X]; - height = b->dimensions()[Geom::Y]; - min = b->min(); - } else { - width = height = 0; - min = Geom::Point(0, 0); - } - - row = cnt / NoOfCols; - col = cnt % NoOfCols; - - new_x = grid_left + (((col_widths[col] - width)/2)*HorizAlign) + col_xs[col]; - new_y = grid_top + (((row_heights[row] - height)/2)*VertAlign) + row_ys[row]; - - // signs are inverted between x and y due to y inversion - Geom::Point move = Geom::Point(new_x - min[Geom::X], min[Geom::Y] - new_y); - Geom::Affine const affine = Geom::Affine(Geom::Translate(move)); - item->set_i2d_affine(item->i2dt_affine() * affine); - item->doWriteTransform(repr, item->transform, NULL); - SP_OBJECT (current_row->data)->updateRepr(); - cnt +=1; - } - g_slist_free (current_row); - } - - DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_SELECTION_ARRANGE, - _("Arrange in a grid")); - -} - - -//######################################################################### -//## E V E N T S -//######################################################################### - -/** - * changed value in # of columns spinbox. - */ -void GridArrangeTab::on_row_spinbutton_changed() -{ - // quit if run by the attr_changed listener - if (updating) { - return; - } - - // in turn, prevent listener from responding - updating = true; - SPDesktop *desktop = Parent->getDesktop(); - - Inkscape::Selection *selection = desktop ? desktop->selection : 0; - g_return_if_fail( selection ); - - GSList const *items = selection->itemList(); - int selcount = g_slist_length((GSList *)items); - - double PerCol = ceil(selcount / NoOfColsSpinner.get_value()); - NoOfRowsSpinner.set_value(PerCol); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setDouble("/dialogs/gridtiler/NoOfCols", NoOfColsSpinner.get_value()); - updating=false; -} - -/** - * changed value in # of rows spinbox. - */ -void GridArrangeTab::on_col_spinbutton_changed() -{ - // quit if run by the attr_changed listener - if (updating) { - return; - } - - // in turn, prevent listener from responding - updating = true; - SPDesktop *desktop = Parent->getDesktop(); - Inkscape::Selection *selection = desktop ? desktop->selection : 0; - g_return_if_fail(selection); - - GSList const *items = selection->itemList(); - int selcount = g_slist_length((GSList *)items); - - double PerRow = ceil(selcount / NoOfRowsSpinner.get_value()); - NoOfColsSpinner.set_value(PerRow); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setDouble("/dialogs/gridtiler/NoOfCols", PerRow); - - updating=false; -} - -/** - * changed value in x padding spinbox. - */ -void GridArrangeTab::on_xpad_spinbutton_changed() -{ - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setDouble("/dialogs/gridtiler/XPad", XPadding.getValue("px")); - -} - -/** - * changed value in y padding spinbox. - */ -void GridArrangeTab::on_ypad_spinbutton_changed() -{ - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setDouble("/dialogs/gridtiler/YPad", YPadding.getValue("px")); -} - - -/** - * checked/unchecked autosize Rows button. - */ -void GridArrangeTab::on_RowSize_checkbutton_changed() -{ - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - if (RowHeightButton.get_active()) { - prefs->setDouble("/dialogs/gridtiler/AutoRowSize", 20); - } else { - prefs->setDouble("/dialogs/gridtiler/AutoRowSize", -20); - } - RowHeightBox.set_sensitive ( !RowHeightButton.get_active()); -} - -/** - * checked/unchecked autosize Rows button. - */ -void GridArrangeTab::on_ColSize_checkbutton_changed() -{ - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - if (ColumnWidthButton.get_active()) { - prefs->setDouble("/dialogs/gridtiler/AutoColSize", 20); - } else { - prefs->setDouble("/dialogs/gridtiler/AutoColSize", -20); - } - ColumnWidthBox.set_sensitive ( !ColumnWidthButton.get_active()); -} - -/** - * changed value in columns spinbox. - */ -void GridArrangeTab::on_rowSize_spinbutton_changed() -{ - // quit if run by the attr_changed listener - if (updating) { - return; - } - - // in turn, prevent listener from responding - updating = true; - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setDouble("/dialogs/gridtiler/RowHeight", RowHeightSpinner.get_value()); - updating=false; - -} - -/** - * changed value in rows spinbox. - */ -void GridArrangeTab::on_colSize_spinbutton_changed() -{ - // quit if run by the attr_changed listener - if (updating) { - return; - } - - // in turn, prevent listener from responding - updating = true; - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setDouble("/dialogs/gridtiler/ColWidth", ColumnWidthSpinner.get_value()); - updating=false; - -} - -/** - * changed Radio button in Spacing group. - */ -void GridArrangeTab::Spacing_button_changed() -{ - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - if (SpaceManualRadioButton.get_active()) { - prefs->setDouble("/dialogs/gridtiler/SpacingType", 20); - } else { - prefs->setDouble("/dialogs/gridtiler/SpacingType", -20); - } - - XPadding.set_sensitive ( SpaceManualRadioButton.get_active()); - YPadding.set_sensitive ( SpaceManualRadioButton.get_active()); -} - -/** - * changed Anchor selection widget. - */ -void GridArrangeTab::Align_changed() -{ - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - VertAlign = AlignmentSelector.getVerticalAlignment(); - prefs->setInt("/dialogs/gridtiler/VertAlign", VertAlign); - HorizAlign = AlignmentSelector.getHorizontalAlignment(); - prefs->setInt("/dialogs/gridtiler/HorizAlign", HorizAlign); -} - -/** - * Desktop selection changed - */ -void GridArrangeTab::updateSelection() -{ - // quit if run by the attr_changed listener - if (updating) { - return; - } - - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - // in turn, prevent listener from responding - updating = true; - SPDesktop *desktop = Parent->getDesktop(); - Inkscape::Selection *selection = desktop ? desktop->selection : 0; - GSList const *items = selection ? selection->itemList() : 0; - - if (items) { - int selcount = g_slist_length((GSList *)items); - - if (NoOfColsSpinner.get_value() > 1 && NoOfRowsSpinner.get_value() > 1){ - // Update the number of rows assuming number of columns wanted remains same. - double NoOfRows = ceil(selcount / NoOfColsSpinner.get_value()); - NoOfRowsSpinner.set_value(NoOfRows); - - // if the selection has less than the number set for one row, reduce it appropriately - if (selcount < NoOfColsSpinner.get_value()) { - double NoOfCols = ceil(selcount / NoOfRowsSpinner.get_value()); - NoOfColsSpinner.set_value(NoOfCols); - prefs->setInt("/dialogs/gridtiler/NoOfCols", NoOfCols); - } - } else { - double PerRow = ceil(sqrt(selcount)); - double PerCol = ceil(sqrt(selcount)); - NoOfRowsSpinner.set_value(PerRow); - NoOfColsSpinner.set_value(PerCol); - prefs->setInt("/dialogs/gridtiler/NoOfCols", static_cast(PerCol)); - } - } - - updating = false; -} - - - -/*########################## -## Experimental -##########################*/ - -static void updateSelectionCallback(Inkscape::Application */*inkscape*/, Inkscape::Selection */*selection*/, GridArrangeTab *dlg) -{ - dlg->updateSelection(); -} - - -//######################################################################### -//## C O N S T R U C T O R / D E S T R U C T O R -//######################################################################### -/** - * Constructor - */ -GridArrangeTab::GridArrangeTab(ArrangeDialog *parent) - : Parent(parent), - XPadding(_("X:"), _("Horizontal spacing between columns."), UNIT_TYPE_LINEAR, "", "object-columns"), - YPadding(_("Y:"), _("Vertical spacing between rows."), XPadding, "", "object-rows") -{ - // bool used by spin button callbacks to stop loops where they change each other. - updating = false; - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - - // could not do this in gtkmm - there's no Gtk::SizeGroup public constructor (!) - GtkSizeGroup *_col1 = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); - GtkSizeGroup *_col2 = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); - GtkSizeGroup *_col3 = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); - - { - // Selection Change signal - g_signal_connect ( G_OBJECT (INKSCAPE), "change_selection", G_CALLBACK (updateSelectionCallback), this); - } - - Gtk::Box *contents = this; - -#define MARGIN 2 - - //##Set up the panel - - SPDesktop *desktop = Parent->getDesktop(); - - Inkscape::Selection *selection = desktop ? desktop->selection : 0; - g_return_if_fail( selection ); - int selcount = 1; - if (!selection->isEmpty()) { - GSList const *items = selection->itemList(); - selcount = g_slist_length((GSList *)items); - } - - - /*#### Number of Rows ####*/ - - double PerRow = ceil(sqrt(selcount)); - double PerCol = ceil(sqrt(selcount)); - - #ifdef DEBUG_GRID_ARRANGE - g_print("/n PerRox = %f PerCol = %f selcount = %d",PerRow,PerCol,selcount); - #endif - - NoOfRowsLabel.set_text_with_mnemonic(_("_Rows:")); - NoOfRowsLabel.set_mnemonic_widget(NoOfRowsSpinner); - NoOfRowsBox.pack_start(NoOfRowsLabel, false, false, MARGIN); - - NoOfRowsSpinner.set_digits(0); - NoOfRowsSpinner.set_increments(1, 0); - NoOfRowsSpinner.set_range(1.0, 10000.0); - NoOfRowsSpinner.set_value(PerCol); - NoOfRowsSpinner.signal_changed().connect(sigc::mem_fun(*this, &GridArrangeTab::on_col_spinbutton_changed)); - NoOfRowsSpinner.set_tooltip_text(_("Number of rows")); - NoOfRowsBox.pack_start(NoOfRowsSpinner, false, false, MARGIN); - gtk_size_group_add_widget(_col1, (GtkWidget *) NoOfRowsBox.gobj()); - - RowHeightButton.set_label(_("Equal _height")); - RowHeightButton.set_use_underline(true); - double AutoRow = prefs->getDouble("/dialogs/gridtiler/AutoRowSize", 15); - if (AutoRow>0) - AutoRowSize=true; - else - AutoRowSize=false; - RowHeightButton.set_active(AutoRowSize); - - NoOfRowsBox.pack_start(RowHeightButton, false, false, MARGIN); - - RowHeightButton.set_tooltip_text(_("If not set, each row has the height of the tallest object in it")); - RowHeightButton.signal_toggled().connect(sigc::mem_fun(*this, &GridArrangeTab::on_RowSize_checkbutton_changed)); - - SpinsHBox.pack_start(NoOfRowsBox, false, false, MARGIN); - - - /*#### Label for X ####*/ - padXByYLabel.set_label(" "); - XByYLabelVBox.pack_start(padXByYLabel, false, false, MARGIN); - XByYLabel.set_markup(" × "); - XByYLabelVBox.pack_start(XByYLabel, false, false, MARGIN); - SpinsHBox.pack_start(XByYLabelVBox, false, false, MARGIN); - gtk_size_group_add_widget(_col2, (GtkWidget *) XByYLabelVBox.gobj()); - - /*#### Number of columns ####*/ - - NoOfColsLabel.set_text_with_mnemonic(_("_Columns:")); - NoOfColsLabel.set_mnemonic_widget(NoOfColsSpinner); - NoOfColsBox.pack_start(NoOfColsLabel, false, false, MARGIN); - - NoOfColsSpinner.set_digits(0); - NoOfColsSpinner.set_increments(1, 0); - NoOfColsSpinner.set_range(1.0, 10000.0); - NoOfColsSpinner.set_value(PerRow); - NoOfColsSpinner.signal_changed().connect(sigc::mem_fun(*this, &GridArrangeTab::on_row_spinbutton_changed)); - NoOfColsSpinner.set_tooltip_text(_("Number of columns")); - NoOfColsBox.pack_start(NoOfColsSpinner, false, false, MARGIN); - gtk_size_group_add_widget(_col3, (GtkWidget *) NoOfColsBox.gobj()); - - ColumnWidthButton.set_label(_("Equal _width")); - ColumnWidthButton.set_use_underline(true); - double AutoCol = prefs->getDouble("/dialogs/gridtiler/AutoColSize", 15); - if (AutoCol>0) - AutoColSize=true; - else - AutoColSize=false; - ColumnWidthButton.set_active(AutoColSize); - NoOfColsBox.pack_start(ColumnWidthButton, false, false, MARGIN); - - ColumnWidthButton.set_tooltip_text(_("If not set, each column has the width of the widest object in it")); - ColumnWidthButton.signal_toggled().connect(sigc::mem_fun(*this, &GridArrangeTab::on_ColSize_checkbutton_changed)); - - SpinsHBox.pack_start(NoOfColsBox, false, false, MARGIN); - - TileBox.pack_start(SpinsHBox, false, false, MARGIN); - - VertAlign = prefs->getInt("/dialogs/gridtiler/VertAlign", 1); - HorizAlign = prefs->getInt("/dialogs/gridtiler/HorizAlign", 1); - - // Anchor selection widget - AlignLabel.set_label("Alignment:"); - AlignLabel.set_alignment(Gtk::ALIGN_START, Gtk::ALIGN_CENTER); - AlignmentSelector.setAlignment(HorizAlign, VertAlign); - AlignmentSelector.on_selectionChanged().connect(sigc::mem_fun(*this, &GridArrangeTab::Align_changed)); - TileBox.pack_start(AlignLabel, false, false, MARGIN); - TileBox.pack_start(AlignmentSelector, true, false, MARGIN); - - { - /*#### Radio buttons to control spacing manually or to fit selection bbox ####*/ - SpaceByBBoxRadioButton.set_label(_("_Fit into selection box")); - SpaceByBBoxRadioButton.set_use_underline (true); - SpaceByBBoxRadioButton.signal_toggled().connect(sigc::mem_fun(*this, &GridArrangeTab::Spacing_button_changed)); - SpacingGroup = SpaceByBBoxRadioButton.get_group(); - - SpacingVBox.pack_start(SpaceByBBoxRadioButton, false, false, MARGIN); - - SpaceManualRadioButton.set_label(_("_Set spacing:")); - SpaceManualRadioButton.set_use_underline (true); - SpaceManualRadioButton.set_group(SpacingGroup); - SpaceManualRadioButton.signal_toggled().connect(sigc::mem_fun(*this, &GridArrangeTab::Spacing_button_changed)); - SpacingVBox.pack_start(SpaceManualRadioButton, false, false, MARGIN); - - TileBox.pack_start(SpacingVBox, false, false, MARGIN); - } - - { - /*#### Padding ####*/ - - YPadding.setDigits(5); - YPadding.setIncrements(0.2, 0); - YPadding.setRange(-10000, 10000); - double yPad = prefs->getDouble("/dialogs/gridtiler/YPad", 15); - YPadding.setValue(yPad, "px"); - YPadding.signal_value_changed().connect(sigc::mem_fun(*this, &GridArrangeTab::on_ypad_spinbutton_changed)); - - XPadding.setDigits(5); - XPadding.setIncrements(0.2, 0); - XPadding.setRange(-10000, 10000); - double xPad = prefs->getDouble("/dialogs/gridtiler/XPad", 15); - XPadding.setValue(xPad, "px"); - - XPadding.signal_value_changed().connect(sigc::mem_fun(*this, &GridArrangeTab::on_xpad_spinbutton_changed)); - } - TileBox.pack_start(XPadding, false, false, MARGIN); - TileBox.pack_start(YPadding, false, false, MARGIN); - - contents->pack_start(TileBox); - - double SpacingType = prefs->getDouble("/dialogs/gridtiler/SpacingType", 15); - if (SpacingType>0) { - ManualSpacing=true; - } else { - ManualSpacing=false; - } - SpaceManualRadioButton.set_active(ManualSpacing); - SpaceByBBoxRadioButton.set_active(!ManualSpacing); - XPadding.set_sensitive (ManualSpacing); - YPadding.set_sensitive (ManualSpacing); - - //## The OK button FIXME - /*TileOkButton = addResponseButton(C_("Rows and columns dialog","_Arrange"), GTK_RESPONSE_APPLY); - TileOkButton->set_use_underline(true); - TileOkButton->set_tooltip_text(_("Arrange selected objects"));*/ - - show_all_children(); -} - -} //namespace Dialog -} //namespace UI -} //namespace Inkscape - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/dialog/gridarrangetab.h b/src/ui/dialog/gridarrangetab.h deleted file mode 100644 index 16780e55f..000000000 --- a/src/ui/dialog/gridarrangetab.h +++ /dev/null @@ -1,147 +0,0 @@ -/** - * @brief Arranges Objects into a Grid - */ -/* Authors: - * Bob Jamison ( based off trace dialog) - * John Cliff - * Other dudes from The Inkscape Organization - * Abhishek Sharma - * Declara Denis - * - * Copyright (C) 2004 Bob Jamison - * Copyright (C) 2004 John Cliff - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#ifndef INKSCAPE_UI_DIALOG_GRID_ARRANGE_TAB_H -#define INKSCAPE_UI_DIALOG_GRID_ARRANGE_TAB_H - -#include - -#include "ui/dialog/arrangetab.h" - -#include "ui/widget/anchor-selector.h" -#include "ui/widget/scalar-unit.h" -#include "ui/widget/spinbutton.h" - -namespace Inkscape { -namespace UI { -namespace Dialog { - -class ArrangeDialog; - -/** - * Dialog for tiling an object - */ -class GridArrangeTab : public ArrangeTab { -public: - GridArrangeTab(ArrangeDialog *parent); - virtual ~GridArrangeTab() {}; - - /** - * Do the actual work - */ - virtual void arrange(); - - /** - * Respond to selection change - */ - void updateSelection(); - - // Callbacks from spinbuttons - void on_row_spinbutton_changed(); - void on_col_spinbutton_changed(); - void on_xpad_spinbutton_changed(); - void on_ypad_spinbutton_changed(); - void on_RowSize_checkbutton_changed(); - void on_ColSize_checkbutton_changed(); - void on_rowSize_spinbutton_changed(); - void on_colSize_spinbutton_changed(); - void Spacing_button_changed(); - void Align_changed(); - - -private: - GridArrangeTab(GridArrangeTab const &d); // no copy - void operator=(GridArrangeTab const &d); // no assign - - ArrangeDialog *Parent; - - bool userHidden; - bool updating; - - Gtk::VBox TileBox; - Gtk::Button *TileOkButton; - Gtk::Button *TileCancelButton; - - // Number selected label - Gtk::Label SelectionContentsLabel; - - - Gtk::HBox AlignHBox; - Gtk::HBox SpinsHBox; - - // Number per Row - Gtk::VBox NoOfColsBox; - Gtk::Label NoOfColsLabel; - Inkscape::UI::Widget::SpinButton NoOfColsSpinner; - bool AutoRowSize; - Gtk::CheckButton RowHeightButton; - - Gtk::VBox XByYLabelVBox; - Gtk::Label padXByYLabel; - Gtk::Label XByYLabel; - - // Number per Column - Gtk::VBox NoOfRowsBox; - Gtk::Label NoOfRowsLabel; - Inkscape::UI::Widget::SpinButton NoOfRowsSpinner; - bool AutoColSize; - Gtk::CheckButton ColumnWidthButton; - - // Alignment - Gtk::Label AlignLabel; - AnchorSelector AlignmentSelector; - double VertAlign; - double HorizAlign; - - Inkscape::UI::Widget::ScalarUnit XPadding; - Inkscape::UI::Widget::ScalarUnit YPadding; - - // BBox or manual spacing - Gtk::VBox SpacingVBox; - Gtk::RadioButtonGroup SpacingGroup; - Gtk::RadioButton SpaceByBBoxRadioButton; - Gtk::RadioButton SpaceManualRadioButton; - bool ManualSpacing; - - // Row height - Gtk::VBox RowHeightVBox; - Gtk::HBox RowHeightBox; - Gtk::Label RowHeightLabel; - Inkscape::UI::Widget::SpinButton RowHeightSpinner; - - // Column width - Gtk::VBox ColumnWidthVBox; - Gtk::HBox ColumnWidthBox; - Gtk::Label ColumnWidthLabel; - Inkscape::UI::Widget::SpinButton ColumnWidthSpinner; -}; - -} //namespace Dialog -} //namespace UI -} //namespace Inkscape - -#endif /* INKSCAPE_UI_DIALOG_GRID_ARRANGE_TAB_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/dialog/polar-arrange-tab.cpp b/src/ui/dialog/polar-arrange-tab.cpp new file mode 100644 index 000000000..a1df794a5 --- /dev/null +++ b/src/ui/dialog/polar-arrange-tab.cpp @@ -0,0 +1,414 @@ +/** + * @brief Arranges Objects into a Circle/Ellipse + */ +/* Authors: + * Declara Denis + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include <2geom/transforms.h> +#include + +#include "ui/dialog/polar-arrange-tab.h" +#include "ui/dialog/tile.h" + +#include "verbs.h" +#include "preferences.h" +#include "inkscape.h" +#include "desktop-handles.h" +#include "selection.h" +#include "document.h" +#include "document-undo.h" +#include "sp-item.h" +#include "widgets/icon.h" +#include "desktop.h" +#include "sp-ellipse.h" +#include "sp-item-transform.h" + +namespace Inkscape { +namespace UI { +namespace Dialog { + +PolarArrangeTab::PolarArrangeTab(ArrangeDialog *parent_) + : parent(parent_), + parametersTable(3, 3, false), + centerY("", "Y coordinate of the center", UNIT_TYPE_LINEAR), + centerX("", "X coordinate of the center", centerY), + radiusY("", "Y coordinate of the radius", UNIT_TYPE_LINEAR), + radiusX("", "X coordinate of the radius", radiusY), + angleY("", "Starting angle", UNIT_TYPE_RADIAL), + angleX("", "End angle", angleY) +{ + anchorPointLabel.set_text(C_("Polar arrange tab", "Anchor point:")); + anchorPointLabel.set_alignment(Gtk::ALIGN_START); + pack_start(anchorPointLabel, false, false); + + anchorBoundingBoxRadio.set_label(C_("Polar arrange tab", "Object's bounding box:")); + anchorRadioGroup = anchorBoundingBoxRadio.get_group(); + anchorBoundingBoxRadio.signal_toggled().connect(sigc::mem_fun(*this, &PolarArrangeTab::on_anchor_radio_changed)); + pack_start(anchorBoundingBoxRadio, false, false); + + pack_start(anchorSelector, false, false); + + anchorObjectPivotRadio.set_label(C_("Polar arrange tab", "Object's rotational center")); + anchorObjectPivotRadio.set_group(anchorRadioGroup); + anchorObjectPivotRadio.signal_toggled().connect(sigc::mem_fun(*this, &PolarArrangeTab::on_anchor_radio_changed)); + pack_start(anchorObjectPivotRadio, false, false); + + arrangeOnLabel.set_text(C_("Polar arrange tab", "Arrange on:")); + arrangeOnLabel.set_alignment(Gtk::ALIGN_START); + pack_start(arrangeOnLabel, false, false); + + arrangeOnFirstCircleRadio.set_label(C_("Polar arrange tab", "First selected circle/ellipse/arc")); + arrangeRadioGroup = arrangeOnFirstCircleRadio.get_group(); + arrangeOnFirstCircleRadio.signal_toggled().connect(sigc::mem_fun(*this, &PolarArrangeTab::on_arrange_radio_changed)); + pack_start(arrangeOnFirstCircleRadio, false, false); + + arrangeOnLastCircleRadio.set_label(C_("Polar arrange tab", "Last selected circle/ellipse/arc")); + arrangeOnLastCircleRadio.set_group(arrangeRadioGroup); + arrangeOnLastCircleRadio.signal_toggled().connect(sigc::mem_fun(*this, &PolarArrangeTab::on_arrange_radio_changed)); + pack_start(arrangeOnLastCircleRadio, false, false); + + arrangeOnParametersRadio.set_label(C_("Polar arrange tab", "Parameterized:")); + arrangeOnParametersRadio.set_group(arrangeRadioGroup); + arrangeOnParametersRadio.signal_toggled().connect(sigc::mem_fun(*this, &PolarArrangeTab::on_arrange_radio_changed)); + pack_start(arrangeOnParametersRadio, false, false); + + //FIXME: Objects in grid do not line up properly! + centerLabel.set_text(_("Center X/Y:")); + parametersTable.attach(centerLabel, 0, 1, 0, 1, Gtk::FILL); + centerX.setDigits(2); + //centerX.set_size_request(60, -1); + centerX.setIncrements(0.2, 0); + centerX.setRange(-10000, 10000); + centerX.setValue(0, "px"); + centerY.setDigits(2); + //centerY.set_size_request(120, -1); + centerY.setIncrements(0.2, 0); + centerY.setRange(-10000, 10000); + centerY.setValue(0, "px"); + parametersTable.attach(centerX, 1, 2, 0, 1, Gtk::FILL); + parametersTable.attach(centerY, 2, 3, 0, 1, Gtk::FILL); + + radiusLabel.set_text(_("Radius X/Y:")); + parametersTable.attach(radiusLabel, 0, 1, 1, 2, Gtk::FILL); + radiusX.setDigits(2); + //radiusX.set_size_request(60, -1); + radiusX.setIncrements(0.2, 0); + radiusX.setRange(0.001, 10000); + radiusX.setValue(100, "px"); + radiusY.setDigits(2); + //radiusY.set_size_request(120, -1); + radiusY.setIncrements(0.2, 0); + radiusY.setRange(0.001, 10000); + radiusY.setValue(100, "px"); + parametersTable.attach(radiusX, 1, 2, 1, 2, Gtk::FILL); + parametersTable.attach(radiusY, 2, 3, 1, 2, Gtk::FILL); + + angleLabel.set_text(_("Angle X/Y:")); + parametersTable.attach(angleLabel, 0, 1, 2, 3, Gtk::FILL); + angleX.setDigits(2); + //angleX.set_size_request(60, -1); + angleX.setIncrements(0.2, 0); + angleX.setRange(-10000, 10000); + angleX.setValue(0, "°"); + angleY.setDigits(2); + //angleY.set_size_request(120, -1); + angleY.setIncrements(0.2, 0); + angleY.setRange(-10000, 10000); + angleY.setValue(180, "°"); + parametersTable.attach(angleX, 1, 2, 2, 3, Gtk::FILL); + parametersTable.attach(angleY, 2, 3, 2, 3, Gtk::FILL); + pack_start(parametersTable, false, false); + + rotateObjectsCheckBox.set_label(_("Rotate objects")); + rotateObjectsCheckBox.set_active(true); + pack_start(rotateObjectsCheckBox, false, false); + + centerX.set_sensitive(false); + centerY.set_sensitive(false); + angleX.set_sensitive(false); + angleY.set_sensitive(false); + radiusX.set_sensitive(false); + radiusY.set_sensitive(false); +} + +/** + * This function rotates an item around a given point by a given amount + * @param item item to rotate + * @param center center of the rotation to perform + * @param rotation amount to rotate the object by + */ +void rotateAround(SPItem *item, Geom::Point center, Geom::Rotate const &rotation) +{ + Geom::Translate const s(center); + Geom::Affine affine = Geom::Affine(s).inverse() * Geom::Affine(rotation) * Geom::Affine(s); + + // Save old center + center = item->getCenter(); + + item->set_i2d_affine(item->i2dt_affine() * affine); + item->doWriteTransform(item->getRepr(), item->transform); + + if(item->isCenterSet()) + { + item->setCenter(center * affine); + item->updateRepr(); + } +} + +/** + * Calculates the angle at which to put an object given the total amount + * of objects, the index of the objects as well as the arc start and end + * points + * @param arcBegin angle at which the arc begins + * @param arcEnd angle at which the arc ends + * @param count number of objects in the selection + * @param n index of the object in the selection + */ +float calcAngle(float arcBegin, float arcEnd, int count, int n) +{ + float arcLength = arcEnd - arcBegin; + float delta = std::abs(std::abs(arcLength) - 2*M_PI); + if(delta > 0.01) count--; // If not a complete circle, put an object also at the extremes of the arc; + + float angle = n / (float)count; + // Normalize for arcLength: + angle = angle * arcLength; + angle += arcBegin; + + return angle; +} + +/** + * Calculates the point at which the object needs to be, given the center of the ellipse, + * it's radius (x and y), as well as the angle + */ +Geom::Point calcPoint(float cx, float cy, float rx, float ry, float angle) +{ + return Geom::Point(cx + cos(angle) * rx, cy + sin(angle) * ry); +} + +/** + * Returns the selected anchor point in document coordinates. If anchor + * is 0 to 8, then a bounding box point has been choosen. If it is 9 however + * the rotational center is chosen. + * @todo still using a hack to get the real coordinate space (subtracting document height + * and inverting axes) + */ +Geom::Point getAnchorPoint(int anchor, SPItem *item) +{ + Geom::Point source; + + Geom::OptRect bbox = item->documentVisualBounds(); + + switch(anchor) + { + case 0: // Top - Left + case 3: // Middle - Left + case 6: // Bottom - Left + source[0] = bbox->min()[Geom::X]; + break; + case 1: // Top - Middle + case 4: // Middle - Middle + case 7: // Bottom - Middle + source[0] = (bbox->min()[Geom::X] + bbox->max()[Geom::X]) / 2.0f; + break; + case 2: // Top - Right + case 5: // Middle - Right + case 8: // Bottom - Right + source[0] = bbox->max()[Geom::X]; + break; + }; + + switch(anchor) + { + case 0: // Top - Left + case 1: // Top - Middle + case 2: // Top - Right + source[1] = bbox->min()[Geom::Y]; + break; + case 3: // Middle - Left + case 4: // Middle - Middle + case 5: // Middle - Right + source[1] = (bbox->min()[Geom::Y] + bbox->max()[Geom::Y]) / 2.0f; + break; + case 6: // Bottom - Left + case 7: // Bottom - Middle + case 8: // Bottom - Right + source[1] = bbox->max()[Geom::Y]; + break; + }; + + // If using center + if(anchor == 9) + source = item->getCenter(); + else + { + // FIXME: + source[1] -= item->document->getHeight(); + source[1] *= -1; + } + + return source; +} + +void moveToPoint(int anchor, SPItem *item, Geom::Point p) +{ + sp_item_move_rel(item, Geom::Translate(p - getAnchorPoint(anchor, item))); +} + +void PolarArrangeTab::arrange() +{ + std::cout << "PolarArrangeTab::arrange()" << std::endl; + + Inkscape::Selection *selection = sp_desktop_selection(parent->getDesktop()); + const GSList *items, *tmp; + tmp = items = selection->itemList(); + SPGenericEllipse *referenceEllipse = NULL; // Last ellipse in selection + + bool arrangeOnEllipse = !arrangeOnParametersRadio.get_active(); + bool arrangeOnFirstEllipse = arrangeOnEllipse && arrangeOnFirstCircleRadio.get_active(); + + int count = 0; + while(tmp) + { + if(arrangeOnEllipse) + { + SPItem *item = SP_ITEM(tmp->data); + + if(arrangeOnFirstEllipse) + { + // The first selected ellipse is actually the last one in the list + if(SP_IS_GENERICELLIPSE(item)) + referenceEllipse = SP_GENERICELLIPSE(item); + } else { + // The last selected ellipse is actually the first in list + if(SP_IS_GENERICELLIPSE(item) && referenceEllipse == NULL) + referenceEllipse = SP_GENERICELLIPSE(item); + } + } + tmp = tmp->next; + ++count; + } + + float cx, cy; // Center of the ellipse + float rx, ry; // Radiuses of the ellipse in x and y direction + float arcBeg, arcEnd; // begin and end angles for arcs + Geom::Affine transformation; // Any additional transformation to apply to the objects + + if(arrangeOnEllipse) + { + if(referenceEllipse == NULL) + { + Gtk::MessageDialog dialog(_("Couldn't find an ellipse in selection"), false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_CLOSE, true); + dialog.run(); + return; + } else { + cx = referenceEllipse->cx.value; + cy = referenceEllipse->cy.value; + rx = referenceEllipse->rx.value; + ry = referenceEllipse->ry.value; + arcBeg = referenceEllipse->start; + arcEnd = referenceEllipse->end; + + std::cout << "Arc: " << arcBeg << ", " << arcEnd << std::endl; + transformation = referenceEllipse->i2dt_affine(); + + // We decrement the count by 1 as we are not going to lay + // out the reference ellipse + --count; + } + + } else { + // Read options from UI + cx = centerX.getValue("px"); + cy = centerY.getValue("px"); + rx = radiusX.getValue("px"); + ry = radiusY.getValue("px"); + arcBeg = angleX.getValue("rad"); + arcEnd = angleY.getValue("rad"); + transformation.setIdentity(); + referenceEllipse = NULL; + } + + int anchor = 9; + if(anchorBoundingBoxRadio.get_active()) + { + anchor = anchorSelector.getHorizontalAlignment() + + anchorSelector.getVerticalAlignment() * 3; + } + + Geom::Point realCenter = Geom::Point(cx, cy) * transformation; + + tmp = items; + int i = 0; + while(tmp) + { + SPItem *item = SP_ITEM(tmp->data); + + // Ignore the reference ellipse if any + if(item != referenceEllipse) + { + float angle = calcAngle(arcBeg, arcEnd, count, i); + Geom::Point newLocation = calcPoint(cx, cy, rx, ry, angle) * transformation; + + moveToPoint(anchor, item, newLocation); + + if(rotateObjectsCheckBox.get_active()) { + // Calculate the angle by which to rotate each object + angle = -atan2f(newLocation.x() - realCenter.x(), newLocation.y() - realCenter.y()); + rotateAround(item, newLocation, Geom::Rotate(angle)); + } + + std::cout << "object " << i << " out of " << count << ": " << angle << std::endl; + + ++i; + } + tmp = tmp->next; + } + + DocumentUndo::done(sp_desktop_document(parent->getDesktop()), SP_VERB_SELECTION_ARRANGE, + _("Arrange on ellipse")); +} + +void PolarArrangeTab::updateSelection() +{ +} + +void PolarArrangeTab::on_arrange_radio_changed() +{ + bool arrangeParametric = arrangeOnParametersRadio.get_active(); + + centerX.set_sensitive(arrangeParametric); + centerY.set_sensitive(arrangeParametric); + + angleX.set_sensitive(arrangeParametric); + angleY.set_sensitive(arrangeParametric); + + radiusX.set_sensitive(arrangeParametric); + radiusY.set_sensitive(arrangeParametric); +} + +void PolarArrangeTab::on_anchor_radio_changed() +{ + bool anchorBoundingBox = anchorBoundingBoxRadio.get_active(); + + anchorSelector.set_sensitive(anchorBoundingBox); +} + +} //namespace Dialog +} //namespace UI +} //namespace Inkscape + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/dialog/polar-arrange-tab.h b/src/ui/dialog/polar-arrange-tab.h new file mode 100644 index 000000000..e62ebd76b --- /dev/null +++ b/src/ui/dialog/polar-arrange-tab.h @@ -0,0 +1,87 @@ +/** + * @brief Arranges Objects into a Circle/Ellipse + */ +/* Authors: + * Declara Denis + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifndef INKSCAPE_UI_DIALOG_POLAR_ARRANGE_TAB_H +#define INKSCAPE_UI_DIALOG_POLAR_ARRANGE_TAB_H + +#include + +#include "ui/dialog/arrangetab.h" + +#include "ui/widget/anchor-selector.h" +#include "ui/widget/scalar-unit.h" + +namespace Inkscape { +namespace UI { +namespace Dialog { + +class ArrangeDialog; + +class PolarArrangeTab : public ArrangeTab { +public: + PolarArrangeTab(ArrangeDialog *parent_); + virtual ~PolarArrangeTab() {}; + + /** + * Do the actual work + */ + virtual void arrange(); + + /** + * Respond to selection change + */ + void updateSelection(); + + void on_anchor_radio_changed(); + void on_arrange_radio_changed(); + +private: + PolarArrangeTab(PolarArrangeTab const &d); // no copy + void operator=(PolarArrangeTab const &d); // no assign + + ArrangeDialog *parent; + + Gtk::Label anchorPointLabel; + + Gtk::RadioButtonGroup anchorRadioGroup; + Gtk::RadioButton anchorBoundingBoxRadio; + Gtk::RadioButton anchorObjectPivotRadio; + Inkscape::UI::Widget::AnchorSelector anchorSelector; + + Gtk::Label arrangeOnLabel; + + Gtk::RadioButtonGroup arrangeRadioGroup; + Gtk::RadioButton arrangeOnFirstCircleRadio; + Gtk::RadioButton arrangeOnLastCircleRadio; + Gtk::RadioButton arrangeOnParametersRadio; + + Gtk::Table parametersTable; + + Gtk::Label centerLabel; + Inkscape::UI::Widget::ScalarUnit centerY; + Inkscape::UI::Widget::ScalarUnit centerX; + + Gtk::Label radiusLabel; + Inkscape::UI::Widget::ScalarUnit radiusY; + Inkscape::UI::Widget::ScalarUnit radiusX; + + Gtk::Label angleLabel; + Inkscape::UI::Widget::ScalarUnit angleY; + Inkscape::UI::Widget::ScalarUnit angleX; + + Gtk::CheckButton rotateObjectsCheckBox; + + +}; + +} //namespace Dialog +} //namespace UI +} //namespace Inkscape + +#endif /* INKSCAPE_UI_DIALOG_POLAR_ARRANGE_TAB_H */ diff --git a/src/ui/dialog/polararrangetab.cpp b/src/ui/dialog/polararrangetab.cpp deleted file mode 100644 index 6968be35a..000000000 --- a/src/ui/dialog/polararrangetab.cpp +++ /dev/null @@ -1,414 +0,0 @@ -/** - * @brief Arranges Objects into a Circle/Ellipse - */ -/* Authors: - * Declara Denis - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include <2geom/transforms.h> -#include - -#include "ui/dialog/polararrangetab.h" -#include "ui/dialog/tile.h" - -#include "verbs.h" -#include "preferences.h" -#include "inkscape.h" -#include "desktop-handles.h" -#include "selection.h" -#include "document.h" -#include "document-undo.h" -#include "sp-item.h" -#include "widgets/icon.h" -#include "desktop.h" -#include "sp-ellipse.h" -#include "sp-item-transform.h" - -namespace Inkscape { -namespace UI { -namespace Dialog { - -PolarArrangeTab::PolarArrangeTab(ArrangeDialog *parent_) - : parent(parent_), - parametersTable(3, 3, false), - centerY("", "Y coordinate of the center", UNIT_TYPE_LINEAR), - centerX("", "X coordinate of the center", centerY), - radiusY("", "Y coordinate of the radius", UNIT_TYPE_LINEAR), - radiusX("", "X coordinate of the radius", radiusY), - angleY("", "Starting angle", UNIT_TYPE_RADIAL), - angleX("", "End angle", angleY) -{ - anchorPointLabel.set_text(C_("Polar arrange tab", "Anchor point:")); - anchorPointLabel.set_alignment(Gtk::ALIGN_START); - pack_start(anchorPointLabel, false, false); - - anchorBoundingBoxRadio.set_label(C_("Polar arrange tab", "Object's bounding box:")); - anchorRadioGroup = anchorBoundingBoxRadio.get_group(); - anchorBoundingBoxRadio.signal_toggled().connect(sigc::mem_fun(*this, &PolarArrangeTab::on_anchor_radio_changed)); - pack_start(anchorBoundingBoxRadio, false, false); - - pack_start(anchorSelector, false, false); - - anchorObjectPivotRadio.set_label(C_("Polar arrange tab", "Object's rotational center")); - anchorObjectPivotRadio.set_group(anchorRadioGroup); - anchorObjectPivotRadio.signal_toggled().connect(sigc::mem_fun(*this, &PolarArrangeTab::on_anchor_radio_changed)); - pack_start(anchorObjectPivotRadio, false, false); - - arrangeOnLabel.set_text(C_("Polar arrange tab", "Arrange on:")); - arrangeOnLabel.set_alignment(Gtk::ALIGN_START); - pack_start(arrangeOnLabel, false, false); - - arrangeOnFirstCircleRadio.set_label(C_("Polar arrange tab", "First selected circle/ellipse/arc")); - arrangeRadioGroup = arrangeOnFirstCircleRadio.get_group(); - arrangeOnFirstCircleRadio.signal_toggled().connect(sigc::mem_fun(*this, &PolarArrangeTab::on_arrange_radio_changed)); - pack_start(arrangeOnFirstCircleRadio, false, false); - - arrangeOnLastCircleRadio.set_label(C_("Polar arrange tab", "Last selected circle/ellipse/arc")); - arrangeOnLastCircleRadio.set_group(arrangeRadioGroup); - arrangeOnLastCircleRadio.signal_toggled().connect(sigc::mem_fun(*this, &PolarArrangeTab::on_arrange_radio_changed)); - pack_start(arrangeOnLastCircleRadio, false, false); - - arrangeOnParametersRadio.set_label(C_("Polar arrange tab", "Parameterized:")); - arrangeOnParametersRadio.set_group(arrangeRadioGroup); - arrangeOnParametersRadio.signal_toggled().connect(sigc::mem_fun(*this, &PolarArrangeTab::on_arrange_radio_changed)); - pack_start(arrangeOnParametersRadio, false, false); - - //FIXME: Objects in grid do not line up properly! - centerLabel.set_text(_("Center X/Y:")); - parametersTable.attach(centerLabel, 0, 1, 0, 1, Gtk::FILL); - centerX.setDigits(2); - //centerX.set_size_request(60, -1); - centerX.setIncrements(0.2, 0); - centerX.setRange(-10000, 10000); - centerX.setValue(0, "px"); - centerY.setDigits(2); - //centerY.set_size_request(120, -1); - centerY.setIncrements(0.2, 0); - centerY.setRange(-10000, 10000); - centerY.setValue(0, "px"); - parametersTable.attach(centerX, 1, 2, 0, 1, Gtk::FILL); - parametersTable.attach(centerY, 2, 3, 0, 1, Gtk::FILL); - - radiusLabel.set_text(_("Radius X/Y:")); - parametersTable.attach(radiusLabel, 0, 1, 1, 2, Gtk::FILL); - radiusX.setDigits(2); - //radiusX.set_size_request(60, -1); - radiusX.setIncrements(0.2, 0); - radiusX.setRange(0.001, 10000); - radiusX.setValue(100, "px"); - radiusY.setDigits(2); - //radiusY.set_size_request(120, -1); - radiusY.setIncrements(0.2, 0); - radiusY.setRange(0.001, 10000); - radiusY.setValue(100, "px"); - parametersTable.attach(radiusX, 1, 2, 1, 2, Gtk::FILL); - parametersTable.attach(radiusY, 2, 3, 1, 2, Gtk::FILL); - - angleLabel.set_text(_("Angle X/Y:")); - parametersTable.attach(angleLabel, 0, 1, 2, 3, Gtk::FILL); - angleX.setDigits(2); - //angleX.set_size_request(60, -1); - angleX.setIncrements(0.2, 0); - angleX.setRange(-10000, 10000); - angleX.setValue(0, "°"); - angleY.setDigits(2); - //angleY.set_size_request(120, -1); - angleY.setIncrements(0.2, 0); - angleY.setRange(-10000, 10000); - angleY.setValue(180, "°"); - parametersTable.attach(angleX, 1, 2, 2, 3, Gtk::FILL); - parametersTable.attach(angleY, 2, 3, 2, 3, Gtk::FILL); - pack_start(parametersTable, false, false); - - rotateObjectsCheckBox.set_label(_("Rotate objects")); - rotateObjectsCheckBox.set_active(true); - pack_start(rotateObjectsCheckBox, false, false); - - centerX.set_sensitive(false); - centerY.set_sensitive(false); - angleX.set_sensitive(false); - angleY.set_sensitive(false); - radiusX.set_sensitive(false); - radiusY.set_sensitive(false); -} - -/** - * This function rotates an item around a given point by a given amount - * @param item item to rotate - * @param center center of the rotation to perform - * @param rotation amount to rotate the object by - */ -void rotateAround(SPItem *item, Geom::Point center, Geom::Rotate const &rotation) -{ - Geom::Translate const s(center); - Geom::Affine affine = Geom::Affine(s).inverse() * Geom::Affine(rotation) * Geom::Affine(s); - - // Save old center - center = item->getCenter(); - - item->set_i2d_affine(item->i2dt_affine() * affine); - item->doWriteTransform(item->getRepr(), item->transform); - - if(item->isCenterSet()) - { - item->setCenter(center * affine); - item->updateRepr(); - } -} - -/** - * Calculates the angle at which to put an object given the total amount - * of objects, the index of the objects as well as the arc start and end - * points - * @param arcBegin angle at which the arc begins - * @param arcEnd angle at which the arc ends - * @param count number of objects in the selection - * @param n index of the object in the selection - */ -float calcAngle(float arcBegin, float arcEnd, int count, int n) -{ - float arcLength = arcEnd - arcBegin; - float delta = std::abs(std::abs(arcLength) - 2*M_PI); - if(delta > 0.01) count--; // If not a complete circle, put an object also at the extremes of the arc; - - float angle = n / (float)count; - // Normalize for arcLength: - angle = angle * arcLength; - angle += arcBegin; - - return angle; -} - -/** - * Calculates the point at which the object needs to be, given the center of the ellipse, - * it's radius (x and y), as well as the angle - */ -Geom::Point calcPoint(float cx, float cy, float rx, float ry, float angle) -{ - return Geom::Point(cx + cos(angle) * rx, cy + sin(angle) * ry); -} - -/** - * Returns the selected anchor point in document coordinates. If anchor - * is 0 to 8, then a bounding box point has been choosen. If it is 9 however - * the rotational center is chosen. - * @todo still using a hack to get the real coordinate space (subtracting document height - * and inverting axes) - */ -Geom::Point getAnchorPoint(int anchor, SPItem *item) -{ - Geom::Point source; - - Geom::OptRect bbox = item->documentVisualBounds(); - - switch(anchor) - { - case 0: // Top - Left - case 3: // Middle - Left - case 6: // Bottom - Left - source[0] = bbox->min()[Geom::X]; - break; - case 1: // Top - Middle - case 4: // Middle - Middle - case 7: // Bottom - Middle - source[0] = (bbox->min()[Geom::X] + bbox->max()[Geom::X]) / 2.0f; - break; - case 2: // Top - Right - case 5: // Middle - Right - case 8: // Bottom - Right - source[0] = bbox->max()[Geom::X]; - break; - }; - - switch(anchor) - { - case 0: // Top - Left - case 1: // Top - Middle - case 2: // Top - Right - source[1] = bbox->min()[Geom::Y]; - break; - case 3: // Middle - Left - case 4: // Middle - Middle - case 5: // Middle - Right - source[1] = (bbox->min()[Geom::Y] + bbox->max()[Geom::Y]) / 2.0f; - break; - case 6: // Bottom - Left - case 7: // Bottom - Middle - case 8: // Bottom - Right - source[1] = bbox->max()[Geom::Y]; - break; - }; - - // If using center - if(anchor == 9) - source = item->getCenter(); - else - { - // FIXME: - source[1] -= item->document->getHeight(); - source[1] *= -1; - } - - return source; -} - -void moveToPoint(int anchor, SPItem *item, Geom::Point p) -{ - sp_item_move_rel(item, Geom::Translate(p - getAnchorPoint(anchor, item))); -} - -void PolarArrangeTab::arrange() -{ - std::cout << "PolarArrangeTab::arrange()" << std::endl; - - Inkscape::Selection *selection = sp_desktop_selection(parent->getDesktop()); - const GSList *items, *tmp; - tmp = items = selection->itemList(); - SPGenericEllipse *referenceEllipse = NULL; // Last ellipse in selection - - bool arrangeOnEllipse = !arrangeOnParametersRadio.get_active(); - bool arrangeOnFirstEllipse = arrangeOnEllipse && arrangeOnFirstCircleRadio.get_active(); - - int count = 0; - while(tmp) - { - if(arrangeOnEllipse) - { - SPItem *item = SP_ITEM(tmp->data); - - if(arrangeOnFirstEllipse) - { - // The first selected ellipse is actually the last one in the list - if(SP_IS_GENERICELLIPSE(item)) - referenceEllipse = SP_GENERICELLIPSE(item); - } else { - // The last selected ellipse is actually the first in list - if(SP_IS_GENERICELLIPSE(item) && referenceEllipse == NULL) - referenceEllipse = SP_GENERICELLIPSE(item); - } - } - tmp = tmp->next; - ++count; - } - - float cx, cy; // Center of the ellipse - float rx, ry; // Radiuses of the ellipse in x and y direction - float arcBeg, arcEnd; // begin and end angles for arcs - Geom::Affine transformation; // Any additional transformation to apply to the objects - - if(arrangeOnEllipse) - { - if(referenceEllipse == NULL) - { - Gtk::MessageDialog dialog(_("Couldn't find an ellipse in selection"), false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_CLOSE, true); - dialog.run(); - return; - } else { - cx = referenceEllipse->cx.value; - cy = referenceEllipse->cy.value; - rx = referenceEllipse->rx.value; - ry = referenceEllipse->ry.value; - arcBeg = referenceEllipse->start; - arcEnd = referenceEllipse->end; - - std::cout << "Arc: " << arcBeg << ", " << arcEnd << std::endl; - transformation = referenceEllipse->i2dt_affine(); - - // We decrement the count by 1 as we are not going to lay - // out the reference ellipse - --count; - } - - } else { - // Read options from UI - cx = centerX.getValue("px"); - cy = centerY.getValue("px"); - rx = radiusX.getValue("px"); - ry = radiusY.getValue("px"); - arcBeg = angleX.getValue("rad"); - arcEnd = angleY.getValue("rad"); - transformation.setIdentity(); - referenceEllipse = NULL; - } - - int anchor = 9; - if(anchorBoundingBoxRadio.get_active()) - { - anchor = anchorSelector.getHorizontalAlignment() + - anchorSelector.getVerticalAlignment() * 3; - } - - Geom::Point realCenter = Geom::Point(cx, cy) * transformation; - - tmp = items; - int i = 0; - while(tmp) - { - SPItem *item = SP_ITEM(tmp->data); - - // Ignore the reference ellipse if any - if(item != referenceEllipse) - { - float angle = calcAngle(arcBeg, arcEnd, count, i); - Geom::Point newLocation = calcPoint(cx, cy, rx, ry, angle) * transformation; - - moveToPoint(anchor, item, newLocation); - - if(rotateObjectsCheckBox.get_active()) { - // Calculate the angle by which to rotate each object - angle = -atan2f(newLocation.x() - realCenter.x(), newLocation.y() - realCenter.y()); - rotateAround(item, newLocation, Geom::Rotate(angle)); - } - - std::cout << "object " << i << " out of " << count << ": " << angle << std::endl; - - ++i; - } - tmp = tmp->next; - } - - DocumentUndo::done(sp_desktop_document(parent->getDesktop()), SP_VERB_SELECTION_ARRANGE, - _("Arrange on ellipse")); -} - -void PolarArrangeTab::updateSelection() -{ -} - -void PolarArrangeTab::on_arrange_radio_changed() -{ - bool arrangeParametric = arrangeOnParametersRadio.get_active(); - - centerX.set_sensitive(arrangeParametric); - centerY.set_sensitive(arrangeParametric); - - angleX.set_sensitive(arrangeParametric); - angleY.set_sensitive(arrangeParametric); - - radiusX.set_sensitive(arrangeParametric); - radiusY.set_sensitive(arrangeParametric); -} - -void PolarArrangeTab::on_anchor_radio_changed() -{ - bool anchorBoundingBox = anchorBoundingBoxRadio.get_active(); - - anchorSelector.set_sensitive(anchorBoundingBox); -} - -} //namespace Dialog -} //namespace UI -} //namespace Inkscape - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/dialog/polararrangetab.h b/src/ui/dialog/polararrangetab.h deleted file mode 100644 index 24760a8bc..000000000 --- a/src/ui/dialog/polararrangetab.h +++ /dev/null @@ -1,87 +0,0 @@ -/** - * @brief Arranges Objects into a Circle/Ellipse - */ -/* Authors: - * Declara Denis - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#ifndef INKSCAPE_UI_DIALOG_POLAR_ARRANGE_TAB_H -#define INKSCAPE_UI_DIALOG_POLAR_ARRANGE_TAB_H - -#include - -#include "ui/dialog/arrangetab.h" - -#include "ui/widget/anchor-selector.h" -#include "ui/widget/scalar-unit.h" - -namespace Inkscape { -namespace UI { -namespace Dialog { - -class ArrangeDialog; - -class PolarArrangeTab : public ArrangeTab { -public: - PolarArrangeTab(ArrangeDialog *parent_); - virtual ~PolarArrangeTab() {}; - - /** - * Do the actual work - */ - virtual void arrange(); - - /** - * Respond to selection change - */ - void updateSelection(); - - void on_anchor_radio_changed(); - void on_arrange_radio_changed(); - -private: - PolarArrangeTab(PolarArrangeTab const &d); // no copy - void operator=(PolarArrangeTab const &d); // no assign - - ArrangeDialog *parent; - - Gtk::Label anchorPointLabel; - - Gtk::RadioButtonGroup anchorRadioGroup; - Gtk::RadioButton anchorBoundingBoxRadio; - Gtk::RadioButton anchorObjectPivotRadio; - AnchorSelector anchorSelector; - - Gtk::Label arrangeOnLabel; - - Gtk::RadioButtonGroup arrangeRadioGroup; - Gtk::RadioButton arrangeOnFirstCircleRadio; - Gtk::RadioButton arrangeOnLastCircleRadio; - Gtk::RadioButton arrangeOnParametersRadio; - - Gtk::Table parametersTable; - - Gtk::Label centerLabel; - Inkscape::UI::Widget::ScalarUnit centerY; - Inkscape::UI::Widget::ScalarUnit centerX; - - Gtk::Label radiusLabel; - Inkscape::UI::Widget::ScalarUnit radiusY; - Inkscape::UI::Widget::ScalarUnit radiusX; - - Gtk::Label angleLabel; - Inkscape::UI::Widget::ScalarUnit angleY; - Inkscape::UI::Widget::ScalarUnit angleX; - - Gtk::CheckButton rotateObjectsCheckBox; - - -}; - -} //namespace Dialog -} //namespace UI -} //namespace Inkscape - -#endif /* INKSCAPE_UI_DIALOG_POLAR_ARRANGE_TAB_H */ diff --git a/src/ui/dialog/tile.cpp b/src/ui/dialog/tile.cpp index 917544d3d..c967509f9 100644 --- a/src/ui/dialog/tile.cpp +++ b/src/ui/dialog/tile.cpp @@ -19,8 +19,8 @@ #include "tile.h" #include "verbs.h" -#include "ui/dialog/gridarrangetab.h" -#include "ui/dialog/polararrangetab.h" +#include "ui/dialog/grid-arrange-tab.h" +#include "ui/dialog/polar-arrange-tab.h" namespace Inkscape { namespace UI { diff --git a/src/ui/widget/anchor-selector.cpp b/src/ui/widget/anchor-selector.cpp index 87f50cf5f..82e27ee89 100644 --- a/src/ui/widget/anchor-selector.cpp +++ b/src/ui/widget/anchor-selector.cpp @@ -12,6 +12,10 @@ #include "widgets/icon.h" #include "ui/icon-names.h" +namespace Inkscape { +namespace UI { +namespace Widget { + void AnchorSelector::setupButton(const Glib::ustring& icon, Gtk::ToggleButton& button) { Gtk::Widget* buttonIcon = Gtk::manage(sp_icon_get_icon(icon, Inkscape::ICON_SIZE_SMALL_TOOLBAR)); buttonIcon->show(); @@ -76,3 +80,18 @@ void AnchorSelector::setAlignment(int horizontal, int vertical) _buttons[index].set_active(!_buttons[index].get_active()); } } + +} // namespace Widget +} // namespace UI +} // namespace Inkscape + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/ui/widget/anchor-selector.h b/src/ui/widget/anchor-selector.h index 361528d11..2263438e3 100644 --- a/src/ui/widget/anchor-selector.h +++ b/src/ui/widget/anchor-selector.h @@ -12,6 +12,10 @@ #include +namespace Inkscape { +namespace UI { +namespace Widget { + class AnchorSelector : public Gtk::Alignment { private: @@ -37,4 +41,19 @@ public: virtual ~AnchorSelector(); }; +} // namespace Widget +} // namespace UI +} // namespace Inkscape + #endif /* ANCHOR_SELECTOR_H_ */ + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : -- cgit v1.2.3 From c620ecb0f432de693f537f020999dfa4316b1859 Mon Sep 17 00:00:00 2001 From: Denis Declara Date: Wed, 9 May 2012 17:09:29 +0200 Subject: Removed debug output (bzr r11073.1.32) --- src/ui/dialog/polar-arrange-tab.cpp | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/polar-arrange-tab.cpp b/src/ui/dialog/polar-arrange-tab.cpp index a1df794a5..32f05c5e8 100644 --- a/src/ui/dialog/polar-arrange-tab.cpp +++ b/src/ui/dialog/polar-arrange-tab.cpp @@ -261,8 +261,6 @@ void moveToPoint(int anchor, SPItem *item, Geom::Point p) void PolarArrangeTab::arrange() { - std::cout << "PolarArrangeTab::arrange()" << std::endl; - Inkscape::Selection *selection = sp_desktop_selection(parent->getDesktop()); const GSList *items, *tmp; tmp = items = selection->itemList(); @@ -313,7 +311,6 @@ void PolarArrangeTab::arrange() arcBeg = referenceEllipse->start; arcEnd = referenceEllipse->end; - std::cout << "Arc: " << arcBeg << ", " << arcEnd << std::endl; transformation = referenceEllipse->i2dt_affine(); // We decrement the count by 1 as we are not going to lay @@ -362,8 +359,6 @@ void PolarArrangeTab::arrange() rotateAround(item, newLocation, Geom::Rotate(angle)); } - std::cout << "object " << i << " out of " << count << ": " << angle << std::endl; - ++i; } tmp = tmp->next; -- cgit v1.2.3 From 48cd3195741c6590d7129da3bae23fd72784d4a4 Mon Sep 17 00:00:00 2001 From: Denis Declara Date: Sat, 19 May 2012 14:19:14 +0200 Subject: Renamed "arrangetab.h" to "arrange-tab.h" (bzr r11073.1.33) --- src/ui/CMakeLists.txt | 2 +- src/ui/dialog/Makefile_insert | 2 +- src/ui/dialog/arrange-tab.h | 54 +++++++++++++++++++++++++++++++++++++++ src/ui/dialog/arrangetab.h | 54 --------------------------------------- src/ui/dialog/grid-arrange-tab.h | 2 +- src/ui/dialog/polar-arrange-tab.h | 2 +- 6 files changed, 58 insertions(+), 58 deletions(-) create mode 100644 src/ui/dialog/arrange-tab.h delete mode 100644 src/ui/dialog/arrangetab.h (limited to 'src') diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 7435720fd..2e419bbc3 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -136,7 +136,7 @@ set(ui_SRC dialog/aboutbox.h dialog/align-and-distribute.h - dialog/arrangetab.h + dialog/arrange-tab.h dialog/behavior.h dialog/calligraphic-profile-rename.h dialog/color-item.h diff --git a/src/ui/dialog/Makefile_insert b/src/ui/dialog/Makefile_insert index 53533a08f..5a367248e 100644 --- a/src/ui/dialog/Makefile_insert +++ b/src/ui/dialog/Makefile_insert @@ -5,7 +5,7 @@ ink_common_sources += \ ui/dialog/aboutbox.h \ ui/dialog/align-and-distribute.cpp \ ui/dialog/align-and-distribute.h \ - ui/dialog/arrangetab.h \ + ui/dialog/arrange-tab.h \ ui/dialog/behavior.h \ ui/dialog/calligraphic-profile-rename.h \ ui/dialog/calligraphic-profile-rename.cpp \ diff --git a/src/ui/dialog/arrange-tab.h b/src/ui/dialog/arrange-tab.h new file mode 100644 index 000000000..3ffe1ef4c --- /dev/null +++ b/src/ui/dialog/arrange-tab.h @@ -0,0 +1,54 @@ +/** + * @brief Arrange tools base class + */ +/* Authors: + * * Declara Denis + * Copyright (C) 2012 Authors + * + * Released under GNU GPL. Read the file 'COPYING' for more information. + */ + +#ifndef INKSCAPE_UI_DIALOG_ARRANGE_TAB_H +#define INKSCAPE_UI_DIALOG_ARRANGE_TAB_H + +#include + +namespace Inkscape { +namespace UI { +namespace Dialog { + +/** + * This interface should be implemented by each arrange mode. + * The class is a Gtk::VBox and will be displayed as a tab in + * the dialog + */ +class ArrangeTab : public Gtk::VBox +{ +public: + ArrangeTab() {}; + virtual ~ArrangeTab() {}; + + /** + * Do the actual work! This method is invoked to actually arrange the + * selection + */ + virtual void arrange() = 0; +}; + +} //namespace Dialog +} //namespace UI +} //namespace Inkscape + + +#endif /* INKSCAPE_UI_DIALOG_ARRANGE_TAB_H */ + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/dialog/arrangetab.h b/src/ui/dialog/arrangetab.h deleted file mode 100644 index 3ffe1ef4c..000000000 --- a/src/ui/dialog/arrangetab.h +++ /dev/null @@ -1,54 +0,0 @@ -/** - * @brief Arrange tools base class - */ -/* Authors: - * * Declara Denis - * Copyright (C) 2012 Authors - * - * Released under GNU GPL. Read the file 'COPYING' for more information. - */ - -#ifndef INKSCAPE_UI_DIALOG_ARRANGE_TAB_H -#define INKSCAPE_UI_DIALOG_ARRANGE_TAB_H - -#include - -namespace Inkscape { -namespace UI { -namespace Dialog { - -/** - * This interface should be implemented by each arrange mode. - * The class is a Gtk::VBox and will be displayed as a tab in - * the dialog - */ -class ArrangeTab : public Gtk::VBox -{ -public: - ArrangeTab() {}; - virtual ~ArrangeTab() {}; - - /** - * Do the actual work! This method is invoked to actually arrange the - * selection - */ - virtual void arrange() = 0; -}; - -} //namespace Dialog -} //namespace UI -} //namespace Inkscape - - -#endif /* INKSCAPE_UI_DIALOG_ARRANGE_TAB_H */ - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/ui/dialog/grid-arrange-tab.h b/src/ui/dialog/grid-arrange-tab.h index 7e90accf1..2744ca87f 100644 --- a/src/ui/dialog/grid-arrange-tab.h +++ b/src/ui/dialog/grid-arrange-tab.h @@ -19,7 +19,7 @@ #include -#include "ui/dialog/arrangetab.h" +#include "ui/dialog/arrange-tab.h" #include "ui/widget/anchor-selector.h" #include "ui/widget/scalar-unit.h" diff --git a/src/ui/dialog/polar-arrange-tab.h b/src/ui/dialog/polar-arrange-tab.h index e62ebd76b..3481bc4a0 100644 --- a/src/ui/dialog/polar-arrange-tab.h +++ b/src/ui/dialog/polar-arrange-tab.h @@ -12,7 +12,7 @@ #include -#include "ui/dialog/arrangetab.h" +#include "ui/dialog/arrange-tab.h" #include "ui/widget/anchor-selector.h" #include "ui/widget/scalar-unit.h" -- cgit v1.2.3 From 24e2360f100a9372e7f2d0af894ec1b2d1357ace Mon Sep 17 00:00:00 2001 From: Denis Declara Date: Sat, 19 May 2012 14:51:48 +0200 Subject: Added documentation and made helper functions in polar-arrange-tab.cpp static (bzr r11073.1.34) --- src/ui/dialog/polar-arrange-tab.cpp | 22 ++++++++++++++++------ src/ui/dialog/polar-arrange-tab.h | 17 ++++++++++++++++- 2 files changed, 32 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/polar-arrange-tab.cpp b/src/ui/dialog/polar-arrange-tab.cpp index 32f05c5e8..2056c7820 100644 --- a/src/ui/dialog/polar-arrange-tab.cpp +++ b/src/ui/dialog/polar-arrange-tab.cpp @@ -140,7 +140,7 @@ PolarArrangeTab::PolarArrangeTab(ArrangeDialog *parent_) * @param center center of the rotation to perform * @param rotation amount to rotate the object by */ -void rotateAround(SPItem *item, Geom::Point center, Geom::Rotate const &rotation) +static void rotateAround(SPItem *item, Geom::Point center, Geom::Rotate const &rotation) { Geom::Translate const s(center); Geom::Affine affine = Geom::Affine(s).inverse() * Geom::Affine(rotation) * Geom::Affine(s); @@ -167,7 +167,7 @@ void rotateAround(SPItem *item, Geom::Point center, Geom::Rotate const &rotation * @param count number of objects in the selection * @param n index of the object in the selection */ -float calcAngle(float arcBegin, float arcEnd, int count, int n) +static float calcAngle(float arcBegin, float arcEnd, int count, int n) { float arcLength = arcEnd - arcBegin; float delta = std::abs(std::abs(arcLength) - 2*M_PI); @@ -182,10 +182,10 @@ float calcAngle(float arcBegin, float arcEnd, int count, int n) } /** - * Calculates the point at which the object needs to be, given the center of the ellipse, + * Calculates the point at which an object needs to be, given the center of the ellipse, * it's radius (x and y), as well as the angle */ -Geom::Point calcPoint(float cx, float cy, float rx, float ry, float angle) +static Geom::Point calcPoint(float cx, float cy, float rx, float ry, float angle) { return Geom::Point(cx + cos(angle) * rx, cy + sin(angle) * ry); } @@ -197,7 +197,7 @@ Geom::Point calcPoint(float cx, float cy, float rx, float ry, float angle) * @todo still using a hack to get the real coordinate space (subtracting document height * and inverting axes) */ -Geom::Point getAnchorPoint(int anchor, SPItem *item) +static Geom::Point getAnchorPoint(int anchor, SPItem *item) { Geom::Point source; @@ -254,7 +254,17 @@ Geom::Point getAnchorPoint(int anchor, SPItem *item) return source; } -void moveToPoint(int anchor, SPItem *item, Geom::Point p) +/** + * Moves an SPItem to a given location, the location is based on the given anchor point. + * @param anchor 0 to 8 are the various bounding box points like follows: + * 0 1 2 + * 3 4 5 + * 6 7 8 + * Anchor mode 9 is the rotational center of the object + * @param item Item to move + * @param p point at which to move the object + */ +static void moveToPoint(int anchor, SPItem *item, Geom::Point p) { sp_item_move_rel(item, Geom::Translate(p - getAnchorPoint(anchor, item))); } diff --git a/src/ui/dialog/polar-arrange-tab.h b/src/ui/dialog/polar-arrange-tab.h index 3481bc4a0..019b64511 100644 --- a/src/ui/dialog/polar-arrange-tab.h +++ b/src/ui/dialog/polar-arrange-tab.h @@ -23,13 +23,17 @@ namespace Dialog { class ArrangeDialog; +/** + * PolarArrangeTab is a Tab displayed in the Arrange dialog and contains + * enables the user to arrange objects on a circular or elliptical shape + */ class PolarArrangeTab : public ArrangeTab { public: PolarArrangeTab(ArrangeDialog *parent_); virtual ~PolarArrangeTab() {}; /** - * Do the actual work + * Do the actual arrangement */ virtual void arrange(); @@ -85,3 +89,14 @@ private: } //namespace Inkscape #endif /* INKSCAPE_UI_DIALOG_POLAR_ARRANGE_TAB_H */ + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : -- cgit v1.2.3 From 8d97fe84d570a73ba3b48269308bd360332b8250 Mon Sep 17 00:00:00 2001 From: Denis Declara Date: Sat, 19 May 2012 18:39:38 +0200 Subject: The Polar Arrange Tab of the Arrange Dialog now hides the parametric controls until the user selects the corresponding radio button (bzr r11073.1.35) --- src/ui/dialog/polar-arrange-tab.cpp | 9 ++------- src/ui/dialog/tile.cpp | 9 ++++++++- src/ui/dialog/tile.h | 2 ++ 3 files changed, 12 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/polar-arrange-tab.cpp b/src/ui/dialog/polar-arrange-tab.cpp index 2056c7820..623aa4e3e 100644 --- a/src/ui/dialog/polar-arrange-tab.cpp +++ b/src/ui/dialog/polar-arrange-tab.cpp @@ -75,16 +75,13 @@ PolarArrangeTab::PolarArrangeTab(ArrangeDialog *parent_) arrangeOnParametersRadio.signal_toggled().connect(sigc::mem_fun(*this, &PolarArrangeTab::on_arrange_radio_changed)); pack_start(arrangeOnParametersRadio, false, false); - //FIXME: Objects in grid do not line up properly! centerLabel.set_text(_("Center X/Y:")); parametersTable.attach(centerLabel, 0, 1, 0, 1, Gtk::FILL); centerX.setDigits(2); - //centerX.set_size_request(60, -1); centerX.setIncrements(0.2, 0); centerX.setRange(-10000, 10000); centerX.setValue(0, "px"); centerY.setDigits(2); - //centerY.set_size_request(120, -1); centerY.setIncrements(0.2, 0); centerY.setRange(-10000, 10000); centerY.setValue(0, "px"); @@ -94,12 +91,10 @@ PolarArrangeTab::PolarArrangeTab(ArrangeDialog *parent_) radiusLabel.set_text(_("Radius X/Y:")); parametersTable.attach(radiusLabel, 0, 1, 1, 2, Gtk::FILL); radiusX.setDigits(2); - //radiusX.set_size_request(60, -1); radiusX.setIncrements(0.2, 0); radiusX.setRange(0.001, 10000); radiusX.setValue(100, "px"); radiusY.setDigits(2); - //radiusY.set_size_request(120, -1); radiusY.setIncrements(0.2, 0); radiusY.setRange(0.001, 10000); radiusY.setValue(100, "px"); @@ -109,12 +104,10 @@ PolarArrangeTab::PolarArrangeTab(ArrangeDialog *parent_) angleLabel.set_text(_("Angle X/Y:")); parametersTable.attach(angleLabel, 0, 1, 2, 3, Gtk::FILL); angleX.setDigits(2); - //angleX.set_size_request(60, -1); angleX.setIncrements(0.2, 0); angleX.setRange(-10000, 10000); angleX.setValue(0, "°"); angleY.setDigits(2); - //angleY.set_size_request(120, -1); angleY.setIncrements(0.2, 0); angleY.setRange(-10000, 10000); angleY.setValue(180, "°"); @@ -394,6 +387,8 @@ void PolarArrangeTab::on_arrange_radio_changed() radiusX.set_sensitive(arrangeParametric); radiusY.set_sensitive(arrangeParametric); + + parametersTable.set_visible(arrangeParametric); } void PolarArrangeTab::on_anchor_radio_changed() diff --git a/src/ui/dialog/tile.cpp b/src/ui/dialog/tile.cpp index c967509f9..1ed099120 100644 --- a/src/ui/dialog/tile.cpp +++ b/src/ui/dialog/tile.cpp @@ -41,7 +41,14 @@ ArrangeDialog::ArrangeDialog() _arrangeButton->set_use_underline(true); _arrangeButton->set_tooltip_text(_("Arrange selected objects")); contents->pack_start(_arrangeBox); - show_all_children(); + //show_all_children(); +} + + +void ArrangeDialog::on_show() +{ + UI::Widget::Panel::on_show(); + _polarArrangeTab->on_arrange_radio_changed(); } void ArrangeDialog::_apply() diff --git a/src/ui/dialog/tile.h b/src/ui/dialog/tile.h index d42dd7f65..8d4e9584b 100644 --- a/src/ui/dialog/tile.h +++ b/src/ui/dialog/tile.h @@ -54,6 +54,8 @@ public: */ virtual void _apply(); + virtual void on_show(); + static ArrangeDialog& getInstance() { return *new ArrangeDialog(); } }; -- cgit v1.2.3 From 2b34ad03d59938b3ab142cca56b71366d0cf61ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20dos=20Santos=20Oliveira?= Date: Sun, 6 Oct 2013 22:47:06 -0300 Subject: Running libdepixelize expensive process in a background thread (bzr r12667.1.1) --- src/ui/dialog/pixelartdialog.cpp | 164 ++++++++++++++++++++++++++++----------- 1 file changed, 117 insertions(+), 47 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/pixelartdialog.cpp b/src/ui/dialog/pixelartdialog.cpp index ff527434e..3f3ebc0b6 100644 --- a/src/ui/dialog/pixelartdialog.cpp +++ b/src/ui/dialog/pixelartdialog.cpp @@ -16,6 +16,16 @@ # include #endif +#ifdef GLIBMM_DISABLE_DEPRECATED +# undef GLIBMM_DISABLE_DEPRECATED +# include +# include +# define GLIBMM_DISABLE_DEPRECATED 1 +#else // GLIBMM_DISABLE_DEPRECATED +# include +# include +#endif // GLIBMM_DISABLE_DEPRECATED + #include "pixelartdialog.h" #include #include @@ -54,18 +64,6 @@ namespace Inkscape { namespace UI { namespace Dialog { -template -T move(T &obj) -{ -#ifdef LIBDEPIXELIZE_ENABLE_CPP11 - return std::move(obj); -#else - T ret; - std::swap(obj, ret); - return ret; -#endif // LIBDEPIXELIZE_ENABLE_CPP11 -} - /** * A dialog for adjusting pixel art -> vector tracing parameters */ @@ -77,6 +75,23 @@ public: ~PixelArtDialogImpl(); private: + struct Input + { + Glib::RefPtr pixbuf; + SVGLength x; + SVGLength y; + }; + struct Output + { + Output(Tracer::Splines splines, SVGLength x, SVGLength y) : + splines(splines), x(x), y(y) + {} + + Tracer::Splines splines; + SVGLength x; + SVGLength y; + }; + void setDesktop(SPDesktop *desktop); void setTargetDesktop(SPDesktop *desktop); @@ -89,7 +104,8 @@ private: Tracer::Kopf2011::Options options(); void vectorize(); - void processLibdepixelize(SPImage *img); + void processLibdepixelize(const Input &image); + void importOutput(const Output &out); void setDefaults(); void updatePreview(); @@ -133,9 +149,21 @@ private: Gtk::RadioButton optimizeRadioButton; #endif // LIBDEPIXELIZE_INKSCAPE_ENABLE_SMOOTH + //############ UI Logic data + SPDesktop *desktop; DesktopTracker deskTrack; sigc::connection desktopChangeConn; + + //############ Threads + void workerThread(); + void onWorkerThreadFinished(); + Glib::Thread *thread; + volatile gint abortThread; // C++11's atomic stuff is sooo much nicer + Glib::Dispatcher dispatcher; + std::vector queue; + std::vector output; + Tracer::Kopf2011::Options lastOptions; }; void PixelArtDialogImpl::setDesktop(SPDesktop *desktop) @@ -288,6 +316,9 @@ PixelArtDialogImpl::PixelArtDialogImpl() : deskTrack.connect(GTK_WIDGET(gobj())); signalResponse().connect(sigc::mem_fun(*this, &PixelArtDialogImpl::responseCallback)); + + dispatcher.connect( + sigc::mem_fun(*this, &PixelArtDialogImpl::onWorkerThreadFinished) ); } void PixelArtDialogImpl::responseCallback(int response_id) @@ -295,7 +326,8 @@ void PixelArtDialogImpl::responseCallback(int response_id) if (response_id == GTK_RESPONSE_OK) { vectorize(); } else if (response_id == GTK_RESPONSE_CANCEL) { - // TODO + // libdepixelize's interface need to be extended to allow aborts + g_atomic_int_set(&abortThread, true); } else if (response_id == GTK_RESPONSE_HELP) { setDefaults(); } else { @@ -340,60 +372,69 @@ void PixelArtDialogImpl::vectorize() return; } - bool found = false; - for ( GSList const *list = desktop->selection->itemList() ; list ; list = list->next ) { if ( !SP_IS_IMAGE(list->data) ) continue; - found = true; + SPImage *img = SP_IMAGE(list->data); + Input input; + input.pixbuf = Glib::wrap(img->pixbuf->getPixbufRaw(), true); + input.x = img->x; + input.y = img->y; + + if ( input.pixbuf->get_width() > 256 + || input.pixbuf->get_height() > 256 ) { + char *msg = _("Image looks too big. Process may take a while and is" + " wise to save your document before continue." + "\n\nContinue the procedure (without saving)?"); + Gtk::MessageDialog dialog(msg, false, Gtk::MESSAGE_WARNING, + Gtk::BUTTONS_OK_CANCEL, true); + + if ( dialog.run() != Gtk::RESPONSE_OK ) + continue; + } - processLibdepixelize(SP_IMAGE(list->data)); + queue.push_back(input); + //processLibdepixelize(SP_IMAGE(list->data)); } - if ( !found ) { + if ( !queue.size() ) { char *msg = _("Select an image to trace"); msgStack->flash(Inkscape::ERROR_MESSAGE, msg); return; } - DocumentUndo::done(desktop->doc(), SP_VERB_SELECTION_PIXEL_ART, - _("Trace pixel art")); + mainCancelButton->set_sensitive(true); + mainOkButton->set_sensitive(false); - // Flush pending updates - desktop->doc()->ensureUpToDate(); + lastOptions = options(); + + g_atomic_int_set(&abortThread, false); + thread = Glib::Thread::create( + sigc::mem_fun(*this, &PixelArtDialogImpl::workerThread) ); } -void PixelArtDialogImpl::processLibdepixelize(SPImage *img) +void PixelArtDialogImpl::processLibdepixelize(const Input &input) { - Tracer::Splines out; - - Glib::RefPtr pixbuf - = Glib::wrap(img->pixbuf->getPixbufRaw(), true); - - if ( pixbuf->get_width() > 256 || pixbuf->get_height() > 256 ) { - char *msg = _("Image looks too big. Process may take a while and is" - " wise to save your document before continue." - "\n\nContinue the procedure (without saving)?"); - Gtk::MessageDialog dialog(msg, false, Gtk::MESSAGE_WARNING, - Gtk::BUTTONS_OK_CANCEL, true); - - if ( dialog.run() != Gtk::RESPONSE_OK ) - return; - } - if ( voronoiRadioButton.get_active() ) { - out = Tracer::Kopf2011::to_voronoi(pixbuf, options()); + output.push_back(Output(Tracer::Kopf2011::to_voronoi(input.pixbuf, + lastOptions), + input.x, input.y)); } else { - out = Tracer::Kopf2011::to_splines(pixbuf, options()); + output.push_back(Output(Tracer::Kopf2011::to_splines(input.pixbuf, + lastOptions), + input.x, input.y)); } +} +void PixelArtDialogImpl::importOutput(const Output &output) +{ Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); Inkscape::XML::Node *group = xml_doc->createElement("svg:g"); - for ( Tracer::Splines::iterator it = out.begin(), end = out.end() - ; it != end ; ++it ) { + for ( Tracer::Splines::const_iterator it = output.splines.begin(), + end = output.splines.end() ; it != end ; ++it ) { Inkscape::XML::Node *repr = xml_doc->createElement("svg:path"); { @@ -421,7 +462,7 @@ void PixelArtDialogImpl::processLibdepixelize(SPImage *img) sp_repr_css_attr_unref(css); } - gchar *str = sp_svg_write_path(move(it->pathVector)); + gchar *str = sp_svg_write_path(it->pathVector); repr->setAttribute("d", str); g_free(str); @@ -433,14 +474,20 @@ void PixelArtDialogImpl::processLibdepixelize(SPImage *img) { group->setAttribute("transform", (std::string("translate(") - + sp_svg_length_write_with_units(img->x) - + ' ' + sp_svg_length_write_with_units(img->y) + + sp_svg_length_write_with_units(output.x) + + ' ' + sp_svg_length_write_with_units(output.y) + ')').c_str()); } desktop->currentLayer()->appendChildRepr(group); Inkscape::GC::release(group); + + DocumentUndo::done(desktop->doc(), SP_VERB_SELECTION_PIXEL_ART, + _("Trace pixel art")); + + // Flush pending updates + desktop->doc()->ensureUpToDate(); } void PixelArtDialogImpl::setDefaults() @@ -481,6 +528,29 @@ void PixelArtDialogImpl::updatePreview() pendingPreview = false; } +void PixelArtDialogImpl::workerThread() +{ + for ( std::vector::iterator it = queue.begin(), end = queue.end() + ; it != end && !g_atomic_int_get(&abortThread) ; ++it ) { + processLibdepixelize(*it); + } + queue.clear(); + dispatcher(); +} + +void PixelArtDialogImpl::onWorkerThreadFinished() +{ + thread->join(); + thread = NULL; + for ( std::vector::const_iterator it = output.begin(), + end = output.end() ; it != end ; ++it ) { + importOutput(*it); + } + output.clear(); + mainCancelButton->set_sensitive(false); + mainOkButton->set_sensitive(true); +} + /** * Factory method. Use this to create a new PixelArtDialog */ -- cgit v1.2.3 From 20062e01bfce8a97746e438bc0f7e89ce6400015 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20dos=20Santos=20Oliveira?= Date: Mon, 7 Oct 2013 00:26:05 -0300 Subject: Removing useless comment (bzr r12667.1.2) --- src/ui/dialog/pixelartdialog.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/ui/dialog/pixelartdialog.cpp b/src/ui/dialog/pixelartdialog.cpp index 3f3ebc0b6..d5313b2c8 100644 --- a/src/ui/dialog/pixelartdialog.cpp +++ b/src/ui/dialog/pixelartdialog.cpp @@ -396,7 +396,6 @@ void PixelArtDialogImpl::vectorize() } queue.push_back(input); - //processLibdepixelize(SP_IMAGE(list->data)); } if ( !queue.size() ) { -- cgit v1.2.3 From 0c59dfecac91c2c606a8172a78bdcad71329e4f1 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sun, 12 Jan 2014 22:00:46 +0100 Subject: fix build with boehm-gc 7.4.0+ (patch by Vladimir Smirnov, slightly modified by me) Fixed bugs: - https://launchpad.net/bugs/1265072 (bzr r12918) --- src/gc-core.h | 2 +- src/gc.cpp | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/gc-core.h b/src/gc-core.h index 85fbada60..3957bda1a 100644 --- a/src/gc-core.h +++ b/src/gc-core.h @@ -57,7 +57,7 @@ struct Ops { CleanupFunc *old_func, void **old_data); int (*general_register_disappearing_link)(void **p_ptr, - void *base); + void const *base); int (*unregister_disappearing_link)(void **p_ptr); std::size_t (*get_heap_size)(); std::size_t (*get_free_bytes)(); diff --git a/src/gc.cpp b/src/gc.cpp index 9c59691cb..280a8b1dc 100644 --- a/src/gc.cpp +++ b/src/gc.cpp @@ -70,9 +70,13 @@ void *debug_base(void *ptr) { return base + debug_base_fixup(); } -int debug_general_register_disappearing_link(void **p_ptr, void *base) { - char *real_base=reinterpret_cast(base) - debug_base_fixup(); +int debug_general_register_disappearing_link(void **p_ptr, void const *base) { + char const *real_base = reinterpret_cast(base) - debug_base_fixup(); +#if (GC_MAJOR_VERSION >= 7 && GC_MINOR_VERSION >= 4) return GC_general_register_disappearing_link(p_ptr, real_base); +#else // compatibility with older Boehm GC versions + return GC_general_register_disappearing_link(p_ptr, const_cast(real_base)); +#endif } void dummy_do_init() {} @@ -90,7 +94,7 @@ void dummy_register_finalizer(void *, CleanupFunc, void *, } } -int dummy_general_register_disappearing_link(void **, void *) { return false; } +int dummy_general_register_disappearing_link(void **, void const *) { return false; } int dummy_unregister_disappearing_link(void **/*link*/) { return false; } @@ -112,7 +116,11 @@ Ops enabled_ops = { &GC_malloc_atomic_uncollectable, &GC_base, &GC_register_finalizer_ignore_self, - &GC_general_register_disappearing_link, +#if (GC_MAJOR_VERSION >= 7 && GC_MINOR_VERSION >= 4) + &GC_general_register_disappearing_link, +#else // compatibility with older Boehm GC versions + (int (*)(void**, const void*))(&GC_general_register_disappearing_link), +#endif &GC_unregister_disappearing_link, &GC_get_heap_size, &GC_get_free_bytes, @@ -202,7 +210,7 @@ void stub_register_finalizer_ignore_self(void *, CleanupFunc, void *, die_because_not_initialized(); } -int stub_general_register_disappearing_link(void **, void *) { +int stub_general_register_disappearing_link(void **, void const *) { die_because_not_initialized(); return 0; } -- cgit v1.2.3 From 529a8c8e082f55e197a31a428751392849731674 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sun, 12 Jan 2014 22:32:42 +0100 Subject: lpe knot: code cleanup. mostly adding parens to if-statement predicates that relied on operator precedence (bzr r12919) --- src/live_effects/lpe-knot.cpp | 71 ++++++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-knot.cpp b/src/live_effects/lpe-knot.cpp index 8fec69958..e91677e18 100644 --- a/src/live_effects/lpe-knot.cpp +++ b/src/live_effects/lpe-knot.cpp @@ -161,14 +161,14 @@ CrossingPoints::CrossingPoints(std::vector const &paths) : std::vect for( unsigned j=i; j > times; - if ( i==j && ii==jj){ + if ( (i==j) && (ii==jj) ) { // std::cout<<"--(self int)\n"; // std::cout << paths[i][ii].toSBasis()[Geom::X] <<"\n"; // std::cout << paths[i][ii].toSBasis()[Geom::Y] <<"\n"; find_self_intersections( times, paths[i][ii].toSBasis() ); - }else{ + } else { // std::cout<<"--(pair int)\n"; // std::cout << paths[i][ii].toSBasis()[Geom::X] <<"\n"; // std::cout << paths[i][ii].toSBasis()[Geom::Y] <<"\n"; @@ -180,15 +180,17 @@ CrossingPoints::CrossingPoints(std::vector const &paths) : std::vect } for (unsigned k=0; k const &paths) : std::vect } unsigned count = 0; for ( std::map < double, unsigned >::iterator m=cuts.begin(); m!=cuts.end(); ++m ){ - if ( (*this)[m->second].i == i && (*this)[m->second].ti == m->first ){ + if ( ((*this)[m->second].i == i) && ((*this)[m->second].ti == m->first) ){ (*this)[m->second].ni = count; }else{ (*this)[m->second].nj = count; @@ -230,7 +232,7 @@ CrossingPoints::CrossingPoints(std::vector const &paths) : std::vect CrossingPoints::CrossingPoints(std::vector const &input) : std::vector() { - if (input.size()>0 && input.size()%9 ==0){ + if ( (input.size() > 0) && (input.size()%9 == 0) ){ using namespace Geom; for( unsigned n=0; ndist_k){ + if ( (dist < 0) || (dist > dist_k) ) { result = k; dist = dist_k; } @@ -304,28 +307,28 @@ void CrossingPoints::inherit_signs(CrossingPoints const &other, int default_value) { bool topo_changed = false; - for (unsigned n=0; n const &path_in) std::vector dom; dom.push_back(Interval(0., size_nondegenerate(gpaths[i0]))); for (unsigned p = 0; p < crossing_points.size(); p++){ - if (crossing_points[p].i == i0 || crossing_points[p].j == i0){ + if ( (crossing_points[p].i == i0) || (crossing_points[p].j == i0) ) { unsigned i = crossing_points[p].i; unsigned j = crossing_points[p].j; double ti = crossing_points[p].ti; @@ -475,14 +478,14 @@ LPEKnot::doEffect_path (std::vector const &path_in) //If the current path is closed and the last/first point is still there, glue first and last piece. unsigned beg_comp = 0, end_comp = dom.size(); - if ( gpaths[i0].closed() && dom.front().min() == 0 && dom.back().max() == size_nondegenerate(gpaths[i0]) ){ + if ( gpaths[i0].closed() && (dom.front().min() == 0) && (dom.back().max() == size_nondegenerate(gpaths[i0])) ) { if ( dom.size() == 1){ path_out.push_back(gpaths[i0]); continue; }else{ // std::cout<<"fusing first and last component\n"; - beg_comp++; - end_comp--; + ++beg_comp; + --end_comp; Path first = gpaths[i0].portion(dom.back()); //FIXME: STITCH_DISCONTINUOUS should not be necessary (?!?) first.append(gpaths[i0].portion(dom.front()), Path::STITCH_DISCONTINUOUS); @@ -594,19 +597,19 @@ LPEKnot::addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector= crossing_points.size()||crossing_points[selectedCrossing].sign > 0){ + if ( (selectedCrossing >= crossing_points.size()) || (crossing_points[selectedCrossing].sign > 0) ) { //svgd = "M -10,0 A 10 10 0 1 0 0,-10 l 5,-1 -1,2"; svgd = "m -7.07,7.07 c 3.9,3.91 10.24,3.91 14.14,0 3.91,-3.9 3.91,-10.24 0,-14.14 -3.9,-3.91 -10.24,-3.91 -14.14,0 l 2.83,-4.24 0.7,2.12"; - }else if (crossing_points[selectedCrossing].sign < 0){ + } else if (crossing_points[selectedCrossing].sign < 0) { //svgd = "M 10,0 A 10 10 0 1 1 0,-10 l -5,-1 1,2"; svgd = "m 7.07,7.07 c -3.9,3.91 -10.24,3.91 -14.14,0 -3.91,-3.9 -3.91,-10.24 0,-14.14 3.9,-3.91 10.24,-3.91 14.14,0 l -2.83,-4.24 -0.7,2.12"; - }else{ + } else { //svgd = "M 10,0 A 10 10 0 1 0 -10,0 A 10 10 0 1 0 10,0 "; svgd = "M 10,0 C 10,5.52 5.52,10 0,10 -5.52,10 -10,5.52 -10,0 c 0,-5.52 4.48,-10 10,-10 5.52,0 10,4.48 10,10 z"; } PathVector pathv = sp_svg_read_pathv(svgd); pathv *= Affine(r,0,0,r,0,0); - pathv+=switcher; + pathv += switcher; hp_vec.push_back(pathv); } -- cgit v1.2.3 From 64e60300f6690bdf1482fa67d368ef98889b7817 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sun, 12 Jan 2014 23:12:14 +0100 Subject: LPE: rename function getHelperPaths --> getCanvasIndicators (the function is not yet called by anyone, but the naming was confusing) (bzr r12920) --- src/live_effects/effect.cpp | 20 +++++++------------- src/live_effects/effect.h | 2 +- 2 files changed, 8 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 70ce1e89d..12990ee24 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -486,11 +486,13 @@ Effect::addHandles(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) { } /** - * Return a vector of PathVectors which contain all helperpaths that should be drawn by the effect. - * This is the function called by external code like SPLPEItem. + * Return a vector of PathVectors which contain all canvas indicators for this effect. + * This is the function called by external code to get all canvas indicators (effect and its parameters) + * lpeitem = the item onto which this effect is applied + * @todo change return type to one pathvector, add all paths to one pathvector instead of maintaining a vector of pathvectors */ std::vector -Effect::getHelperPaths(SPLPEItem const* lpeitem) +Effect::getCanvasIndicators(SPLPEItem const* lpeitem) { std::vector hp_vec; @@ -499,18 +501,10 @@ Effect::getHelperPaths(SPLPEItem const* lpeitem) return hp_vec; } - // TODO: we can probably optimize this by using a lot more references - // rather than copying PathVectors all over the place - if (show_orig_path) { - // add original path to helperpaths - SPCurve* curve = SP_SHAPE(lpeitem)->getCurve (); - hp_vec.push_back(curve->get_pathvector()); - } - - // add other helperpaths provided by the effect itself + // add indicators provided by the effect itself addCanvasIndicators(lpeitem, hp_vec); - // add helperpaths provided by the effect's parameters + // add indicators provided by the effect's parameters for (std::vector::iterator p = param_vector.begin(); p != param_vector.end(); ++p) { (*p)->addCanvasIndicators(lpeitem, hp_vec); } diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h index b9d86628f..1da9b4cc9 100644 --- a/src/live_effects/effect.h +++ b/src/live_effects/effect.h @@ -90,7 +90,7 @@ public: // (but spiro lpe still needs it!) virtual LPEPathFlashType pathFlashType() const { return DEFAULT; } void addHandles(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item); - std::vector getHelperPaths(SPLPEItem const* lpeitem); + std::vector getCanvasIndicators(SPLPEItem const* lpeitem); inline bool providesOwnFlashPaths() const { return provides_own_flash_paths || show_orig_path; -- cgit v1.2.3 From 5eb9b4815a12cc0dafd07905f7715a7e15a92b41 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Mon, 13 Jan 2014 00:25:39 +0100 Subject: update 2geom's copy to r2142 (bzr r12921) --- src/2geom/Makefile_insert | 4 +- src/2geom/affine.cpp | 3 +- src/2geom/affine.h | 15 +- src/2geom/angle.h | 18 ++- src/2geom/basic-intersection.cpp | 17 +- src/2geom/bezier-clipping.cpp | 16 +- src/2geom/bezier-utils.cpp | 3 +- src/2geom/circle.cpp | 19 ++- src/2geom/circle.h | 1 + src/2geom/conicsec.cpp | 10 +- src/2geom/convex-cover.cpp | 14 +- src/2geom/convex-cover.h | 7 +- src/2geom/crossing.cpp | 2 +- src/2geom/d2.h | 2 +- src/2geom/ellipse.h | 5 +- src/2geom/elliptical-arc.cpp | 12 +- src/2geom/generic-rect.h | 2 +- src/2geom/interval.h | 4 +- src/2geom/linear.h | 2 +- src/2geom/math-utils.h | 7 +- src/2geom/nearest-point.cpp | 7 +- src/2geom/ord.h | 2 +- src/2geom/path-intersection.cpp | 7 +- src/2geom/path-sink.cpp | 119 ++++++++++++++ src/2geom/path-sink.h | 230 ++++++++++++++++++++++++++++ src/2geom/path.cpp | 9 +- src/2geom/pathvector.h | 5 +- src/2geom/piecewise.h | 15 +- src/2geom/point.cpp | 7 +- src/2geom/point.h | 9 -- src/2geom/recursive-bezier-intersection.cpp | 36 ++--- src/2geom/sbasis-geometric.cpp | 10 +- src/2geom/sbasis-to-bezier.cpp | 123 ++++++++++++++- src/2geom/sbasis-to-bezier.h | 1 + src/2geom/solve-bezier-one-d.cpp | 7 +- src/2geom/solve-bezier-parametric.cpp | 44 ++---- src/2geom/solve-bezier.cpp | 18 +-- src/2geom/svg-elliptical-arc.cpp | 12 +- src/2geom/svg-path-parser.cpp | 77 +++++----- src/2geom/svg-path-parser.h | 7 +- src/2geom/svg-path.cpp | 111 -------------- src/2geom/svg-path.h | 185 ---------------------- src/2geom/toposweep.h | 2 +- src/2geom/transforms.cpp | 1 + src/2geom/utils.cpp | 5 +- src/2geom/utils.h | 2 +- src/display/drawing-shape.cpp | 2 +- src/libnrtype/FontInstance.cpp | 4 +- src/live_effects/lpe-powerstroke.cpp | 4 +- src/sp-ellipse.cpp | 4 +- src/svg/svg-path.cpp | 6 +- src/ui/tool/path-manipulator.cpp | 4 +- 52 files changed, 698 insertions(+), 540 deletions(-) create mode 100644 src/2geom/path-sink.cpp create mode 100644 src/2geom/path-sink.h delete mode 100644 src/2geom/svg-path.cpp delete mode 100644 src/2geom/svg-path.h (limited to 'src') diff --git a/src/2geom/Makefile_insert b/src/2geom/Makefile_insert index 07e066df5..e77f413cb 100644 --- a/src/2geom/Makefile_insert +++ b/src/2geom/Makefile_insert @@ -71,6 +71,8 @@ 2geom/path.h \ 2geom/path-intersection.cpp \ 2geom/path-intersection.h \ + 2geom/path-sink.cpp \ + 2geom/path-sink.h \ 2geom/pathvector.cpp \ 2geom/pathvector.h \ 2geom/piecewise.cpp \ @@ -110,8 +112,6 @@ 2geom/solver.h \ 2geom/svg-elliptical-arc.cpp \ 2geom/svg-elliptical-arc.h \ - 2geom/svg-path.cpp \ - 2geom/svg-path.h \ 2geom/svg-path-parser.cpp \ 2geom/svg-path-parser.h \ 2geom/sweep.cpp \ diff --git a/src/2geom/affine.cpp b/src/2geom/affine.cpp index 0ef6d2708..738d0fc48 100644 --- a/src/2geom/affine.cpp +++ b/src/2geom/affine.cpp @@ -454,8 +454,7 @@ Eigen::Eigen(Affine const &m) { } } -static void quadratic_roots(double q0, double q1, double q2, int &n, double&r0, double&r1) { - std::vector r; +static void quadratic_roots(const double q0, const double q1, const double q2, int &n, double&r0, double&r1) { if(q2 == 0) { if(q1 == 0) { // zero or infinite roots n = 0; diff --git a/src/2geom/affine.h b/src/2geom/affine.h index b17da1887..af7b39360 100644 --- a/src/2geom/affine.h +++ b/src/2geom/affine.h @@ -75,12 +75,6 @@ public: _c[1] = _c[2] = _c[4] = _c[5] = 0; } - Affine(Affine const &m) { - for(int i = 0; i < 6; i++) { - _c[i] = m[i]; - } - } - /** @brief Create a matrix from its coefficient values. * It's rather inconvenient to directly create matrices in this way. Use transform classes * if your transformation has a geometric interpretation. @@ -88,19 +82,14 @@ public: * @see Scale * @see Rotate * @see HShear - * @see VShear */ + * @see VShear + * @see Zoom */ Affine(Coord c0, Coord c1, Coord c2, Coord c3, Coord c4, Coord c5) { _c[0] = c0; _c[1] = c1; _c[2] = c2; _c[3] = c3; _c[4] = c4; _c[5] = c5; } - Affine &operator=(Affine const &m) { - for(int i = 0; i < 6; i++) - _c[i] = m._c[i]; - return *this; - } - /** @brief Access a coefficient by its index. */ inline Coord operator[](unsigned i) const { return _c[i]; } inline Coord &operator[](unsigned i) { return _c[i]; } diff --git a/src/2geom/angle.h b/src/2geom/angle.h index bdf546989..1faf63c3f 100644 --- a/src/2geom/angle.h +++ b/src/2geom/angle.h @@ -48,6 +48,9 @@ namespace Geom { #ifndef M_PI # define M_PI 3.14159265358979323846 #endif +#ifndef M_1_2PI +# define M_1_2PI 0.159154943091895335768883763373 +#endif /** @brief Wrapper for angular values. * @@ -64,6 +67,7 @@ class Angle > > { public: + Angle() : _angle(0) {} //added default constructor because of cython Angle(Coord v) : _angle(v) { _normalize(); } // this can be called implicitly explicit Angle(Point p) : _angle(atan2(p)) { _normalize(); } Angle(Point a, Point b) : _angle(angle_between(a, b)) { _normalize(); } @@ -85,7 +89,7 @@ public: /** @brief Get the angle as radians. * @return Number in range \f$[-\pi, \pi)\f$. */ Coord radians() const { - return _angle > M_PI ? _angle - 2*M_PI : _angle; + return _angle >= M_PI ? _angle - 2*M_PI : _angle; } /** @brief Get the angle as positive radians. * @return Number in range \f$[0, 2\pi)\f$. */ @@ -95,7 +99,7 @@ public: /** @brief Get the angle as degrees in math convention. * @return Number in range [-180, 180) obtained by scaling the result of radians() * by \f$180/\pi\f$. */ - Coord degrees() const { return radians() / M_PI * 180.0; } + Coord degrees() const { return radians() * (180.0 / M_PI); } /** @brief Get the angle as degrees in clock convention. * This method converts the angle to the "clock convention": angles start from the +Y axis * and grow clockwise. This means that 0 corresponds to \f$\pi/2\f$ radians, @@ -103,7 +107,7 @@ public: * @return A number in the range [0, 360). */ Coord degreesClock() const { - Coord ret = 90.0 - _angle / M_PI * 180.0; + Coord ret = 90.0 - _angle * (180.0 / M_PI); if (ret < 0) ret += 360; return ret; } @@ -114,7 +118,7 @@ public: } /** @brief Create an angle from its measure in degrees. */ static Angle from_degrees(Coord d) { - Angle a(d * M_PI / 180); + Angle a(d * (M_PI / 180.0)); return a; } /** @brief Create an angle from its measure in degrees in clock convention. @@ -123,16 +127,16 @@ public: // first make sure d is in [0, 360) d = std::fmod(d, 360.0); if (d < 0) d += 360.0; - Coord rad = M_PI/2 - d * M_PI / 180.0; + Coord rad = M_PI/2 - d * (M_PI / 180.0); if (rad < 0) rad += 2*M_PI; Angle a; a._angle = rad; return a; } private: - Angle() {} + void _normalize() { - _angle -= floor(_angle / (2*M_PI)) * 2*M_PI; + _angle -= floor(_angle * (1.0/(2*M_PI))) * 2*M_PI; } Coord _angle; // this is always in [0, 2pi) friend class AngleInterval; diff --git a/src/2geom/basic-intersection.cpp b/src/2geom/basic-intersection.cpp index 544bf0dd1..379ec597c 100644 --- a/src/2geom/basic-intersection.cpp +++ b/src/2geom/basic-intersection.cpp @@ -64,15 +64,13 @@ void find_intersections(std::vector< std::pair > & xs, void split(vector const &p, double t, vector &left, vector &right) { const unsigned sz = p.size(); - - Geom::Point **Vtemp = new Geom::Point* [sz]; - - for (unsigned int i = 0; i < sz; ++i) { - Vtemp[i] = new Geom::Point[sz]; - } + //Geom::Point Vtemp[sz][sz]; + vector > Vtemp(sz); + for ( size_t i = 0; i < sz; ++i ) + Vtemp[i].reserve(sz); /* Copy control points */ - std::copy(p.begin(), p.end(), Vtemp[0]); + std::copy(p.begin(), p.end(), Vtemp[0].begin()); /* Triangle computation */ for (unsigned i = 1; i < sz; i++) { @@ -87,11 +85,6 @@ void split(vector const &p, double t, left[j] = Vtemp[j][0]; for (unsigned j = 0; j < sz; j++) right[j] = Vtemp[sz-1-j][j]; - - for (unsigned int i = 0; i < sz; ++i) - delete[] Vtemp[i]; - - delete[] Vtemp; } diff --git a/src/2geom/bezier-clipping.cpp b/src/2geom/bezier-clipping.cpp index fe925cf28..9a055204f 100644 --- a/src/2geom/bezier-clipping.cpp +++ b/src/2geom/bezier-clipping.cpp @@ -473,10 +473,9 @@ void fat_line_bounds (Interval& bound, { bound[0] = 0; bound[1] = 0; - double d; for (size_t i = 0; i < c.size(); ++i) { - d = distance(c[i], l); + const double d = distance(c[i], l); if (bound[0] > d) bound[0] = d; if (bound[1] < d) bound[1] = d; } @@ -509,10 +508,9 @@ void clip_interval (Interval& dom, double n = B.size() - 1; // number of sub-intervals std::vector D; // distance curve control points D.reserve (B.size()); - double d; for (size_t i = 0; i < B.size(); ++i) { - d = distance (B[i], l); + const double d = distance (B[i], l); D.push_back (Point(i/n, d)); } //print(D); @@ -699,8 +697,8 @@ void distance_control_points (std::vector & D, for (size_t j = 0; j < F.size(); ++j) dBF(i,j) = dot (dB[i], F[j]); - size_t k0, kn, l; - double bc, bri; + size_t l; + double bc; Point dij; std::vector d(F.size()); for (size_t i = 0; i <= r; ++i) @@ -709,9 +707,9 @@ void distance_control_points (std::vector & D, { d[j] = 0; } - k0 = std::max(i, n) - n; - kn = std::min(i, n-1); - bri = n / binomial(r,i); + const size_t k0 = std::max(i, n) - n; + const size_t kn = std::min(i, n-1); + const double bri = n / binomial(r,i); for (size_t k = k0; k <= kn; ++k) { //if (k > i || (i-k) > n) continue; diff --git a/src/2geom/bezier-utils.cpp b/src/2geom/bezier-utils.cpp index af07db707..ec17f6869 100644 --- a/src/2geom/bezier-utils.cpp +++ b/src/2geom/bezier-utils.cpp @@ -194,8 +194,6 @@ bezier_fit_cubic_full(Point bezier[], int split_points[], Point const &tHat1, Point const &tHat2, double const error, unsigned const max_beziers) { - int const maxIterations = 4; /* std::max times to try iterating */ - if(!(bezier != NULL) || !(data != NULL) || !(len > 0) || @@ -257,6 +255,7 @@ bezier_fit_cubic_full(Point bezier[], int split_points[], /* If error not too large, then try some reparameterization and iteration. */ if ( 0.0 <= maxErrorRatio && maxErrorRatio <= 3.0 ) { + int const maxIterations = 4; /* std::max times to try iterating */ for (int i = 0; i < maxIterations; i++) { generate_bezier(bezier, data, u, len, tHat1, tHat2, error); reparameterize(data, len, u, bezier); diff --git a/src/2geom/circle.cpp b/src/2geom/circle.cpp index 06eb4c2a1..d021882ea 100644 --- a/src/2geom/circle.cpp +++ b/src/2geom/circle.cpp @@ -88,7 +88,9 @@ void Circle::set(std::vector const& points) model.instance(*this, fitter.result(z)); } - +/** + @param inner a point whose angle with the circle center is inside the angle that the arc spans + */ EllipticalArc * Circle::arc(Point const& initial, Point const& inner, Point const& final, bool _svg_compliant) @@ -98,10 +100,8 @@ Circle::arc(Point const& initial, Point const& inner, Point const& final, return e.arc(initial, inner, final, _svg_compliant); } -void -Circle::getPath(std::vector &path_out) { - Path pb; - +D2 Circle::toSBasis() +{ D2 B; Linear bo = Linear(0, 2 * M_PI); @@ -110,6 +110,15 @@ Circle::getPath(std::vector &path_out) { B = B * m_ray + m_centre; + return B; +} + +void +Circle::getPath(std::vector &path_out) { + Path pb; + + D2 B = toSBasis(); + pb.append(SBasisCurve(B)); path_out.push_back(pb); diff --git a/src/2geom/circle.h b/src/2geom/circle.h index 67a638437..ca9241047 100644 --- a/src/2geom/circle.h +++ b/src/2geom/circle.h @@ -89,6 +89,7 @@ class Circle arc(Point const& initial, Point const& inner, Point const& final, bool _svg_compliant = true); + D2 toSBasis(); void getPath(std::vector &path_out); Point center() const diff --git a/src/2geom/conicsec.cpp b/src/2geom/conicsec.cpp index 7625df2fb..367dc2503 100644 --- a/src/2geom/conicsec.cpp +++ b/src/2geom/conicsec.cpp @@ -211,8 +211,6 @@ RatQuad RatQuad::fromPointsTangents(Point P0, Point dP0, } RatQuad RatQuad::circularArc(Point P0, Point P1, Point P2) { - Line Line0 = Line::from_origin_and_versor(P0, P1 - P0); - Line Line2 = Line::from_origin_and_versor(P2, P1 - P2); return RatQuad(P0, P1, P2, dot(unit_vector(P0 - P1), unit_vector(P0 - P2))); } @@ -583,7 +581,7 @@ xAx xAx::operator*(double const &b) const { LineSegment ls = intersection(Line::from_origin_and_versor(A, dA), bnd); return RatQuad::fromPointsTangents(A, dA, ls.pointAt(0.5), ls[1], dA); } - else if(crs.size() >= 2 and crs.size() < 4) { + else if(crs.size() >= 2 && crs.size() < 4) { Point A = crs[0]; Point C = crs[1]; if(crs.size() == 3) { @@ -607,7 +605,7 @@ xAx xAx::operator*(double const &b) const { Point dA = gradient(A); Point dC = gradient(C); - if(L2sq(dA) <= 1e-10 or L2sq(dC) <= 1e-10) { + if(L2sq(dA) <= 1e-10 || L2sq(dC) <= 1e-10) { return RatQuad::fromPointsTangents(A, C-A, B, C, A-C); } @@ -710,7 +708,7 @@ boost::optional xAx::bottom() const { } Interval xAx::extrema(Rect r) const { - if (c[0] == 0 and c[1] == 0 and c[2] == 0) { + if (c[0] == 0 && c[1] == 0 && c[2] == 0) { Interval ext(valueAt(r.corner(0))); for(int i = 1; i < 4; i++) ext |= Interval(valueAt(r.corner(i))); @@ -725,7 +723,7 @@ Interval xAx::extrema(Rect r) const { k = r[1][1]; ext |= quad_ex(c[0], c[1]*k+c[3], (c[2]*k + c[4])*k + c[5], r[0]); boost::optional B0 = bottom(); - if (B0 and r.contains(*B0)) + if (B0 && r.contains(*B0)) ext.expandTo(0); return ext; } diff --git a/src/2geom/convex-cover.cpp b/src/2geom/convex-cover.cpp index 306060f7c..5e599fdde 100644 --- a/src/2geom/convex-cover.cpp +++ b/src/2geom/convex-cover.cpp @@ -433,7 +433,7 @@ bool same_side(Point L[2], Point xs[4]) { int side = 0; for(int i = 0; i < 4; i++) { int sn = sgn(SignedTriangleArea(L[0], L[1], xs[i])); - if(sn and not side) + if(sn && !side) side = sn; else if(sn != side) return false; } @@ -455,7 +455,7 @@ std::vector > bridges(ConvexHull a, ConvexHull b) { double ap_angle = atan2(a[ai+1] - a[ai]); double bp_angle = atan2(b[bi+1] - b[bi]); Point L[2] = {a[ai], b[bi]}; - while(ai < int(a.size()) or bi < int(b.size())) { + while(ai < int(a.size()) || bi < int(b.size())) { if(ap_angle == bp_angle) { // In the case of parallel support lines, we must consider all four pairs of copodal points { @@ -478,7 +478,7 @@ std::vector > bridges(ConvexHull a, ConvexHull b) { bi++; bp_angle += angle_between(b[bi] - b[bi-1], b[bi+1] - b[bi]); L[1] = b[bi]; - //std::cout << "parallel\n"; + std::cout << "parallel\n"; } else if(ap_angle < bp_angle) { ai++; ap_angle += angle_between(a[ai] - a[ai-1], a[ai+1] - a[ai]); @@ -559,7 +559,7 @@ T idx_to_pair(pair p, int idx) { ConvexHull merge(ConvexHull a, ConvexHull b) { ConvexHull ret; - //std::cout << "---\n"; + std::cout << "---\n"; std::vector > bpair = bridges(a, b); // Given our list of bridges {(pb1, qb1), ..., (pbk, qbk)} @@ -574,10 +574,10 @@ ConvexHull merge(ConvexHull a, ConvexHull b) { for(unsigned k = 0; k < bpair.size(); k++) { unsigned limit = idx_to_pair(bpair[k], state); - /*std::cout << bpair[k].first << " , " << bpair[k].second << "; " + std::cout << bpair[k].first << " , " << bpair[k].second << "; " << idx << ", " << limit << ", s: " << state - << " \n";*/ + << " \n"; while(idx <= limit) { ret.boundary.push_back(chs[state][idx++]); } @@ -681,7 +681,7 @@ Point const * ConvexHull::furthest(Point direction) const { // is currently n*O(furthest) double ConvexHull::narrowest_diameter(Point &a, Point &b, Point &c) { Point tb = boundary.back(); - double d = INFINITY; + double d = std::numeric_limits::max(); for(unsigned i = 0; i < boundary.size(); i++) { Point tc = boundary[i]; Point n = -rot90(tb-tc); diff --git a/src/2geom/convex-cover.h b/src/2geom/convex-cover.h index a5f95a5fb..d290b7e80 100644 --- a/src/2geom/convex-cover.h +++ b/src/2geom/convex-cover.h @@ -84,8 +84,9 @@ public: public: ConvexHull() {} - ConvexHull(std::vector const & points) { - boundary = points; + ConvexHull(std::vector const & points) : + boundary (points) + { graham(); } @@ -163,7 +164,7 @@ unsigned find_bottom_right(ConvexHull const &a); /*** Arbitrary transform operator. * Take a convex hull and apply an arbitrary convexity preserving transform. - * we should be concerned about singular transforms here. + * we should be concerned about singular tranforms here. */ template ConvexHull operator*(ConvexHull const &p, T const &m) { ConvexHull pr; diff --git a/src/2geom/crossing.cpp b/src/2geom/crossing.cpp index 379eb4b00..13affa8e9 100644 --- a/src/2geom/crossing.cpp +++ b/src/2geom/crossing.cpp @@ -154,7 +154,7 @@ Crossings reverse_tb(Crossings const &cr, unsigned split, std::vector ma Crossings ret; for(Crossings::const_iterator i = cr.begin(); i != cr.end(); ++i) { double mx = max[i->b - split]; - //std::cout << i->b << "\n"; + std::cout << i->b << "\n"; ret.push_back(Crossing(i->ta, i->tb > mx+0.01 ? (1 - (i->tb - mx) + mx) : mx - i->tb, !i->dir)); } diff --git a/src/2geom/d2.h b/src/2geom/d2.h index ef88b2d68..5fc955854 100644 --- a/src/2geom/d2.h +++ b/src/2geom/d2.h @@ -150,7 +150,7 @@ template inline bool are_near(D2 const &a, D2 const &b, double tol) { boost::function_requires >(); - return are_near(a[0], b[0]) && are_near(a[1], b[1]); + return are_near(a[0], b[0], tol) && are_near(a[1], b[1], tol); } //IMPL: AddableConcept diff --git a/src/2geom/ellipse.h b/src/2geom/ellipse.h index 297254366..c971c6065 100644 --- a/src/2geom/ellipse.h +++ b/src/2geom/ellipse.h @@ -49,7 +49,10 @@ class Circle; class Ellipse { public: - Ellipse() + Ellipse(): + m_centre(), + m_ray(), + m_angle(0) {} Ellipse(double cx, double cy, double rx, double ry, double a) diff --git a/src/2geom/elliptical-arc.cpp b/src/2geom/elliptical-arc.cpp index d2cb0b707..c96d5f1a6 100644 --- a/src/2geom/elliptical-arc.cpp +++ b/src/2geom/elliptical-arc.cpp @@ -115,9 +115,11 @@ Rect EllipticalArc::boundsExact() const if ( arc_extremes[2] < arc_extremes[3] ) std::swap(arc_extremes[2], arc_extremes[3]); - for (unsigned i = 0; i < 4; ++i) { - if (containsAngle(extremes[i])) { - arc_extremes[i] = valueAtAngle(extremes[i], (i >> 1) ? Y : X); + if ( !are_near(initialPoint(), finalPoint()) ) { + for (unsigned i = 0; i < 4; ++i) { + if (containsAngle(extremes[i])) { + arc_extremes[i] = valueAtAngle(extremes[i], (i >> 1) ? Y : X); + } } } @@ -264,7 +266,7 @@ std::vector EllipticalArc::roots(Coord v, Dim2 d) const } double rotx, roty; - sincos(_rot_angle, roty, rotx); + sincos(_rot_angle, roty, rotx); /// \todo sin and cos are calculated in many places in this function, optimize this a bit! if (d == X) roty = -roty; double rxrotx = ray(X) * rotx; @@ -569,7 +571,7 @@ std::vector EllipticalArc::allNearestPoints( Point const& p, double from double mindistsq1 = std::numeric_limits::max(); double mindistsq2 = std::numeric_limits::max(); double dsq; - unsigned int mi1, mi2; + unsigned int mi1 = 0, mi2 = 0; for ( unsigned int i = 0; i < real_sol.size(); ++i ) { dsq = distanceSq(p, pointAtAngle(real_sol[i])); diff --git a/src/2geom/generic-rect.h b/src/2geom/generic-rect.h index eb9705a4b..bb6f2d2b8 100644 --- a/src/2geom/generic-rect.h +++ b/src/2geom/generic-rect.h @@ -261,7 +261,7 @@ public: expandBy(amount, amount); } /** @brief Expand the rectangle in both directions. - * Note that this is different from scaling. Negative values will shrink the + * Note that this is different from scaling. Negative values wil shrink the * rectangle. If -x is larger than * half of the width, the X interval will contain only the X coordinate * of the midpoint; same for height. */ diff --git a/src/2geom/interval.h b/src/2geom/interval.h index b1fac04d9..1714435be 100644 --- a/src/2geom/interval.h +++ b/src/2geom/interval.h @@ -114,9 +114,9 @@ public: /** @brief Check whether the interior of the interval includes the given interval. * Interior means all numbers in the interval except its ends. */ bool interiorContains(Interval const &val) const { return min() < val.min() && val.max() < max(); } - /** @brief Check whether the interiors of the intervals have any common elements. */ + /** @brief Check whether the interiors of the intervals have any common elements. A single point in common is not considered an intersection. */ bool interiorIntersects(Interval const &val) const { - return interiorContains(val.min()) || interiorContains(val.max()) || val.interiorContains(*this); + return std::max(min(), val.min()) < std::min(max(), val.max()); } /// @} diff --git a/src/2geom/linear.h b/src/2geom/linear.h index 6e5132e12..8c154364e 100644 --- a/src/2geom/linear.h +++ b/src/2geom/linear.h @@ -55,7 +55,7 @@ class SBasis; class Linear{ public: double a[2]; - Linear() {} + Linear() {a[0]=0; a[1]=0;} Linear(double aa, double b) {a[0] = aa; a[1] = b;} Linear(double aa) {a[0] = aa; a[1] = aa;} diff --git a/src/2geom/math-utils.h b/src/2geom/math-utils.h index 77280aa50..83c7b4f5e 100644 --- a/src/2geom/math-utils.h +++ b/src/2geom/math-utils.h @@ -40,6 +40,7 @@ #include // sincos is usually only available in math.h #include #include // for std::pair +#include namespace Geom { @@ -49,6 +50,8 @@ namespace Geom { * @return -1 when x is negative, 1 when positive, and 0 if equal to 0. */ template inline int sgn(const T& x) { return (x < 0 ? -1 : (x > 0 ? 1 : 0) ); +// can we 'optimize' this with: +// return ( (T(0) < x) - (x < T(0)) ); } template inline T sqr(const T& x) {return x * x;} @@ -111,7 +114,7 @@ inline void sincos(double angle, double &sin_, double &cos_) { #elif defined (SOLARIS_2_8) && __GNUC__ == 3 && __GNUC_MINOR__ == 2 # define IS_NAN(_a) (isnan(_a)) /* GNU definition */ #else -# define IS_NAN(_a) (std::isnan(_a)) +# define IS_NAN(_a) (boost::math::isnan(_a)) #endif /* If the above doesn't work, then try (a != a). */ @@ -130,7 +133,7 @@ inline void sincos(double angle, double &sin_, double &cos_) { #include #define IS_FINITE(_a) (finite(_a) && !IS_NAN(_a)) #else -# define IS_FINITE(_a) (std::isfinite(_a)) +# define IS_FINITE(_a) (boost::math::isfinite(_a)) #endif } // end namespace Geom diff --git a/src/2geom/nearest-point.cpp b/src/2geom/nearest-point.cpp index 68a863434..75e1ebaad 100644 --- a/src/2geom/nearest-point.cpp +++ b/src/2geom/nearest-point.cpp @@ -61,15 +61,14 @@ double nearest_point( Point const& p, } if (c.isConstant()) return from; SBasis dd = dot(c - p, dc); - //std::cout << dd << std::endl; + std::cout << dd << std::endl; std::vector zeros = Geom::roots(dd); double closest = from; double min_dist_sq = L2sq(c(from) - p); - double distsq; - for ( unsigned int i = 0; i < zeros.size(); ++i ) + for ( size_t i = 0; i < zeros.size(); ++i ) { - distsq = L2sq(c(zeros[i]) - p); + double distsq = L2sq(c(zeros[i]) - p); if ( min_dist_sq > L2sq(c(zeros[i]) - p) ) { closest = zeros[i]; diff --git a/src/2geom/ord.h b/src/2geom/ord.h index ce524ebf7..0add83da4 100644 --- a/src/2geom/ord.h +++ b/src/2geom/ord.h @@ -43,7 +43,7 @@ enum Cmp { EQUAL_TO=0 }; -inline Cmp operator-(Cmp x) { +static inline Cmp operator-(Cmp x) { switch(x) { case LESS_THAN: return GREATER_THAN; diff --git a/src/2geom/path-intersection.cpp b/src/2geom/path-intersection.cpp index 494a25843..ff24b92eb 100644 --- a/src/2geom/path-intersection.cpp +++ b/src/2geom/path-intersection.cpp @@ -113,11 +113,12 @@ int winding(Path const &path, Point p) { */ bool path_direction(Path const &p) { if(p.empty()) return false; + + /*goto doh; //could probably be more efficient, but this is a quick job double y = p.initialPoint()[Y]; double x = p.initialPoint()[X]; Cmp res = cmp(p[0].finalPoint()[Y], y); - /*goto doh; for(unsigned i = 1; i < p.size(); i++) { Cmp final_to_ray = cmp(p[i].finalPoint()[Y], y); Cmp initial_to_ray = cmp(p[i].initialPoint()[Y], y); @@ -271,9 +272,9 @@ intersect_polish_root (Curve const &A, double &s, Curve const &B, double &t) } #ifdef HAVE_GSL - int status; - size_t iter = 0; if(0) { // the GSL version is more accurate, but taints this with GPL + int status; + size_t iter = 0; const size_t n = 2; struct rparams p = {A, B}; gsl_multiroot_function f = {&intersect_polish_f, n, &p}; diff --git a/src/2geom/path-sink.cpp b/src/2geom/path-sink.cpp new file mode 100644 index 000000000..6acd9508c --- /dev/null +++ b/src/2geom/path-sink.cpp @@ -0,0 +1,119 @@ +/* + * callback interface for SVG path data + * + * Copyright 2007 MenTaLguY + * + * This library is free software; you can redistribute it and/or + * modify it either under the terms of the GNU Lesser General Public + * License version 2.1 as published by the Free Software Foundation + * (the "LGPL") or, at your option, under the terms of the Mozilla + * Public License Version 1.1 (the "MPL"). If you do not alter this + * notice, a recipient may use your version of this file under either + * the MPL or the LGPL. + * + * You should have received a copy of the LGPL along with this library + * in the file COPYING-LGPL-2.1; if not, output to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * You should have received a copy of the MPL along with this library + * in the file COPYING-MPL-1.1 + * + * The contents of this file are subject to the Mozilla Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY + * OF ANY KIND, either express or implied. See the LGPL or the MPL for + * the specific language governing rights and limitations. + * + */ + +#include <2geom/sbasis-to-bezier.h> +#include <2geom/path-sink.h> +#include <2geom/exception.h> + +namespace Geom { + +void output(Curve const &curve, PathSink &sink) { + std::vector pts; + sbasis_to_bezier(pts, curve.toSBasis(), 2); //TODO: use something better! + sink.curveTo(pts[0], pts[1], pts[2]); +} + +void output(HLineSegment const &curve, PathSink &sink) { + sink.hlineTo(curve.finalPoint()[X]); +} + +void output(VLineSegment const &curve, PathSink &sink) { + sink.vlineTo(curve.finalPoint()[Y]); +} + +void output(LineSegment const &curve, PathSink &sink) { + sink.lineTo(curve[1]); +} + +void output(CubicBezier const &curve, PathSink &sink) { + sink.curveTo(curve[1], curve[2], curve[3]); +} + +void output(QuadraticBezier const &curve, PathSink &sink) { + sink.quadTo(curve[1], curve[2]); +} + +void output(SVGEllipticalArc const &curve, PathSink &sink) { + sink.arcTo( curve.ray(X), curve.ray(Y), curve.rotationAngle(), + curve.largeArc(), curve.sweep(), + curve.finalPoint() ); +} + +template +bool output_as(Curve const &curve, PathSink &sink) { + T const *t = dynamic_cast(&curve); + if (t) { + output(*t, sink); + return true; + } else { + return false; + } +} + +void PathSink::path(Path const &path) { + flush(); + moveTo(path.front().initialPoint()); + + Path::const_iterator iter; + for (iter = path.begin(); iter != path.end(); ++iter) { + output_as(*iter, *this) || + output_as(*iter, *this) || + output_as(*iter, *this) || + output_as(*iter, *this) || + output_as(*iter, *this) || + output_as(*iter, *this) || + output_as(*iter, *this); + } + + if (path.closed()) { + closePath(); + } + flush(); +} + +void PathSink::pathvector(PathVector const &pv) { + flush(); + for (PathVector::const_iterator i = pv.begin(); i != pv.end(); ++i) { + path(*i); + } +} + +} + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/2geom/path-sink.h b/src/2geom/path-sink.h new file mode 100644 index 000000000..949369b80 --- /dev/null +++ b/src/2geom/path-sink.h @@ -0,0 +1,230 @@ +/** + * \file + * \brief callback interface for SVG path data + *//* + * Copyright 2007 MenTaLguY + * + * This library is free software; you can redistribute it and/or + * modify it either under the terms of the GNU Lesser General Public + * License version 2.1 as published by the Free Software Foundation + * (the "LGPL") or, at your option, under the terms of the Mozilla + * Public License Version 1.1 (the "MPL"). If you do not alter this + * notice, a recipient may use your version of this file under either + * the MPL or the LGPL. + * + * You should have received a copy of the LGPL along with this library + * in the file COPYING-LGPL-2.1; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * You should have received a copy of the MPL along with this library + * in the file COPYING-MPL-1.1 + * + * The contents of this file are subject to the Mozilla Public License + * Version 1.1 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY + * OF ANY KIND, either express or implied. See the LGPL or the MPL for + * the specific language governing rights and limitations. + * + */ + +#ifndef SEEN_SVG_PATH_H +#define SEEN_SVG_PATH_H + +#include <2geom/pathvector.h> +#include <2geom/curves.h> +#include + +namespace Geom { + + +/** @brief Callback interface for processing path data. + * + * PathSink provides an interface that allows one to easily write + * code which processes path data, for instance when converting + * between path formats used by different graphics libraries. + * + * To store a path in a new format, implement the virtual methods + * for segments in a derived class and call path() or pathvector(). + */ +class PathSink { +public: + /** Move to a different point without creating a segment. + * Usually starts a new subpath. */ + virtual void moveTo(Point const &p) = 0; + /// Output a horizontal line segment. Only the X coordinate of the final point is given. + virtual void hlineTo(Coord v) = 0; + /// Output a vertical line segment. Only the Y coordinate of the final point is given. + virtual void vlineTo(Coord v) = 0; + /// Output a line segment. + virtual void lineTo(Point const &p) = 0; + /// Output a quadratic Bezier segment. + virtual void curveTo(Point const &c0, Point const &c1, Point const &p) = 0; + /// Output a cubic Bezier segment. + virtual void quadTo(Point const &c, Point const &p) = 0; + /** Output an elliptical arc segment. + * See the EllipticalArc class for the documentation of parameters. */ + virtual void arcTo(double rx, double ry, double angle, + bool large_arc, bool sweep, Point const &p) = 0; + + /// Close the current path with a line segment. + virtual void closePath() = 0; + /** Flush any internal state of the generator. + * + * This call should implicitly finish the current subpath. + * Calling this method should be idempotent, because the default + * implementations of path() and pathvector() will be call it + * multiple times in a row. */ + virtual void flush() = 0; + + /** Undo the last segment. + * This method is optional. + * @return true true if a segment was erased, false otherwise. */ + virtual bool backspace() { return false; } + + // these have a default implementation + /** Output a subpath. + * Calls the appropriate segment methods according to the contents + * of the passed subpath. You can override this function. */ + virtual void path(Path const &p); + /** Output a path. + * Calls the appropriate segment methods according to the contents + * of the passed path. You can override this function. */ + virtual void pathvector(PathVector const &v); + + virtual ~PathSink() {} +}; + +template +class PathIteratorSink : public PathSink { +public: + explicit PathIteratorSink(OutputIterator out) + : _in_path(false), _out(out) {} + + void moveTo(Point const &p) { + flush(); + _path.start(p); + _start_p = p; + _in_path = true; + } +//TODO: what if _in_path = false? + + void hlineTo(Coord v) { + // check for implicit moveto, like in: "M 1,1 L 2,2 z l 2,2 z" + if (!_in_path) { + moveTo(_start_p); + } + _path.template appendNew(Point(v, _path.finalPoint()[Y])); + } + + void vlineTo(Coord v) { + // check for implicit moveto, like in: "M 1,1 L 2,2 z l 2,2 z" + if (!_in_path) { + moveTo(_start_p); + } + _path.template appendNew(Point(_path.finalPoint()[X], v)); + } + + void lineTo(Point const &p) { + // check for implicit moveto, like in: "M 1,1 L 2,2 z l 2,2 z" + if (!_in_path) { + moveTo(_start_p); + } + _path.template appendNew(p); + } + + void quadTo(Point const &c, Point const &p) { + // check for implicit moveto, like in: "M 1,1 L 2,2 z l 2,2 z" + if (!_in_path) { + moveTo(_start_p); + } + _path.template appendNew(c, p); + } + + void curveTo(Point const &c0, Point const &c1, Point const &p) { + // check for implicit moveto, like in: "M 1,1 L 2,2 z l 2,2 z" + if (!_in_path) { + moveTo(_start_p); + } + _path.template appendNew(c0, c1, p); + } + + void arcTo(double rx, double ry, double angle, + bool large_arc, bool sweep, Point const &p) + { + // check for implicit moveto, like in: "M 1,1 L 2,2 z l 2,2 z" + if (!_in_path) { + moveTo(_start_p); + } + _path.template appendNew(rx, ry, angle, + large_arc, sweep, p); + } + + bool backspace() + { + if (_in_path && _path.size() > 0) { + _path.erase_last(); + return true; + } + return false; + } + + void append(Path const &other, Path::Stitching stitching = Path::NO_STITCHING) + { + if (!_in_path) { + moveTo(other.initialPoint()); + } + _path.append(other, stitching); + } + + void closePath() { + _path.close(); + flush(); + } + + void flush() { + if (_in_path) { + _in_path = false; + *_out++ = _path; + _path.clear(); + _path.close(false); + } + } + + void path(Path const &other) + { + flush(); + *_out++ = other; + } + +protected: + bool _in_path; + OutputIterator _out; + Path _path; + Point _start_p; +}; + +typedef std::back_insert_iterator > iter; + +class PathBuilder : public PathIteratorSink { +private: + std::vector _pathset; +public: + PathBuilder() : PathIteratorSink(iter(_pathset)) {} + std::vector const &peek() const {return _pathset;} +}; + +} + +#endif +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/2geom/path.cpp b/src/2geom/path.cpp index 857028ccd..93def6c55 100644 --- a/src/2geom/path.cpp +++ b/src/2geom/path.cpp @@ -347,16 +347,15 @@ void Path::do_update(Sequence::iterator first_replaced, } void Path::do_append(Curve *c) { - boost::shared_ptr curve(c); if ( get_curves().front().get() == final_ ) { - final_->setPoint(1, curve->initialPoint()); + final_->setPoint(1, c->initialPoint()); } else { - if (curve->initialPoint() != finalPoint()) { + if (c->initialPoint() != finalPoint()) { THROW_CONTINUITYERROR(); } } - get_curves().insert(get_curves().end()-1, curve); - final_->setPoint(0, curve->finalPoint()); + get_curves().insert(get_curves().end()-1, boost::shared_ptr(c)); + final_->setPoint(0, c->finalPoint()); } void Path::stitch(Sequence::iterator first_replaced, diff --git a/src/2geom/pathvector.h b/src/2geom/pathvector.h index 791cb0703..e875e915f 100644 --- a/src/2geom/pathvector.h +++ b/src/2geom/pathvector.h @@ -108,7 +108,10 @@ struct PathVectorPosition { // pathvector[path_nr].pointAt(t) is the position unsigned int path_nr; double t; - PathVectorPosition() {} + PathVectorPosition() : + path_nr(0), + t(0) + {} PathVectorPosition(unsigned int path_nr, double t) : path_nr(path_nr), t(t) {} }; diff --git a/src/2geom/piecewise.h b/src/2geom/piecewise.h index e3b4d3456..ab8417254 100644 --- a/src/2geom/piecewise.h +++ b/src/2geom/piecewise.h @@ -34,6 +34,7 @@ #include #include +#include #include #include <2geom/concepts.h> #include <2geom/math-utils.h> @@ -92,8 +93,8 @@ class Piecewise { inline void reserve(unsigned i) { segs.reserve(i); cuts.reserve(i + 1); } - inline T operator[](unsigned i) const { return segs[i]; } - inline T &operator[](unsigned i) { return segs[i]; } + inline T const& operator[](unsigned i) const { return segs[i]; } + inline T& operator[](unsigned i) { return segs[i]; } inline output_type operator()(double t) const { return valueAt(t); } inline output_type valueAt(double t) const { unsigned n = segN(t); @@ -139,6 +140,13 @@ class Piecewise { push_seg(s); push_cut(to); } +#ifdef CPP11 + inline void push(T &&s, double to) { + assert(cuts.size() - segs.size() == 1); + push_seg(s); + push_cut(to); + } +#endif //Convenience/implementation hiding function to add cuts. inline void push_cut(double c) { ASSERT_INVARIANTS(cuts.empty() || c > cuts.back()); @@ -146,6 +154,9 @@ class Piecewise { } //Convenience/implementation hiding function to add segments. inline void push_seg(const T &s) { segs.push_back(s); } +#ifdef CPP11 + inline void push_seg(T &&s) { segs.emplace_back(s); } +#endif /**Returns the segment index which corresponds to a 'global' piecewise time. * Also takes optional low/high parameters to expedite the search for the segment. diff --git a/src/2geom/point.cpp b/src/2geom/point.cpp index 3ad9dd1fd..b0b00b5da 100644 --- a/src/2geom/point.cpp +++ b/src/2geom/point.cpp @@ -57,11 +57,10 @@ namespace Geom { * @code p += q; p -= q; r = p + q; r = p - q; p *= s; p /= s; q = p * s; q = s * p; q = p / s; - p *= m; p /= m; q = p * m; q = m * p; q = p / m; + p *= m; q = p * m; q = m * p; @endcode * It is possible to left-multiply a point by a matrix, even though mathematically speaking * this is undefined. The result is a point identical to that obtained by right-multiplying. - * Division of points by matrices is defined as multiplication by their inverses. * * @ingroup Primitives */ @@ -127,7 +126,7 @@ Coord L1(Point const &p) { } /** @brief Compute the infinity norm (maximum norm) of @a p. - * @return \f$\max(p_X, p_Y)\f$ + * @return \f$\max(|p_X|, |p_Y|)\f$ * @relates Point */ Coord LInfty(Point const &p) { Coord const a(fabs(p[0])); @@ -231,7 +230,7 @@ Point constrain_angle(Point const &A, Point const &B, unsigned int n, Point cons return A + dir * Rotate(k * 2.0 * M_PI / (double)n) * L2(diff); } -} //namespace Geom +} // end namespace Geom /* Local Variables: diff --git a/src/2geom/point.h b/src/2geom/point.h index 0eb771874..23dcfd54f 100644 --- a/src/2geom/point.h +++ b/src/2geom/point.h @@ -78,15 +78,6 @@ public: _pt[X] = p[X]; _pt[Y] = p[Y]; } - Point(Point const &p) { - for (unsigned i = 0; i < 2; ++i) - _pt[i] = p._pt[i]; - } - Point &operator=(Point const &p) { - for (unsigned i = 0; i < 2; ++i) - _pt[i] = p._pt[i]; - return *this; - } /** @brief Construct a point from its polar coordinates. * The angle is specified in radians, in the mathematical convention (increasing * counter-clockwise from +X). */ diff --git a/src/2geom/recursive-bezier-intersection.cpp b/src/2geom/recursive-bezier-intersection.cpp index 7db0438a7..0c7977970 100644 --- a/src/2geom/recursive-bezier-intersection.cpp +++ b/src/2geom/recursive-bezier-intersection.cpp @@ -81,14 +81,13 @@ const double INV_EPS = (1L<<14); */ void OldBezier::split(double t, OldBezier &left, OldBezier &right) const { const unsigned sz = p.size(); - - Geom::Point **Vtemp = new Geom::Point* [sz]; - - for (unsigned int i = 0; i < sz; ++i) - Vtemp[i] = new Geom::Point[sz]; + //Geom::Point Vtemp[sz][sz]; + std::vector< std::vector< Geom::Point > > Vtemp; + for (size_t i = 0; i < sz; ++i ) + Vtemp[i].reserve(sz); /* Copy control points */ - std::copy(p.begin(), p.end(), Vtemp[0]); + std::copy(p.begin(), p.end(), Vtemp[0].begin()); /* Triangle computation */ for (unsigned i = 1; i < sz; i++) { @@ -103,11 +102,6 @@ void OldBezier::split(double t, OldBezier &left, OldBezier &right) const { left.p[j] = Vtemp[j][0]; for (unsigned j = 0; j < sz; j++) right.p[j] = Vtemp[sz-1-j][j]; - - for (unsigned int i = 0; i < sz; ++i) - delete[] Vtemp[i]; - - delete[] Vtemp; } #if 0 @@ -134,17 +128,15 @@ Point OldBezier::operator()(double t) const { #endif // suggested by Sederberg. -Point OldBezier::operator()(double t) const { - int n = p.size()-1; - double u, bc, tn, tmp; - int i; +Point OldBezier::operator()(double const t) const { + size_t const n = p.size()-1; Point r; for(int dim = 0; dim < 2; dim++) { - u = 1.0 - t; - bc = 1; - tn = 1; - tmp = p[0][dim]*u; - for(i=1; i= : need boundary case - return not( ( minax > maxbx ) || ( minay > maxby ) - || ( minbx > maxax ) || ( minby > maxay ) ); + return !( ( minax > maxbx ) || ( minay > maxby ) + || ( minbx > maxax ) || ( minby > maxay ) ); } /* diff --git a/src/2geom/sbasis-geometric.cpp b/src/2geom/sbasis-geometric.cpp index 74827e27c..4c474f7f0 100644 --- a/src/2geom/sbasis-geometric.cpp +++ b/src/2geom/sbasis-geometric.cpp @@ -1,4 +1,5 @@ /** Geometric operators on D2 (1D->2D). + * Copyright 2012 JBC Engelen * Copyright 2007 JF Barraud * Copyright 2007 N Hurst * @@ -18,7 +19,6 @@ #include <2geom/sbasis-geometric.h> #include <2geom/sbasis.h> #include <2geom/sbasis-math.h> -//#include <2geom/solver.h> #include <2geom/sbasis-geometric.h> //namespace Geom{ @@ -363,7 +363,6 @@ Geom::length(Piecewise > const &M, Piecewise Geom::curvature(D2 const &M, double tol) { D2 dM=derivative(M); - Piecewise result; Piecewise > unitv = unitVector(dM,tol); Piecewise dMlength = dot(Piecewise >(dM),unitv); Piecewise k = cross(derivative(unitv),unitv); @@ -436,11 +435,10 @@ Geom::arc_length_parametrization(Piecewise > const &M, unsigned order, double tol){ Piecewise > result; - for (unsigned i=0; i > uniform_seg=arc_length_parametrization(M[i],order,tol); - result.concat(uniform_seg); + for (unsigned i=0; i diff --git a/src/2geom/sbasis-to-bezier.cpp b/src/2geom/sbasis-to-bezier.cpp index 8e47580ce..bd88f93c0 100644 --- a/src/2geom/sbasis-to-bezier.cpp +++ b/src/2geom/sbasis-to-bezier.cpp @@ -35,7 +35,7 @@ #include <2geom/sbasis-to-bezier.h> #include <2geom/d2.h> #include <2geom/choose.h> -#include <2geom/svg-path.h> +#include <2geom/path-sink.h> #include <2geom/exception.h> #include @@ -180,6 +180,118 @@ void sbasis_to_bezier (std::vector & bz, D2 const& sb, size_t sz) } } +/** Changes the basis of p to be Bernstein. + \param p the D2 Symmetric basis polynomial + \returns the D2 Bernstein basis cubic polynomial + +Bezier is always cubic. +For general asymmetric case, fit the SBasis function value at midpoint +For parallel, symmetric case, find the point of closest approach to the midpoint +For parallel, anti-symmetric case, fit the SBasis slope at midpoint +*/ +void sbasis_to_cubic_bezier (std::vector & bz, D2 const& sb) +{ + double delx[2], dely[2]; + double xprime[2], yprime[2]; + double midx = 0; + double midy = 0; + double numer; + double denom; + double div; + + if ((sb[X].size() == 0) || (sb[Y].size() == 0)) { + THROW_RANGEERROR("size of sb is too small"); + } + + bz.resize(4, Point(0,0)); + bz[0][X] = sb[X][0][0]; + bz[0][Y] = sb[Y][0][0]; + bz[3][X] = sb[X][0][1]; + bz[3][Y] = sb[Y][0][1]; + +// calculate first derivatives of x and y wrt t + + for (int i = 0; i < 2; ++i) { + xprime[i] = sb[X][0][1] - sb[X][0][0]; + yprime[i] = sb[Y][0][1] - sb[Y][0][0]; + } + if (sb[X].size() > 0) { + xprime[0] += sb[X][1][0]; + xprime[1] -= sb[X][1][1]; + } + if (sb[Y].size() > 0) { + yprime[0] += sb[Y][1][0]; + yprime[1] -= sb[Y][1][1]; + } + +// calculate midpoint at t = 0.5 + + div = 2; + for (size_t i = 0; i < sb[X].size(); ++i) { + midx += (sb[X][i][0] + sb[X][i][1])/div; + div *= 4; + } + midx = 8*midx - 4*bz[0][X] - 4*bz[3][X]; + + div = 2; + for (size_t i = 0; i < sb[Y].size(); ++i) { + midy += (sb[Y][i][0] + sb[Y][i][1])/div; + div *= 4; + } + midy = 8*midy - 4*bz[0][Y] - 4*bz[3][Y]; + +// calculate Bezier control arms + + if (std::abs(xprime[1]*yprime[0] - yprime[1]*xprime[0]) > 1.e-5) { // general case : fit mid fxn value + denom = xprime[1]*yprime[0] - yprime[1]*xprime[0]; + for (int i = 0; i < 2; ++i) { + numer = xprime[1 - i]*midy - yprime[1 - i]*midx; + delx[i] = xprime[i]*numer/denom/3; + dely[i] = yprime[i]*numer/denom/3; + } + } + else if ((xprime[0]*xprime[1] < 0) || (yprime[0]*yprime[1] < 0)) { // symmetric case : use distance of closest approach + numer = midx*xprime[0] + midy*yprime[0]; + denom = 6.0*(xprime[0]*xprime[0] + yprime[0]*yprime[0]); + delx[0] = xprime[0]*numer/denom; + dely[0] = yprime[0]*numer/denom; + delx[1] = -delx[0]; + dely[1] = -dely[0]; + } + else { // anti-symmetric case : fit mid slope + // calculate slope at t = 0.5 + midx = 0; + div = 1; + for (size_t i = 0; i < sb[X].size(); ++i) { + midx += (sb[X][i][1] - sb[X][i][0])/div; + div *= 4; + } + midy = 0; + div = 1; + for (size_t i = 0; i < sb[Y].size(); ++i) { + midy += (sb[Y][i][1] - sb[Y][i][0])/div; + div *= 4; + } + if (midx*yprime[0] != midy*xprime[0]) { + denom = midx*yprime[0] - midy*xprime[0]; + numer = midx*(bz[3][Y] - bz[0][Y]) - midy*(bz[3][X] - bz[0][X]); + for (int i = 0; i < 2; ++i) { + delx[i] = xprime[0]*numer/denom; + dely[i] = yprime[0]*numer/denom; + } + } + else { // linear case + for (int i = 0; i < 2; ++i) { + delx[i] = (bz[3][X] - bz[0][X])/3; + dely[i] = (bz[3][Y] - bz[0][Y])/3; + } + } + } + bz[1][X] = bz[0][X] + delx[0]; + bz[1][Y] = bz[0][Y] + dely[0]; + bz[2][X] = bz[3][X] - delx[1]; + bz[2][Y] = bz[3][Y] - dely[1]; +} /** Changes the basis of p to be sbasis. \param p the Bernstein basis polynomial @@ -347,12 +459,13 @@ void build_from_sbasis(Geom::PathBuilder &pb, D2 const &B, double tol, b if (!B.isFinite()) { THROW_EXCEPTION("assertion failed: B.isFinite()"); } - if(tail_error(B, 2) < tol || sbasis_size(B) == 2) { // nearly cubic enough + if(tail_error(B, 3) < tol || sbasis_size(B) == 2) { // nearly cubic enough if( !only_cubicbeziers && (sbasis_size(B) <= 1) ) { pb.lineTo(B.at1()); } else { std::vector bez; - sbasis_to_bezier(bez, B, 4); +// sbasis_to_bezier(bez, B, 4); + sbasis_to_cubic_bezier(bez, B); pb.curveTo(bez[1], bez[2], bez[3]); } } else { @@ -372,7 +485,7 @@ path_from_sbasis(D2 const &B, double tol, bool only_cubicbeziers) { PathBuilder pb; pb.moveTo(B.at0()); build_from_sbasis(pb, B, tol, only_cubicbeziers); - pb.finish(); + pb.flush(); return pb.peek().front(); } @@ -414,7 +527,7 @@ path_from_piecewise(Geom::Piecewise > const &B, double to build_from_sbasis(pb, B[i], tol, only_cubicbeziers); } } - pb.finish(); + pb.flush(); return pb.peek(); } diff --git a/src/2geom/sbasis-to-bezier.h b/src/2geom/sbasis-to-bezier.h index b386bd520..07511f4a4 100644 --- a/src/2geom/sbasis-to-bezier.h +++ b/src/2geom/sbasis-to-bezier.h @@ -46,6 +46,7 @@ class PathBuilder; void sbasis_to_bezier (Bezier & bz, SBasis const& sb, size_t sz = 0); void sbasis_to_bezier (std::vector & bz, D2 const& sb, size_t sz = 0); +void sbasis_to_cubic_bezier (std::vector & bz, D2 const& sb); void bezier_to_sbasis (SBasis & sb, Bezier const& bz); void bezier_to_sbasis (D2 & sb, std::vector const& bz); void build_from_sbasis(PathBuilder &pb, D2 const &B, double tol, bool only_cubicbeziers); diff --git a/src/2geom/solve-bezier-one-d.cpp b/src/2geom/solve-bezier-one-d.cpp index f14f701d0..3d87d4926 100644 --- a/src/2geom/solve-bezier-one-d.cpp +++ b/src/2geom/solve-bezier-one-d.cpp @@ -92,11 +92,10 @@ void Bernsteins::find_bernstein_roots(double const *w, /* The control points */ int old_sign = SGN(w[0]); //std::cout << "w[0] = " << w[0] << std::endl; - int sign; for (size_t i = 1; i < N; i++) { //std::cout << "w[" << i << "] = " << w[i] << std::endl; - sign = SGN(w[i]); + int sign = SGN(w[i]); if (sign != 0) { if (sign != old_sign && old_sign != 0) @@ -128,14 +127,14 @@ void Bernsteins::find_bernstein_roots(double const *w, /* The control points */ double s = 0, t = 1; double e = 1e-10; int side = 0; - double r, fr, fs = w[0], ft = w[degree]; + double r, fs = w[0], ft = w[degree]; for (size_t n = 0; n < 100; ++n) { r = (fs*t - ft*s) / (fs - ft); if (fabs(t-s) < e * fabs(t+s)) break; - fr = horner(w, r); + double fr = horner(w, r); if (fr * ft > 0) { diff --git a/src/2geom/solve-bezier-parametric.cpp b/src/2geom/solve-bezier-parametric.cpp index ed693c584..9b0feaee4 100644 --- a/src/2geom/solve-bezier-parametric.cpp +++ b/src/2geom/solve-bezier-parametric.cpp @@ -68,20 +68,16 @@ find_parametric_bezier_roots(Geom::Point const *w, /* The control points */ break; } - /* - * Otherwise, solve recursively after subdividing control polygon - * New left and right control polygons - */ - Geom::Point *Left = new Geom::Point[degree+1]; - Geom::Point *Right = new Geom::Point[degree+1]; - - Bezier(w, degree, 0.5, Left, Right); - total_subs ++; - find_parametric_bezier_roots(Left, degree, solutions, depth+1); - find_parametric_bezier_roots(Right, degree, solutions, depth+1); + /* Otherwise, solve recursively after subdividing control polygon */ + + //Geom::Point Left[degree+1], /* New left and right */ + // Right[degree+1]; /* control polygons */ + std::vector Left( degree+1 ), Right(degree+1); - delete[] Left; - delete[] Right; + Bezier(w, degree, 0.5, Left.data(), Right.data()); + total_subs ++; + find_parametric_bezier_roots(Left.data(), degree, solutions, depth+1); + find_parametric_bezier_roots(Right.data(), degree, solutions, depth+1); } @@ -130,7 +126,8 @@ control_poly_flat_enough(Geom::Point const *V, /* Control points */ const double abSquared = (a * a) + (b * b); - double distance[degree]; /* Distances from pts to line */ + //double distance[degree]; /* Distances from pts to line */ + std::vector distance(degree); /* Distances from pts to line */ for (unsigned i = 1; i < degree; i++) { /* Compute distance from each of the points to that line */ double & dist(distance[i-1]); @@ -198,13 +195,13 @@ Bezier(Geom::Point const *V, /* Control pts */ Geom::Point *Left, /* RETURN left half ctl pts */ Geom::Point *Right) /* RETURN right half ctl pts */ { - Geom::Point **Vtemp = new Geom::Point* [degree+1]; - - for (unsigned int i = 0; i < degree+1; ++i) - Vtemp[i] = new Geom::Point[degree+1]; + //Geom::Point Vtemp[degree+1][degree+1]; + std::vector > Vtemp(degree+1); + for ( size_t i = 0; i < degree + 1; ++i ) + Vtemp.reserve(degree+1); /* Copy control points */ - std::copy(V, V+degree+1, Vtemp[0]); + std::copy(V, V+degree+1, Vtemp[0].begin()); /* Triangle computation */ for (unsigned i = 1; i <= degree; i++) { @@ -218,14 +215,7 @@ Bezier(Geom::Point const *V, /* Control pts */ for (unsigned j = 0; j <= degree; j++) Right[j] = Vtemp[degree-j][j]; - Geom::Point return_value = Vtemp[degree][0]; - - for (unsigned int i = 0; i < degree+1; ++i) - delete[] Vtemp[i]; - - delete[] Vtemp; - - return return_value; + return (Vtemp[degree][0]); } }; diff --git a/src/2geom/solve-bezier.cpp b/src/2geom/solve-bezier.cpp index 09f8d9289..adf3c9ac0 100644 --- a/src/2geom/solve-bezier.cpp +++ b/src/2geom/solve-bezier.cpp @@ -80,7 +80,7 @@ void convex_hull_marching(Bezier src_bz, Bezier bz, double left_t, double right_t) { - while(bz.order() > 0 and bz[0] == 0) { + while(bz.order() > 0 && bz[0] == 0) { std::cout << "deflate\n"; bz = bz.deflate(); solutions.push_back(left_t); @@ -89,12 +89,11 @@ void convex_hull_marching(Bezier src_bz, Bezier bz, int old_sign = SGN(bz[0]); - int sign; double left_bound = 0; double dt = 0; for (size_t i = 1; i < bz.size(); i++) { - sign = SGN(bz[i]); + int sign = SGN(bz[i]); if (sign != old_sign) { dt = double(i) / bz.order(); @@ -113,7 +112,7 @@ void convex_hull_marching(Bezier src_bz, Bezier bz, double new_left_t = left_bound * (right_t - left_t) + left_t; std::cout << "new_left_t = " << new_left_t << std::endl; Bezier bzr = subRight(src_bz, new_left_t); - while(bzr.order() > 0 and bzr[0] == 0) { + while(bzr.order() > 0 && bzr[0] == 0) { std::cout << "deflate\n"; bzr = bzr.deflate(); solutions.push_back(new_left_t); @@ -124,7 +123,7 @@ void convex_hull_marching(Bezier src_bz, Bezier bz, new_left_t, right_t); } else { std::cout << "epsilon reached\n"; - while(bzr.order() > 0 and fabs(bzr[0]) <= 1e-10) { + while(bzr.order() > 0 && fabs(bzr[0]) <= 1e-10) { std::cout << "deflate\n"; bzr = bzr.deflate(); std::cout << bzr << std::endl; @@ -182,11 +181,10 @@ void Bernsteins::find_bernstein_roots(Bezier bz, int old_sign = SGN(bz[0]); //std::cout << "w[0] = " << bz[0] << std::endl; - int sign; for (size_t i = 1; i < bz.size(); i++) { //std::cout << "w[" << i << "] = " << w[i] << std::endl; - sign = SGN(bz[i]); + int sign = SGN(bz[i]); if (sign != 0) { if (sign != old_sign && old_sign != 0) @@ -259,7 +257,7 @@ void Bernsteins::find_bernstein_roots(Bezier bz, debug(std::cout << "Solution is exactly on the subdivision point.\n"); debug(std::cout << Left << " , " << Right << std::endl); Left = reverse(Left); - while(Right.order() > 0 and fabs(Right[0]) <= 1e-10) { + while(Right.order() > 0 && fabs(Right[0]) <= 1e-10) { debug(std::cout << "deflate\n"); Right = Right.deflate(); Left = Left.deflate(); @@ -293,7 +291,7 @@ double Bernsteins::secant(Bezier bz) { double s = 0, t = 1; double e = 1e-14; int side = 0; - double r, fr, fs = bz.at0(), ft = bz.at1(); + double r, fs = bz.at0(), ft = bz.at1(); for (size_t n = 0; n < 100; ++n) { @@ -305,7 +303,7 @@ double Bernsteins::secant(Bezier bz) { return r; } - fr = horner(bz, r); + double fr = horner(bz, r); if (fr * ft > 0) { diff --git a/src/2geom/svg-elliptical-arc.cpp b/src/2geom/svg-elliptical-arc.cpp index 14a4b4f16..96a4f99d8 100644 --- a/src/2geom/svg-elliptical-arc.cpp +++ b/src/2geom/svg-elliptical-arc.cpp @@ -218,15 +218,23 @@ bool make_elliptical_arc::make_elliptiarc() if (svg_compliant_flag()) { +#ifdef CPP11 + std::unique_ptr arc( e.arc(initial_point, inner_point, final_point, true) ); +#else std::auto_ptr arc( e.arc(initial_point, inner_point, final_point, true) ); +#endif ea = *arc; } else { try { - std::auto_ptr eap( - e.arc(initial_point, inner_point, final_point, false) ); +#ifdef CPP11 + std::unique_ptr +#else + std::auto_ptr +#endif + eap( e.arc(initial_point, inner_point, final_point, false) ); ea = *eap; } catch(RangeError const &exc) diff --git a/src/2geom/svg-path-parser.cpp b/src/2geom/svg-path-parser.cpp index 60a734ece..fa31b57b5 100644 --- a/src/2geom/svg-path-parser.cpp +++ b/src/2geom/svg-path-parser.cpp @@ -1,4 +1,5 @@ -#line 1 "/opt/shared/work/programming/eclipse/eclipse_3.4/lib2geom/src/2geom/svg-path-parser.rl" + +#line 1 "/home/tweenk/src/lib2geom/src/2geom/svg-path-parser.rl" /** * \file * \brief parse SVG path specifications @@ -46,7 +47,7 @@ namespace { class Parser { public: - Parser(SVGPathSink &sink) : _absolute(false), _sink(sink) {} + Parser(PathSink &sink) : _absolute(false), _sink(sink) {} void parse(char const *str) throw(SVGPathParseError); @@ -57,7 +58,7 @@ private: Point _cubic_tangent; Point _quad_tangent; std::vector _params; - SVGPathSink &_sink; + PathSink &_sink; void _reset() { _absolute = false; @@ -140,7 +141,7 @@ private: }; -#line 144 "/opt/shared/work/programming/eclipse/eclipse_3.4/lib2geom/src/2geom/svg-path-parser.cpp" +#line 145 "/home/tweenk/src/lib2geom/src/2geom/svg-path-parser.cpp" static const char _svg_path_actions[] = { 0, 1, 0, 1, 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 15, 1, @@ -956,7 +957,7 @@ static const short _svg_path_indicies[] = { 1, 0 }; -static const short _svg_path_trans_targs_wi[] = { +static const short _svg_path_trans_targs[] = { 270, 0, 1, 2, 193, 3, 4, 5, 194, 3, 4, 5, 194, 5, 194, 6, 7, 8, 195, 9, 204, 7, 8, 195, @@ -1048,7 +1049,7 @@ static const short _svg_path_trans_targs_wi[] = { 268, 269 }; -static const char _svg_path_trans_actions_wi[] = { +static const char _svg_path_trans_actions[] = { 15, 0, 0, 0, 0, 9, 47, 47, 47, 0, 1, 1, 1, 0, 0, 0, 3, 17, 3, 17, 0, 0, 1, 0, @@ -1145,7 +1146,8 @@ static const int svg_path_first_final = 270; static const int svg_path_en_main = 1; -#line 144 "/opt/shared/work/programming/eclipse/eclipse_3.4/lib2geom/src/2geom/svg-path-parser.rl" + +#line 144 "/home/tweenk/src/lib2geom/src/2geom/svg-path-parser.rl" void Parser::parse(char const *str) @@ -1158,12 +1160,12 @@ throw(SVGPathParseError) _reset(); -#line 1162 "/opt/shared/work/programming/eclipse/eclipse_3.4/lib2geom/src/2geom/svg-path-parser.cpp" +#line 1164 "/home/tweenk/src/lib2geom/src/2geom/svg-path-parser.cpp" { cs = svg_path_start; } -#line 1167 "/opt/shared/work/programming/eclipse/eclipse_3.4/lib2geom/src/2geom/svg-path-parser.cpp" +#line 1169 "/home/tweenk/src/lib2geom/src/2geom/svg-path-parser.cpp" { int _klen; unsigned int _trans; @@ -1192,7 +1194,7 @@ _resume: else if ( (*p) > *_mid ) _lower = _mid + 1; else { - _trans += (_mid - _keys); + _trans += (unsigned int)(_mid - _keys); goto _match; } } @@ -1215,7 +1217,7 @@ _resume: else if ( (*p) > _mid[1] ) _lower = _mid + 2; else { - _trans += ((_mid - _keys)>>1); + _trans += (unsigned int)((_mid - _keys)>>1); goto _match; } } @@ -1224,25 +1226,25 @@ _resume: _match: _trans = _svg_path_indicies[_trans]; - cs = _svg_path_trans_targs_wi[_trans]; + cs = _svg_path_trans_targs[_trans]; - if ( _svg_path_trans_actions_wi[_trans] == 0 ) + if ( _svg_path_trans_actions[_trans] == 0 ) goto _again; - _acts = _svg_path_actions + _svg_path_trans_actions_wi[_trans]; + _acts = _svg_path_actions + _svg_path_trans_actions[_trans]; _nacts = (unsigned int) *_acts++; while ( _nacts-- > 0 ) { switch ( *_acts++ ) { case 0: -#line 156 "/opt/shared/work/programming/eclipse/eclipse_3.4/lib2geom/src/2geom/svg-path-parser.rl" +#line 156 "/home/tweenk/src/lib2geom/src/2geom/svg-path-parser.rl" { start = p; } break; case 1: -#line 160 "/opt/shared/work/programming/eclipse/eclipse_3.4/lib2geom/src/2geom/svg-path-parser.rl" +#line 160 "/home/tweenk/src/lib2geom/src/2geom/svg-path-parser.rl" { char const *end=p; std::string buf(start, end); @@ -1251,55 +1253,55 @@ _match: } break; case 2: -#line 167 "/opt/shared/work/programming/eclipse/eclipse_3.4/lib2geom/src/2geom/svg-path-parser.rl" +#line 167 "/home/tweenk/src/lib2geom/src/2geom/svg-path-parser.rl" { _push(1.0); } break; case 3: -#line 171 "/opt/shared/work/programming/eclipse/eclipse_3.4/lib2geom/src/2geom/svg-path-parser.rl" +#line 171 "/home/tweenk/src/lib2geom/src/2geom/svg-path-parser.rl" { _push(0.0); } break; case 4: -#line 175 "/opt/shared/work/programming/eclipse/eclipse_3.4/lib2geom/src/2geom/svg-path-parser.rl" +#line 175 "/home/tweenk/src/lib2geom/src/2geom/svg-path-parser.rl" { _absolute = true; } break; case 5: -#line 179 "/opt/shared/work/programming/eclipse/eclipse_3.4/lib2geom/src/2geom/svg-path-parser.rl" +#line 179 "/home/tweenk/src/lib2geom/src/2geom/svg-path-parser.rl" { _absolute = false; } break; case 6: -#line 183 "/opt/shared/work/programming/eclipse/eclipse_3.4/lib2geom/src/2geom/svg-path-parser.rl" +#line 183 "/home/tweenk/src/lib2geom/src/2geom/svg-path-parser.rl" { _moveTo(_pop_point()); } break; case 7: -#line 187 "/opt/shared/work/programming/eclipse/eclipse_3.4/lib2geom/src/2geom/svg-path-parser.rl" +#line 187 "/home/tweenk/src/lib2geom/src/2geom/svg-path-parser.rl" { _lineTo(_pop_point()); } break; case 8: -#line 191 "/opt/shared/work/programming/eclipse/eclipse_3.4/lib2geom/src/2geom/svg-path-parser.rl" +#line 191 "/home/tweenk/src/lib2geom/src/2geom/svg-path-parser.rl" { _hlineTo(Point(_pop_coord(X), _current[Y])); } break; case 9: -#line 195 "/opt/shared/work/programming/eclipse/eclipse_3.4/lib2geom/src/2geom/svg-path-parser.rl" +#line 195 "/home/tweenk/src/lib2geom/src/2geom/svg-path-parser.rl" { _vlineTo(Point(_current[X], _pop_coord(Y))); } break; case 10: -#line 199 "/opt/shared/work/programming/eclipse/eclipse_3.4/lib2geom/src/2geom/svg-path-parser.rl" +#line 199 "/home/tweenk/src/lib2geom/src/2geom/svg-path-parser.rl" { Point p = _pop_point(); Point c1 = _pop_point(); @@ -1308,7 +1310,7 @@ _match: } break; case 11: -#line 206 "/opt/shared/work/programming/eclipse/eclipse_3.4/lib2geom/src/2geom/svg-path-parser.rl" +#line 206 "/home/tweenk/src/lib2geom/src/2geom/svg-path-parser.rl" { Point p = _pop_point(); Point c1 = _pop_point(); @@ -1316,7 +1318,7 @@ _match: } break; case 12: -#line 212 "/opt/shared/work/programming/eclipse/eclipse_3.4/lib2geom/src/2geom/svg-path-parser.rl" +#line 212 "/home/tweenk/src/lib2geom/src/2geom/svg-path-parser.rl" { Point p = _pop_point(); Point c = _pop_point(); @@ -1324,14 +1326,14 @@ _match: } break; case 13: -#line 218 "/opt/shared/work/programming/eclipse/eclipse_3.4/lib2geom/src/2geom/svg-path-parser.rl" +#line 218 "/home/tweenk/src/lib2geom/src/2geom/svg-path-parser.rl" { Point p = _pop_point(); _quadTo(_quad_tangent, p); } break; case 14: -#line 223 "/opt/shared/work/programming/eclipse/eclipse_3.4/lib2geom/src/2geom/svg-path-parser.rl" +#line 223 "/home/tweenk/src/lib2geom/src/2geom/svg-path-parser.rl" { Point point = _pop_point(); bool sweep = _pop_flag(); @@ -1344,16 +1346,16 @@ _match: } break; case 15: -#line 234 "/opt/shared/work/programming/eclipse/eclipse_3.4/lib2geom/src/2geom/svg-path-parser.rl" +#line 234 "/home/tweenk/src/lib2geom/src/2geom/svg-path-parser.rl" { _closePath(); } break; case 16: -#line 370 "/opt/shared/work/programming/eclipse/eclipse_3.4/lib2geom/src/2geom/svg-path-parser.rl" - {goto _out;} +#line 370 "/home/tweenk/src/lib2geom/src/2geom/svg-path-parser.rl" + {{p++; goto _out; }} break; -#line 1357 "/opt/shared/work/programming/eclipse/eclipse_3.4/lib2geom/src/2geom/svg-path-parser.cpp" +#line 1359 "/home/tweenk/src/lib2geom/src/2geom/svg-path-parser.cpp" } } @@ -1364,7 +1366,8 @@ _again: goto _resume; _out: {} } -#line 380 "/opt/shared/work/programming/eclipse/eclipse_3.4/lib2geom/src/2geom/svg-path-parser.rl" + +#line 380 "/home/tweenk/src/lib2geom/src/2geom/svg-path-parser.rl" if ( cs < svg_path_first_final ) { @@ -1374,12 +1377,12 @@ _again: } -void parse_svg_path(char const *str, SVGPathSink &sink) +void parse_svg_path(char const *str, PathSink &sink) throw(SVGPathParseError) { Parser parser(sink); parser.parse(str); - sink.finish(); + sink.flush(); } } @@ -1393,4 +1396,4 @@ throw(SVGPathParseError) fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/2geom/svg-path-parser.h b/src/2geom/svg-path-parser.h index 365287d8c..163fbe5c4 100644 --- a/src/2geom/svg-path-parser.h +++ b/src/2geom/svg-path-parser.h @@ -38,11 +38,11 @@ #include #include <2geom/exception.h> #include <2geom/point.h> -#include <2geom/svg-path.h> +#include <2geom/path-sink.h> namespace Geom { -void parse_svg_path(char const *str, SVGPathSink &sink) throw(SVGPathParseError); +void parse_svg_path(char const *str, PathSink &sink) throw(SVGPathParseError); inline std::vector parse_svg_path(char const *str) throw(SVGPathParseError) { typedef std::vector Subpaths; @@ -50,13 +50,14 @@ inline std::vector parse_svg_path(char const *str) throw(SVGPathParseError Subpaths subpaths; Inserter iter(subpaths); - SVGPathGenerator generator(iter); + PathIteratorSink generator(iter); parse_svg_path(str, generator); return subpaths; } inline std::vector read_svgd_f(FILE * fi) throw(SVGPathParseError) { + /// @bug The 10kB length limit should be removed char input[1024 * 10]; fgets(input, 1024 * 10, fi); return parse_svg_path(input); diff --git a/src/2geom/svg-path.cpp b/src/2geom/svg-path.cpp deleted file mode 100644 index d459b3e1b..000000000 --- a/src/2geom/svg-path.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/* - * callback interface for SVG path data - * - * Copyright 2007 MenTaLguY - * - * This library is free software; you can redistribute it and/or - * modify it either under the terms of the GNU Lesser General Public - * License version 2.1 as published by the Free Software Foundation - * (the "LGPL") or, at your option, under the terms of the Mozilla - * Public License Version 1.1 (the "MPL"). If you do not alter this - * notice, a recipient may use your version of this file under either - * the MPL or the LGPL. - * - * You should have received a copy of the LGPL along with this library - * in the file COPYING-LGPL-2.1; if not, output to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * You should have received a copy of the MPL along with this library - * in the file COPYING-MPL-1.1 - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY - * OF ANY KIND, either express or implied. See the LGPL or the MPL for - * the specific language governing rights and limitations. - * - */ - -#include <2geom/sbasis-to-bezier.h> -#include <2geom/svg-path.h> -#include <2geom/exception.h> - -namespace Geom { - -void output(Curve const &curve, SVGPathSink &sink) { - std::vector pts; - sbasis_to_bezier(pts, curve.toSBasis(), 2); //TODO: use something better! - sink.curveTo(pts[0], pts[1], pts[2]); -} - -void output(HLineSegment const &curve, SVGPathSink &sink) { - sink.hlineTo(curve.finalPoint()[X]); -} - -void output(VLineSegment const &curve, SVGPathSink &sink) { - sink.vlineTo(curve.finalPoint()[Y]); -} - -void output(LineSegment const &curve, SVGPathSink &sink) { - sink.lineTo(curve[1]); -} - -void output(CubicBezier const &curve, SVGPathSink &sink) { - sink.curveTo(curve[1], curve[2], curve[3]); -} - -void output(QuadraticBezier const &curve, SVGPathSink &sink) { - sink.quadTo(curve[1], curve[2]); -} - -void output(SVGEllipticalArc const &curve, SVGPathSink &sink) { - sink.arcTo( curve.ray(X), curve.ray(Y), curve.rotationAngle(), - curve.largeArc(), curve.sweep(), - curve.finalPoint() ); -} - -template -bool output_as(Curve const &curve, SVGPathSink &sink) { - T const *t = dynamic_cast(&curve); - if (t) { - output(*t, sink); - return true; - } else { - return false; - } -} - -void output_svg_path(Path &path, SVGPathSink &sink) { - sink.moveTo(path.front().initialPoint()); - - Path::iterator iter; - for ( iter = path.begin() ; iter != path.end() ; ++iter ) { - output_as(*iter, sink) || - output_as(*iter, sink) || - output_as(*iter, sink) || - output_as(*iter, sink) || - output_as(*iter, sink) || - output_as(*iter, sink) || - output_as(*iter, sink); - } - - if (path.closed()) { - sink.closePath(); - } - sink.finish(); -} - -} - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/2geom/svg-path.h b/src/2geom/svg-path.h deleted file mode 100644 index c22f65d11..000000000 --- a/src/2geom/svg-path.h +++ /dev/null @@ -1,185 +0,0 @@ -/** - * \file - * \brief callback interface for SVG path data - * - * Copyright 2007 MenTaLguY - * - * This library is free software; you can redistribute it and/or - * modify it either under the terms of the GNU Lesser General Public - * License version 2.1 as published by the Free Software Foundation - * (the "LGPL") or, at your option, under the terms of the Mozilla - * Public License Version 1.1 (the "MPL"). If you do not alter this - * notice, a recipient may use your version of this file under either - * the MPL or the LGPL. - * - * You should have received a copy of the LGPL along with this library - * in the file COPYING-LGPL-2.1; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * You should have received a copy of the MPL along with this library - * in the file COPYING-MPL-1.1 - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY - * OF ANY KIND, either express or implied. See the LGPL or the MPL for - * the specific language governing rights and limitations. - * - */ - -#ifndef SEEN_SVG_PATH_H -#define SEEN_SVG_PATH_H - -#include <2geom/path.h> -#include <2geom/curves.h> -#include - -namespace Geom { - -class SVGPathSink { -public: - virtual void moveTo(Point p) = 0; - virtual void hlineTo(Coord v) = 0; - virtual void vlineTo(Coord v) = 0; - virtual void lineTo(Point p) = 0; - virtual void curveTo(Point c0, Point c1, Point p) = 0; - virtual void quadTo(Point c, Point p) = 0; - virtual void arcTo(double rx, double ry, double angle, - bool large_arc, bool sweep, Point p) = 0; - - /** Undo the last lineTo, curveTo, etc. call. */ - virtual void backspace() = 0; - - virtual void closePath() = 0; - virtual void finish() = 0; - virtual ~SVGPathSink() {} -}; - -void output_svg_path(Path &path, SVGPathSink &sink); - -template -class SVGPathGenerator : public SVGPathSink { -public: - explicit SVGPathGenerator(OutputIterator out) - : _in_path(false), _out(out) {} - - void moveTo(Point p) { - finish(); - _path.start(p); - _start_p = p; - _in_path = true; - } -//TODO: what if _in_path = false? - - void hlineTo(Coord v) { - // check for implicit moveto, like in: "M 1,1 L 2,2 z l 2,2 z" - if (!_in_path) { - moveTo(_start_p); - } - _path.template appendNew(Point(v, _path.finalPoint()[Y])); - } - - void vlineTo(Coord v) { - // check for implicit moveto, like in: "M 1,1 L 2,2 z l 2,2 z" - if (!_in_path) { - moveTo(_start_p); - } - _path.template appendNew(Point(_path.finalPoint()[X], v)); - } - - void lineTo(Point p) { - // check for implicit moveto, like in: "M 1,1 L 2,2 z l 2,2 z" - if (!_in_path) { - moveTo(_start_p); - } - _path.template appendNew(p); - } - - void quadTo(Point c, Point p) { - // check for implicit moveto, like in: "M 1,1 L 2,2 z l 2,2 z" - if (!_in_path) { - moveTo(_start_p); - } - _path.template appendNew(c, p); - } - - void curveTo(Point c0, Point c1, Point p) { - // check for implicit moveto, like in: "M 1,1 L 2,2 z l 2,2 z" - if (!_in_path) { - moveTo(_start_p); - } - _path.template appendNew(c0, c1, p); - } - - void arcTo(double rx, double ry, double angle, - bool large_arc, bool sweep, Point p) - { - // check for implicit moveto, like in: "M 1,1 L 2,2 z l 2,2 z" - if (!_in_path) { - moveTo(_start_p); - } - _path.template appendNew(rx, ry, angle, - large_arc, sweep, p); - } - - void backspace() - { - if (_in_path && _path.size() > 0) { - _path.erase_last(); - } - } - - void append(Path const &other, Path::Stitching stitching = Path::NO_STITCHING) - { - if (!_in_path) { - moveTo(other.initialPoint()); - } - _path.append(other, stitching); - } - - void closePath() { - _path.close(); - finish(); - } - - void finish() { - if (_in_path) { - _in_path = false; - *_out = _path; - _path.clear(); - _path.close(false); - } - } - -protected: - bool _in_path; - OutputIterator _out; - Path _path; - Point _start_p; -}; - -typedef std::back_insert_iterator > iter; - -class PathBuilder : public SVGPathGenerator { -private: - std::vector _pathset; -public: - PathBuilder() : SVGPathGenerator(iter(_pathset)) {} - std::vector const &peek() const {return _pathset;} -}; - -} - -#endif -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/2geom/toposweep.h b/src/2geom/toposweep.h index 428115dd3..b6a55b154 100644 --- a/src/2geom/toposweep.h +++ b/src/2geom/toposweep.h @@ -193,7 +193,7 @@ Areas filter_areas(PathVector const &ps, Areas const & areas, Z const &z) { if(areas[i].size() < 2) continue; //find a representative section unsigned rj = 0; - bool rev = are_near(areas[i][0]->fp, areas[i][1]->tp); + //bool rev = are_near(areas[i][0]->fp, areas[i][1]->tp); for(unsigned j = 1; j < areas[i].size(); j++) if(sorty(*areas[i][rj], *areas[i][j])) rj = j; if(sortx(*areas[i][rj], *areas[i][(rj+areas[i].size() - 1) % areas[i].size()])) { diff --git a/src/2geom/transforms.cpp b/src/2geom/transforms.cpp index 65df9b22f..091079d5a 100644 --- a/src/2geom/transforms.cpp +++ b/src/2geom/transforms.cpp @@ -164,6 +164,7 @@ void check_transforms() // notice that the first column is always the same and enumerates all transform types, // while the second one changes to each transform type in turn. + // cppcheck-suppress redundantAssignment m = t * t; m = t * s; m = t * r; m = t * h; m = t * v; m = t * z; m = s * t; m = s * s; m = s * r; m = s * h; m = s * v; m = s * z; m = r * t; m = r * s; m = r * r; m = r * h; m = r * v; m = r * z; diff --git a/src/2geom/utils.cpp b/src/2geom/utils.cpp index a40b7253d..83d93cc87 100644 --- a/src/2geom/utils.cpp +++ b/src/2geom/utils.cpp @@ -37,16 +37,15 @@ namespace Geom { // return a vector that contains all the binomial coefficients of degree n -void binomial_coefficients(std::vector& bc, size_t n) +void binomial_coefficients(std::vector& bc, std::size_t n) { size_t s = n+1; bc.clear(); bc.resize(s); bc[0] = 1; - size_t k; for (size_t i = 1; i < n; ++i) { - k = i >> 1; + size_t k = i >> 1; if (i & 1u) { bc[k+1] = bc[k] << 1; diff --git a/src/2geom/utils.h b/src/2geom/utils.h index 6a72d42c4..fe955dd41 100644 --- a/src/2geom/utils.h +++ b/src/2geom/utils.h @@ -41,7 +41,7 @@ namespace Geom { // proper logical xor inline bool logical_xor (bool a, bool b) { return (a || b) && !(a && b); } -void binomial_coefficients(std::vector& bc, size_t n); +void binomial_coefficients(std::vector& bc, std::size_t n); struct EmptyClass {}; diff --git a/src/display/drawing-shape.cpp b/src/display/drawing-shape.cpp index e80f12486..03d7f51b5 100644 --- a/src/display/drawing-shape.cpp +++ b/src/display/drawing-shape.cpp @@ -12,7 +12,7 @@ #include #include <2geom/curves.h> #include <2geom/pathvector.h> -#include <2geom/svg-path.h> +#include <2geom/path-sink.h> #include <2geom/svg-path-parser.h> #include "display/cairo-utils.h" diff --git a/src/libnrtype/FontInstance.cpp b/src/libnrtype/FontInstance.cpp index 38a105459..434f3ee47 100644 --- a/src/libnrtype/FontInstance.cpp +++ b/src/libnrtype/FontInstance.cpp @@ -21,7 +21,7 @@ #include FT_TRUETYPE_TABLES_H #include #include <2geom/pathvector.h> -#include <2geom/svg-path.h> +#include <2geom/path-sink.h> #include "libnrtype/font-glyph.h" #include "libnrtype/font-instance.h" #include "livarot/Path.h" @@ -618,7 +618,7 @@ void font_instance::LoadGlyph(int glyph_id) doAdd=true; } #endif - path_builder.finish(); + path_builder.flush(); if ( doAdd ) { Geom::PathVector pv = path_builder.peek(); diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp index 0533c1ed6..acf8ab6a5 100644 --- a/src/live_effects/lpe-powerstroke.cpp +++ b/src/live_effects/lpe-powerstroke.cpp @@ -24,7 +24,7 @@ #include <2geom/bezier-utils.h> #include <2geom/svg-elliptical-arc.h> #include <2geom/sbasis-to-bezier.h> -#include <2geom/svg-path.h> +#include <2geom/path-sink.h> #include <2geom/path-intersection.h> #include <2geom/crossing.h> #include <2geom/ellipse.h> @@ -537,7 +537,7 @@ static Geom::Path path_from_piecewise_fix_cusps( Geom::Piecewise #include <2geom/transforms.h> #include <2geom/pathvector.h> -#include <2geom/svg-path.h> +#include <2geom/path-sink.h> #include "document.h" #include "sp-ellipse.h" #include "preferences.h" @@ -441,7 +441,7 @@ void SPGenericEllipse::set_shape() pb.closePath(); } else { // arc only - pb.finish(); + pb.flush(); } curve = new SPCurve(pb.peek()); diff --git a/src/svg/svg-path.cpp b/src/svg/svg-path.cpp index 135f9ff75..59dad9ead 100644 --- a/src/svg/svg-path.cpp +++ b/src/svg/svg-path.cpp @@ -40,7 +40,7 @@ #include <2geom/path.h> #include <2geom/curves.h> #include <2geom/sbasis-to-bezier.h> -#include <2geom/svg-path.h> +#include <2geom/path-sink.h> #include <2geom/svg-path-parser.h> #include <2geom/exception.h> #include <2geom/angle.h> @@ -59,13 +59,13 @@ Geom::PathVector sp_svg_read_pathv(char const * str) typedef std::back_insert_iterator Inserter; Inserter iter(pathv); - Geom::SVGPathGenerator generator(iter); + Geom::PathIteratorSink generator(iter); try { Geom::parse_svg_path(str, generator); } catch (Geom::SVGPathParseError &e) { - generator.finish(); + generator.flush(); // This warning is extremely annoying when testing //g_warning("Malformed SVG path, truncated path up to where error was found.\n Input path=\"%s\"\n Parsed path=\"%s\"", str, sp_svg_write_path(pathv)); } diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index ec58e2141..338499672 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -18,7 +18,7 @@ #include #include <2geom/bezier-curve.h> #include <2geom/bezier-utils.h> -#include <2geom/svg-path.h> +#include <2geom/path-sink.h> #include #include "ui/tool/path-manipulator.h" #include "desktop.h" @@ -1202,7 +1202,7 @@ void PathManipulator::_createGeometryFromControlPoints(bool alert_LPE) } ++spi; } - builder.finish(); + builder.flush(); Geom::PathVector pathv = builder.peek() * (_edit_transform * _i2d_transform).inverse(); _spcurve->set_pathvector(pathv); if (alert_LPE) { -- cgit v1.2.3 From 2919a4d76fb8e60bbfefecedbeac05749b5ca805 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Mon, 13 Jan 2014 12:24:07 +0100 Subject: Prevent segfault if 'tableValues' is empty. (bzr r12922) --- src/display/nr-filter-component-transfer.cpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/display/nr-filter-component-transfer.cpp b/src/display/nr-filter-component-transfer.cpp index 3bc00d2d7..dd90193fe 100644 --- a/src/display/nr-filter-component-transfer.cpp +++ b/src/display/nr-filter-component-transfer.cpp @@ -254,16 +254,21 @@ void FilterComponentTransfer::render_cairo(FilterSlot &slot) // parameters: R = 0, G = 1, B = 2, A = 3 // Cairo: R = 2, G = 1, B = 0, A = 3 + // If tableValues is empty, use identity. for (unsigned i = 0; i < 3; ++i) { guint32 color = 2 - i; switch (type[i]) { case COMPONENTTRANSFER_TYPE_TABLE: - ink_cairo_surface_filter(out, out, - ComponentTransferTable(color, tableValues[i])); + if(!tableValues[i].empty()) { + ink_cairo_surface_filter(out, out, + ComponentTransferTable(color, tableValues[i])); + } break; case COMPONENTTRANSFER_TYPE_DISCRETE: - ink_cairo_surface_filter(out, out, - ComponentTransferDiscrete(color, tableValues[i])); + if(!tableValues[i].empty()) { + ink_cairo_surface_filter(out, out, + ComponentTransferDiscrete(color, tableValues[i])); + } break; case COMPONENTTRANSFER_TYPE_LINEAR: ink_cairo_surface_filter(out, out, @@ -284,12 +289,16 @@ void FilterComponentTransfer::render_cairo(FilterSlot &slot) // fast paths for alpha channel switch (type[3]) { case COMPONENTTRANSFER_TYPE_TABLE: - ink_cairo_surface_filter(out, out, - ComponentTransferTable(tableValues[3])); + if(!tableValues[3].empty()) { + ink_cairo_surface_filter(out, out, + ComponentTransferTable(tableValues[3])); + } break; case COMPONENTTRANSFER_TYPE_DISCRETE: - ink_cairo_surface_filter(out, out, - ComponentTransferDiscrete(tableValues[3])); + if(!tableValues[3].empty()) { + ink_cairo_surface_filter(out, out, + ComponentTransferDiscrete(tableValues[3])); + } break; case COMPONENTTRANSFER_TYPE_LINEAR: ink_cairo_surface_filter(out, out, -- cgit v1.2.3 From 71abe5b8c4ed9e53a6a7299e4abc0deeb2c586a7 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Mon, 13 Jan 2014 13:55:24 +0100 Subject: Add GUI for feComponentTransfer filter primitive. (bzr r12923) --- src/filters/componenttransfer-funcnode.cpp | 25 ++- src/ui/dialog/filter-effects-dialog.cpp | 246 +++++++++++++++++++++++++---- src/ui/dialog/filter-effects-dialog.h | 5 +- 3 files changed, 231 insertions(+), 45 deletions(-) (limited to 'src') diff --git a/src/filters/componenttransfer-funcnode.cpp b/src/filters/componenttransfer-funcnode.cpp index 7c7375802..d8c5b0d49 100644 --- a/src/filters/componenttransfer-funcnode.cpp +++ b/src/filters/componenttransfer-funcnode.cpp @@ -205,14 +205,18 @@ void SPFeFuncNode::set(unsigned int key, gchar const *value) { } /** - * * Receives update notifications. - * */ + * Receives update notifications. + */ void SPFeFuncNode::update(SPCtx *ctx, guint flags) { + std::cout << "SPFeFuncNode::update" << std::endl; if (flags & SP_OBJECT_MODIFIED_FLAG) { - /* do something to trigger redisplay, updates? */ - //TODO - //this->readAttr( "azimuth" ); - //this->readAttr( "elevation" ); + this->readAttr( "type" ); + this->readAttr( "tableValues" ); + this->readAttr( "slope" ); + this->readAttr( "intercept" ); + this->readAttr( "amplitude" ); + this->readAttr( "exponent" ); + this->readAttr( "offset" ); } SPObject::update(ctx, flags); @@ -222,18 +226,11 @@ void SPFeFuncNode::update(SPCtx *ctx, guint flags) { * Writes its settings to an incoming repr object, if any. */ Inkscape::XML::Node* SPFeFuncNode::write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) { + std::cout << "SPFeFuncNode::write" << std::endl; if (!repr) { repr = this->getRepr()->duplicate(doc); } - /* - TODO: I'm not sure what to do here... - - if (fefuncnode->azimuth_set) - sp_repr_set_css_double(repr, "azimuth", fefuncnode->azimuth); - if (fefuncnode->elevation_set) - sp_repr_set_css_double(repr, "elevation", fefuncnode->elevation);*/ - SPObject::write(doc, repr, flags); return repr; diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index 38e05a1c7..6a3a4c3f1 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -47,6 +47,7 @@ #include "filters/blend.h" #include "filters/colormatrix.h" #include "filters/componenttransfer.h" +#include "filters/componenttransfer-funcnode.h" #include "filters/composite.h" #include "filters/convolvematrix.h" #include "filters/displacementmap.h" @@ -369,6 +370,36 @@ public: } }; +// Used for tableValue in feComponentTransfer +class EntryAttr : public Gtk::Entry, public AttrWidget +{ +public: + EntryAttr(const SPAttributeEnum a, char* tip_text) + : AttrWidget(a) + { + signal_changed().connect(signal_attr_changed().make_slot()); + if (tip_text) { + set_tooltip_text(tip_text); + } + } + + // No validity checking is done + Glib::ustring get_as_attribute() const + { + return get_text(); + } + + void set_from_attribute(SPObject* o) + { + const gchar* val = attribute_value(o); + if(val) { + set_text( val ); + } else { + set_text( "" ); + } + } +}; + /* Displays/Edits the matrix for feConvolveMatrix or feColorMatrix */ class FilterEffectsDialog::MatrixAttr : public Gtk::Frame, public AttrWidget { @@ -746,7 +777,7 @@ public: _groups[i] = new Gtk::VBox; b.pack_start(*_groups[i], false, false); } - _current_type = 0; + //_current_type = 0; If set to 0 then update_and_show() fails to update properly. } ~Settings() @@ -766,9 +797,9 @@ public: for(unsigned i = 0; i < _groups.size(); ++i) _groups[i]->hide(); } - if(t >= 0) - _groups[t]->show_all(); - + if(t >= 0) { + _groups[t]->show(); // Do not use show_all(), it shows children than should be hidden + } _dialog.set_attrs_locked(true); for(unsigned i = 0; i < _attrwidgets[_current_type].size(); ++i) _attrwidgets[_current_type][i]->set_from_attribute(ob); @@ -800,7 +831,10 @@ public: // LightSource LightSourceControl* add_lightsource(); - // CheckBox + // Component Transfer Values + ComponentTransferValues* add_componenttransfervalues(const Glib::ustring& label, SPFeFuncNode::Channel channel); + + // CheckButton CheckButtonAttr* add_checkbutton(bool def, const SPAttributeEnum attr, const Glib::ustring& label, const Glib::ustring& tv, const Glib::ustring& fv, char* tip_text = NULL) { @@ -938,6 +972,18 @@ public: add_attr_widget(combo->get_attrwidget()); return combo->get_attrwidget(); } + + // Entry + EntryAttr* add_entry(const SPAttributeEnum attr, + const Glib::ustring& label, + char* tip_text = NULL) + { + EntryAttr* entry = new EntryAttr(attr, tip_text); + add_widget(entry, label); + add_attr_widget(entry); + return entry; + } + private: void add_attr_widget(AttrWidget* a) { @@ -973,6 +1019,154 @@ private: int _current_type, _max_types; }; +// Displays sliders and/or tables for feComponentTransfer +class FilterEffectsDialog::ComponentTransferValues : public Gtk::Frame, public AttrWidget +{ +public: + ComponentTransferValues(FilterEffectsDialog& d, SPFeFuncNode::Channel channel) + : AttrWidget(SP_ATTR_INVALID), + _dialog(d), + _settings(d, _box, sigc::mem_fun(*this, &ComponentTransferValues::set_func_attr), COMPONENTTRANSFER_TYPE_ERROR), + _type(ComponentTransferTypeConverter, SP_ATTR_TYPE, false), + _channel(channel), + _funcNode(NULL) + { + set_shadow_type(Gtk::SHADOW_IN); + add(_box); + _box.add(_type); + _box.reorder_child(_type, 0); + _type.signal_changed().connect(sigc::mem_fun(*this, &ComponentTransferValues::on_type_changed)); + + _settings.type(COMPONENTTRANSFER_TYPE_LINEAR); + _settings.add_spinscale(1, SP_ATTR_SLOPE, _("Slope"), -10, 10, 0.1, 0.01, 2); + _settings.add_spinscale(0, SP_ATTR_INTERCEPT, _("Intercept"), -10, 10, 0.1, 0.01, 2); + + _settings.type(COMPONENTTRANSFER_TYPE_GAMMA); + _settings.add_spinscale(1, SP_ATTR_AMPLITUDE, _("Amplitude"), 0, 10, 0.1, 0.01, 2); + _settings.add_spinscale(1, SP_ATTR_EXPONENT, _("Exponent"), 0, 10, 0.1, 0.01, 2); + _settings.add_spinscale(0, SP_ATTR_OFFSET, _("Offset"), -10, 10, 0.1, 0.01, 2); + + _settings.type(COMPONENTTRANSFER_TYPE_TABLE); + _settings.add_entry(SP_ATTR_TABLEVALUES, _("Table")); + + _settings.type(COMPONENTTRANSFER_TYPE_DISCRETE); + _settings.add_entry(SP_ATTR_TABLEVALUES, _("Discrete")); + + //_settings.type(COMPONENTTRANSFER_TYPE_IDENTITY); + _settings.type(-1); // Force update_and_show() to show/hide windows correctly + } + + // FuncNode can be in any order so we must search to find correct one. + SPFeFuncNode* find_node(SPFeComponentTransfer* ct) + { + SPObject* node = ct->children; + SPFeFuncNode* funcNode = NULL; + bool found = false; + for(;node;node=node->next){ + funcNode = SP_FEFUNCNODE(node); + if( funcNode->channel == _channel ) { + found = true; + break; + } + } + if( !found ) + funcNode = NULL; + + return funcNode; + } + + void set_func_attr(const AttrWidget* input) + { + _dialog.set_attr( _funcNode, input->get_attribute(), input->get_as_attribute().c_str()); + } + + // Set new type and update widget visibility + virtual void set_from_attribute(SPObject* o) + { + // See componenttransfer.cpp + if(SP_IS_FECOMPONENTTRANSFER(o)) { + SPFeComponentTransfer* ct = SP_FECOMPONENTTRANSFER(o); + + _funcNode = find_node(ct); + if( _funcNode ) { + _type.set_from_attribute( _funcNode ); + } else { + // Create + SPFilterPrimitive* prim = _dialog._primitive_list.get_selected(); + if(prim) { + Inkscape::XML::Document *xml_doc = prim->document->getReprDoc(); + Inkscape::XML::Node *repr = NULL; + switch(_channel) { + case SPFeFuncNode::R: + repr = xml_doc->createElement("svg:feFuncR"); + break; + case SPFeFuncNode::G: + repr = xml_doc->createElement("svg:feFuncG"); + break; + case SPFeFuncNode::B: + repr = xml_doc->createElement("svg:feFuncB"); + break; + case SPFeFuncNode::A: + repr = xml_doc->createElement("svg:feFuncA"); + break; + } + + //XML Tree being used directly here while it shouldn't be. + prim->getRepr()->appendChild(repr); + Inkscape::GC::release(repr); + + // Now we should find it! + _funcNode = find_node(ct); + if( _funcNode ) { + _funcNode->setAttribute( "type", "identity" ); + } else { + //std::cout << "ERROR ERROR: feFuncX not found!" << std::endl; + } + } + } + + update(); + } + } + +private: + void on_type_changed() + { + SPFilterPrimitive* prim = _dialog._primitive_list.get_selected(); + if(prim) { + + _funcNode->getRepr()->setAttribute( "type", _type.get_as_attribute().c_str() ); + + SPFilter* filter = _dialog._filter_modifier.get_selected_filter(); + filter->requestModified(SP_OBJECT_MODIFIED_FLAG); + + DocumentUndo::done(prim->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("New transfer function type")); + update(); + } + } + + void update() + { + SPFilterPrimitive* prim = _dialog._primitive_list.get_selected(); + if(prim && _funcNode) { + _settings.show_and_update(_type.get_active_data()->id, _funcNode); + } + } + +public: + virtual Glib::ustring get_as_attribute() const + { + return ""; + } + + FilterEffectsDialog& _dialog; + Gtk::VBox _box; + Settings _settings; + ComboBoxEnum _type; + SPFeFuncNode::Channel _channel; // RGBA + SPFeFuncNode* _funcNode; +}; + // Settings for the three light source objects class FilterEffectsDialog::LightSourceControl : public AttrWidget { @@ -1012,6 +1206,9 @@ public: _settings.add_spinscale(1, SP_ATTR_SPECULAREXPONENT, _("Specular Exponent"), 1, 100, 1, 1, 0, _("Exponent value controlling the focus for the light source")); //TODO: here I have used 100 degrees as default value. But spec says that if not specified, no limiting cone is applied. So, there should be a way for the user to set a "no limiting cone" option. _settings.add_spinscale(100, SP_ATTR_LIMITINGCONEANGLE, _("Cone Angle"), 1, 100, 1, 1, 0, _("This is the angle between the spot light axis (i.e. the axis between the light source and the point to which it is pointing at) and the spot light cone. No light is projected outside this cone.")); + + _settings.type(-1); // Force update_and_show() to show/hide windows correctly + } Gtk::VBox& get_box() @@ -1102,6 +1299,16 @@ private: bool _locked; }; + // ComponentTransferValues +FilterEffectsDialog::ComponentTransferValues* FilterEffectsDialog::Settings::add_componenttransfervalues(const Glib::ustring& label, SPFeFuncNode::Channel channel) + { + ComponentTransferValues* ct = new ComponentTransferValues(_dialog, channel); + add_widget(ct, label); + add_attr_widget(ct); + return ct; + } + + FilterEffectsDialog::LightSourceControl* FilterEffectsDialog::Settings::add_lightsource() { LightSourceControl* ls = new LightSourceControl(_dialog); @@ -2527,7 +2734,6 @@ FilterEffectsDialog::FilterEffectsDialog() _sizegroup->set_ignore_hidden(); _add_primitive_type.remove_row(NR_FILTER_TILE); - _add_primitive_type.remove_row(NR_FILTER_COMPONENTTRANSFER); // Initialize widget hierarchy #if WITH_GTKMM_3_0 @@ -2629,15 +2835,10 @@ void FilterEffectsDialog::init_settings_widgets() colmat->signal_attr_changed().connect(sigc::mem_fun(*this, &FilterEffectsDialog::update_color_matrix)); _settings->type(NR_FILTER_COMPONENTTRANSFER); - _settings->add_notimplemented(); - /* - //TRANSLATORS: for info on "Slope" and "Intercept", see http://id.mind.net/~zona/mmts/functionInstitute/linearFunctions/lsif.html - _settings->add_combo(COMPONENTTRANSFER_TYPE_IDENTITY, SP_ATTR_TYPE, _("Type"), ComponentTransferTypeConverter); - _ct_slope = _settings->add_spinscale(1, SP_ATTR_SLOPE, _("Slope"), -10, 10, 0.1, 0.01, 2); - _ct_intercept = _settings->add_spinscale(0, SP_ATTR_INTERCEPT, _("Intercept"), -10, 10, 0.1, 0.01, 2); - _ct_amplitude = _settings->add_spinscale(1, SP_ATTR_AMPLITUDE, _("Amplitude"), 0, 10, 0.1, 0.01, 2); - _ct_exponent = _settings->add_spinscale(1, SP_ATTR_EXPONENT, _("Exponent"), 0, 10, 0.1, 0.01, 2); - _ct_offset = _settings->add_spinscale(0, SP_ATTR_OFFSET, _("Offset"), -10, 10, 0.1, 0.01, 2);*/ + _settings->add_componenttransfervalues(_("R:"), SPFeFuncNode::R); + _settings->add_componenttransfervalues(_("G:"), SPFeFuncNode::G); + _settings->add_componenttransfervalues(_("B:"), SPFeFuncNode::B); + _settings->add_componenttransfervalues(_("A:"), SPFeFuncNode::A); _settings->type(NR_FILTER_COMPOSITE); _settings->add_combo(COMPOSITE_OVER, SP_ATTR_OPERATOR, _("Operator:"), CompositeOperatorConverter); @@ -2953,21 +3154,6 @@ void FilterEffectsDialog::update_settings_sensitivity() _k3->set_sensitive(use_k); _k4->set_sensitive(use_k); -// Component transfer not yet implemented -/* - if(SP_IS_FECOMPONENTTRANSFER(prim)) { - SPFeComponentTransfer* ct = SP_FECOMPONENTTRANSFER(prim); - const bool linear = ct->type == COMPONENTTRANSFER_TYPE_LINEAR; - const bool gamma = ct->type == COMPONENTTRANSFER_TYPE_GAMMA; - - _ct_table->set_sensitive(ct->type == COMPONENTTRANSFER_TYPE_TABLE || ct->type == COMPONENTTRANSFER_TYPE_DISCRETE); - _ct_slope->set_sensitive(linear); - _ct_intercept->set_sensitive(linear); - _ct_amplitude->set_sensitive(gamma); - _ct_exponent->set_sensitive(gamma); - _ct_offset->set_sensitive(gamma); - } -*/ } void FilterEffectsDialog::update_color_matrix() diff --git a/src/ui/dialog/filter-effects-dialog.h b/src/ui/dialog/filter-effects-dialog.h index a2a2a3c6e..ccf79e60d 100644 --- a/src/ui/dialog/filter-effects-dialog.h +++ b/src/ui/dialog/filter-effects-dialog.h @@ -282,6 +282,7 @@ private: class Settings; class MatrixAttr; class ColorMatrixValues; + class ComponentTransferValues; class LightSourceControl; Settings* _settings; Settings* _filter_general_settings; @@ -290,6 +291,9 @@ private: // Color Matrix ColorMatrixValues* _color_matrix_values; + // Component Transfer + ComponentTransferValues* _component_transfer_values; + // Convolve Matrix MatrixAttr* _convolve_matrix; DualSpinButton* _convolve_order; @@ -297,7 +301,6 @@ private: // For controlling setting sensitivity Gtk::Widget* _k1, *_k2, *_k3, *_k4; - Gtk::Widget* _ct_table, *_ct_slope, *_ct_intercept, *_ct_amplitude, *_ct_exponent, *_ct_offset; // To prevent unwanted signals bool _locked; -- cgit v1.2.3 From 1261aa2ea7b3a229f7606dde8ddb7dc73752a1bc Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Tue, 14 Jan 2014 10:55:26 -0500 Subject: Fix bug #1239779 by removing caching for symbols. Fixed bugs: - https://launchpad.net/bugs/1239779 (bzr r12924) --- src/ui/dialog/symbols.cpp | 65 ++++++++++++++--------------------------------- src/ui/dialog/symbols.h | 7 +++-- 2 files changed, 22 insertions(+), 50 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index fb353fec1..2f2652bb1 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -73,8 +73,6 @@ namespace Inkscape { namespace UI { -static Cache::SvgPreview svg_preview_cache; - namespace Dialog { // See: http://developer.gnome.org/gtkmm/stable/classGtk_1_1TreeModelColumnRecord.html @@ -276,7 +274,7 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : instanceConns.push_back(documentReplacedConn); get_symbols(); - draw_symbols( currentDocument ); /* Defaults to current document */ + add_symbols( currentDocument ); /* Defaults to current document */ sigc::connection desktopChangeConn = deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &SymbolsDialog::setTargetDesktop) ); @@ -329,7 +327,7 @@ void SymbolsDialog::rebuild() { addSymbol->set_sensitive( false ); removeSymbol->set_sensitive( false ); } - draw_symbols( symbolDocument ); + add_symbols( symbolDocument ); } void SymbolsDialog::insertSymbol() { @@ -651,18 +649,18 @@ gchar const* SymbolsDialog::style_from_use( gchar const* id, SPDocument* documen return style; } -void SymbolsDialog::draw_symbols( SPDocument* symbolDocument ) { +void SymbolsDialog::add_symbols( SPDocument* symbolDocument ) { GSList* l = symbols_in_doc( symbolDocument ); for( ; l != NULL; l = l->next ) { SPObject* symbol = SP_OBJECT(l->data); if (SP_IS_SYMBOL(symbol)) { - draw_symbol( symbol ); + add_symbol( symbol ); } } } -void SymbolsDialog::draw_symbol( SPObject* symbol ) { +void SymbolsDialog::add_symbol( SPObject* symbol ) { SymbolColumns* columns = getColumns(); @@ -672,7 +670,7 @@ void SymbolsDialog::draw_symbol( SPObject* symbol ) { title = id; } - Glib::RefPtr pixbuf = create_symbol_image(id, symbol ); + Glib::RefPtr pixbuf = draw_symbol( symbol ); if( pixbuf ) { Gtk::ListStore::iterator row = store->append(); @@ -694,7 +692,7 @@ void SymbolsDialog::draw_symbol( SPObject* symbol ) { * the temporary document is rendered. */ Glib::RefPtr -SymbolsDialog::create_symbol_image(gchar const *symbol_id, SPObject *symbol) +SymbolsDialog::draw_symbol(SPObject *symbol) { // Create a copy repr of the symbol with id="the_symbol" Inkscape::XML::Document *xml_doc = previewDocument->getReprDoc(); @@ -713,7 +711,8 @@ SymbolsDialog::create_symbol_image(gchar const *symbol_id, SPObject *symbol) if( !style ) { // If no default style in , look in documents. if( symbol->document == currentDocument ) { - style = style_from_use( symbol_id, symbol->document ); + gchar const *id = symbol->getRepr()->attribute("id"); + style = style_from_use( id, symbol->document ); } else { style = symbol->document->getReprRoot()->attribute("style"); } @@ -722,9 +721,7 @@ SymbolsDialog::create_symbol_image(gchar const *symbol_id, SPObject *symbol) if( !style ) style = "fill:#bbbbbb;stroke:#808080"; // This is for display in Symbols dialog only - if( style ) { - repr->setAttribute( "style", style ); - } + if( style ) repr->setAttribute( "style", style ); // BUG: Symbols don't work if defined outside of . Causes Inkscape // crash when trying to read in such a file. @@ -733,7 +730,7 @@ SymbolsDialog::create_symbol_image(gchar const *symbol_id, SPObject *symbol) Inkscape::GC::release(repr); // Uncomment this to get the previewDocument documents saved (useful for debugging) - // FILE *fp = fopen (g_strconcat(symbol_id, ".svg", NULL), "w"); + // FILE *fp = fopen (g_strconcat(id, ".svg", NULL), "w"); // sp_repr_save_stream(previewDocument->getReprDoc(), fp); // fclose (fp); @@ -746,55 +743,31 @@ SymbolsDialog::create_symbol_image(gchar const *symbol_id, SPObject *symbol) previewDocument->getRoot()->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); previewDocument->ensureUpToDate(); - // if( object_temp == NULL || !SP_IS_ITEM(object_temp) ) { - // //std::cout << " previewDocument broken?" << std::endl; - // //return 0; - // } - SPItem *item = SP_ITEM(object_temp); - unsigned psize = SYMBOL_ICON_SIZES[in_sizes]; - /* Update to renderable state */ - Glib::ustring key = svg_preview_cache.cache_key(previewDocument->getURI(), symbol_id, psize); - //std::cout << " Key: " << key << std::endl; - Glib::RefPtr pixbuf(NULL); - GdkPixbuf *pixbuf_gobj = svg_preview_cache.get_preview_from_cache(key); - if (pixbuf_gobj) { - g_object_ref(pixbuf_gobj); // the reference in svg_preview_cache will get destroyed when it's freed - pixbuf = Glib::wrap(pixbuf_gobj); - } + // We could use cache here, but it doesn't really work with the structure + // of this user interface and we've already cached the pixbuf in the gtklist // Find object's bbox in document. // Note symbols can have own viewport... ignore for now. //Geom::OptRect dbox = item->geometricBounds(); Geom::OptRect dbox = item->documentVisualBounds(); - if (!dbox) { - //std::cout << " No dbox" << std::endl; - return pixbuf; - } - - if (!pixbuf) { + if (dbox) { /* Scale symbols to fit */ double scale = 1.0; double width = dbox->width(); double height = dbox->height(); - if( width == 0.0 ) { - width = 1.0; - } - if( height == 0.0 ) { - height = 1.0; - } - if( fitSymbol->get_active() ) { - /* Fit */ - scale = psize/std::max(width,height); - } + if( width == 0.0 ) width = 1.0; + if( height == 0.0 ) height = 1.0; + + if( fitSymbol->get_active() ) + scale = psize / std::max(width, height); pixbuf = Glib::wrap(render_pixbuf(renderDrawing, scale, *dbox, psize)); - svg_preview_cache.set_preview_in_cache(key, pixbuf->gobj()); } return pixbuf; diff --git a/src/ui/dialog/symbols.h b/src/ui/dialog/symbols.h index 074af6764..8021fb0c1 100644 --- a/src/ui/dialog/symbols.h +++ b/src/ui/dialog/symbols.h @@ -79,8 +79,8 @@ private: void iconDragDataGet(const Glib::RefPtr& context, Gtk::SelectionData& selection_data, guint info, guint time); void get_symbols(); - void draw_symbols( SPDocument* symbol_document ); - void draw_symbol( SPObject* symbol_document ); + void add_symbols( SPDocument* symbol_document ); + void add_symbol( SPObject* symbol_document ); SPDocument* symbols_preview_doc(); GSList* symbols_in_doc_recursive(SPObject *r, GSList *l); @@ -89,8 +89,7 @@ private: GSList* use_in_doc( SPDocument* document ); gchar const* style_from_use( gchar const* id, SPDocument* document); - Glib::RefPtr - create_symbol_image(gchar const *symbol_name, SPObject *symbol); + Glib::RefPtr draw_symbol(SPObject *symbol); /* Keep track of all symbol template documents */ std::map symbolSets; -- cgit v1.2.3 From e5bf7dcf9275a4b3da6375262fbe5992a1b66238 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Tue, 14 Jan 2014 11:25:49 -0500 Subject: Merge in patch from mathog in Bug #1241797 Fixed bugs: - https://launchpad.net/bugs/1241797 (bzr r12926) --- src/libuemf/uemf.c | 42 +++++++++++++++++++++++++++++++++++++++--- src/libuemf/uemf.h | 53 ++++++++++++++++++++++++++++------------------------- 2 files changed, 67 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/libuemf/uemf.c b/src/libuemf/uemf.c index 220c88545..3079c5095 100644 --- a/src/libuemf/uemf.c +++ b/src/libuemf/uemf.c @@ -1535,15 +1535,15 @@ int drawing_size( return(0); } + /** - \brief Set a U_COLORREF value from separeate R,G,B values. - Or use macro directly: cr = U_RGB(r,g,b). + \brief Set a U_COLORREF value from separate R,G,B values. \param red Red component \param green Green component \param blue Blue component */ -U_COLORREF colorref_set( +U_COLORREF colorref3_set( uint8_t red, uint8_t green, uint8_t blue @@ -1552,6 +1552,42 @@ U_COLORREF colorref_set( return(cr); } +/** + \brief Set a U_COLORREF value from separate R,G,B, and Reserved values. + \param red Red component + \param green Green component + \param blue Blue component + \param blue Reserved component + +*/ +U_COLORREF colorref4_set( + uint8_t red, + uint8_t green, + uint8_t blue, + uint8_t Reserved + ){ + U_COLORREF cr = (U_COLORREF){red , green, blue, Reserved}; + return(cr); +} + +/** + \brief Set a U_RGBQUAD value from separate R,G,B, Reserved values. + \param red Red component + \param green Green component + \param blue Blue component + \param reserved Reserved component + +*/ +U_RGBQUAD rgbquad_set( + uint8_t red, + uint8_t green, + uint8_t blue, + uint8_t reserved + ){ + U_RGBQUAD cr = (U_RGBQUAD){blue , green, red, reserved}; + return(cr); +} + /** \brief Set rect and rectl objects from Upper Left and Lower Right corner points. \param ul upper left corner of rectangle diff --git a/src/libuemf/uemf.h b/src/libuemf/uemf.h index 1ff6ead60..00c605d02 100644 --- a/src/libuemf/uemf.h +++ b/src/libuemf/uemf.h @@ -1096,34 +1096,35 @@ extern "C" { /** \defgroup Common_macros Common Macros @{ */ -// Color U_BGR(A), byte order lo to hi: {B,G,R,A} corresponding to U_RGBQUAD. Set/Get Macros. +// Note, many of these were originally defined using C99 (type){val,val,val} format, but that turned out to +// have incompatibilities with C++, so use functions as the basis to avoid this. + +// Set/Get for U_RGBQUAD Colors, which are stored in byte order: {B,G,R,A}. // These are used in EMF structures and the byte order must be the same in memory or on disk. -#define U_BGR(r,g,b) (U_RGBQUAD){b,g,r,0} //!< Set any BGR color with an {r,g,b} triplet -#define U_BGRA(r,g,b,a) (U_RGBQUAD){b,g,r,a} //!< Set any BGRA color with an {r,g,b,a} quad -#define U_WHITE U_BGR(255,255,255) //!< Set BGR white. -#define U_BLACK U_BGR(0,0,0) //!< Set BGR black. -#define U_BGRAGetR(rgb) (rgb.Red ) //!< Color BGR Get Red Macro. -#define U_BGRAGetG(rgb) (rgb.Green ) //!< Color BGR Get Green Macro. -#define U_BGRAGetB(rgb) (rgb.Blue ) //!< Color BGR Get Blue Macro. -#define U_BGRAGetA(rgb) (rgb.Reserved) //!< Color BGR Get A/reserved Macro. - -#define U_PALETTERGB(r,g,b) U_RGB(r,g,b,0x02)) //!< Set any Palette RGB color. -#define U_PALETTEINDEX(i) ((U_COLORREF)(0x01000000 | (uint16_t)(i)))\ - //!< Get RGB from Palette by index. - -// Color U_RGB(A), byte order lo to hi: {R,G,B,A} corresponding to U_COLORREF. Set/Get Macros. +#define U_BGR(r,g,b) rgbquad_set(r, g, b, 0) //!< Set any BGR color with an {r,g,b} triplet +#define U_BGRA(r,g,b,a) rgbquad_set(r, g, b, a) //!< Set any BGRA color with an {r,g,b,a} quad +#define U_WHITE U_BGR(255,255,255) //!< Set BGR white. +#define U_BLACK U_BGR(0,0,0) //!< Set BGR black. +#define U_BGRAGetR(rgb) (rgb.Red ) //!< Color BGR Red. +#define U_BGRAGetG(rgb) (rgb.Green ) //!< Color BGR Green. +#define U_BGRAGetB(rgb) (rgb.Blue ) //!< Color BGR Blue. +#define U_BGRAGetA(rgb) (rgb.Reserved) //!< Color BGRA A/reserved + + +// Set/Get for U_COLORREF Color, which are stored in byte order:: {R,G,B,A}. // These are used in EMF structures and the byte order must be the same in memory or on disk. -// These MAY be used in PNG and other libraries if these enforce byte order in memory,otherwise +// These MAY be used in PNG and other libraries if these enforce byte order in memory, otherwise // U_swap4 may need to also be employed. +// + +#define colorref_set colorref3_set //!< Most frequent usage is 3 colors, so set the unqualified one to that +#define U_RGB(r,g,b) colorref3_set(r, g, b) //!< Set any RGB color with an {r,g,b} triplet +#define U_RGBA(r,g,b,a) colorref4_set(r, g, b, a) //!< Set any RGBA color with an {r,g,b,a} quad +#define U_RGBAGetR(rgb) (rgb.Red ) //!< Color RGB Red. +#define U_RGBAGetG(rgb) (rgb.Green ) //!< Color RGB Green +#define U_RGBAGetB(rgb) (rgb.Blue ) //!< Color RGB Blue +#define U_RGBAGetA(rgb) (rgb.Reserved) //!< Color RGBA A/reserved -/// Set any RGB color with an {r,g,b} triplet -#define U_RGB(r,g,b) (U_COLORREF){(uint8_t)(r), (uint8_t)(g), (uint8_t)(b), 0} -/// Set any RGBA color with an {r,g,b,a} quad -#define U_RGBA(r,g,b,a) (U_COLORREF){(uint8_t)(r), (uint8_t)(g), (uint8_t)(b), (uint8_t)(a)} -#define U_RGBAGetR(rgb) ((U_COLORREF)rgb).Red //!< Color RGB Get Red Macro. -#define U_RGBAGetG(rgb) ((U_COLORREF)rgb).Green //!< Color RGB Get Green Macro. -#define U_RGBAGetB(rgb) ((U_COLORREF)rgb).Blue //!< Color RGB Get Blue Macro. -#define U_RGBAGetA(rgb) ((U_COLORREF)rgb).Reserved //!< Color RGBA Get A/reserved Macro. // color type conversions #define U_RGB2BGR(rgb) (U_RGBQUAD){ U_RGBAGetB(rgb),U_RGBAGetG(rgb),U_RGBAGetR(rgb),0} //!< Set any BGR color from an RGB color @@ -2652,7 +2653,9 @@ U_POINT16 point16_set(int16_t x, int16_t y); U_PANOSE panose_set(uint8_t bFamilyType, uint8_t bSerifStyle, uint8_t bWeight, uint8_t bProportion, uint8_t bContrast, uint8_t bStrokeVariation, uint8_t bArmStyle, uint8_t bLetterform, uint8_t bMidline, uint8_t bXHeight ); -U_COLORREF colorref_set(uint8_t red, uint8_t green, uint8_t blue); +U_COLORREF colorref3_set(uint8_t red, uint8_t green, uint8_t blue); +U_COLORREF colorref4_set(uint8_t red, uint8_t green, uint8_t blue, uint8_t reserved); +U_RGBQUAD rgbquad_set(uint8_t red,uint8_t green, uint8_t blue, uint8_t reserved); U_LOGBRUSH logbrush_set(uint32_t lbStyle, U_COLORREF lbColor, int32_t lbHatch); U_XFORM xform_set(U_FLOAT eM11, U_FLOAT eM12, U_FLOAT eM21, U_FLOAT eM22, U_FLOAT eDx, U_FLOAT eDy); U_XFORM xform_alt_set(U_FLOAT scale, U_FLOAT ratio, U_FLOAT rot, U_FLOAT axisrot, U_FLOAT eDx, U_FLOAT eDy); -- cgit v1.2.3 From 744053120dad8edd7085dda1a02e9f9ecd65d701 Mon Sep 17 00:00:00 2001 From: Bryce Harrington Date: Tue, 14 Jan 2014 10:46:05 -0800 Subject: Fix bzr revision number in version string (LP #1071923) Patch from David Evans. (bzr r12928) --- src/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 2f91c3c24..7fbc135c5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -223,7 +223,7 @@ endif # someone updates the BZR working directory. inkscape-version.cpp: $(inkscape_version_deps) VER_PREFIX="$(VERSION)";\ - VER_BZRREV=" r`bzr revno`"; \ + VER_BZRREV=" r`bzr revno --tree`"; \ if test ! -z "`bzr status -S -V $(srcdir)`"; then \ VER_CUSTOM=" custom"; \ fi; \ -- cgit v1.2.3 From 53fe5bb2f9a2f4956ad63ac42df2047a8b8705ec Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Tue, 14 Jan 2014 19:05:56 +0000 Subject: fix warnings on compilers that provide unordered_set (bzr r12929) --- src/util/unordered-containers.h | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/util/unordered-containers.h b/src/util/unordered-containers.h index 70d36c4dc..98c2fa3c9 100644 --- a/src/util/unordered-containers.h +++ b/src/util/unordered-containers.h @@ -19,8 +19,24 @@ #include #ifndef DOXYGEN_SHOULD_SKIP_THIS -#if defined(HAVE_TR1_UNORDERED_SET) +#if defined(HAVE_NATIVE_UNORDERED_SET) +# include +# include +# define INK_UNORDERED_SET std::unordered_set +# define INK_UNORDERED_MAP std::unordered_map +# define INK_HASH std::hash + +namespace std { +template <> +struct hash : public std::unary_function { + std::size_t operator()(Glib::ustring const &s) const { + return hash()(s.raw()); + } +}; +} // namespace std + +#elif defined(HAVE_TR1_UNORDERED_SET) # include # include # define INK_UNORDERED_SET std::tr1::unordered_set -- cgit v1.2.3 From bfc7eb940ec9472a1a01af0f3622f8419bd30051 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Tue, 14 Jan 2014 21:24:09 +0000 Subject: multi-path-manipulator: strip dead code (bzr r12930) --- src/ui/tool/multi-path-manipulator.cpp | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'src') diff --git a/src/ui/tool/multi-path-manipulator.cpp b/src/ui/tool/multi-path-manipulator.cpp index 1c683f717..65987ad52 100644 --- a/src/ui/tool/multi-path-manipulator.cpp +++ b/src/ui/tool/multi-path-manipulator.cpp @@ -30,17 +30,6 @@ #include -#ifdef USE_GNU_HASHES -namespace __gnu_cxx { -template<> -struct hash { - size_t operator()(Inkscape::UI::NodeList::iterator const &n) const { - return reinterpret_cast(n.ptr()); - } -}; -} // namespace __gnu_cxx -#endif // USE_GNU_HASHES - namespace Inkscape { namespace UI { -- cgit v1.2.3 From 35649d3846d690ad444db4645156995baba945ff Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Tue, 14 Jan 2014 23:02:41 +0100 Subject: Fix for Bug #1268778 (Move cursor disappears after clicking on Select Tool (F1) twice). Fixed bugs: - https://launchpad.net/bugs/1268778 (bzr r12931) --- src/desktop.cpp | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/desktop.cpp b/src/desktop.cpp index 195127ca1..bc917c6f3 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -657,19 +657,18 @@ SPDesktop::change_document (SPDocument *theDocument) /** * Replaces the currently active tool with a new one. */ -void SPDesktop::set_event_context2(const std::string& toolName) { - Inkscape::UI::Tools::ToolBase* new_tool = ToolFactory::instance().createObject(toolName); - new_tool->desktop = this; - new_tool->message_context = new Inkscape::MessageContext(this->messageStack()); - +void SPDesktop::set_event_context2(const std::string& toolName) +{ Inkscape::UI::Tools::ToolBase* old_tool = event_context; - event_context = new_tool; - - if (old_tool) { - old_tool->finish(); - delete old_tool; - } - + if (old_tool) { + old_tool->finish(); + delete old_tool; + } + + Inkscape::UI::Tools::ToolBase* new_tool = ToolFactory::instance().createObject(toolName); + new_tool->desktop = this; + new_tool->message_context = new Inkscape::MessageContext(this->messageStack()); + event_context = new_tool; new_tool->setup(); // Make sure no delayed snapping events are carried over after switching tools @@ -677,7 +676,7 @@ void SPDesktop::set_event_context2(const std::string& toolName) { // tool should take care of this by itself) sp_event_context_discard_delayed_snap_event(event_context); - _event_context_changed_signal.emit(this, event_context); + _event_context_changed_signal.emit(this, event_context); } /** -- cgit v1.2.3 From c31b1410b8b7d9059561e8102a38402a999f4aef Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Wed, 15 Jan 2014 13:21:45 +0100 Subject: Additional fix for Bug #1268778 (Move cursor disappears after clicking on Select Tool (F1) twice). Fixed bugs: - https://launchpad.net/bugs/1268778 (bzr r12932) --- src/desktop.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/desktop.cpp b/src/desktop.cpp index bc917c6f3..bf3b70d43 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -660,9 +660,16 @@ SPDesktop::change_document (SPDocument *theDocument) void SPDesktop::set_event_context2(const std::string& toolName) { Inkscape::UI::Tools::ToolBase* old_tool = event_context; + if (old_tool) { - old_tool->finish(); - delete old_tool; + if (toolName.compare(old_tool->pref_observer->observed_path) != 0) { + //g_message("Old tool: %s", old_tool->pref_observer->observed_path.c_str()); + //g_message("New tool: %s", toolName.c_str()); + old_tool->finish(); + delete old_tool; + } else { + return; + } } Inkscape::UI::Tools::ToolBase* new_tool = ToolFactory::instance().createObject(toolName); -- cgit v1.2.3 From 89a93a3c248c4fd116235137fffd50b192861821 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Wed, 15 Jan 2014 12:26:03 +0000 Subject: drop useless checks for hard Cairo version dependency (bzr r12933) --- src/extension/internal/cairo-ps-out.cpp | 4 ---- src/extension/internal/cairo-render-context.cpp | 4 ---- 2 files changed, 8 deletions(-) (limited to 'src') diff --git a/src/extension/internal/cairo-ps-out.cpp b/src/extension/internal/cairo-ps-out.cpp index 5f535dc64..055a30add 100644 --- a/src/extension/internal/cairo-ps-out.cpp +++ b/src/extension/internal/cairo-ps-out.cpp @@ -328,9 +328,7 @@ CairoPsOutput::init (void) "" SP_MODULE_KEY_PRINT_CAIRO_PS "\n" "\n" "<_item value='PS3'>" N_("PostScript level 3") "\n" -#if (CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 5, 2)) "<_item value='PS2'>" N_("PostScript level 2") "\n" -#endif "\n" "false\n" "false\n" @@ -369,9 +367,7 @@ CairoEpsOutput::init (void) "" SP_MODULE_KEY_PRINT_CAIRO_EPS "\n" "\n" "<_item value='PS3'>" N_("PostScript level 3") "\n" -#if (CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 5, 2)) "<_item value='PS2'>" N_("PostScript level 2") "\n" -#endif "\n" "false\n" "false\n" diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp index 4f9273cbb..47de62ac0 100644 --- a/src/extension/internal/cairo-render-context.cpp +++ b/src/extension/internal/cairo-render-context.cpp @@ -803,9 +803,7 @@ CairoRenderContext::setupSurface(double width, double height) #ifdef CAIRO_HAS_PDF_SURFACE case CAIRO_SURFACE_TYPE_PDF: surface = cairo_pdf_surface_create_for_stream(Inkscape::Extension::Internal::_write_callback, _stream, width, height); -#if (CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 10, 0)) cairo_pdf_surface_restrict_to_version(surface, (cairo_pdf_version_t)_pdf_level); -#endif break; #endif #ifdef CAIRO_HAS_PS_SURFACE @@ -814,10 +812,8 @@ CairoRenderContext::setupSurface(double width, double height) if(CAIRO_STATUS_SUCCESS != cairo_surface_status(surface)) { return FALSE; } -#if (CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 5, 2)) cairo_ps_surface_restrict_to_level(surface, (cairo_ps_level_t)_ps_level); cairo_ps_surface_set_eps(surface, (cairo_bool_t) _eps); -#endif // Cairo calculates the bounding box itself, however we want to override this. See Launchpad bug #380501 #if (CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 11, 2)) // cairo_ps_dsc_comment(surface, os_bbox.str().c_str()); -- cgit v1.2.3 From 9d40e9669a1024b7caed1db4c5ff99e06c96a57f Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Wed, 15 Jan 2014 16:26:12 +0100 Subject: Fix for Bug #1236282 (add full keyboard navigation support for new templates dialog). Fixed bugs: - https://launchpad.net/bugs/1236282 (bzr r12934) --- src/ui/dialog/new-from-template.cpp | 7 +++++-- src/ui/dialog/new-from-template.h | 3 +++ src/ui/dialog/template-load-tab.cpp | 7 ++++--- 3 files changed, 12 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/new-from-template.cpp b/src/ui/dialog/new-from-template.cpp index 177f15195..71d1c22d0 100644 --- a/src/ui/dialog/new-from-template.cpp +++ b/src/ui/dialog/new-from-template.cpp @@ -44,10 +44,13 @@ NewFromTemplate::NewFromTemplate() void NewFromTemplate::_createFromTemplate() { _main_widget.createTemplate(); - - response(0); + _onClose(); } +void NewFromTemplate::_onClose() +{ + response(0); +} void NewFromTemplate::load_new_from_template() { diff --git a/src/ui/dialog/new-from-template.h b/src/ui/dialog/new-from-template.h index 8ebcb2863..2b40af2a6 100644 --- a/src/ui/dialog/new-from-template.h +++ b/src/ui/dialog/new-from-template.h @@ -23,6 +23,8 @@ namespace UI { class NewFromTemplate : public Gtk::Dialog { + +friend class TemplateLoadTab; public: static void load_new_from_template(); @@ -32,6 +34,7 @@ private: TemplateLoadTab _main_widget; void _createFromTemplate(); + void _onClose(); }; } diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index 057eff337..1b9b734fc 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -10,6 +10,7 @@ #include "template-widget.h" #include "template-load-tab.h" +#include "new-from-template.h" #include #include @@ -31,10 +32,8 @@ #include "xml/document.h" #include "xml/node.h" - namespace Inkscape { namespace UI { - TemplateLoadTab::TemplateLoadTab() : _current_keyword("") @@ -84,7 +83,9 @@ void TemplateLoadTab::createTemplate() void TemplateLoadTab::_onRowActivated(const Gtk::TreeModel::Path &, Gtk::TreeViewColumn*) { - _info_widget->create(); + createTemplate(); + NewFromTemplate* parent = static_cast (this->get_toplevel()); + parent->_onClose(); } void TemplateLoadTab::_displayTemplateInfo() -- cgit v1.2.3 From 88d24fc0c21e087b6c460a0c1b58aac556c666e1 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Wed, 15 Jan 2014 17:33:48 +0100 Subject: Revert r12544. Fixes bug 1256449 (Clipping missing on Cairo-based exports). Note: 523285 is not a bug. (bzr r12935) --- src/extension/internal/cairo-renderer.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index 0a4c86f0b..6fbc85c05 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -580,9 +580,9 @@ void CairoRenderer::renderItem(CairoRenderContext *ctx, SPItem *item) setStateForItem(ctx, item); CairoRenderState *state = ctx->getCurrentState(); - state->need_layer = ( state->mask || state->opacity != 1.0 ); + state->need_layer = ( state->mask || state->clip_path || state->opacity != 1.0 ); - // Draw item on a temporary surface so a mask or opacity can be applied to it. + // Draw item on a temporary surface so a mask, clip-path, or opacity can be applied to it. if (state->need_layer) { state->merge_opacity = FALSE; ctx->pushLayer(); @@ -591,7 +591,7 @@ void CairoRenderer::renderItem(CairoRenderContext *ctx, SPItem *item) sp_item_invoke_render(item, ctx); if (state->need_layer) - ctx->popLayer(); + ctx->popLayer(); // This applies clipping/masking ctx->popState(); } -- cgit v1.2.3 From 82f4d9a7537fdb3267bf5570cd34aef0692b0f9f Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Wed, 15 Jan 2014 14:22:31 -0500 Subject: for rubberband outline, add shading instead of XOR (Bug 1266308) Fixed bugs: - https://launchpad.net/bugs/1266308 (bzr r12936) --- src/display/sodipodi-ctrlrect.cpp | 13 ++++++++++++- src/rubberband.cpp | 1 + src/selcue.cpp | 1 + src/ui/tools/text-tool.cpp | 1 + 4 files changed, 15 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/display/sodipodi-ctrlrect.cpp b/src/display/sodipodi-ctrlrect.cpp index c350e4614..e6e427047 100644 --- a/src/display/sodipodi-ctrlrect.cpp +++ b/src/display/sodipodi-ctrlrect.cpp @@ -142,7 +142,18 @@ void CtrlRect::render(SPCanvasBuf *buf) ink_cairo_set_source_rgba32(buf->ct, _border_color); cairo_stroke(buf->ct); - if (_shadow_size > 0) { + if (_shadow_size == 1) { // highlight the border by drawing it in _shadow_color + if (_dashed) { + cairo_set_dash(buf->ct, dashes, 2, 4); + cairo_rectangle(buf->ct, 0.5 + area[X].min(), 0.5 + area[Y].min(), + area[X].max() - area[X].min(), area[Y].max() - area[Y].min()); + } else { + cairo_rectangle(buf->ct, -0.5 + area[X].min(), -0.5 + area[Y].min(), + area[X].max() - area[X].min(), area[Y].max() - area[Y].min()); + } + ink_cairo_set_source_rgba32(buf->ct, _shadow_color); + cairo_stroke(buf->ct); + } else if (_shadow_size > 1) { // fill the shadow ink_cairo_set_source_rgba32(buf->ct, _shadow_color); cairo_rectangle(buf->ct, 1 + area[X].max(), area[Y].min() + _shadow_size, _shadow_size, area[Y].max() - area[Y].min() + 1); // right shadow diff --git a/src/rubberband.cpp b/src/rubberband.cpp index 08492837a..6ec4b3e45 100644 --- a/src/rubberband.cpp +++ b/src/rubberband.cpp @@ -99,6 +99,7 @@ void Inkscape::Rubberband::move(Geom::Point const &p) if (_mode == RUBBERBAND_MODE_RECT) { if (_rect == NULL) { _rect = static_cast(sp_canvas_item_new(sp_desktop_controls(_desktop), SP_TYPE_CTRLRECT, NULL)); + _rect->setShadow(1, 0xffffffff); } _rect->setRectangle(Geom::Rect(_start, _end)); diff --git a/src/selcue.cpp b/src/selcue.cpp index 3f8a93e21..805629636 100644 --- a/src/selcue.cpp +++ b/src/selcue.cpp @@ -177,6 +177,7 @@ void Inkscape::SelCue::_newItemBboxes() SP_CTRLRECT(box)->setRectangle(*b); SP_CTRLRECT(box)->setColor(0x000000a0, 0, 0); SP_CTRLRECT(box)->setDashed(true); + SP_CTRLRECT(box)->setShadow(1, 0xffffffff); sp_canvas_item_move_to_z(box, 0); } diff --git a/src/ui/tools/text-tool.cpp b/src/ui/tools/text-tool.cpp index 2927606a7..c73164c09 100644 --- a/src/ui/tools/text-tool.cpp +++ b/src/ui/tools/text-tool.cpp @@ -154,6 +154,7 @@ void TextTool::setup() { this->indicator = sp_canvas_item_new(sp_desktop_controls(desktop), SP_TYPE_CTRLRECT, NULL); SP_CTRLRECT(this->indicator)->setRectangle(Geom::Rect(Geom::Point(0, 0), Geom::Point(100, 100))); SP_CTRLRECT(this->indicator)->setColor(0x0000ff7f, false, 0); + SP_CTRLRECT(this->indicator)->setShadow(1, 0xffffff7f); sp_canvas_item_hide(this->indicator); this->frame = sp_canvas_item_new(sp_desktop_controls(desktop), SP_TYPE_CTRLRECT, NULL); -- cgit v1.2.3 From d1a182e5e94e5967d1ef19519e25e41ed81f3e9e Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Wed, 15 Jan 2014 22:08:27 +0100 Subject: i18n. New from Template entries now translatable (see Bug #383844). POT file and French translation updated. Fixed bugs: - https://launchpad.net/bugs/383844 (bzr r12937) --- src/ui/dialog/template-load-tab.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index 1b9b734fc..4f2d51ef7 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -291,26 +291,26 @@ void TemplateLoadTab::_getDataFromNode(Inkscape::XML::Node *dataNode, TemplateDa { Inkscape::XML::Node *currentData; if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:_name")) != NULL) - data.display_name = dgettext("Document template name", currentData->firstChild()->content()); + data.display_name = _(currentData->firstChild()->content()); if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:author")) != NULL) data.author = currentData->firstChild()->content(); if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:_shortdesc")) != NULL) - data.short_description = dgettext("Document template short description", currentData->firstChild()->content()); + data.short_description = _( currentData->firstChild()->content()); if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:_long") )!= NULL) - data.long_description = dgettext("Document template long description", currentData->firstChild()->content()); + data.long_description = _(currentData->firstChild()->content()); if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:preview")) != NULL) data.preview_name = currentData->firstChild()->content(); if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:date")) != NULL) data.creation_date = currentData->firstChild()->content(); if ((currentData = sp_repr_lookup_name(dataNode, "inkscape:_keywords")) != NULL){ - Glib::ustring tplKeywords = currentData->firstChild()->content(); + Glib::ustring tplKeywords = _(currentData->firstChild()->content()); while (!tplKeywords.empty()){ std::size_t pos = tplKeywords.find_first_of(" "); if (pos == Glib::ustring::npos) pos = tplKeywords.size(); - Glib::ustring keyword = dgettext("Document template keyword", tplKeywords.substr(0, pos).data()); + Glib::ustring keyword = tplKeywords.substr(0, pos).data(); data.keywords.insert(keyword.lowercase()); _keywords.insert(keyword.lowercase()); -- cgit v1.2.3 From b31224a81f04f0ff9b412983f2f35fa63c0e7e41 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Thu, 16 Jan 2014 12:20:34 -0500 Subject: Add the ability to load external documents in xlink:hrefs such as the use element. See bug #1269880 Fixed bugs: - https://launchpad.net/bugs/1269880 (bzr r12939) --- src/uri-references.cpp | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/uri-references.cpp b/src/uri-references.cpp index 2c09695d4..718b2d451 100644 --- a/src/uri-references.cpp +++ b/src/uri-references.cpp @@ -12,6 +12,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include #include #include @@ -21,6 +22,7 @@ #include "uri-references.h" #include "extract-uri.h" +#include #include namespace Inkscape { @@ -45,15 +47,31 @@ URIReference::~URIReference() void URIReference::attach(const URI &uri) throw(BadURIException) { - SPDocument *document; + SPDocument *document = NULL; + + // Attempt to get the document that contains the URI if (_owner) { document = _owner->document; } else if (_owner_document) { document = _owner_document; - } else { - g_assert_not_reached(); } + // The path contains references to seperate document files to load. + const char *path = uri.getPath(); + if(path) { + if(document != NULL) { + // Calculate the absolute path from an available document + std::string basePath = std::string( document->getBase() ); + std::string absPath = Glib::build_filename(basePath, std::string( path ) ); + path = absPath.c_str(); + } + // TODO: This is inefficient because it will load the same svg file + // many times if it's used many times. A global list of documents would + // be useful for tracking linked items. + document = SPDocument::createNewDoc(path, FALSE); + } + g_return_if_fail(document != NULL); + gchar const *fragment = uri.getFragment(); if ( !uri.isRelative() || uri.getQuery() || !fragment ) { throw UnsupportedURIException(); -- cgit v1.2.3 From 096e6a7b96509afc811c4dafef94b53ccbb15638 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Thu, 16 Jan 2014 18:45:17 +0100 Subject: 2geom: remove accidentally forgotten debug message (bzr r12940) --- src/2geom/nearest-point.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/2geom/nearest-point.cpp b/src/2geom/nearest-point.cpp index 75e1ebaad..c5dfc133c 100644 --- a/src/2geom/nearest-point.cpp +++ b/src/2geom/nearest-point.cpp @@ -61,7 +61,7 @@ double nearest_point( Point const& p, } if (c.isConstant()) return from; SBasis dd = dot(c - p, dc); - std::cout << dd << std::endl; + //std::cout << dd << std::endl; std::vector zeros = Geom::roots(dd); double closest = from; -- cgit v1.2.3 From ca96c851e8a89543a49a96f2b02cd43fe3fb124c Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Thu, 16 Jan 2014 20:43:44 +0100 Subject: Fixing edit-clear icon in the star tool (partial fix for Bug #1269698). Fixed bugs: - https://launchpad.net/bugs/1269698 (bzr r12941) --- src/widgets/star-toolbar.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/widgets/star-toolbar.cpp b/src/widgets/star-toolbar.cpp index 1691a9b25..28b2c7e0c 100644 --- a/src/widgets/star-toolbar.cpp +++ b/src/widgets/star-toolbar.cpp @@ -568,13 +568,14 @@ void sp_star_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje { /* Reset */ { - GtkAction* act = gtk_action_new( "StarResetAction", + InkAction* inky = ink_action_new( "StarResetAction", _("Defaults"), _("Reset shape parameters to defaults (use Inkscape Preferences > Tools to change defaults)"), - INKSCAPE_ICON("edit-clear")); - g_signal_connect_after( G_OBJECT(act), "activate", G_CALLBACK(sp_stb_defaults), holder ); - gtk_action_group_add_action( mainActions, act ); - gtk_action_set_sensitive( act, TRUE ); + INKSCAPE_ICON("edit-clear"), + Inkscape::ICON_SIZE_SMALL_TOOLBAR); + g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_stb_defaults), holder ); + gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); + gtk_action_set_sensitive( GTK_ACTION(inky), TRUE ); } } -- cgit v1.2.3 From d41eb702951c69bfd362e70bd072a869bf73967a Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Thu, 16 Jan 2014 16:05:23 -0500 Subject: Clean up sp-image's read_image, remove duplicate code (bzr r12942) --- src/sp-image.cpp | 57 ++++++++++++++------------------------------------------ 1 file changed, 14 insertions(+), 43 deletions(-) (limited to 'src') diff --git a/src/sp-image.cpp b/src/sp-image.cpp index 8f7a60ca6..9044257f4 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -649,56 +649,27 @@ Inkscape::DrawingItem* SPImage::show(Inkscape::Drawing &drawing, unsigned int /* Inkscape::Pixbuf *sp_image_repr_read_image(gchar const *href, gchar const *absref, gchar const *base) { Inkscape::Pixbuf *inkpb = 0; - gchar const *filename = href; - + if (filename != NULL) { if (strncmp (filename,"file:",5) == 0) { - gchar *fullname = g_filename_from_uri(filename, NULL, NULL); - if (fullname) { - inkpb = Inkscape::Pixbuf::create_from_file(fullname); - g_free(fullname); - if (inkpb != NULL) { - return inkpb; - } - } + filename = g_filename_from_uri(filename, NULL, NULL); } else if (strncmp (filename,"data:",5) == 0) { /* data URI - embedded image */ filename += 5; - inkpb = Inkscape::Pixbuf::create_from_data_uri(filename); - if (inkpb != NULL) { - return inkpb; - } - } else { - - if (!g_path_is_absolute (filename)) { - /* try to load from relative pos combined with document base*/ - const gchar *docbase = base; - if (!docbase) { - docbase = "."; - } - gchar *fullname = g_build_filename(docbase, filename, NULL); - - // document base can be wrong (on the temporary doc when importing bitmap from a - // different dir) or unset (when doc is not saved yet), so we check for base+href existence first, - // and if it fails, we also try to use bare href regardless of its g_path_is_absolute - if (g_file_test (fullname, G_FILE_TEST_EXISTS) && !g_file_test (fullname, G_FILE_TEST_IS_DIR)) { - inkpb = Inkscape::Pixbuf::create_from_file(fullname); - if (inkpb != NULL) { - g_free (fullname); - return inkpb; - } - } - g_free (fullname); - } + } else if (!g_path_is_absolute (filename)) { + /* try to load from relative pos combined with document base*/ + const gchar *docbase = base; + if (!docbase) docbase = "."; + filename = g_build_filename(docbase, filename, NULL); + } + } - /* try filename as absolute */ - if (g_file_test (filename, G_FILE_TEST_EXISTS) && !g_file_test (filename, G_FILE_TEST_IS_DIR)) { - inkpb = Inkscape::Pixbuf::create_from_file(filename); - if (inkpb != NULL) { - return inkpb; - } - } + if (filename && g_file_test(filename, G_FILE_TEST_EXISTS) ) { + inkpb = Inkscape::Pixbuf::create_from_file(filename); + if (inkpb != NULL) { + // g_free filename? + return inkpb; } } -- cgit v1.2.3 From 4531eff8dbddaabfb1c67d7907879480a8fd7309 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Thu, 16 Jan 2014 22:12:33 +0100 Subject: fix null pointer dereference (bzr r12943) --- src/ui/tools/gradient-tool.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/ui/tools/gradient-tool.cpp b/src/ui/tools/gradient-tool.cpp index e4ab7b424..10f78a8a8 100644 --- a/src/ui/tools/gradient-tool.cpp +++ b/src/ui/tools/gradient-tool.cpp @@ -339,10 +339,12 @@ sp_gradient_context_add_stops_between_selected_stops (GradientTool *rc) SPGradient *gradient = getGradient(d->item, d->fill_or_stroke); SPGradient *vector = sp_gradient_get_forked_vector_if_necessary (gradient, false); SPStop *this_stop = sp_get_stop_i (vector, d->point_i); - SPStop *next_stop = this_stop->getNextStop(); - if (this_stop && next_stop) { - these_stops = g_slist_prepend (these_stops, this_stop); - next_stops = g_slist_prepend (next_stops, next_stop); + if (this_stop) { + SPStop *next_stop = this_stop->getNextStop(); + if (next_stop) { + these_stops = g_slist_prepend (these_stops, this_stop); + next_stops = g_slist_prepend (next_stops, next_stop); + } } } } -- cgit v1.2.3 From 79faac5dcf70ef3c046787805959d1cbfe00af02 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Thu, 16 Jan 2014 22:25:19 +0100 Subject: prevent compiler warnings (bzr r12944) --- src/filters/mergenode.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/filters/mergenode.cpp b/src/filters/mergenode.cpp index 1b06db706..ba237c776 100644 --- a/src/filters/mergenode.cpp +++ b/src/filters/mergenode.cpp @@ -45,7 +45,7 @@ SPFeMergeNode::~SPFeMergeNode() { * our name must be associated with a repr via "sp_object_type_register". Best done through * sp-object-repr.cpp's repr_name_entries array. */ -void SPFeMergeNode::build(SPDocument *document, Inkscape::XML::Node *repr) { +void SPFeMergeNode::build(SPDocument */*document*/, Inkscape::XML::Node */*repr*/) { this->readAttr( "in" ); } -- cgit v1.2.3 From 47edb3f774f4eca0716960c66cdcdea3954c86b1 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Thu, 16 Jan 2014 22:31:43 -0500 Subject: More cleaning of the image tag handler and seperate filename from load. (bzr r12945) --- src/sp-image.cpp | 50 ++++++++++++++++++++++++-------------------------- 1 file changed, 24 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/sp-image.cpp b/src/sp-image.cpp index 9044257f4..f4995ce31 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -24,6 +24,7 @@ #include <2geom/rect.h> #include <2geom/transforms.h> #include +#include #include "display/drawing-image.h" #include "display/cairo-utils.h" @@ -75,7 +76,7 @@ static void sp_image_set_curve(SPImage *image); -static Inkscape::Pixbuf *sp_image_repr_read_image(gchar const *href, gchar const *absref, gchar const *base ); +gchar const *sp_image_repr_read_filename(gchar const *href, gchar const *absref, gchar const *base ); static void sp_image_update_arenaitem (SPImage *img, Inkscape::DrawingImage *ai); static void sp_image_update_canvas_image (SPImage *image); @@ -333,11 +334,26 @@ void SPImage::update(SPCtx *ctx, unsigned int flags) { if (this->href) { Inkscape::Pixbuf *pixbuf = NULL; - pixbuf = sp_image_repr_read_image ( + + gchar const* filename = sp_image_repr_read_filename ( this->getRepr()->attribute("xlink:href"), this->getRepr()->attribute("sodipodi:absref"), doc->getBase()); - + + if(filename && g_str_has_suffix(filename, ".svg")) { + // TODO: We want to deal with svg images properly. This + // space allows us to do so later. + g_warning("Including svg images tags is not yet supported."); + } else if (filename) { + pixbuf = Inkscape::Pixbuf::create_from_file(filename); + } else { + /* Nope: We do not find any valid pixmap file :-( */ + pixbuf = new Inkscape::Pixbuf( + gdk_pixbuf_new_from_xpm_data((const gchar **) brokenimage_xpm)); + + /* If the xpm doesn't load, our libraries are broken */ + g_assert (pixbuf != NULL); + } if (pixbuf) { // BLIP #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) @@ -646,9 +662,8 @@ Inkscape::DrawingItem* SPImage::show(Inkscape::Drawing &drawing, unsigned int /* return ai; } -Inkscape::Pixbuf *sp_image_repr_read_image(gchar const *href, gchar const *absref, gchar const *base) +gchar const *sp_image_repr_read_filename(gchar const *href, gchar const *absref, gchar const *base) { - Inkscape::Pixbuf *inkpb = 0; gchar const *filename = href; if (filename != NULL) { @@ -666,37 +681,20 @@ Inkscape::Pixbuf *sp_image_repr_read_image(gchar const *href, gchar const *absre } if (filename && g_file_test(filename, G_FILE_TEST_EXISTS) ) { - inkpb = Inkscape::Pixbuf::create_from_file(filename); - if (inkpb != NULL) { - // g_free filename? - return inkpb; - } + return filename; } /* at last try to load from sp absolute path name */ - filename = absref; - if (filename != NULL) { + if (absref != NULL && g_file_test(absref, G_FILE_TEST_EXISTS)) { // using absref is outside of SVG rules, so we must at least warn the user if ( base != NULL && href != NULL ) { g_warning (" did not resolve to a valid image file (base dir is %s), now trying sodipodi:absref=\"%s\"", href, base, absref); } else { g_warning ("xlink:href did not resolve to a valid image file, now trying sodipodi:absref=\"%s\"", absref); } - - inkpb = Inkscape::Pixbuf::create_from_file(filename); - if (inkpb != NULL) { - return inkpb; - } + return absref; } - /* Nope: We do not find any valid pixmap file :-( */ - GdkPixbuf *pixbuf = gdk_pixbuf_new_from_xpm_data((const gchar **) brokenimage_xpm); - inkpb = new Inkscape::Pixbuf(pixbuf); - - /* It should be included xpm, so if it still does not does load, */ - /* our libraries are broken */ - g_assert (inkpb != NULL); - - return inkpb; + return NULL; } /* We assert that realpixbuf is either NULL or identical size to pixbuf */ -- cgit v1.2.3 From 90867e5163a560f8905badd1a91f1688b6d9b36c Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Fri, 17 Jan 2014 14:29:51 +0100 Subject: i18n. Symbols are now translatable (see Bug #1261198); POT file and French translation updated. (bzr r12946) --- src/ui/dialog/symbols.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index 2f2652bb1..9a154209e 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -538,7 +538,8 @@ void SymbolsDialog::get_symbols() { gchar *fullname = g_build_filename((*it).c_str(), filename, NULL); - if ( !Inkscape::IO::file_test( fullname, G_FILE_TEST_IS_DIR ) ) { + if ( !Inkscape::IO::file_test( fullname, G_FILE_TEST_IS_DIR ) + && ( Glib::str_has_suffix(fullname, ".svg") || Glib::str_has_suffix(fullname, ".vss") ) ) { Glib::ustring fn( filename ); Glib::ustring tag = fn.substr( fn.find_last_of(".") + 1 ); @@ -560,7 +561,7 @@ void SymbolsDialog::get_symbols() { symbol_doc = SPDocument::createNewDoc( fullname, FALSE ); if( symbol_doc ) { - gchar *title = symbol_doc->getRoot()->title(); + const gchar *title = g_dpgettext2(NULL, "Symbol", symbol_doc->getRoot()->title()); if( title == NULL ) { title = _("Unnamed Symbols"); } @@ -675,7 +676,7 @@ void SymbolsDialog::add_symbol( SPObject* symbol ) { if( pixbuf ) { Gtk::ListStore::iterator row = store->append(); (*row)[columns->symbol_id] = Glib::ustring( id ); - (*row)[columns->symbol_title] = Glib::ustring( title ); + (*row)[columns->symbol_title] = Glib::ustring( g_dpgettext2(NULL, "Symbol", title) ); (*row)[columns->symbol_image] = pixbuf; } -- cgit v1.2.3 From 34414ec8b460d990ba48b3ed6a8e94dccc260d1f Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Fri, 17 Jan 2014 19:02:54 +0100 Subject: GTK3 build error in symbols.cpp. (bzr r12949) --- src/ui/dialog/symbols.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index 9a154209e..be22c1c5b 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -49,6 +49,7 @@ #include "symbols.h" +#include "filedialog.h" #include "selection.h" #include "desktop.h" #include "desktop-handles.h" @@ -539,7 +540,7 @@ void SymbolsDialog::get_symbols() { gchar *fullname = g_build_filename((*it).c_str(), filename, NULL); if ( !Inkscape::IO::file_test( fullname, G_FILE_TEST_IS_DIR ) - && ( Glib::str_has_suffix(fullname, ".svg") || Glib::str_has_suffix(fullname, ".vss") ) ) { + && ( hasSuffix(fullname, ".svg") || hasSuffix(fullname, ".vss") ) ) { Glib::ustring fn( filename ); Glib::ustring tag = fn.substr( fn.find_last_of(".") + 1 ); -- cgit v1.2.3 From ab4ca32239250dd70c615ec37dad2a552b66038c Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Fri, 17 Jan 2014 19:07:22 +0100 Subject: Better fix for GTK3 build error in symbols.cpp. (bzr r12950) --- src/ui/dialog/symbols.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index be22c1c5b..c33920117 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include "path-prefix.h" @@ -49,7 +50,6 @@ #include "symbols.h" -#include "filedialog.h" #include "selection.h" #include "desktop.h" #include "desktop-handles.h" @@ -540,7 +540,7 @@ void SymbolsDialog::get_symbols() { gchar *fullname = g_build_filename((*it).c_str(), filename, NULL); if ( !Inkscape::IO::file_test( fullname, G_FILE_TEST_IS_DIR ) - && ( hasSuffix(fullname, ".svg") || hasSuffix(fullname, ".vss") ) ) { + && ( Glib::str_has_suffix(fullname, ".svg") || Glib::str_has_suffix(fullname, ".vss") ) ) { Glib::ustring fn( filename ); Glib::ustring tag = fn.substr( fn.find_last_of(".") + 1 ); -- cgit v1.2.3 From 497bc9a5b7d4501902052ec5df39197f73082c38 Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Fri, 17 Jan 2014 14:06:02 -0500 Subject: avoid singularity when scaling horizontal or vertical line. (Bug 1262146) Fixed bugs: - https://launchpad.net/bugs/1262146 (bzr r12951) --- src/sp-item-transform.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/sp-item-transform.cpp b/src/sp-item-transform.cpp index 250713beb..9dbe412d7 100644 --- a/src/sp-item-transform.cpp +++ b/src/sp-item-transform.cpp @@ -132,7 +132,7 @@ Geom::Affine get_scale_transform_for_uniform_stroke(Geom::Rect const &bbox_visua // We will now try to calculate the affine transformation required to transform the first visual bounding box into // the second one, while accounting for strokewidth - if ((fabs(w0 - r0) < 1e-6) && (fabs(h0 - r0) < 1e-6)) { + if ((fabs(w0 - stroke_x) < 1e-6) && (fabs(h0 - stroke_y) < 1e-6)) { return Geom::Affine(); } @@ -140,11 +140,11 @@ Geom::Affine get_scale_transform_for_uniform_stroke(Geom::Rect const &bbox_visua gdouble scale_y = 1; gdouble r1 = r0; - if ((fabs(w0 - r0) < 1e-6) || w1 == 0) { // We have a vertical line at hand + if ((fabs(w0 - stroke_x) < 1e-6) || w1 == 0) { // We have a vertical line at hand r1 = transform_stroke ? r0 * sqrt(h1/h0) : r0; scale_x = 1; scale_y = preserve ? h1/h0 : (h1 - r1)/(h0 - r0); - } else if ((fabs(h0 - r0) < 1e-6) || h1 == 0) { // We have a horizontal line at hand + } else if ((fabs(h0 - stroke_y) < 1e-6) || h1 == 0) { // We have a horizontal line at hand r1 = transform_stroke ? r0 * sqrt(w1/w0) : r0; scale_x = preserve ? w1/w0 : (w1 - r1)/(w0 - r0); scale_y = 1; -- cgit v1.2.3 From 0eb7cf56b9229a6bcc6c79574d2ac58413c46049 Mon Sep 17 00:00:00 2001 From: kris-degussem <> Date: Fri, 17 Jan 2014 20:27:53 +0100 Subject: i18n. Fix for Bug #1269943 (Context for message Offset:). Fixed bugs: - https://launchpad.net/bugs/1269943 (bzr r12952) --- src/widgets/gradient-toolbar.cpp | 2 +- src/widgets/gradient-vector.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp index 8fa29e60a..4bed3101d 100644 --- a/src/widgets/gradient-toolbar.cpp +++ b/src/widgets/gradient-toolbar.cpp @@ -1171,7 +1171,7 @@ void sp_gradient_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, { EgeAdjustmentAction* eact = 0; eact = create_adjustment_action( "GradientEditOffsetAction", - _("Offset"), _("Offset:"), _("Offset of selected stop"), + _("Offset"), C_("Gradient", "Offset:"), _("Offset of selected stop"), "/tools/gradient/stopoffset", 0, GTK_WIDGET(desktop->canvas), holder, FALSE, NULL, 0.0, 1.0, 0.01, 0.1, diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp index e9fc426f6..17ac887c4 100644 --- a/src/widgets/gradient-vector.cpp +++ b/src/widgets/gradient-vector.cpp @@ -923,7 +923,7 @@ static GtkWidget * sp_gradient_vector_widget_new(SPGradient *gradient, SPStop *s #endif /* Label */ - GtkWidget *l = gtk_label_new(_("Offset:")); + GtkWidget *l = gtk_label_new(C_("Gradient","Offset:")); gtk_misc_set_alignment(GTK_MISC(l), 1.0, 0.5); gtk_box_pack_start(GTK_BOX(hb),l, FALSE, FALSE, AUX_BETWEEN_BUTTON_GROUPS); gtk_widget_show(l); -- cgit v1.2.3 From 0564ac341f92d0d892d046a9096ac50fb0a9a27d Mon Sep 17 00:00:00 2001 From: David Mathog Date: Sat, 18 Jan 2014 00:24:11 +0100 Subject: libUEMF update; EMF linear gradient bug fixes (bug #1263242) Fixed bugs: - https://launchpad.net/bugs/1263242 (bzr r12953) --- src/extension/CMakeLists.txt | 1 + src/extension/internal/Makefile_insert | 2 + src/extension/internal/emf-inout.cpp | 618 ++- src/extension/internal/emf-inout.h | 43 +- src/extension/internal/emf-print.cpp | 417 +- src/extension/internal/emf-print.h | 5 + src/extension/internal/metafile-inout.cpp | 210 + src/extension/internal/metafile-inout.h | 93 + src/extension/internal/metafile-print.cpp | 4 +- src/extension/internal/wmf-inout.cpp | 150 +- src/extension/internal/wmf-inout.h | 39 +- src/extension/internal/wmf-print.cpp | 116 +- src/libuemf/CMakeLists.txt | 4 + src/libuemf/Makefile_insert | 4 + src/libuemf/README | 480 +- src/libuemf/uemf.c | 72 +- src/libuemf/uemf.h | 2940 ++++++----- src/libuemf/uemf_endian.c | 52 +- src/libuemf/uemf_endian.h | 31 +- src/libuemf/uemf_print.c | 239 +- src/libuemf/uemf_print.h | 217 +- src/libuemf/uemf_utf.c | 6 +- src/libuemf/uemf_utf.h | 4 +- src/libuemf/upmf.c | 8057 +++++++++++++++++++++++++++++ src/libuemf/upmf.h | 3177 ++++++++++++ src/libuemf/upmf_print.c | 3138 +++++++++++ src/libuemf/upmf_print.h | 180 + src/libuemf/uwmf.c | 429 +- src/libuemf/uwmf.h | 1338 ++--- src/libuemf/uwmf_endian.c | 13 +- src/libuemf/uwmf_endian.h | 19 +- src/libuemf/uwmf_print.c | 40 +- src/libuemf/uwmf_print.h | 8 +- 33 files changed, 19226 insertions(+), 2920 deletions(-) create mode 100644 src/extension/internal/metafile-inout.cpp create mode 100644 src/extension/internal/metafile-inout.h create mode 100644 src/libuemf/upmf.c create mode 100644 src/libuemf/upmf.h create mode 100644 src/libuemf/upmf_print.c create mode 100644 src/libuemf/upmf_print.h (limited to 'src') diff --git a/src/extension/CMakeLists.txt b/src/extension/CMakeLists.txt index 6310ceaea..9bc30a592 100644 --- a/src/extension/CMakeLists.txt +++ b/src/extension/CMakeLists.txt @@ -45,6 +45,7 @@ set(extension_SRC internal/image-resolution.cpp internal/latex-pstricks.cpp internal/latex-pstricks-out.cpp + internal/metafile-inout.cpp internal/metafile-print.cpp internal/odf.cpp internal/latex-text-renderer.cpp diff --git a/src/extension/internal/Makefile_insert b/src/extension/internal/Makefile_insert index 726bca28f..a31843114 100644 --- a/src/extension/internal/Makefile_insert +++ b/src/extension/internal/Makefile_insert @@ -162,6 +162,8 @@ ink_common_sources += \ extension/internal/emf-print.cpp \ extension/internal/emf-inout.h \ extension/internal/emf-inout.cpp \ + extension/internal/metafile-inout.h \ + extension/internal/metafile-inout.cpp \ extension/internal/metafile-print.h \ extension/internal/metafile-print.cpp \ extension/internal/wmf-print.h \ diff --git a/src/extension/internal/emf-inout.cpp b/src/extension/internal/emf-inout.cpp index c8c708051..cca541c5b 100644 --- a/src/extension/internal/emf-inout.cpp +++ b/src/extension/internal/emf-inout.cpp @@ -26,7 +26,7 @@ # include "config.h" #endif -#include //This must precede text_reassemble.h or it blows up in pngconf.h when compiling +//#include //This must precede text_reassemble.h or it blows up in pngconf.h when compiling #include #include #include @@ -69,154 +69,6 @@ static bool clipset = false; static uint32_t ICMmode = 0; // not used yet, but code to read it from EMF implemented static uint32_t BLTmode = 0; -/** Construct a PNG in memory from an RGB from the EMF file - -from: -http://www.lemoda.net/c/write-png/ - -which was based on: -http://stackoverflow.com/questions/1821806/how-to-encode-png-to-buffer-using-libpng - -gcc -Wall -o testpng testpng.c -lpng - -Originally here, but moved up - -#include -#include -#include -#include -*/ - - -/* Given "bitmap", this returns the pixel of bitmap at the point - ("x", "y"). */ - -pixel_t * Emf::pixel_at (bitmap_t * bitmap, int x, int y) -{ - return bitmap->pixels + bitmap->width * y + x; -} - - -/* Write "bitmap" to a PNG file specified by "path"; returns 0 on - success, non-zero on error. */ - -void -Emf::my_png_write_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - PMEMPNG p=(PMEMPNG)png_get_io_ptr(png_ptr); - - size_t nsize = p->size + length; - - /* allocate or grow buffer */ - if(p->buffer){ p->buffer = (char *) realloc(p->buffer, nsize); } - else{ p->buffer = (char *) malloc(nsize); } - - if(!p->buffer){ png_error(png_ptr, "Write Error"); } - - /* copy new bytes to end of buffer */ - memcpy(p->buffer + p->size, data, length); - p->size += length; -} - -void Emf::toPNG(PMEMPNG accum, int width, int height, const char *px){ - bitmap_t bmStore; - bitmap_t *bitmap = &bmStore; - accum->buffer=NULL; // PNG constructed in memory will end up here, caller must free(). - accum->size=0; - bitmap->pixels=(pixel_t *)px; - bitmap->width = width; - bitmap->height = height; - - png_structp png_ptr = NULL; - png_infop info_ptr = NULL; - size_t x, y; - png_byte ** row_pointers = NULL; - /* The following number is set by trial and error only. I cannot - see where it it is documented in the libpng manual. - */ - int pixel_size = 3; - int depth = 8; - - png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - if (png_ptr == NULL){ - accum->buffer=NULL; - return; - } - - info_ptr = png_create_info_struct (png_ptr); - if (info_ptr == NULL){ - png_destroy_write_struct (&png_ptr, &info_ptr); - accum->buffer=NULL; - return; - } - - /* Set up error handling. */ - - if (setjmp (png_jmpbuf (png_ptr))) { - png_destroy_write_struct (&png_ptr, &info_ptr); - accum->buffer=NULL; - return; - } - - /* Set image attributes. */ - - png_set_IHDR ( - png_ptr, - info_ptr, - bitmap->width, - bitmap->height, - depth, - PNG_COLOR_TYPE_RGB, - PNG_INTERLACE_NONE, - PNG_COMPRESSION_TYPE_DEFAULT, - PNG_FILTER_TYPE_DEFAULT - ); - - /* Initialize rows of PNG. */ - - row_pointers = (png_byte **) png_malloc (png_ptr, bitmap->height * sizeof (png_byte *)); - for (y = 0; y < bitmap->height; ++y) { - png_byte *row = - (png_byte *) png_malloc (png_ptr, sizeof (uint8_t) * bitmap->width * pixel_size); - row_pointers[bitmap->height - y - 1] = row; // Row order in EMF is reversed. - for (x = 0; x < bitmap->width; ++x) { - pixel_t * pixel = pixel_at (bitmap, x, y); - *row++ = pixel->red; // R & B channels were set correctly by DIB_to_RGB - *row++ = pixel->green; - *row++ = pixel->blue; - } - } - - /* Write the image data to memory */ - - png_set_rows (png_ptr, info_ptr, row_pointers); - - png_set_write_fn(png_ptr, accum, my_png_write_data, NULL); - - png_write_png (png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, NULL); - - for (y = 0; y < bitmap->height; y++) { - png_free (png_ptr, row_pointers[y]); - } - png_free (png_ptr, row_pointers); - png_destroy_write_struct(&png_ptr, &info_ptr); - -} - - -/* convert an EMF RGB(A) color to 0RGB -inverse of gethexcolor() in emf-print.cpp -*/ -uint32_t Emf::sethexcolor(U_COLORREF color){ - - uint32_t out; - out = (U_RGBAGetR(color) << 16) + - (U_RGBAGetG(color) << 8 ) + - (U_RGBAGetB(color) ); - return(out); -} - - Emf::Emf (void) // The null constructor { return; @@ -298,6 +150,7 @@ Emf::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar const *filena // reserve FixPPT2 for opacity bug. Currently EMF does not export opacity values bool new_FixPPTDashLine = mod->get_param_bool("FixPPTDashLine"); // dashed line bug bool new_FixPPTGrad2Polys = mod->get_param_bool("FixPPTGrad2Polys"); // gradient bug + bool new_FixPPTLinGrad = mod->get_param_bool("FixPPTLinGrad"); // allow native rectangular linear gradient bool new_FixPPTPatternAsHatch = mod->get_param_bool("FixPPTPatternAsHatch"); // force all patterns as standard EMF hatch bool new_FixImageRot = mod->get_param_bool("FixImageRot"); // remove rotations on images @@ -311,6 +164,7 @@ Emf::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar const *filena ext->set_param_bool("FixPPTCharPos",new_FixPPTCharPos); // Remember to add any new ones to PrintEmf::init or a mysterious failure will result! ext->set_param_bool("FixPPTDashLine",new_FixPPTDashLine); ext->set_param_bool("FixPPTGrad2Polys",new_FixPPTGrad2Polys); + ext->set_param_bool("FixPPTLinGrad",new_FixPPTLinGrad); ext->set_param_bool("FixPPTPatternAsHatch",new_FixPPTPatternAsHatch); ext->set_param_bool("FixImageRot",new_FixImageRot); ext->set_param_bool("textToPath", new_val); @@ -615,10 +469,10 @@ uint32_t Emf::add_image(PEMF_CALLBACK_DATA d, void *pEmr, uint32_t cbBits, uint uint32_t iUsage, uint32_t offBits, uint32_t offBmi){ uint32_t idx; - char imagename[64]; // big enough - char imrotname[64]; // big enough - char xywh[64]; // big enough - int dibparams; + char imagename[64]; // big enough + char imrotname[64]; // big enough + char xywh[64]; // big enough + int dibparams = U_BI_UNKNOWN; // type of image not yet determined MEMPNG mempng; // PNG in memory comes back in this mempng.buffer = NULL; @@ -627,74 +481,60 @@ uint32_t Emf::add_image(PEMF_CALLBACK_DATA d, void *pEmr, uint32_t cbBits, uint const char *px = NULL; // DIB pixels const U_RGBQUAD *ct = NULL; // DIB color table U_RGBQUAD ct2[2]; - uint32_t width, height, colortype, numCt, invert; - if( !cbBits || - !cbBmi || - (iUsage != U_DIB_RGB_COLORS) || - !(dibparams = get_DIB_params( // this returns pointers and values, but allocates no memory - pEmr, - offBits, - offBmi, - &px, - (const U_RGBQUAD **) &ct, - &numCt, - &width, - &height, - &colortype, - &invert - )) - ){ + uint32_t width, height, colortype, numCt, invert; // if needed these values will be set in get_DIB_params + if(cbBits && cbBmi && (iUsage == U_DIB_RGB_COLORS)){ + // next call returns pointers and values, but allocates no memory + dibparams = get_DIB_params(pEmr, offBits, offBmi, &px, (const U_RGBQUAD **) &ct, + &numCt, &width, &height, &colortype, &invert); + if(dibparams ==U_BI_RGB){ + // U_EMRCREATEMONOBRUSH uses text/bk colors instead of what is in the color map. + if(((PU_EMR)pEmr)->iType == U_EMR_CREATEMONOBRUSH){ + if(numCt==2){ + ct2[0] = U_RGB2BGR(d->dc[d->level].textColor); + ct2[1] = U_RGB2BGR(d->dc[d->level].bkColor); + ct = &ct2[0]; + } + else { // This record is invalid, nothing more to do here, let caller handle it + return(U_EMR_INVALID); + } + } - // U_EMRCREATEMONOBRUSH uses text/bk colors instead of what is in the color map. - if(((PU_EMR)pEmr)->iType == U_EMR_CREATEMONOBRUSH){ - if(numCt==2){ - ct2[0] = U_RGB2BGR(d->dc[d->level].textColor); - ct2[1] = U_RGB2BGR(d->dc[d->level].bkColor); - ct = &ct2[0]; - } - else { // createmonobrush renders on other platforms this way - return(0xFFFFFFFF); - } - } - - if(!DIB_to_RGBA( - px, // DIB pixel array - ct, // DIB color table - numCt, // DIB color table number of entries - &rgba_px, // U_RGBA pixel array (32 bits), created by this routine, caller must free. - width, // Width of pixel array in record - height, // Height of pixel array in record - colortype, // DIB BitCount Enumeration - numCt, // Color table used if not 0 - invert // If DIB rows are in opposite order from RGBA rows - ) && - rgba_px - ){ - toPNG( // Get the image from the RGBA px into mempng - &mempng, - width, height, // of the SRC bitmap - rgba_px - ); - free(rgba_px); + if(!DIB_to_RGBA( + px, // DIB pixel array + ct, // DIB color table + numCt, // DIB color table number of entries + &rgba_px, // U_RGBA pixel array (32 bits), created by this routine, caller must free. + width, // Width of pixel array in record + height, // Height of pixel array in record + colortype, // DIB BitCount Enumeration + numCt, // Color table used if not 0 + invert // If DIB rows are in opposite order from RGBA rows + )){ + toPNG( // Get the image from the RGBA px into mempng + &mempng, + width, height, // of the SRC bitmap + rgba_px + ); + free(rgba_px); + } } } - gchar *base64String; - if(dibparams == U_BI_JPEG || dibparams==U_BI_PNG){ + + gchar *base64String=NULL; + if(dibparams == U_BI_JPEG || dibparams==U_BI_PNG){ // image was binary png or jpg in source file base64String = g_base64_encode((guchar*) px, numCt ); - idx = in_images(d, (char *) base64String); } - else if(mempng.buffer){ + else if(mempng.buffer){ // image was DIB in source file, converted to png in this routine base64String = g_base64_encode((guchar*) mempng.buffer, mempng.size ); free(mempng.buffer); - idx = in_images(d, (char *) base64String); } - else { - // insert a random 3x4 blotch otherwise + else { // unknown or unsupported image type or failed conversion, insert the common bad image picture width = 3; height = 4; - base64String = g_strdup("iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAIAAAA7ljmRAAAAA3NCSVQICAjb4U/gAAAALElEQVQImQXBQQ2AMAAAsUJQMSWI2H8qME1yMshojwrvGB8XcHKvR1XtOTc/8HENumHCsOMAAAAASUVORK5CYII="); - idx = in_images(d, (char *) base64String); + base64String = bad_image_png(); } + + idx = in_images(d, (char *) base64String); if(!idx){ // add it if not already present - we looked at the actual data for comparison if(d->images.count == d->images.size){ enlarge_images(d); } idx = d->images.count; @@ -732,7 +572,7 @@ uint32_t Emf::add_image(PEMF_CALLBACK_DATA d, void *pEmr, uint32_t cbBits, uint *(d->defs) += " "; *(d->defs) += " \n"; } - g_free(base64String); + g_free(base64String);//wait until this point to free because it might be a duplicate image /* image allows the inner image to be rotated nicely, load this one second only if needed imagename retained from above @@ -772,6 +612,115 @@ uint32_t Emf::add_image(PEMF_CALLBACK_DATA d, void *pEmr, uint32_t cbBits, uint return(idx-1); } +/* Add another 100 blank slots to the gradients array. +*/ +void Emf::enlarge_gradients(PEMF_CALLBACK_DATA d){ + d->gradients.size += 100; + d->gradients.strings = (char **) realloc(d->gradients.strings,d->gradients.size * sizeof(char *)); +} + +/* See if the gradient name is already in the list. If it is return its position (1->n, not 1-n-1) +*/ +int Emf::in_gradients(PEMF_CALLBACK_DATA d, char *test){ + int i; + for(i=0; igradients.count; i++){ + if(strcmp(test,d->gradients.strings[i])==0)return(i+1); + } + return(0); +} + +U_COLORREF trivertex_to_colorref(U_TRIVERTEX tv){ + U_COLORREF uc; + uc.Red = tv.Red >> 8; + uc.Green = tv.Green >> 8; + uc.Blue = tv.Blue >> 8; + uc.Reserved = tv.Alpha >> 8; // Not used + return(uc); +} + +/* (Conditionally) add a gradient. If a matching gradient already exists nothing happens. If one + does not exist it is added to the gradients list and also entered into . + Only call this with H or V gradient, not a triangle. +*/ +uint32_t Emf::add_gradient(PEMF_CALLBACK_DATA d, uint32_t gradientType, U_TRIVERTEX tv1, U_TRIVERTEX tv2){ + char hgradname[64]; // big enough + char tmpcolor1[8]; + char tmpcolor2[8]; + char gradc; + uint32_t idx; + std::string x2,y2; + + U_COLORREF gradientColor1 = trivertex_to_colorref(tv1); + U_COLORREF gradientColor2 = trivertex_to_colorref(tv2); + + + sprintf(tmpcolor1,"%6.6X",sethexcolor(gradientColor1)); + sprintf(tmpcolor2,"%6.6X",sethexcolor(gradientColor2)); + switch(gradientType){ + case U_GRADIENT_FILL_RECT_H: + gradc='H'; + x2="100"; + y2="0"; + break; + case U_GRADIENT_FILL_RECT_V: + gradc='V'; + x2="0"; + y2="100"; + break; + default: // this should never happen, but fill these in to avoid compiler warnings + gradc='!'; + x2="0"; + y2="0"; + break; + } + + /* Even though the gradient was defined as Horizontal or Vertical if the rectangle is rotated it needs to + be at some other alignment, and that needs gradienttransform. Set the name using the same sort of hack + as for add_image. + */ + int tangle = round(current_rotation(d)*1000000.0); + sprintf(hgradname,"LinGrd%c_%s_%s_%d",gradc,tmpcolor1,tmpcolor2,tangle); + + idx = in_gradients(d,hgradname); + if(!idx){ // gradient does not yet exist + if(d->gradients.count == d->gradients.size){ enlarge_gradients(d); } + d->gradients.strings[d->gradients.count++]=strdup(hgradname); + idx = d->gradients.count; + SVGOStringStream stmp; + stmp << " \n"; + stmp << " \n"; + stmp << " \n"; + stmp << " \n"; + *(d->defs) += stmp.str().c_str(); + } + + return(idx-1); +} + + void Emf::output_style(PEMF_CALLBACK_DATA d, int iType) @@ -871,10 +820,11 @@ Emf::output_style(PEMF_CALLBACK_DATA d, int iType) snprintf(tmp, 1023, "fill:url(#%s); ",d->hatches.strings[d->dc[d->level].fill_idx]); tmp_style << tmp; break; - case DRAW_IMAGE: + case DRAW_IMAGE: snprintf(tmp, 1023, "fill:url(#EMFimage%d_ref); ",d->dc[d->level].fill_idx); tmp_style << tmp; break; + case DRAW_LINEAR_GRADIENT: case DRAW_PAINT: default: // <-- this should never happen, but just in case... snprintf( @@ -927,6 +877,7 @@ Emf::output_style(PEMF_CALLBACK_DATA d, int iType) snprintf(tmp, 1023, "stroke:url(#EMFimage%d_ref); ",d->dc[d->level].stroke_idx); tmp_style << tmp; break; + case DRAW_LINEAR_GRADIENT: case DRAW_PAINT: default: // <-- this should never happen, but just in case... snprintf( @@ -1343,7 +1294,7 @@ Emf::select_brush(PEMF_CALLBACK_DATA d, int index) else if(iType == U_EMR_CREATEDIBPATTERNBRUSHPT || iType == U_EMR_CREATEMONOBRUSH){ PU_EMRCREATEDIBPATTERNBRUSHPT pEmr = (PU_EMRCREATEDIBPATTERNBRUSHPT) d->emf_obj[index].lpEMFR; tidx = add_image(d, (void *) pEmr, pEmr->cbBits, pEmr->cbBmi, pEmr->iUsage, pEmr->offBits, pEmr->offBmi); - if(tidx == 0xFFFFFFFF){ // This happens if createmonobrush has a DIB that isn't monochrome + if(tidx == U_EMR_INVALID){ // This happens if createmonobrush has a DIB that isn't monochrome double r, g, b; r = SP_COLOR_U_TO_F( U_RGBAGetR(d->dc[d->level].textColor)); g = SP_COLOR_U_TO_F( U_RGBAGetG(d->dc[d->level].textColor)); @@ -1502,13 +1453,11 @@ void Emf::common_image_extraction(PEMF_CALLBACK_DATA d, void *pEmr, uint32_t iUsage, uint32_t offBits, uint32_t cbBits, uint32_t offBmi, uint32_t cbBmi){ SVGOStringStream tmp_image; - int dibparams; + int dibparams = U_BI_UNKNOWN; // type of image not yet determined + tmp_image << "\n\t outsvg) += tmp_image.str().c_str(); + tmp_image << "/> \n"; - *(d->outsvg) += "/> \n"; + *(d->outsvg) += tmp_image.str().c_str(); *(d->path) = ""; } @@ -1664,7 +1596,7 @@ int Emf::myEnhMetaFileProc(char *contents, unsigned int length, PEMF_CALLBACK_DA // incompatible change to text drawing detected (color or background change) forces out existing text // OR // next record is valid type and forces pending text to be drawn immediately - if ((d->dc[d->level].dirty & DIRTY_TEXT) || ((emr_mask != 0xFFFFFFFF) && (emr_mask & U_DRAW_TEXT) && d->tri->dirty)){ + if ((d->dc[d->level].dirty & DIRTY_TEXT) || ((emr_mask != U_EMR_INVALID) && (emr_mask & U_DRAW_TEXT) && d->tri->dirty)){ TR_layout_analyze(d->tri); TR_layout_2_svg(d->tri); SVGOStringStream ts; @@ -1711,7 +1643,7 @@ std::cout << "BEFORE DRAW" */ if( - (emr_mask != 0xFFFFFFFF) && // next record is valid type + (emr_mask != U_EMR_INVALID) && // next record is valid type (d->mask & U_DRAW_VISIBLE) && // Current set of objects are drawable ( (d->mask & U_DRAW_FORCE) || // This draw is forced by STROKE/FILL/STROKEANDFILL PATH @@ -1726,7 +1658,7 @@ std::cout << "BEFORE DRAW" ) ){ // std::cout << "PATH DRAW at TOP" << std::endl; - *(d->outsvg) += " outsvg) += " drawtype){ // explicit draw type EMR record output_style(d, d->drawtype); } @@ -1737,7 +1669,7 @@ std::cout << "BEFORE DRAW" output_style(d, U_EMR_STROKEPATH); } *(d->outsvg) += "\n\t"; - *(d->outsvg) += "\n\td=\""; // this is the ONLY place d=" should be used!!!! + *(d->outsvg) += "\n\td=\""; // this is the ONLY place d=" should be used!!!! One exception, gradientfill. *(d->outsvg) += *(d->path); *(d->outsvg) += " \" /> \n"; *(d->path) = ""; @@ -2625,7 +2557,7 @@ std::cout << "BEFORE DRAW" int stat = emr_arc_points( lpEMFR, &f1, f2, ¢er, &start, &end, &size); if(!stat){ tmp_path << "\n\tM " << pix_to_xy(d, start.x, start.y); - tmp_path << " A " << pix_to_abs_size(d, size.x)/2.0 << "," << pix_to_abs_size(d, size.y)/2.0 ; + tmp_path << " A " << pix_to_abs_size(d, size.x)/2.0 << "," << pix_to_abs_size(d, size.y)/2.0; tmp_path << " "; tmp_path << 180.0 * current_rotation(d)/M_PI; tmp_path << " "; @@ -2646,7 +2578,7 @@ std::cout << "BEFORE DRAW" int f2 = (d->arcdir == U_AD_COUNTERCLOCKWISE ? 0 : 1); if(!emr_arc_points( lpEMFR, &f1, f2, ¢er, &start, &end, &size)){ tmp_path << "\n\tM " << pix_to_xy(d, start.x, start.y); - tmp_path << " A " << pix_to_abs_size(d, size.x)/2.0 << "," << pix_to_abs_size(d, size.y)/2.0 ; + tmp_path << " A " << pix_to_abs_size(d, size.x)/2.0 << "," << pix_to_abs_size(d, size.y)/2.0; tmp_path << " "; tmp_path << 180.0 * current_rotation(d)/M_PI; tmp_path << " "; @@ -2669,7 +2601,7 @@ std::cout << "BEFORE DRAW" if(!emr_arc_points( lpEMFR, &f1, f2, ¢er, &start, &end, &size)){ tmp_path << "\n\tM " << pix_to_xy(d, center.x, center.y); tmp_path << "\n\tL " << pix_to_xy(d, start.x, start.y); - tmp_path << " A " << pix_to_abs_size(d, size.x)/2.0 << "," << pix_to_abs_size(d, size.y)/2.0 ; + tmp_path << " A " << pix_to_abs_size(d, size.x)/2.0 << "," << pix_to_abs_size(d, size.y)/2.0; tmp_path << " "; tmp_path << 180.0 * current_rotation(d)/M_PI; tmp_path << " "; @@ -2710,7 +2642,7 @@ std::cout << "BEFORE DRAW" if(!emr_arc_points( lpEMFR, &f1, f2, ¢er, &start, &end, &size)){ // draw a line from current position to start, arc from there tmp_path << "\n\tL " << pix_to_xy(d, start.x, start.y); - tmp_path << " A " << pix_to_abs_size(d, size.x)/2.0 << "," << pix_to_abs_size(d, size.y)/2.0 ; + tmp_path << " A " << pix_to_abs_size(d, size.x)/2.0 << "," << pix_to_abs_size(d, size.y)/2.0; tmp_path << " "; tmp_path << 180.0 * current_rotation(d)/M_PI; tmp_path << " "; @@ -3332,13 +3264,64 @@ std::cout << "BEFORE DRAW" case U_EMR_SETLAYOUT: dbg_str << "\n"; break; case U_EMR_TRANSPARENTBLT: dbg_str << "\n"; break; case U_EMR_UNDEF117: dbg_str << "\n"; break; - case U_EMR_GRADIENTFILL: dbg_str << "\n"; break; - /* Gradient fill is doable for rectangles because those correspond to linear gradients. However, - the general case for the triangle fill, with a different color in each corner of the triangle, - has no SVG equivalent and cannot be easily emulated with SVG gradients. Except that so far - I (DM) have not been able to make an EMF with a rectangular gradientfill record which is not - completely toxic to other EMF readers. So far now, do nothing. - */ + case U_EMR_GRADIENTFILL: + { + /* Gradient fill is doable for rectangles because those correspond to linear gradients. However, + the general case for the triangle fill, with a different color in each corner of the triangle, + has no SVG equivalent and cannot be easily emulated with SVG gradients. So the linear gradient + is implemented, and the triangle fill just paints with the color of the first corner. + + This record can hold a series of gradients so we are forced to add path elements directly here, + it cannot wait for the top of the main loop. Any existing path is erased. + + */ + dbg_str << "\n"; + PU_EMRGRADIENTFILL pEmr = (PU_EMRGRADIENTFILL) lpEMFR; + int nV = pEmr->nTriVert; // Number of TriVertex objects + int nG = pEmr->nGradObj; // Number of gradient triangle/rectangle objects + U_TRIVERTEX *tv = (U_TRIVERTEX *)(((char *)lpEMFR) + sizeof(U_EMRGRADIENTFILL)); + if( pEmr->ulMode == U_GRADIENT_FILL_RECT_H || + pEmr->ulMode == U_GRADIENT_FILL_RECT_V + ){ + SVGOStringStream tmp_rectangle; + int i,fill_idx; + U_GRADIENT4 *rcs = (U_GRADIENT4 *)(((char *)lpEMFR) + sizeof(U_EMRGRADIENTFILL) + sizeof(U_TRIVERTEX)*nV); + for(i=0;iulMode, tv[rcs[i].UpperLeft], tv[rcs[i].LowerRight]); + tmp_rectangle << "\n\tM " << pix_to_xy( d, tv[rcs[i].UpperLeft ].x , tv[rcs[i].UpperLeft ].y ) << " "; + tmp_rectangle << "\n\tL " << pix_to_xy( d, tv[rcs[i].LowerRight].x , tv[rcs[i].UpperLeft ].y ) << " "; + tmp_rectangle << "\n\tL " << pix_to_xy( d, tv[rcs[i].LowerRight].x , tv[rcs[i].LowerRight].y ) << " "; + tmp_rectangle << "\n\tL " << pix_to_xy( d, tv[rcs[i].UpperLeft ].x , tv[rcs[i].LowerRight].y ) << " "; + tmp_rectangle << "\n\tz\""; + tmp_rectangle << "\n\tstyle=\"stroke:none;fill:url(#"; + tmp_rectangle << d->gradients.strings[fill_idx]; + tmp_rectangle << ");\"\n/>\n"; + } + *(d->outsvg) += tmp_rectangle.str().c_str(); + } + else if(pEmr->ulMode == U_GRADIENT_FILL_TRIANGLE){ + SVGOStringStream tmp_triangle; + char tmpcolor[8]; + int i; + U_GRADIENT3 *tris = (U_GRADIENT3 *)(((char *)lpEMFR) + sizeof(U_EMRGRADIENTFILL) + sizeof(U_TRIVERTEX)*nV); + for(i=0;i\n"; + } + *(d->outsvg) += tmp_triangle.str().c_str(); + } + *(d->path) = ""; + // if it is anything else the record is bogus, so ignore it + break; + } case U_EMR_SETLINKEDUFIS: dbg_str << "\n"; break; case U_EMR_SETTEXTJUSTIFICATION: dbg_str << "\n"; break; case U_EMR_COLORMATCHTOTARGETW: dbg_str << "\n"; break; @@ -3354,37 +3337,12 @@ std::cout << "BEFORE DRAW" } //end of while // When testing, uncomment the following to show the final SVG derived from the EMF -//std::cout << *(d->outsvg) << std::endl; +// std::cout << *(d->outsvg) << std::endl; (void) emr_properties(U_EMR_INVALID); // force the release of the lookup table memory, returned value is irrelevant return 1; } - -// Aldus Placeable Header =================================================== -// Since we are a 32bit app, we have to be sure this structure compiles to -// be identical to a 16 bit app's version. To do this, we use the #pragma -// to adjust packing, we use a uint16_t for the hmf handle, and a SMALL_RECT -// for the bbox rectangle. -#pragma pack( push ) -#pragma pack( 2 ) -typedef struct _SMALL_RECT { - int16_t Left; - int16_t Top; - int16_t Right; - int16_t Bottom; -} SMALL_RECT, *PSMALL_RECT; -typedef struct -{ - uint32_t dwKey; - uint16_t hmf; - SMALL_RECT bbox; - uint16_t wInch; - uint32_t dwReserved; - uint16_t wCheckSum; -} APMHEADER, *PAPMHEADER; -#pragma pack( pop ) - void Emf::free_emf_strings(EMF_STRINGS name){ if(name.count){ for(int i=0; i< name.count; i++){ free(name.strings[i]); } @@ -3438,6 +3396,9 @@ Emf::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri ) d.images.size = 0; d.images.count = 0; d.images.strings = NULL; + d.gradients.size = 0; + d.gradients.count = 0; + d.gradients.strings = NULL; // set up the size default for patterns in defs. This might not be referenced if there are no patterns defined in the drawing. @@ -3478,6 +3439,7 @@ Emf::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri ) delete d.defs; free_emf_strings(d.hatches); free_emf_strings(d.images); + free_emf_strings(d.gradients); if (d.emf_obj) { int i; @@ -3516,7 +3478,14 @@ Emf::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri ) // Scale and translate objects double scale = Inkscape::Util::Quantity::convert(1, "px", doc_unit); ShapeEditor::blockSetItem(true); - doc->getRoot()->scaleChildItemsRec(Geom::Scale(scale), Geom::Point(0, doc->getHeight().value("px"))); + double dh; + if(SP_ACTIVE_DOCUMENT){ // for file menu open or import, or paste from clipboard + dh = SP_ACTIVE_DOCUMENT->getHeight().value("px"); + } + else { // for open via --file on command line + dh = doc->getHeight().value("px"); + } + doc->getRoot()->scaleChildItemsRec(Geom::Scale(scale), Geom::Point(0, dh)); ShapeEditor::blockSetItem(false); Inkscape::DocumentUndo::setUndoSensitive(doc, saved); @@ -3556,6 +3525,7 @@ Emf::init (void) "false\n" "false\n" "false\n" + "false\n" "false\n" "false\n" "\n" diff --git a/src/extension/internal/emf-inout.h b/src/extension/internal/emf-inout.h index 787a2fdb3..97f93e71b 100644 --- a/src/extension/internal/emf-inout.h +++ b/src/extension/internal/emf-inout.h @@ -11,9 +11,8 @@ #ifndef SEEN_EXTENSION_INTERNAL_EMF_H #define SEEN_EXTENSION_INTERNAL_EMF_H -#define PNG_SKIP_SETJMP_CHECK // else any further png.h include blows up in the compiler -#include #include +#include "extension/internal/metafile-inout.h" // picks up PNG #include "extension/implementation/implementation.h" #include "style.h" #include "text_reassemble.h" @@ -67,34 +66,6 @@ typedef struct emf_device_context { #define EMF_MAX_DC 128 -/* - both emf-inout.h and wmf-inout.h are included by init.cpp, so whichever one goes in first defines these ommon types -*/ -#ifndef SEEN_EXTENSION_INTERNAL_METAFILECOMMON_ -#define SEEN_EXTENSION_INTERNAL_METAFILECOMMON_ -/* A coloured pixel. */ -typedef struct { - uint8_t red; - uint8_t green; - uint8_t blue; - uint8_t opacity; -} pixel_t; - -/* A picture. */ - -typedef struct { - pixel_t *pixels; - size_t width; - size_t height; -} bitmap_t; - -/* structure to store PNG image bytes */ -typedef struct { - char *buffer; - size_t size; -} MEMPNG, *PMEMPNG; -#endif - typedef struct { Glib::ustring *outsvg; Glib::ustring *path; @@ -126,6 +97,7 @@ typedef struct { // both of these end up in under the names shown here. These structures allow duplicates to be avoided. EMF_STRINGS hatches; // hold pattern names, all like EMFhatch#_$$$$$$ where # is the EMF hatch code and $$$$$$ is the color EMF_STRINGS images; // hold images, all like Image#, where # is the slot the image lives. + EMF_STRINGS gradients; // hold gradient names, all like EMF[HV]_$$$$$$_$$$$$$ where $$$$$$ are the colors TR_INFO *tri; // Text Reassembly data structure @@ -133,7 +105,8 @@ typedef struct { PEMF_OBJECT emf_obj; } EMF_CALLBACK_DATA, *PEMF_CALLBACK_DATA; -class Emf : Inkscape::Extension::Implementation::Implementation { //This is a derived class +class Emf : public Metafile +{ public: @@ -155,11 +128,6 @@ public: private: protected: - - static pixel_t *pixel_at (bitmap_t * bitmap, int x, int y); - static void my_png_write_data(png_structp png_ptr, png_bytep data, png_size_t length); - static void toPNG(PMEMPNG accum, int width, int height, const char *px); - static uint32_t sethexcolor(U_COLORREF color); static void print_document_to_file(SPDocument *doc, const gchar *filename); static double current_scale(PEMF_CALLBACK_DATA d); static std::string current_matrix(PEMF_CALLBACK_DATA d, double x, double y, int useoffset); @@ -171,6 +139,9 @@ protected: static int in_images(PEMF_CALLBACK_DATA d, char *test); static uint32_t add_image(PEMF_CALLBACK_DATA d, void *pEmr, uint32_t cbBits, uint32_t cbBmi, uint32_t iUsage, uint32_t offBits, uint32_t offBmi); + static void enlarge_gradients(PEMF_CALLBACK_DATA d); + static int in_gradients(PEMF_CALLBACK_DATA d, char *test); + static uint32_t add_gradient(PEMF_CALLBACK_DATA d, uint32_t gradientType, U_TRIVERTEX tv1, U_TRIVERTEX tv2); static void output_style(PEMF_CALLBACK_DATA d, int iType); static double _pix_x_to_point(PEMF_CALLBACK_DATA d, double px); static double _pix_y_to_point(PEMF_CALLBACK_DATA d, double py); diff --git a/src/extension/internal/emf-print.cpp b/src/extension/internal/emf-print.cpp index 0df643130..3c27ac1b8 100644 --- a/src/extension/internal/emf-print.cpp +++ b/src/extension/internal/emf-print.cpp @@ -70,9 +70,8 @@ namespace Internal { /* globals */ -static double PX2WORLD = 20.0f; -static U_XFORM worldTransform; -static bool FixPPTCharPos, FixPPTDashLine, FixPPTGrad2Polys, FixPPTPatternAsHatch, FixImageRot; +static double PX2WORLD; +static bool FixPPTCharPos, FixPPTDashLine, FixPPTGrad2Polys, FixPPTLinGrad, FixPPTPatternAsHatch, FixImageRot; static EMFTRACK *et = NULL; static EMFHANDLES *eht = NULL; @@ -125,9 +124,12 @@ unsigned int PrintEmf::begin(Inkscape::Extension::Print *mod, SPDocument *doc) char *rec; gchar const *utf8_fn = mod->get_param_string("destination"); + // Typially PX2WORLD is 1200/90, using inkscape's default dpi + PX2WORLD = 1200.0 / Inkscape::Util::Quantity::convert(1.0, "in", "px"); FixPPTCharPos = mod->get_param_bool("FixPPTCharPos"); FixPPTDashLine = mod->get_param_bool("FixPPTDashLine"); FixPPTGrad2Polys = mod->get_param_bool("FixPPTGrad2Polys"); + FixPPTLinGrad = mod->get_param_bool("FixPPTLinGrad"); FixPPTPatternAsHatch = mod->get_param_bool("FixPPTPatternAsHatch"); FixImageRot = mod->get_param_bool("FixImageRot"); @@ -179,12 +181,12 @@ unsigned int PrintEmf::begin(Inkscape::Extension::Print *mod, SPDocument *doc) float dwInchesX = d.width(); float dwInchesY = d.height(); - // dwInchesX x dwInchesY in micrometer units, dpi=90 -> 3543.3 dpm - (void) drawing_size((int) ceil(dwInchesX * 25.4), (int) ceil(dwInchesY * 25.4), 3.543307, &rclBounds, &rclFrame); + // dwInchesX x dwInchesY in micrometer units, 1200 dpi/25.4 -> dpmm + (void) drawing_size((int) ceil(dwInchesX * 25.4), (int) ceil(dwInchesY * 25.4),1200.0/25.4, &rclBounds, &rclFrame); // set up the reference device as 100 X A4 horizontal, (1200 dpi/25.4 -> dpmm). Extra digits maintain dpi better in EMF - int MMX = 21600; - int MMY = 27900; + int MMX = 216; + int MMY = 279; (void) device_size(MMX, MMY, 1200.0 / 25.4, &szlDev, &szlMm); int PixelsX = szlDev.cx; int PixelsY = szlDev.cy; @@ -220,13 +222,16 @@ unsigned int PrintEmf::begin(Inkscape::Extension::Print *mod, SPDocument *doc) } - // Correct for dpi in EMF (1200) vs dpi in Inkscape (always 90). - // Also correct for the scaling in PX2WORLD, which is set to 20. + // In earlier versions this was used to scale from inkscape's dpi of 90 to + // the files 1200 dpi, taking into account PX2WORLD which was 20. Now PX2WORLD + // is set so that this matrix is unitary. The usual value of PX2WORLD is 1200/90, + // but might be different if the internal dpi is changed. - worldTransform.eM11 = 1200. / (90.0 * PX2WORLD); + U_XFORM worldTransform; + worldTransform.eM11 = 1.0; worldTransform.eM12 = 0.0; worldTransform.eM21 = 0.0; - worldTransform.eM22 = 1200. / (90.0 * PX2WORLD); + worldTransform.eM22 = 1.0; worldTransform.eDx = 0; worldTransform.eDy = 0; @@ -420,7 +425,7 @@ int PrintEmf::create_brush(SPStyle const *style, PU_COLORREF fcolor) hatchColor = avg_stop_color(rg); } } else if (lg) { - if (FixPPTGrad2Polys) { + if (FixPPTGrad2Polys || FixPPTLinGrad) { return hold_gradient(lg, fill_mode); } else { hatchColor = avg_stop_color(lg); @@ -696,7 +701,7 @@ int PrintEmf::create_pen(SPStyle const *style, const Geom::Affine &transform) n_dash = style->stroke_dash.n_dash; dash = new uint32_t[n_dash]; for (i = 0; i < style->stroke_dash.n_dash; i++) { - dash[i] = (uint32_t)(style->stroke_dash.dash[i]); + dash[i] = (uint32_t)(Inkscape::Util::Quantity::convert(1, "mm", "px") * style->stroke_dash.dash[i]); } } } @@ -780,6 +785,182 @@ void PrintEmf::destroy_pen() } } +/* Return a Path consisting of just the corner points of the single path in a a PathVector. If the +PathVector has more than one path, or that one path is open, or any of its segments are curved, then the +returned PathVector is . If the input path is already just straight lines and vertices the output will be the +same as the sole path in the input. */ + +Geom::Path PrintEmf::pathv_to_simple_polygon(Geom::PathVector const &pathv, int *vertices) +{ + Geom::Point P1_trail; + Geom::Point P1; + Geom::Point P1_lead; + Geom::Point v1,v2; + Geom::Path output; + Geom::Path bad; + Geom::PathVector pv = pathv_to_linear_and_cubic_beziers(pathv); + Geom::PathVector::const_iterator pit = pv.begin(); + Geom::PathVector::const_iterator pit2 = pv.begin(); + ++pit2; + *vertices = 0; + if(pit->end_closed() != pit->end_default())return(bad); // path must be closed + if(pit2 != pv.end())return(bad); // there may only be one path + P1_trail = pit->finalPoint(); + Geom::Path::const_iterator cit = pit->begin(); + P1 = cit->initialPoint(); + for(;cit != pit->end_closed();++cit) { + if (!is_straight_curve(*cit)) { + *vertices = 0; + return(bad); + } + P1_lead = cit->finalPoint(); + if(Geom::are_near(P1_lead,P1))continue; // duplicate points at the same coordinate + v1 = unit_vector(P1 - P1_trail); + v2 = unit_vector(P1_lead - P1 ); + if(Geom::are_near(dot(v1,v2),1.0)){ // P1 is within a straight line + P1 = P1_lead; + continue; + } + // P1 is the center point of a turn of some angle + if(!*vertices){ + output.start( P1 ); + output.close( pit->closed() ); + } + *vertices += 1; + Geom::LineSegment ls(P1_trail, P1); + output.append(ls); + P1_trail = P1; + P1 = P1_lead; + } + return(output); +} + +/* Returns the simplified PathVector (no matter what). + Sets is_rect if it is a rectangle. + Sets angle that will rotate side closest to horizontal onto horizontal. +*/ +Geom::Path PrintEmf::pathv_to_rect(Geom::PathVector const &pathv, bool *is_rect, double *angle) +{ + Geom::Point P1_trail; + Geom::Point P1; + Geom::Point P1_lead; + Geom::Point v1,v2; + int vertices; + Geom::Path pR = pathv_to_simple_polygon(pathv, &vertices); + *is_rect = false; + if(vertices==4){ // or else it cannot be a rectangle rectangle + int vertex_count=0; + /* Get the ends of the LAST line segment. + Find minimum rotation to align rectangle with X,Y axes. (Very degenerate if it is rotated 45 degrees.) */ + *angle = 10.0; /* must be > than the actual angle in radians. */ + for(Geom::Path::const_iterator cit = pR.begin(); cit != pR.end_open(); ++cit){ + P1_trail = cit->initialPoint(); + P1 = cit->finalPoint(); + v1 = unit_vector(P1 - P1_trail); + if(v1[Geom::X] > 0){ // only check the 1 or 2 points on vectors aimed the same direction as unit X + double ang = asin(v1[Geom::Y]); // because component is rotation by ang of {1,0| vector + if(fabs(ang) < fabs(*angle))*angle = -ang; // y increases down, flips sign on angle + } + } + + for(Geom::Path::const_iterator cit = pR.begin(); cit != pR.end_open();++cit) { + P1_lead = cit->finalPoint(); + v1 = unit_vector(P1 - P1_trail); + v2 = unit_vector(P1_lead - P1 ); + if(!Geom::are_near(dot(v1,v2),0.0))break; // P1 is center of a turn that is not 90 degrees + P1_trail = P1; + P1 = P1_lead; + vertex_count++; + } + if(vertex_count == 4){ + *is_rect=true; + } + } + return(pR); +} + +/* Compare a vector with a rectangle's orientation (angle needed to rotate side(s) + closest to horizontal to exactly horizontal) and return: + 0 none of the following + 1 parallel to horizontal + 2 parallel to vertical + 3 antiparallel to horizontal + 4 antiparallel to vertical +*/ +int PrintEmf::vector_rect_alignment(double angle, Geom::Point vtest){ + int stat = 0; + Geom::Point v1 = Geom::unit_vector(vtest); // unit vector to test alignment + Geom::Point v2 = Geom::Point(1,0) * Geom::Rotate(-angle); // unit horizontal side (sign change because Y increases DOWN) + if( Geom::are_near(dot(v1,v2), 1.0)){ stat = 1; } + else if(Geom::are_near(dot(v1,v2),-1.0)){ stat = 2; } + if(!stat){ + v2 = Geom::Point(0,1) * Geom::Rotate(-angle); // unit vertical side + if( Geom::are_near(dot(v1,v2), 1.0)){ stat = 3; } + else if(Geom::are_near(dot(v1,v2),-1.0)){ stat = 4; } + } + return(stat); +} + +/* retrieve the point at the indicated corner: + 0 UL (and default) + 1 UR + 2 LR + 3 LL + Needed because the start can be any point, and the direction could run either + clockwise or counterclockwise. This should work even if the corners of the rectangle + are slightly displaced. +*/ +Geom::Point PrintEmf::get_pathrect_corner(Geom::Path pathRect, double angle, int corner){ + Geom::Point v1 = Geom::Point(1,0) * Geom::Rotate(-angle); // unit horizontal side (sign change because Y increases DOWN) + Geom::Point v2 = Geom::Point(0,1) * Geom::Rotate(-angle); // unit vertical side (sign change because Y increases DOWN) + Geom::Point center, P1; + int LR; // 1 if Left, 0 if Right + int UL; // 1 if Lower, 0 if Upper (as viewed on screen, y coordinates increase downwards) + center = Geom::Point(0,0); + Geom::Path::const_iterator cit = pathRect.begin(); + for(; cit != pathRect.end_open();++cit) { + center += cit->initialPoint()/4.0; + } + + switch(corner){ + case 1: //UR + LR = 0; + UL = 0; + break; + case 2: //LR + LR = 0; + UL = 1; + break; + case 3: //LL + LR = 1; + UL = 1; + break; + default: //UL + LR = 1; + UL = 0; + break; + } + cit = pathRect.begin(); + for(int i; cit != pathRect.end_open();++cit,i++) { + P1 = cit->initialPoint(); + if((LR == (dot(P1 - center,v1)> 0 ? 0 : 1)) && + (UL == (dot(P1 - center,v2)> 0 ? 1 : 0)))break; + } + return(P1); +} + +U_TRIVERTEX PrintEmf::make_trivertex(Geom::Point Pt, U_COLORREF uc){ + U_TRIVERTEX tv; + using Geom::X; + using Geom::Y; + tv.x = (int32_t) round(Pt[X]); + tv.y = (int32_t) round(Pt[Y]); + tv.Red = uc.Red << 8; + tv.Green = uc.Green << 8; + tv.Blue = uc.Blue << 8; + tv.Alpha = uc.Reserved << 8; // EMF will ignore this + return(tv); +} unsigned int PrintEmf::fill( Inkscape::Extension::Print * /*mod*/, @@ -795,8 +976,27 @@ unsigned int PrintEmf::fill( use_stroke = false; fill_transform = tf; + + int brush_stat = create_brush(style, NULL); + + /* native linear gradients are only used if the object is a rectangle AND the gradient is parallel to the sides of the object */ + bool is_Rect = false; + double angle; + int rectDir=0; + Geom::Path pathRect; + if(FixPPTLinGrad && brush_stat && gv.mode == DRAW_LINEAR_GRADIENT){ + pathRect = pathv_to_rect(pathv, &is_Rect, &angle); + if(is_Rect){ + /* Gradientfill records can only be used if the gradient is parallel to the sides of the rectangle. + That must be checked here so that we can fall back to another form of gradient fill if it is not + the case. */ + rectDir = vector_rect_alignment(angle, gv.p2 - gv.p1); + if(!rectDir)is_Rect = false; + } + if(!is_Rect && !FixPPTGrad2Polys)brush_stat=0; // fall all the way back to a solid fill + } - if (create_brush(style, NULL)) { // only happens if the style is a gradient + if (brush_stat) { // only happens if the style is a gradient /* Handle gradients. Uses modified livarot as 2geom boolops is currently broken. Can handle gradients with multiple stops. @@ -819,10 +1019,10 @@ unsigned int PrintEmf::fill( SPRadialGradient *tg = (SPRadialGradient *)(gv.grad); // linear/radial are the same here nstops = tg->vector.stops.size(); sp_color_get_rgb_floatv(&tg->vector.stops[0].color, rgb); - opa = tg->vector.stops[0].opacity; + opa = tg->vector.stops[0].opacity; // first stop c1 = U_RGBA(255 * rgb[0], 255 * rgb[1], 255 * rgb[2], 255 * opa); sp_color_get_rgb_floatv(&tg->vector.stops[nstops - 1].color, rgb); - opa = tg->vector.stops[nstops - 1].opacity; + opa = tg->vector.stops[nstops - 1].opacity; // last stop c2 = U_RGBA(255 * rgb[0], 255 * rgb[1], 255 * rgb[2], 255 * opa); doff = 0.0; @@ -868,9 +1068,10 @@ unsigned int PrintEmf::fill( pathvr = sp_pathvector_boolop(pathvc, pathv, bool_op_inters, (FillRule) fill_nonZero, frb); print_pathv(pathvr, fill_transform); // show the intersection - if (doff >= doff_range - doff_base) { + if (doff >= doff_range) { istop++; if (istop >= nstops) { + istop = nstops - 1; continue; // could happen on a rounding error } doff_base = doff_range; @@ -882,56 +1083,145 @@ unsigned int PrintEmf::fill( } } } else if (gv.mode == DRAW_LINEAR_GRADIENT) { - Geom::Point uv = Geom::unit_vector(gv.p2 - gv.p1); // unit vector - Geom::Point puv = uv.cw(); // perp. to unit vector - double range = Geom::distance(gv.p1, gv.p2); // length along the gradient - double step = range / divisions; // adequate approximation for gradient - double overlap = step / 4.0; // overlap slices slightly - double start; - double stop; - Geom::PathVector pathvc, pathvr; - - /* before lower end of gradient, overlap first slice position */ - wc = weight_opacity(c1); - (void) create_brush(style, &wc); - pathvc = rect_cutter(gv.p1, uv * (overlap), uv * (-50000.0), puv * 50000.0); - pathvr = sp_pathvector_boolop(pathvc, pathv, bool_op_inters, (FillRule) fill_nonZero, frb); - print_pathv(pathvr, fill_transform); - - /* after high end of gradient, overlap last slice poosition */ - wc = weight_opacity(c2); - (void) create_brush(style, &wc); - pathvc = rect_cutter(gv.p2, uv * (-overlap), uv * (50000.0), puv * 50000.0); - pathvr = sp_pathvector_boolop(pathvc, pathv, bool_op_inters, (FillRule) fill_nonZero, frb); - print_pathv(pathvr, fill_transform); + if(is_Rect){ + char *rec; + int gMode; + Geom::Point ul, ur, lr; + Geom::Point outUL, outLR; // UL,LR corners of a stop rectangle, in OUTPUT coordinates + U_TRIVERTEX ut[2]; + U_GRADIENT4 ug4; + U_RECTL rcb; + Geom::Affine tf2; + U_XFORM tmpTransform; + double wRect, hRect; + + /* coordinates, w,h and transform for the ENTIRE retangle */ + ul = get_pathrect_corner(pathRect, angle, 0) * fill_transform * PX2WORLD; + ur = get_pathrect_corner(pathRect, angle, 1) * fill_transform * PX2WORLD; + lr = get_pathrect_corner(pathRect, angle, 2) * fill_transform * PX2WORLD; + wRect = Geom::distance(ul,ur); + hRect = Geom::distance(ur,lr); + + /* The basic rectangle for all of these is placed with its UL corner at 0,0 with a size wRect,hRect. + Apply a world transform to place/scale it into the appropriate position on the drawing. + Actual gradientfill records are either this entire rectangle or slices of it as defined by the stops. + */ + + tf2 = Geom::Rotate(-angle); + tmpTransform.eM11 = tf2[0]; + tmpTransform.eM12 = tf2[1]; + tmpTransform.eM21 = tf2[2]; + tmpTransform.eM22 = tf2[3]; + tmpTransform.eDx = (ul)[Geom::X]; + tmpTransform.eDy = (ul)[Geom::Y]; + + rec = U_EMRSAVEDC_set(); + if (!rec || emf_append((PU_ENHMETARECORD)rec, et, U_REC_FREE)) { + g_error("Fatal programming error in PrintEmf::image at U_EMRSAVEDC_set"); + } - sp_color_get_rgb_floatv(&tg->vector.stops[istop].color, rgb); - opa = tg->vector.stops[istop].opacity; - c2 = U_RGBA(255 * rgb[0], 255 * rgb[1], 255 * rgb[2], 255 * opa); + rec = U_EMRMODIFYWORLDTRANSFORM_set(tmpTransform, U_MWT_LEFTMULTIPLY); + if (!rec || emf_append((PU_ENHMETARECORD)rec, et, U_REC_FREE)) { + g_error("Fatal programming error in PrintEmf::image at EMRMODIFYWORLDTRANSFORM"); + } + + for(;istopvector.stops[istop].offset; // next or last stop + if(rectDir == 1 || rectDir == 2){ + outUL = Geom::Point(doff_base *wRect, 0 ); + outLR = Geom::Point(doff_range*wRect, hRect); + gMode = U_GRADIENT_FILL_RECT_H; + } + else { + outUL = Geom::Point(0, doff_base *hRect); + outLR = Geom::Point(wRect,doff_range*hRect); + gMode = U_GRADIENT_FILL_RECT_V; + } + doff_base = doff_range; + rcb.left = outUL[X]; + rcb.top = outUL[Y]; + rcb.right = outLR[X]; + rcb.bottom = outLR[Y]; + sp_color_get_rgb_floatv(&tg->vector.stops[istop].color, rgb); + opa = tg->vector.stops[istop].opacity; + c2 = U_RGBA(255 * rgb[0], 255 * rgb[1], 255 * rgb[2], 255 * opa); + + if(rectDir == 2 || rectDir == 4){ // gradient is reversed, so swap colors + ut[0] = make_trivertex(outUL, c2); + ut[1] = make_trivertex(outLR, c1); + } + else { + ut[0] = make_trivertex(outUL, c1); + ut[1] = make_trivertex(outLR, c2); + } + c1 = c2; // for next stop + ug4.UpperLeft = 0; + ug4.LowerRight= 1; + /* NEED to push world transform here for rotations */ + rec = U_EMRGRADIENTFILL_set(rcb, 2, 1, gMode, ut, (uint32_t *) &ug4 ); + if (!rec || emf_append((PU_ENHMETARECORD)rec, et, U_REC_FREE)) { + g_error("Fatal programming error in PrintEmf::fill at U_EMRGRADIENTFILL_set"); + } + } - for (start = 0.0; start < range; start += step, doff += 1. / divisions) { - stop = start + step + overlap; - if (stop > range) { - stop = range; + rec = U_EMRRESTOREDC_set(-1); + if (!rec || emf_append((PU_ENHMETARECORD)rec, et, U_REC_FREE)) { + g_error("Fatal programming error in PrintEmf::fill at U_EMRRESTOREDC_set"); } - pathvc = rect_cutter(gv.p1, uv * start, uv * stop, puv * 50000.0); + } + else { + Geom::Point uv = Geom::unit_vector(gv.p2 - gv.p1); // unit vector + Geom::Point puv = uv.cw(); // perp. to unit vector + double range = Geom::distance(gv.p1, gv.p2); // length along the gradient + double step = range / divisions; // adequate approximation for gradient + double overlap = step / 4.0; // overlap slices slightly + double start; + double stop; + Geom::PathVector pathvc, pathvr; + + /* before lower end of gradient, overlap first slice position */ + wc = weight_opacity(c1); + (void) create_brush(style, &wc); + pathvc = rect_cutter(gv.p1, uv * (overlap), uv * (-50000.0), puv * 50000.0); + pathvr = sp_pathvector_boolop(pathvc, pathv, bool_op_inters, (FillRule) fill_nonZero, frb); + print_pathv(pathvr, fill_transform); - wc = weight_colors(c1, c2, (doff - doff_base) / (doff_range - doff_base)); + /* after high end of gradient, overlap last slice position */ + wc = weight_opacity(c2); (void) create_brush(style, &wc); - Geom::PathVector pathvr = sp_pathvector_boolop(pathvc, pathv, bool_op_inters, (FillRule) fill_nonZero, frb); - print_pathv(pathvr, fill_transform); // show the intersection + pathvc = rect_cutter(gv.p2, uv * (-overlap), uv * (50000.0), puv * 50000.0); + pathvr = sp_pathvector_boolop(pathvc, pathv, bool_op_inters, (FillRule) fill_nonZero, frb); + print_pathv(pathvr, fill_transform); - if (doff >= doff_range - doff_base) { - istop++; - if (istop >= nstops) { - continue; // could happen on a rounding error + sp_color_get_rgb_floatv(&tg->vector.stops[istop].color, rgb); + opa = tg->vector.stops[istop].opacity; + c2 = U_RGBA(255 * rgb[0], 255 * rgb[1], 255 * rgb[2], 255 * opa); + + for (start = 0.0; start < range; start += step, doff += 1. / divisions) { + stop = start + step + overlap; + if (stop > range) { + stop = range; + } + pathvc = rect_cutter(gv.p1, uv * start, uv * stop, puv * 50000.0); + + wc = weight_colors(c1, c2, (doff - doff_base) / (doff_range - doff_base)); + (void) create_brush(style, &wc); + Geom::PathVector pathvr = sp_pathvector_boolop(pathvc, pathv, bool_op_inters, (FillRule) fill_nonZero, frb); + print_pathv(pathvr, fill_transform); // show the intersection + + if (doff >= doff_range) { + istop++; + if (istop >= nstops) { + istop = nstops - 1; + continue; // could happen on a rounding error + } + doff_base = doff_range; + doff_range = tg->vector.stops[istop].offset; // next or last stop + c1 = c2; + sp_color_get_rgb_floatv(&tg->vector.stops[istop].color, rgb); + opa = tg->vector.stops[istop].opacity; + c2 = U_RGBA(255 * rgb[0], 255 * rgb[1], 255 * rgb[2], 255 * opa); } - doff_base = doff_range; - doff_range = tg->vector.stops[istop].offset; // next or last stop - c1 = c2; - sp_color_get_rgb_floatv(&tg->vector.stops[istop].color, rgb); - opa = tg->vector.stops[istop].opacity; - c2 = U_RGBA(255 * rgb[0], 255 * rgb[1], 255 * rgb[2], 255 * opa); } } } else { @@ -1301,6 +1591,10 @@ unsigned int PrintEmf::image( U_POINTL cDest = pointl_set(round(dw * PX2WORLD), round(dh * PX2WORLD)); U_POINTL Src = pointl_set(0, 0); U_POINTL cSrc = pointl_set(w, h); + /* map the integer Dest coordinates back into pLL2, so that the rounded part does not destabilize the transform offset below */ + pLL2[Geom::X] = Dest.x; + pLL2[Geom::Y] = Dest.y; + pLL2 /= PX2WORLD; if (!FixImageRot) { /* Rotate images - some programs cannot read them in correctly if they are rotated */ tf[4] = tf[5] = 0.0; // get rid of the offset in the transform Geom::Point pLL2prime = pLL2 * tf; @@ -1309,7 +1603,7 @@ unsigned int PrintEmf::image( tmpTransform.eM12 = tf[1]; tmpTransform.eM21 = tf[2]; tmpTransform.eM22 = tf[3]; - tmpTransform.eDx = (pLL2[Geom::X] - pLL2prime[Geom::X]) * PX2WORLD; //map pLL2 (now in EMF coordinates) back onto itself after the rotation + tmpTransform.eDx = (pLL2[Geom::X] - pLL2prime[Geom::X]) * PX2WORLD; tmpTransform.eDy = (pLL2[Geom::Y] - pLL2prime[Geom::Y]) * PX2WORLD; rec = U_EMRSAVEDC_set(); @@ -1734,6 +2028,7 @@ void PrintEmf::init(void) "false\n" "false\n" "false\n" + "false\n" "false\n" "false\n" "\n" diff --git a/src/extension/internal/emf-print.h b/src/extension/internal/emf-print.h index 1546fcaea..8fc9908e3 100644 --- a/src/extension/internal/emf-print.h +++ b/src/extension/internal/emf-print.h @@ -68,6 +68,11 @@ public: protected: static void smuggle_adxkyrtl_out(const char *string, uint32_t **adx, double *ky, int *rtl, int *ndx, float scale); + Geom::Path pathv_to_simple_polygon(Geom::PathVector const &pathv, int *vertices); + Geom::Path pathv_to_rect(Geom::PathVector const &pathv, bool *is_rect, double *angle); + Geom::Point get_pathrect_corner(Geom::Path pathRect, double angle, int corner); + U_TRIVERTEX make_trivertex(Geom::Point Pt, U_COLORREF uc); + int vector_rect_alignment(double angle, Geom::Point vtest); int create_brush(SPStyle const *style, PU_COLORREF fcolor); void destroy_brush(); int create_pen(SPStyle const *style, const Geom::Affine &transform); diff --git a/src/extension/internal/metafile-inout.cpp b/src/extension/internal/metafile-inout.cpp new file mode 100644 index 000000000..c7ae53370 --- /dev/null +++ b/src/extension/internal/metafile-inout.cpp @@ -0,0 +1,210 @@ +/** @file + * @brief Metafile input - common routines + *//* + * Authors: + * David Mathog + * + * Copyright (C) 2013 Authors + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include +#include +#include + +#include "extension/internal/metafile-inout.h" // picks up PNG +#include "extension/print.h" +#include "path-prefix.h" +#include "sp-gradient.h" +#include "sp-image.h" +#include "sp-linear-gradient.h" +#include "sp-pattern.h" +#include "sp-radial-gradient.h" +#include "style.h" + +namespace Inkscape { +namespace Extension { +namespace Internal { + +Metafile::~Metafile() +{ + return; +} + +/** Construct a PNG in memory from an RGB from the EMF file + +from: +http://www.lemoda.net/c/write-png/ + +which was based on: +http://stackoverflow.com/questions/1821806/how-to-encode-png-to-buffer-using-libpng + +gcc -Wall -o testpng testpng.c -lpng + +Originally here, but moved up + +#include +#include +#include +#include +*/ + + +/* Given "bitmap", this returns the pixel of bitmap at the point + ("x", "y"). */ + +pixel_t * Metafile::pixel_at (bitmap_t * bitmap, int x, int y) +{ + return bitmap->pixels + bitmap->width * y + x; +} + + +/* Write "bitmap" to a PNG file specified by "path"; returns 0 on + success, non-zero on error. */ + +void +Metafile::my_png_write_data(png_structp png_ptr, png_bytep data, png_size_t length) +{ + PMEMPNG p=(PMEMPNG)png_get_io_ptr(png_ptr); + + size_t nsize = p->size + length; + + /* allocate or grow buffer */ + if(p->buffer){ p->buffer = (char *) realloc(p->buffer, nsize); } + else{ p->buffer = (char *) malloc(nsize); } + + if(!p->buffer){ png_error(png_ptr, "Write Error"); } + + /* copy new bytes to end of buffer */ + memcpy(p->buffer + p->size, data, length); + p->size += length; +} + +void Metafile::toPNG(PMEMPNG accum, int width, int height, const char *px){ + bitmap_t bmStore; + bitmap_t *bitmap = &bmStore; + accum->buffer=NULL; // PNG constructed in memory will end up here, caller must free(). + accum->size=0; + bitmap->pixels=(pixel_t *)px; + bitmap->width = width; + bitmap->height = height; + + png_structp png_ptr = NULL; + png_infop info_ptr = NULL; + size_t x, y; + png_byte ** row_pointers = NULL; + /* The following number is set by trial and error only. I cannot + see where it it is documented in the libpng manual. + */ + int pixel_size = 3; + int depth = 8; + + png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); + if (png_ptr == NULL){ + accum->buffer=NULL; + return; + } + + info_ptr = png_create_info_struct (png_ptr); + if (info_ptr == NULL){ + png_destroy_write_struct (&png_ptr, &info_ptr); + accum->buffer=NULL; + return; + } + + /* Set up error handling. */ + + if (setjmp (png_jmpbuf (png_ptr))) { + png_destroy_write_struct (&png_ptr, &info_ptr); + accum->buffer=NULL; + return; + } + + /* Set image attributes. */ + + png_set_IHDR ( + png_ptr, + info_ptr, + bitmap->width, + bitmap->height, + depth, + PNG_COLOR_TYPE_RGB, + PNG_INTERLACE_NONE, + PNG_COMPRESSION_TYPE_DEFAULT, + PNG_FILTER_TYPE_DEFAULT + ); + + /* Initialize rows of PNG. */ + + row_pointers = (png_byte **) png_malloc (png_ptr, bitmap->height * sizeof (png_byte *)); + for (y = 0; y < bitmap->height; ++y) { + png_byte *row = + (png_byte *) png_malloc (png_ptr, sizeof (uint8_t) * bitmap->width * pixel_size); + row_pointers[bitmap->height - y - 1] = row; // Row order in EMF is reversed. + for (x = 0; x < bitmap->width; ++x) { + pixel_t * pixel = pixel_at (bitmap, x, y); + *row++ = pixel->red; // R & B channels were set correctly by DIB_to_RGB + *row++ = pixel->green; + *row++ = pixel->blue; + } + } + + /* Write the image data to memory */ + + png_set_rows (png_ptr, info_ptr, row_pointers); + + png_set_write_fn(png_ptr, accum, my_png_write_data, NULL); + + png_write_png (png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, NULL); + + for (y = 0; y < bitmap->height; y++) { + png_free (png_ptr, row_pointers[y]); + } + png_free (png_ptr, row_pointers); + png_destroy_write_struct(&png_ptr, &info_ptr); + +} + + +/* convert an EMF RGB(A) color to 0RGB +inverse of gethexcolor() in emf-print.cpp +*/ +uint32_t Metafile::sethexcolor(U_COLORREF color){ + + uint32_t out; + out = (U_RGBAGetR(color) << 16) + + (U_RGBAGetG(color) << 8 ) + + (U_RGBAGetB(color) ); + return(out); +} + +/* Return the base64 encoded png which is shown for all bad images. +Currently a random 3x4 blotch. +Caller must free. +*/ +gchar *Metafile::bad_image_png(void){ + gchar *gstring = g_strdup("iVBORw0KGgoAAAANSUhEUgAAAAQAAAADCAIAAAA7ljmRAAAAA3NCSVQICAjb4U/gAAAALElEQVQImQXBQQ2AMAAAsUJQMSWI2H8qME1yMshojwrvGB8XcHKvR1XtOTc/8HENumHCsOMAAAAASUVORK5CYII="); + return(gstring); +} + + + +} // namespace Internal +} // namespace Extension +} // namespace Inkscape + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/extension/internal/metafile-inout.h b/src/extension/internal/metafile-inout.h new file mode 100644 index 000000000..968773a3a --- /dev/null +++ b/src/extension/internal/metafile-inout.h @@ -0,0 +1,93 @@ +/** @file + * @brief Metafile input - common functions + *//* + * Authors: + * David Mathog + * + * Copyright (C) 2013 Authors + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_METAFILE_INOUT_H +#define SEEN_INKSCAPE_EXTENSION_INTERNAL_METAFILE_INOUT_H + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#define PNG_SKIP_SETJMP_CHECK // else any further png.h include blows up in the compiler +#include +#include +#include +#include +#include +#include +#include +#include +#include <2geom/affine.h> +#include <2geom/pathvector.h> + +#include "extension/implementation/implementation.h" + +class SPObject; + +namespace Inkscape { +class Pixbuf; + +namespace Extension { +namespace Internal { + +/* A coloured pixel. */ +typedef struct { + uint8_t red; + uint8_t green; + uint8_t blue; + uint8_t opacity; +} pixel_t; + +/* A picture. */ + typedef struct { + pixel_t *pixels; + size_t width; + size_t height; +} bitmap_t; + +/* structure to store PNG image bytes */ +typedef struct { + char *buffer; + size_t size; +} MEMPNG, *PMEMPNG; + +class Metafile + : public Inkscape::Extension::Implementation::Implementation +{ +public: + Metafile() {} + ~Metafile(); + +protected: + static uint32_t sethexcolor(U_COLORREF color); + static pixel_t *pixel_at (bitmap_t * bitmap, int x, int y); + static void my_png_write_data(png_structp png_ptr, png_bytep data, png_size_t length); + static void toPNG(PMEMPNG accum, int width, int height, const char *px); + static gchar *bad_image_png(void); + + +private: +}; + +} // namespace Internal +} // namespace Extension +} // namespace Inkscape + +#endif // SEEN_INKSCAPE_EXTENSION_INTERNAL_METAFILE_INOUT_H + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ diff --git a/src/extension/internal/metafile-print.cpp b/src/extension/internal/metafile-print.cpp index 1e7735410..73d63f27d 100644 --- a/src/extension/internal/metafile-print.cpp +++ b/src/extension/internal/metafile-print.cpp @@ -187,7 +187,6 @@ U_COLORREF PrintMetafile::avg_stop_color(SPGradient *gr) return cr; } -#define clrweight(a,b,t) ((1-t)*((double) a) + (t)*((double) b)) U_COLORREF PrintMetafile::weight_opacity(U_COLORREF c1) { float opa = c1.Reserved / 255.0; @@ -199,9 +198,12 @@ U_COLORREF PrintMetafile::weight_opacity(U_COLORREF c1) return result; } +/* t between 0 and 1, values outside that range use the nearest limit */ U_COLORREF PrintMetafile::weight_colors(U_COLORREF c1, U_COLORREF c2, double t) { +#define clrweight(a,b,t) ((1-t)*((double) a) + (t)*((double) b)) U_COLORREF result; + t = ( t > 1.0 ? 1.0 : ( t < 0.0 ? 0.0 : t)); result.Red = clrweight(c1.Red, c2.Red, t); result.Green = clrweight(c1.Green, c2.Green, t); result.Blue = clrweight(c1.Blue, c2.Blue, t); diff --git a/src/extension/internal/wmf-inout.cpp b/src/extension/internal/wmf-inout.cpp index 870e4061c..a72c16a88 100644 --- a/src/extension/internal/wmf-inout.cpp +++ b/src/extension/internal/wmf-inout.cpp @@ -26,7 +26,7 @@ # include "config.h" #endif -#include //This must precede text_reassemble.h or it blows up in pngconf.h when compiling +//#include //This must precede text_reassemble.h or it blows up in pngconf.h when compiling #include #include #include @@ -70,154 +70,6 @@ static U_RECT16 rc_old; static bool clipset = false; static uint32_t BLTmode=0; -/** Construct a PNG in memory from an RGB from the WMF file - -from: -http://www.lemoda.net/c/write-png/ - -which was based on: -http://stackoverflow.com/questions/1821806/how-to-encode-png-to-buffer-using-libpng - -gcc -Wall -o testpng testpng.c -lpng - -Originally here, but moved up - -#include -#include -#include -#include -*/ - - -/* Given "bitmap", this returns the pixel of bitmap at the point - ("x", "y"). */ - -pixel_t * Wmf::pixel_at (bitmap_t * bitmap, int x, int y) -{ - return bitmap->pixels + bitmap->width * y + x; -} - - -/* Write "bitmap" to a PNG file specified by "path"; returns 0 on - success, non-zero on error. */ - -void -Wmf::my_png_write_data(png_structp png_ptr, png_bytep data, png_size_t length) -{ - PMEMPNG p=(PMEMPNG)png_get_io_ptr(png_ptr); - - size_t nsize = p->size + length; - - /* allocate or grow buffer */ - if(p->buffer){ p->buffer = (char *) realloc(p->buffer, nsize); } - else{ p->buffer = (char *) malloc(nsize); } - - if(!p->buffer){ png_error(png_ptr, "Write Error"); } - - /* copy new bytes to end of buffer */ - memcpy(p->buffer + p->size, data, length); - p->size += length; -} - -void Wmf::toPNG(PMEMPNG accum, int width, int height, const char *px){ - bitmap_t bmStore; - bitmap_t *bitmap = &bmStore; - accum->buffer=NULL; // PNG constructed in memory will end up here, caller must free(). - accum->size=0; - bitmap->pixels=(pixel_t *)px; - bitmap->width = width; - bitmap->height = height; - - png_structp png_ptr = NULL; - png_infop info_ptr = NULL; - size_t x, y; - png_byte ** row_pointers = NULL; - /* The following number is set by trial and error only. I cannot - see where it it is documented in the libpng manual. - */ - int pixel_size = 3; - int depth = 8; - - png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - if (png_ptr == NULL){ - accum->buffer=NULL; - return; - } - - info_ptr = png_create_info_struct (png_ptr); - if (info_ptr == NULL){ - png_destroy_write_struct (&png_ptr, &info_ptr); - accum->buffer=NULL; - return; - } - - /* Set up error handling. */ - - if (setjmp (png_jmpbuf (png_ptr))) { - png_destroy_write_struct (&png_ptr, &info_ptr); - accum->buffer=NULL; - return; - } - - /* Set image attributes. */ - - png_set_IHDR ( - png_ptr, - info_ptr, - bitmap->width, - bitmap->height, - depth, - PNG_COLOR_TYPE_RGB, - PNG_INTERLACE_NONE, - PNG_COMPRESSION_TYPE_DEFAULT, - PNG_FILTER_TYPE_DEFAULT - ); - - /* Initialize rows of PNG. */ - - row_pointers = (png_byte **) png_malloc (png_ptr, bitmap->height * sizeof (png_byte *)); - for (y = 0; y < bitmap->height; ++y) { - png_byte *row = - (png_byte *) png_malloc (png_ptr, sizeof (uint8_t) * bitmap->width * pixel_size); - row_pointers[bitmap->height - y - 1] = row; // Row order in WMF is reversed. - for (x = 0; x < bitmap->width; ++x) { - pixel_t * pixel = pixel_at (bitmap, x, y); - *row++ = pixel->red; // R & B channels were set correctly by DIB_to_RGB - *row++ = pixel->green; - *row++ = pixel->blue; - } - } - - /* Write the image data to memory */ - - png_set_rows (png_ptr, info_ptr, row_pointers); - - png_set_write_fn(png_ptr, accum, my_png_write_data, NULL); - - png_write_png (png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, NULL); - - for (y = 0; y < bitmap->height; y++) { - png_free (png_ptr, row_pointers[y]); - } - png_free (png_ptr, row_pointers); - png_destroy_write_struct(&png_ptr, &info_ptr); - -} - - -/* convert an WMF RGB(A) color to 0RGB -inverse of gethexcolor() in emf-print.cpp -*/ -uint32_t Wmf::sethexcolor(U_COLORREF color){ - - uint32_t out; - out = (U_RGBAGetR(color) << 16) + - (U_RGBAGetG(color) << 8 ) + - (U_RGBAGetB(color) ); - return(out); -} - - Wmf::Wmf (void) // The null constructor { return; diff --git a/src/extension/internal/wmf-inout.h b/src/extension/internal/wmf-inout.h index 90f424c46..3d23ca749 100644 --- a/src/extension/internal/wmf-inout.h +++ b/src/extension/internal/wmf-inout.h @@ -11,9 +11,8 @@ #ifndef SEEN_EXTENSION_INTERNAL_WMF_H #define SEEN_EXTENSION_INTERNAL_WMF_H -#define PNG_SKIP_SETJMP_CHECK // else any further png.h include blows up in the compiler -#include #include +#include "extension/internal/metafile-inout.h" // picks up PNG #include "extension/implementation/implementation.h" #include "style.h" #include "text_reassemble.h" @@ -69,35 +68,6 @@ typedef struct wmf_device_context { #define WMF_MAX_DC 128 -/* - both emf-inout.h and wmf-inout.h are included by init.cpp, so whichever one goes in first defines these ommon types -*/ -#ifndef SEEN_EXTENSION_INTERNAL_METAFILECOMMON_ -#define SEEN_EXTENSION_INTERNAL_METAFILECOMMON_ -/* A coloured pixel. */ -typedef struct { - uint8_t red; - uint8_t green; - uint8_t blue; - uint8_t opacity; -} pixel_t; - -/* A picture. */ - -typedef struct { - pixel_t *pixels; - size_t width; - size_t height; -} bitmap_t; - -/* structure to store PNG image bytes */ -typedef struct { - char *buffer; - size_t size; -} MEMPNG, *PMEMPNG; -#endif - - // like this causes a mysterious crash on the return from Wmf::open //typedef struct emf_callback_data { @@ -138,7 +108,8 @@ typedef struct { PWMF_OBJECT wmf_obj; } WMF_CALLBACK_DATA, *PWMF_CALLBACK_DATA; -class Wmf : Inkscape::Extension::Implementation::Implementation { //This is a derived class +class Wmf : public Metafile +{ public: Wmf(); // Empty constructor @@ -158,10 +129,6 @@ public: private: protected: - static pixel_t *pixel_at (bitmap_t * bitmap, int x, int y); - static void my_png_write_data(png_structp png_ptr, png_bytep data, png_size_t length); - static void toPNG(PMEMPNG accum, int width, int height, const char *px); - static uint32_t sethexcolor(U_COLORREF color); static void print_document_to_file(SPDocument *doc, const gchar *filename); static double current_scale(PWMF_CALLBACK_DATA d); static std::string current_matrix(PWMF_CALLBACK_DATA d, double x, double y, int useoffset); diff --git a/src/extension/internal/wmf-print.cpp b/src/extension/internal/wmf-print.cpp index d60b2adf7..1c7b42c82 100644 --- a/src/extension/internal/wmf-print.cpp +++ b/src/extension/internal/wmf-print.cpp @@ -76,7 +76,7 @@ namespace Internal { /* globals */ -static double PX2WORLD = 1200.0 / 90.0; // inkscape is 90 dpi, WMF file is 1200 +static double PX2WORLD; // value set in begin() static bool FixPPTCharPos, FixPPTDashLine, FixPPTGrad2Polys, FixPPTPatternAsHatch; static WMFTRACK *wt = NULL; static WMFHANDLES *wht = NULL; @@ -128,6 +128,8 @@ unsigned int PrintWmf::begin(Inkscape::Extension::Print *mod, SPDocument *doc) char *rec; gchar const *utf8_fn = mod->get_param_string("destination"); + // Typically PX2WORLD is 1200/90, using inkscape's default dpi + PX2WORLD = 1200.0 / Inkscape::Util::Quantity::convert(1.0, "in", "px"); FixPPTCharPos = mod->get_param_bool("FixPPTCharPos"); FixPPTDashLine = mod->get_param_bool("FixPPTDashLine"); FixPPTGrad2Polys = mod->get_param_bool("FixPPTGrad2Polys"); @@ -188,39 +190,39 @@ unsigned int PrintWmf::begin(Inkscape::Extension::Print *mod, SPDocument *doc) int dwPxY = round(d.height() * 1200.0); #endif - PU_PAIRF ps = U_PAIRF_set(dwInchesX, dwInchesY); + U_PAIRF *ps = U_PAIRF_set(dwInchesX, dwInchesY); rec = U_WMRHEADER_set(ps, 1200); // Example: drawing is A4 horizontal, 1200 dpi if (!rec) { g_error("Fatal programming error in PrintWmf::begin at WMRSETMAPMODE"); } - (void) wmf_header_append((PU_METARECORD)rec, wt, 1); + (void) wmf_header_append((U_METARECORD *)rec, wt, 1); free(ps); rec = U_WMRSETWINDOWEXT_set(point16_set(dwPxX, dwPxY)); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::begin at WMRSETWINDOWEXT"); } rec = U_WMRSETWINDOWORG_set(point16_set(0, 0)); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::begin at WMRSETWINDOWORG"); } rec = U_WMRSETMAPMODE_set(U_MM_ANISOTROPIC); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::begin at WMRSETMAPMODE"); } /* set some parameters, else the program that reads the WMF may default to other values */ rec = U_WMRSETBKMODE_set(U_TRANSPARENT); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::begin at U_WMRSETBKMODE"); } hpolyfillmode = U_WINDING; rec = U_WMRSETPOLYFILLMODE_set(U_WINDING); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::begin at U_WMRSETPOLYFILLMODE"); } @@ -229,24 +231,24 @@ unsigned int PrintWmf::begin(Inkscape::Extension::Print *mod, SPDocument *doc) // actually starts, and already takes into account the text object's alignment; // - for this reason, the WMF text alignment must always be TA_BASELINE|TA_LEFT. rec = U_WMRSETTEXTALIGN_set(U_TA_BASELINE | U_TA_LEFT); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::begin at U_WMRSETTEXTALIGN_set"); } htextcolor_rgb[0] = htextcolor_rgb[1] = htextcolor_rgb[2] = 0.0; rec = U_WMRSETTEXTCOLOR_set(U_RGB(0, 0, 0)); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::begin at U_WMRSETTEXTCOLOR_set"); } rec = U_WMRSETROP2_set(U_R2_COPYPEN); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::begin at U_WMRSETROP2"); } hmiterlimit = 5; rec = wmiterlimit_set(5); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::begin at wmiterlimit_set"); } @@ -255,14 +257,14 @@ unsigned int PrintWmf::begin(Inkscape::Extension::Print *mod, SPDocument *doc) U_PEN up = U_PEN_set(U_PS_SOLID, 1, colorref_set(0, 0, 0)); uint32_t Pen; rec = wcreatepenindirect_set(&Pen, wht, up); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::begin at wcreatepenindirect_set"); } // create a null pen. If no specific pen is set, this is used up = U_PEN_set(U_PS_NULL, 1, colorref_set(0, 0, 0)); rec = wcreatepenindirect_set(&hpen_null, wht, up); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::begin at wcreatepenindirect_set"); } destroy_pen(); // make this pen active @@ -270,7 +272,7 @@ unsigned int PrintWmf::begin(Inkscape::Extension::Print *mod, SPDocument *doc) // create a null brush. If no specific brush is set, this is used U_WLOGBRUSH lb = U_WLOGBRUSH_set(U_BS_NULL, U_RGB(0, 0, 0), U_HS_HORIZONTAL); rec = wcreatebrushindirect_set(&hbrush_null, wht, lb); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::begin at wcreatebrushindirect_set"); } destroy_brush(); // make this brush active @@ -288,25 +290,25 @@ unsigned int PrintWmf::finish(Inkscape::Extension::Print * /*mod*/) // get rid of null brush rec = wdeleteobject_set(&hbrush_null, wht); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::finish at wdeleteobject_set null brush"); } // get rid of null pen rec = wdeleteobject_set(&hpen_null, wht); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::finish at wdeleteobject_set null pen"); } // get rid of object 0, which was a pen that was used to shift the other object indices to >=1. hpen = 0; rec = wdeleteobject_set(&hpen, wht); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::finish at wdeleteobject_set filler object"); } rec = U_WMREOF_set(); // generate the EOF record - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::finish"); } (void) wmf_finish(wt); // Finalize and write out the WMF @@ -330,7 +332,7 @@ unsigned int PrintWmf::comment(Inkscape::Extension::Print * /*module*/, const ch // fcolor is defined when gradients are being expanded, it is the color of one stripe or ring. -int PrintWmf::create_brush(SPStyle const *style, PU_COLORREF fcolor) +int PrintWmf::create_brush(SPStyle const *style, U_COLORREF *fcolor) { float rgb[3]; char *rec; @@ -442,17 +444,17 @@ int PrintWmf::create_brush(SPStyle const *style, PU_COLORREF fcolor) // SVG text has no background attribute, so OPAQUE mode ALWAYS cancels after the next draw, otherwise it would mess up future text output. if (usebk) { rec = U_WMRSETBKCOLOR_set(bkColor); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::create_brush at U_WMRSETBKCOLOR_set"); } rec = U_WMRSETBKMODE_set(U_OPAQUE); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::create_brush at U_WMRSETBKMODE_set"); } } lb = U_WLOGBRUSH_set(brushStyle, hatchColor, hatchType); rec = wcreatebrushindirect_set(&brush, wht, lb); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::create_brush at createbrushindirect_set"); } break; @@ -461,10 +463,10 @@ int PrintWmf::create_brush(SPStyle const *style, PU_COLORREF fcolor) char *rgba_px; uint32_t cbPx; uint32_t colortype; - PU_RGBQUAD ct; + U_RGBQUAD *ct; int numCt; U_BITMAPINFOHEADER Bmih; - PU_BITMAPINFO Bmi; + U_BITMAPINFO *Bmi; rgba_px = (char *) pixbuf->pixels(); // Do NOT free this!!! colortype = U_BCBM_COLOR32; (void) RGBA_to_DIB(&px, &cbPx, &ct, &numCt, rgba_px, width, height, width * 4, colortype, 0, 1); @@ -474,7 +476,7 @@ int PrintWmf::create_brush(SPStyle const *style, PU_COLORREF fcolor) Bmih = bitmapinfoheader_set(width, height, 1, colortype, U_BI_RGB, 0, PXPERMETER, PXPERMETER, numCt, 0); Bmi = bitmapinfo_set(Bmih, ct); rec = wcreatedibpatternbrush_srcdib_set(&brush, wht, U_DIB_RGB_COLORS, Bmi, cbPx, px); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::create_brush at createdibpatternbrushpt_set"); } free(px); @@ -484,14 +486,14 @@ int PrintWmf::create_brush(SPStyle const *style, PU_COLORREF fcolor) hbrush = brush; // need this later for destroy_brush rec = wselectobject_set(brush, wht); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::create_brush at wselectobject_set"); } if (fmode != hpolyfillmode) { hpolyfillmode = fmode; rec = U_WMRSETPOLYFILLMODE_set(fmode); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::create_brush at U_WMRSETPOLYFILLMODE_set"); } } @@ -506,7 +508,7 @@ void PrintWmf::destroy_brush() // WMF lets any object be deleted whenever, and the chips fall where they may... if (hbrush) { rec = wdeleteobject_set(&hbrush, wht); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::destroy_brush"); } hbrush = 0; @@ -515,7 +517,7 @@ void PrintWmf::destroy_brush() // (re)select the null brush rec = wselectobject_set(hbrush_null, wht); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::destroy_brush"); } } @@ -583,7 +585,7 @@ int PrintWmf::create_pen(SPStyle const *style, const Geom::Affine &transform) if ((uint32_t)miterlimit != hmiterlimit) { hmiterlimit = (uint32_t)miterlimit; rec = wmiterlimit_set((uint32_t) miterlimit); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::create_pen at wmiterlimit_set"); } } @@ -605,12 +607,12 @@ int PrintWmf::create_pen(SPStyle const *style, const Geom::Affine &transform) up = U_PEN_set(penstyle | modstyle, linewidth, penColor); rec = wcreatepenindirect_set(&pen, wht, up); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::create_pen at wcreatepenindirect_set"); } rec = wselectobject_set(pen, wht); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::create_pen at wselectobject_set"); } hpen = pen; // need this later for destroy_pen @@ -625,7 +627,7 @@ void PrintWmf::destroy_pen() // WMF lets any object be deleted whenever, and the chips fall where they may... if (hpen) { rec = wdeleteobject_set(&hpen, wht); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::destroy_pen"); } hpen = 0; @@ -634,7 +636,7 @@ void PrintWmf::destroy_pen() // (re)select the null pen rec = wselectobject_set(hpen_null, wht); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::destroy_pen"); } } @@ -757,7 +759,7 @@ unsigned int PrintWmf::fill( pathvr = sp_pathvector_boolop(pathvc, pathv, bool_op_inters, (FillRule) fill_nonZero, frb); print_pathv(pathvr, fill_transform); - /* after high end of gradient, overlap last slice poosition */ + /* after high end of gradient, overlap last slice position */ wc = weight_opacity(c2); (void) create_brush(style, &wc); pathvc = rect_cutter(gv.p2, uv * (-overlap), uv * (50000.0), puv * 50000.0); @@ -898,7 +900,7 @@ unsigned int PrintWmf::stroke( if (usebk) { // OPAQUE was set, revert to TRANSPARENT usebk = false; rec = U_WMRSETBKMODE_set(U_TRANSPARENT); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::stroke at U_WMRSETBKMODE_set"); } } @@ -1066,7 +1068,7 @@ bool PrintWmf::print_simple_shape(Geom::PathVector const &pathv, const Geom::Aff }); rec = U_WMRELLIPSE_set(rcl); } - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::print_simple_shape at retangle/ellipse/polygon"); } @@ -1109,7 +1111,7 @@ unsigned int PrintWmf::image( Geom::Affine tf = m_tr_stack.top(); rec = U_WMRSETSTRETCHBLTMODE_set(U_COLORONCOLOR); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::image at EMRHEADER"); } @@ -1126,10 +1128,10 @@ unsigned int PrintWmf::image( char *px; uint32_t cbPx; uint32_t colortype; - PU_RGBQUAD ct; + U_RGBQUAD *ct; int numCt; U_BITMAPINFOHEADER Bmih; - PU_BITMAPINFO Bmi; + U_BITMAPINFO *Bmi; colortype = U_BCBM_COLOR32; (void) RGBA_to_DIB(&px, &cbPx, &ct, &numCt, (char *) rgba_px, w, h, w * 4, colortype, 0, 1); Bmih = bitmapinfoheader_set(w, h, 1, colortype, U_BI_RGB, 0, PXPERMETER, PXPERMETER, numCt, 0); @@ -1150,7 +1152,7 @@ unsigned int PrintWmf::image( h * rs, //! size in bytes of px px //! (Optional) bitmapbuffer (U_BITMAPINFO section) ); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::image at U_WMRSTRETCHDIB_set"); } free(px); @@ -1165,7 +1167,7 @@ unsigned int PrintWmf::image( unsigned int PrintWmf::print_pathv(Geom::PathVector const &pathv, const Geom::Affine &transform) { char *rec = NULL; - PU_POINT16 pt16hold, pt16ptr; + U_POINT16 *pt16hold, *pt16ptr; uint16_t *n16hold; uint16_t *n16ptr; @@ -1199,7 +1201,7 @@ unsigned int PrintWmf::print_pathv(Geom::PathVector const &pathv, const Geom::Af } if (nPolys > 1) { // a single polypolygon, a single polygon falls through to the else - pt16hold = pt16ptr = (PU_POINT16) malloc(totPoints * sizeof(U_POINT16)); + pt16hold = pt16ptr = (U_POINT16 *) malloc(totPoints * sizeof(U_POINT16)); if (!pt16ptr) { return(false); } @@ -1235,7 +1237,7 @@ unsigned int PrintWmf::print_pathv(Geom::PathVector const &pathv, const Geom::Af } rec = U_WMRPOLYPOLYGON_set(nPolys, n16hold, pt16hold); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::print_pathv at U_WMRPOLYPOLYGON_set"); } free(pt16hold); @@ -1256,7 +1258,7 @@ unsigned int PrintWmf::print_pathv(Geom::PathVector const &pathv, const Geom::Af */ int nPoints = 1 + pit->size_default(); - pt16hold = pt16ptr = (PU_POINT16) malloc(nPoints * sizeof(U_POINT16)); + pt16hold = pt16ptr = (U_POINT16 *) malloc(nPoints * sizeof(U_POINT16)); if (!pt16ptr) { break; } @@ -1280,21 +1282,21 @@ unsigned int PrintWmf::print_pathv(Geom::PathVector const &pathv, const Geom::Af if (pit->end_default() == pit->end_closed()) { rec = U_WMRPOLYGON_set(nPoints, pt16hold); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::print_pathv at U_WMRPOLYGON_set"); } } else if (nPoints > 2) { rec = U_WMRPOLYLINE_set(nPoints, pt16hold); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::print_pathv at U_POLYLINE_set"); } } else if (nPoints == 2) { rec = U_WMRMOVETO_set(pt16hold[0]); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::print_pathv at U_WMRMOVETO_set"); } rec = U_WMRLINETO_set(pt16hold[1]); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::print_pathv at U_WMRLINETO_set"); } } @@ -1348,7 +1350,7 @@ unsigned int PrintWmf::text(Inkscape::Extension::Print * /*mod*/, char const *te if (textalignment != htextalignment) { htextalignment = textalignment; rec = U_WMRSETTEXTALIGN_set(textalignment); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::text at U_WMRSETTEXTALIGN_set"); } } @@ -1420,7 +1422,7 @@ unsigned int PrintWmf::text(Inkscape::Extension::Print * /*mod*/, char const *te // it was streteched asymmetrically.) Few applications support text from WMF which is scaled // differently by height/width, so leave lfWidth alone. - PU_FONT puf = U_FONT_set( + U_FONT *puf = U_FONT_set( textheight, 0, round(rot), @@ -1438,14 +1440,14 @@ unsigned int PrintWmf::text(Inkscape::Extension::Print * /*mod*/, char const *te free(facename); rec = wcreatefontindirect_set(&hfont, wht, puf); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::text at wcreatefontindirect_set"); } free(puf); } rec = wselectobject_set(hfont, wht); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::text at wselectobject_set"); } @@ -1455,7 +1457,7 @@ unsigned int PrintWmf::text(Inkscape::Extension::Print * /*mod*/, char const *te if (memcmp(htextcolor_rgb, rgb, 3 * sizeof(float))) { memcpy(htextcolor_rgb, rgb, 3 * sizeof(float)); rec = U_WMRSETTEXTCOLOR_set(U_RGB(255 * rgb[0], 255 * rgb[1], 255 * rgb[2])); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::text at U_WMRSETTEXTCOLOR_set"); } } @@ -1522,12 +1524,12 @@ unsigned int PrintWmf::text(Inkscape::Extension::Print * /*mod*/, char const *te } free(latin1_text); free(adx); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::text at U_WMREXTTEXTOUTW_set"); } rec = wdeleteobject_set(&hfont, wht); - if (!rec || wmf_append((PU_METARECORD)rec, wt, U_REC_FREE)) { + if (!rec || wmf_append((U_METARECORD *)rec, wt, U_REC_FREE)) { g_error("Fatal programming error in PrintWmf::text at wdeleteobject_set"); } diff --git a/src/libuemf/CMakeLists.txt b/src/libuemf/CMakeLists.txt index dbf9fb36c..f5a97f212 100644 --- a/src/libuemf/CMakeLists.txt +++ b/src/libuemf/CMakeLists.txt @@ -8,6 +8,8 @@ set(libuemf_SRC uwmf.c uwmf_endian.c uwmf_print.c + upmf.c + upmf_print.c # ------- # Headers @@ -19,6 +21,8 @@ set(libuemf_SRC uwmf.h uwmf_endian.h uwmf_print.h + upmf.h + upmf_print.h ) add_inkscape_lib(uemf_LIB "${libuemf_SRC}") diff --git a/src/libuemf/Makefile_insert b/src/libuemf/Makefile_insert index ca14ed19f..004c56dfc 100644 --- a/src/libuemf/Makefile_insert +++ b/src/libuemf/Makefile_insert @@ -20,5 +20,9 @@ libuemf_libuemf_a_SOURCES = \ libuemf/uwmf_endian.h \ libuemf/uwmf_print.c \ libuemf/uwmf_print.h \ + libuemf/upmf.c \ + libuemf/upmf.h \ + libuemf/upmf_print.c \ + libuemf/upmf_print.h \ libuemf/symbol_convert.c \ libuemf/symbol_convert.h diff --git a/src/libuemf/README b/src/libuemf/README index 53e2469e3..4c23cdd52 100644 --- a/src/libuemf/README +++ b/src/libuemf/README @@ -1,5 +1,477 @@ -Theis directory contains the libUEMF library, -a cross-platform library for Windows Metafile and Enhanced Metafile -handling, created by David Mathog. +Overview: -http://sourceforge.net/projects/libuemf/ +libUEMF is a portable C99 implementation for reading/writing Enhanced Metafile (EMF) +and Windows Metafile (WMF) files. libUEMF avoids collisions with with Microsoft defined +functions and values, so portable programs which use it, and have a Windows version, do +not require any conditional logic to separate the native GDI support from the WMF/EMF support +proviced by libUEMF. To accomplish this libUEMF does not implement GDI calls. Instead, +for each WMR/EMR record type, and each object type incorporated into such a record, it provides +corresponding *_set, *_print, and *_swap functions. (For WMF there are also *_get functions, see below.) +For example, for the U_EMRBITBLT record there are corresponding functions: +U_EMRBITBLT_set, U_EMRBITBLT_print, and U_EMRBITBLT_swap. A few additional functions are provided for +assembling the EMF in memory, debugging, and converting the EMF file to/from Little Endian representation. +(EMF files' internal data representation is always Little Endian.) + +This code has been tested on 32 bit Ubuntu (LE), 32 bit Mingw, 64 bit Manriva, and 64 bit Solaris (BE). + +libUEMF is released under the GPL 2 license, read the file 'COPYING' for more information + +Version 0.1.10, released January 15, 2014. + +To report bugs or provide feedback send email to David Mathog, mathog@caltech.edu. + +-------------------------------------------------------------------------------------------- +Sources: + +EMF file Record structure information has been derived from Mingw, Wine, and libEMF +header files, and from Microsoft's EMF Information pdf, release date March 28,2012, +link from here: + + http://msdn2.microsoft.com/en-us/library/cc230514.aspx + +If the direct link fails the document may be found +by searching the web for: "[MS-EMF]: Enhanced Metafile Format". + +WMF file Record structure information is from some of the same sources, as well as: + http://msdn2.microsoft.com/en-us/library/250370.aspx + +If the direct link fails the document may be found +by searching the web for: "[MS-WMF]: Windows Metafile Format" + +EMF+ file Record structure is from many helpful responses from Microsoft documentation support +and from: + http://msdn.microsoft.com/en-us/library/cc230724.aspx + +If the direct link fails the document may be found +by searching the web for: "[MS-EMFPLUS]: Enhanced Metafile Format Plus Extensions" + + +Files: + +README This file. + +COPYING GPL V2 license file. + +DOXYFILE Doxygen configuration file, for generating documentation from the source files. + +testbuild.sh Small bash script to build all programs. Modify as needed for target platform. + +testit.sh Small bash script that generates all test files and compares + them with referencess supplied. This script should be edited + to match your test system before it is run! + +uemf.c Contains the *_set functions needed to construct an EMF file. + Also contains auxilliary functions for debugging and constructing + EMF files in memory. + +uemf.h Definitions and structures for EMF records and objects. + Prototypes for *_set and construction functions. + +uemf_print.c Contains the *_print functions needed to print the contents of EMF records and objects. + +uemf_print.h Prototypes for *_print functions. + +uemf_endian.c Contains the *_swap functions needed to rearrange bytes between Big and Little Endian. + U_emf_endian() is the only function here that user could should call. + +uemf_endian.h Prototype for U_emf_endian() and definitions for Endian type of the local machine. + + +upmf.c Contains the *_set and *_get functions needed to construct or read an EMF+ file. + Also contains auxilliary functions for debugging and constructing + EMF+ files in memory. + +upmf.h Definitions and structures for EMF+ records and objects. + Prototypes for *_set, *_get and construction functions. + +upmf_print.c Contains the *_print functions needed to print the contents of EMF+ records and objects. + +upmf_print.h Prototypes for *_print functions. + + +uwmf.c Contains the *_set and *_get functions needed to construct or read a WMF file. + Also contains auxilliary functions for debugging and constructing + WMF files in memory. + +uwmf.h Definitions and structures for WMF records and objects. + Prototypes for *_set, *_get and construction functions. + +uwmf_print.c Contains the *_print functions needed to print the contents of WMF records and objects. + +uwmf_print.h Prototypes for *_print functions. + +uwmf_endian.c Contains the *_swap functions needed to rearrange bytes between Big and Little Endian. + U_wmf_endian() is the only function here that user could should call. + +uwmf_endian.h Prototype for U_wmf_endian() and definitions for Endian type of the local machine. + + +testbed_emf.c Program used for testing emf functions in libUEMF. Run it like: testbed_emf flags. + Run with no argument to see what the bit flag values are. + It creates a test file "test_libuemf.emf" which should be identical to + test_libuemf_ref.emf. (This file cannot be imported from EMF into PowerPoint + because it contains dotted lines. Use "testbed_emf 1" to generate a file without + any dotted lines. ) + +testbed_pmf.c Program used for testing EMF+ functions in libUEMF. Similar to testbed_emf. + +testbed_wmf.c Program used for testing wmf functions in libUEMF. Similar to testbed_emf. + +test_mapmodes_emf.c + Program used for testing emf functions in libUEMF. Generates one test file + in each MAPMODE, MM_TEXT through MM_ANISOTROPIC, optionally with offsets to the + bounds and with particular Viewport origin. (Bounds offset + Viewport Origin + sets the Window origin.) + +test_mapmodes_wmf.c + Program used for testing wmf functions in libUEMF. Similar to test_mapmodes_emf. + +reademf.c Utility that that reads an EMF file and emits its contents in text form. + Also processes EMF+ files. + Run it like: reademf target_file.emf + +readwmf.c Utility that that reads an WMF file and emits its contents in text form. + Run it like: reademf target_file.wmf + +cutemf.c Utility for removing specific records from an EMF file. + Run it like: cutemf '2,10,12...13' src_file.emf dst_file.emf + +pmfdual2single.c Utility for reducing dual-mode EMF+ file to single mode. Removes all + nonessential EMF records. + Run it like: pmfdual2single dual_mode.emf single_mode.emf + + +test_libuemf_ref.emf + Example output from: testbed_emf 0 +test_libuemf_p_ref.emf + Example output from: testbed_pmf 0 +test_libuemf_ref30.emf + Example output from: testbed_emf 4 +test_libuemf_ref.wmf + Example output from: testbed_wmf 0 + +test_libuemf_ref_emf.txt + Example output from: reademf test_libuemf_ref.emf +test_libuemf_ref_wmf.txt + Example output from: readwmf test_libuemf_ref.wmf + +test_mm__ref.emf + Example output from: test_mapmodes_emf -vX 2000 -vY 1000 + +emf-inout.cpp,example +emf-inout.h.example +emf-print.cpp.example +emf-print.h.example + Example code from Inkscape demonstrate how to integrate libUEMF with another program. + +-------------------------------------------------------------------------------------------- +How to Build: + +In Linux/Unix like environments (omit -g flag for production versions): + + Build and install a shared library (example, details may vary) and then build and link + the example programs to the shared library: + gcc -std=c99 -pedantic -Wall -fPIC -g -c uemf.c + gcc -std=c99 -pedantic -Wall -fPIC -g -c uemf_print.c + gcc -std=c99 -pedantic -Wall -fPIC -g -c uemf_endian.c + gcc -std=c99 -pedantic -Wall -fPIC -g -c uemf_utf.c + gcc -std=c99 -pedantic -Wall -fPIC -g -c uwmf.c + gcc -std=c99 -pedantic -Wall -fPIC -g -c uwmf_print.c + gcc -std=c99 -pedantic -Wall -fPIC -g -c uwmf_endian.c + gcc -std=c99 -pedantic -Wall -fPIC -g -c upmf.c + gcc -std=c99 -pedantic -Wall -fPIC -g -c upmf_print.c + gcc -shared -Wl,-soname,libuemf.so.0 \ + -o libuemf.so.0.0.3 uemf.o uemf_utf.o uemf_print.o uemf_endian.o uwmf.o uwmf_print.o uwmf_endian.o upmf.o upmf_print.o -lc + ln -s libuemf.so.0.0.3 libuemf.so.0 + ln -s libuemf.so.0 libuemf.so + /bin/cp -f libuemf.so* /usr/local/lib + ldconfig + gcc -std=c99 -pedantic -Wall -g -o cutemf cutemf.c -luemf -lm + gcc -std=c99 -pedantic -Wall -g -o pmfdual2single pmfdual2single.c -luemf -lm + gcc -std=c99 -pedantic -Wall -g -o reademf reademf.c -luemf -lm + gcc -std=c99 -pedantic -Wall -g -o readwmf readwmf.c -luemf -lm + gcc -std=c99 -pedantic -Wall -g -o testbed_emf testbed_emf.c -luemf -lm + gcc -std=c99 -pedantic -Wall -g -o testbed_emf testbed_wmf.c -luemf -lm + gcc -std=c99 -pedantic -Wall -g -o test_mapmodes_emf test_mapmodes_emf.c -luemf -lm + + For simple development work just build the example programs statically linked: + gcc -std=c99 -pedantic -Wall -g -o cutemf cutemf.c uemf.c uemf_endian.c uemf_utf.c -lm + gcc -std=c99 -pedantic -Wall -g -o pmfdual2single pmfdual2single.c uemf.c uemf_endian.c uemf_utf.c upmf.c -lm + gcc -std=c99 -pedantic -Wall -g -o reademf reademf.c uemf.c uemf_endian.c uemf_utf.c uemf_print.c upmf.c upmf_print.c -lm + gcc -std=c99 -pedantic -Wall -g -o readwmf readwmf.c uemf.c uemf_endian.c uemf_utf.c uemf_print.c uwmf.c uwmf_endian.c uwmf_print.c upmf.c upmf_print.c -lm + gcc -std=c99 -pedantic -Wall -g -o testbed_emf testbed_emf.c uemf.c uemf_endian.c uemf_utf.c -lm + gcc -std=c99 -pedantic -Wall -g -o testbed_pmf testbed_pmf.c uemf.c uemf_endian.c uemf_utf.c upmf.c upmf.h -lm + gcc -std=c99 -pedantic -Wall -g -o testbed_wmf testbed_wmf.c uemf.c uemf_endian.c uemf_utf.c uwmf.c uwmf_endian.c -lm + gcc -std=c99 -pedantic -Wall -g -o test_mapmodes_emf test_mapmodes_emf.c uemf.c uemf_endian.c uemf_utf.c -lm + +Extra debugging on linux may be enabled in testbed for use under Valgrind. To build that way do instead: + + gcc -std=c99 -pedantic -Wall -g -DU_VALGRIND -o testbed_emf testbed_emf.c uemf.c uemf_endian.c uemf_print.c uemf_utf.c -lm + +Sparc Solaris 8 and 9 are Big Endian, and to work around some minor incompatibilities with more recent systems, +assuming gcc is installed in /opt/csw and PATH is set correctly to use it: + + gcc -DSOL8 -DWORDS_BIGENDIAN -std=c99 -pedantic -Wall -g -o cutemf cutemf.c uemf.c uemf_endian.c uemf_utf.c -lm -L/opt/csw/lib -liconv + gcc -DSOL8 -DWORDS_BIGENDIAN -std=c99 -pedantic -Wall -g -o pmfdual2single pmfdual2single.c uemf.c uemf_endian.c uemf_utf.c upmf.c -lm -L/opt/csw/lib -liconv + gcc -DSOL8 -DWORDS_BIGENDIAN -std=c99 -pedantic -Wall -g -o reademf reademf.c uemf.c uemf_endian.c uemf_utf.c uemf_print.c upmf.c upmf_print.c -lm -L/opt/csw/lib -liconv + gcc -DSOL8 -DWORDS_BIGENDIAN -std=c99 -pedantic -Wall -g -o readwmf readwmf.c uemf.c uemf_endian.c uemf_utf.c uemf_print.c uwmf.c uwmf_endian.c uwmf_print.c upmf.c upmf_print.c -lm -L/opt/csw/lib -liconv + gcc -DSOL8 -DWORDS_BIGENDIAN -std=c99 -pedantic -Wall -g -o testbed_emf testbed_emf.c uemf.c uemf_endian.c uemf_utf.c -lm -L/opt/csw/lib -liconv + gcc -DSOL8 -DWORDS_BIGENDIAN -std=c99 -pedantic -Wall -g -o testbed_pmf testbed_pmf.c uemf.c uemf_endian.c uemf_utf.c upmf.c upmf.h -lm -L/opt/csw/lib -liconv + gcc -DSOL8 -DWORDS_BIGENDIAN -std=c99 -pedantic -Wall -g -o testbed_wmf testbed_wmf.c uemf.c uemf_endian.c uemf_utf.c uwmf.c uwmf_endian.c -lm -L/opt/csw/lib -liconv + gcc -DSOL8 -DWORDS_BIGENDIAN -std=c99 -pedantic -Wall -g -o test_mapmodes_emf test_mapmodes_emf.c uemf.c uemf_endian.c uemf_utf.c -lm -L/opt/csw/lib -liconv + +(Note: WORDS_BIGENDIAN would also be produced by autconf's configure, if that was used.) + +Define WIN32 when compiling for Windows. This uses _wfopen() instead of fopen(), with +filename translation from UTF-8 to UTF-16LE. This will allow file opens to utilize unicode +names. If WIN32 is omitted on Windows file names must be all ASCII. To build on mingw use: + + gcc -DWIN32 -std=c99 -pedantic -Wall -g -o cutemf cutemf.c uemf.c uemf_endian.c uemf_utf.c -lm -liconv + gcc -DWIN32 -std=c99 -pedantic -Wall -g -o pmfdual2single pmfdual2single.c uemf.c uemf_endian.c uemf_utf.c upmf.c -lm -liconv + gcc -DWIN32 -std=c99 -pedantic -Wall -g -o reademf reademf.c uemf.c uemf_endian.c uemf_utf.c uemf_print.c upmf.c upmf_print.c -lm -liconv + gcc -DWIN32 -std=c99 -pedantic -Wall -g -o readwmf readwmf.c uemf.c uemf_endian.c uemf_utf.c uemf_print.c uwmf.c uwmf_endian.c uwmf_print.c upmf.c upmf_print.c -lm -liconv + gcc -DWIN32 -std=c99 -pedantic -Wall -g -o testbed_emf testbed_emf.c uemf.c uemf_endian.c uemf_utf.c -lm -liconv + gcc -DWIN32 -std=c99 -pedantic -Wall -g -o testbed_pmf testbed_pmf.c uemf.c uemf_endian.c uemf_utf.c upmf.c upmf.h -lm -liconv + gcc -DWIN32 -std=c99 -pedantic -Wall -g -o testbed_wmf testbed_wmf.c uemf.c uemf_endian.c uemf_utf.c uwmf.c uwmf_endian.c -lm -liconv + gcc -DWIN32 -std=c99 -pedantic -Wall -g -o test_mapmodes_emf test_mapmodes_emf.c uemf.c uemf_endian.c uemf_utf.c -lm -liconv + +Dependencies: + libiconv (if not built into your compiler) + libpng (in the Inkscape examples) + +-------------------------------------------------------------------------------------------- +Testing + +All modules must also compile without warning under the more restrictive: + + ls -1 *.c \ + | extract -fmt 'gcc -Werror=format-security -Wall -Wformat -Wformat-security -W -Wno-pointer-sign -O2 -c -o deleteme.o [1,]' \ + | execinput + +-------------------------------------------------------------------------------------------- +Using libUEMF: + +To write an EMF file the code first runs two initialization functions: emf_start() and htable_create(). +Then a U_EMRHEADER record is created. This and all subsequent records are appended to the EMF file in +memory with emf_append(). Whichever other EMR records are desired are also added. The last EMR record +added must be the single instance of U_EMREOF. Then the code calls emf_finish(), emf_free(), and +htable_free(). Conversion of byte order on Big Endian machines to Little Endian is carried out +automatically in emf_finish(), if it is required. + +To input an EMF file it is is opened and the data read into a buffer in memory with emf_readdata(). On a +Big Endian machine this will also swap machine dependent byte orders as needed. At that point end user code +generally has to do something with the data in each record. The simplest case is to just print it, as shown +in reademf.c. More typically it must map the operations into its own graphics model, as shown in the +emf32*.*.example files from Inkscape. Basically the processing program needs to enter a loop, processing +one record at a time, pulling the record size and type from the first two uint32_t values present in each +record. It then enters a switch statement with one case for each EMR record type. Each case: statement +will generally define a pointer to that type of data object. Accessing the data from that pointer is +illustrated in the code for the corresponding *_print function. + +While libUEMF implements _print and _swap functions for all supported EMR records, end user code would +never call any of these directly. Instead it should either pass a single EMR record +to U_emf_onerec_print() (see reademf.c) or the entire completed EMF file in memory buffer to U_emf_endian() +(see testbed.c). + +WMF support is similar, except the functions are wmf_start(), wmf_readdata(), and so forth. It is a good +idea to separate end user WMF and EMF generating code into different modules, in order to avoid accidentally +writing EMR records to a WMF file and vice versa. WHile EMF objects are aligned in memory and so may be +accessed using the supplied structs, the ones for WMF files are not usually aligned and so must be accessed +using the supplied *_get functions. (The difference may not be evident on an x86 platform, but on RISC directly +trying to access objects in memory will result in access violations.) + +Things to be aware of in EMF files: + +The usual idea when employing a graphics file type like EMF is to copy a description of the objects in a +drawing from one program to another. Many of the record types in an EMF file can be thought of as objects, +they are lines or shapes or bitmaps or text. However, Microsoft's GDI implements binary and ternary raster +operations (see the descriptions in uemf.h) and most of these operations are not object like, instead they +combine things on the drawing surface. (There is in each case a copy operation which is object like.) +Consequently, EMF files which use these other raster operations are not particularly easy to import as +graphic objects. For instance, when PowerPoint rotates an image and saves it in an EMF the result is not +a single rotated image object. Instead there is an image containing the rotated image, which is followed by +masking operations to make the regions outside of the image transparent. There appears to be no standard +for when and where these subsequent operations will be applied. That is, there is no equivalent of +"begin path" and "end path" to delineate the start and end of such a compound operation. So a program +reading such a file has no easy way of figuring out which previous object is being modified by a subsequent +raster operation. The testbed program provided in this package generates a region which applies all +binary raster operations in vertical slices to two images. The expected result appears in Windows "Preview", +but if that region is imported into PowerPoint and converted to objects within that program the result looks +nothing like what Preview shows. + +Support for U_EMREXTTEXTOUTW is much more common than for U_EMRSMALLTEXT. The latter is easier to use, +since it does not require a Dx array for each text string, but the objects will not import into PowerPoint, +for instance. + +There are two types of dotted/dashed lines. The first uses a set of predefined flags to set the pattern +and the latter is end user user defined. Both are restricted to lines of width 1. These built in types are +problematic as key applications cannot handle them properly. PowerPoint cannot convert either type to its +internal object format. The first form loses the pattern and comes through as solid lines. The second type +is toxic - even a single dotted line of the second type will prevent the entire EMF from being converted. +The safest choice is to avoid these patterned line styles entirely. Convert all dots and dashes to separate +line draws before writing those into the EMF file. libUEMF has no problem reading these records, so code +should accept them for input. + +As with most graphics file formats there is no single object representation of a complex text string (varying +font size, super/sub script, bold, italic,.etc.). Such text must be decomposed into multiple text strings, +each with its own formatting. It is unlikely that a subsequent program reading these records from the EMF +will be able to reassemble them back into a single complex text string. + +If a font used in an EMF file is not present on both the sending and receiving systems text will not look the +same on both. Font substitution is usually silent in most programs, so it may not be evident why the text looks +a little odd. However, if text is simple, that is, consists of just one line of text without size, color, +or other changes, then it will look approximately correct after font substitution. + +Things to be aware of in WMF files: + +WMF graphics are quite limited when compared to EMF graphics. When reading a WMF file it is essential that +end user code always create a specified object, even if that object is just a placeholder with no real +function. If any "create" operation presented by the WMF file is not handled then the object indices used +further along in the WMF file will be off, with very bad results! WMF "regions" are not supported by libUEMF, +however, if an operation creates regions, this type of placeholder must still be created. + +In theory WMF supports mapmodes other than Anisotropic. However, since many programs do not handle +these other modes it is strongly suggested that any WMF files generated use Anisotropic. For this +reason there is no test_mapmodes_wmf program - windows XP preview did not show anything when WMF +files in the other modes were produced. With no positive control there was no way to verify that they +were valid. + +Things to be aware of in EMF+ files: + +EMF+ files are usually stored in files with an ".emf" file extension. In this package EMF+ programs, +functions, and definitions use PMF or PMR to distinguish them from the EMF and WMF material. ("EMF+" +is not an allowed variable or function name in C.) Dual mode EMF+ files contain both EMF and +EMF+ records. HOWEVER, those generated by PowerPoint are defective in that they drop all text +information from the drawing in the EMF+ representation. There is no simple way to line up the +EMF and EMF+ records in their representations to determine which ones correspond to which drawing +object. So it is generally not possible to see which elements are represented in both +representations, or which are missing in one representation. The example file generated by this library +has only EMF+ records plus the few EMF records needed to wrap them. + +Text in EMF+ is placed not from the baseline, as in EMF, but from the upper left corner of the Em square. +Use the utility function U_PMR_drawstring() to draw text onto a baseline. Font +substitutions result in badly placed text because even fonts that look similar on the screen may have +different font metrics. Specifically, font substitutions look worse in EMF+ files than they do +in EMF files. There is no way to embed fonts, or their font information in the EMF+ file. +Consequently the text representation within an EMF+ file is not very portable between systems - it will +only render correctly if the second system has all of the fonts used in the document. The testbed_pmf.c +program contains some metrics for common fonts which may be used with U_PMR_drawstring() +to accurately place text. + + + +-------------------------------------------------------------------------------------------- +History + + (Note, version numbers in files represent the libUEMF release where it was last modified, so not + all files will show the same version numbers in each release.) + +0.1.10 2014-01-14 + Slight changes in documentation for uemf.h. + Fixed typo in uemf_endian.c. + Fixed a tiny bug in uemf.c (if memory allocation failed a struct would have + been deleted before the struct itself. + +0.1.9 2013-12-02 + Added U_PMF_DASHEDLINEDATA_set3 (dot/dash pattern from bits in a uint32_t). + Finally was able to make linear gradient gradientfill records work. Updated + testbed_emf.c to include that. + +0.1.8 2013-11-28 + Fixed a bug in U_PMF_REGIONNODEPATH_print(), returned size was 4 too small. + Changed formatting of U_PMF_REGIONNODECHILDNODES_print() output to improve readability + of nested region structures in reademf. + +0.1.7 2013-11-20 + Added EMF+ support. + Converted U_RGA and similar from defines to functions, because the method being used + in the define (from C99) was not exactly compatible with C++ compilation. + Fixed error in test_mapmodes_emf.c where truncation float to integer was used where round + have been, resulting in an off by 1 error on some platforms. + Eliminated PU_W* pointers. + Cleaned up Doxygen comments. + +0.1.6. 2013-04-18 + Added tests which vary background mode, background color, and text color. + Slight modification to testit.sh. + Updated example files. + +0.1.5. 2013-02-13 + Added missing parameter for WMF RESTOREDC_set/get. + Replaced all sizeof() in uwmf.c that referred to UWMF structures with their + U_SIZE_* equivalents. + Added DIB related WMF _get functions. (Which were missing). These are U_BITMAPCOREHEADER_get, + U_BITMAPINFOHEADER_get, wget_dib_params + Added const where appropriate to wmf _get functions. + Added comprehensive cap,join,miter tests to testbeds. + Fixed bug in gradient4_swap(). + Fixed bug in emr_arc_points_common(), used vector where unit vectors were + needed, sometimes flipped direction for arcs/chords. + Fixed bug in U_WMFTEXTOUT_get(). + Changed all dst->Dst and src->Src as call variables in WMF code. + Denigrated htable_*() for emf, these become emf_htable_*(), to match naming convention + used for wmf_table_*(). +0.1.4 2013-02-04 + Added code to handle DIB formats that use clrUsed=0 to mean "maximum number of color entries", + this showed up in several places, including uemf.c and uemf_print.c. + Added some labels to test drawings, slightly rearranged image section, added + PNG and JPG image tests and clrUsed=0 images. + Modified uemf_endian.c to suppress some compiler warnings. + Changed get_DIB_params to return the Compression enumeration. + Fixed a typo in uwmf_print.c. +0.1.3 2013-01-29 Add modes to EMF test programs that changes worldtransform, so + that the resulting test files will exercise rotation transforms. + Added flags indication for testbed programs. + Added test for ROUNDRECT records. Swapped argument orders for those _get/_set operations. +0.1.2 2013-01-25 Fixed bug revealed by newer gcc on Solaris, assignment of aligned 32 bit to unaligned + 16 bit segfaulted. +0.1.1 2013-01-24 Fixed a few compiler warnings under g++, mostly having to do + with signed unsigned comparisons. Eliminated + an unused variable from wmf_finish and two stray lines from U_WMRHEADER_set. + Cleaned up doxygen comments. +0.1.0 2013-01-09 Added WMF functions. + Simplified print functions. Changed output format of reademf slightly, + from U_EMRXXX to U_EMR_XXX - easier to read the new way. +0.0.11 2012-12-04 Moved UTF and related functions out of uemf.c uemf.h and into uemf_utf.c uemf_utf.h. +0.0.10 2012-11-28 Discovered that not enough space was being allocated for some UTF conversions. To be + safe need 4 bytes per glyph + 1 for UTF-8. +0.0.9 2012-09-26 Some "uninitialized variable warnings" for certain versions of + gcc. These were, as far as I could tell, all spurious, but to quiet them + the variables in question were all initialized to 0. + Fixed header related print/swap functions - depending on what type of header there + could be an access violation. + Fixed U_Utf16leToUtf8, could leak memory if the conversion failed. + Fixed sections which were not testing for all types of EMF headers. + Added RGBA_to_RGBA() so that extractions of subsets of bitmaps (offset, different size) + can be handled. + Added cutemf. Utility to remove records from an EMF file. + Added test_mapmodes. Program to generate test files in each MAPMODE. + Added test_mm_(mode)_ref.emf files. These are reference for: + test_mapmodes -vX 2000 -vY 1000 + +0.0.8 2012-09-10 Fixed bug in htable_insert, failed to celear newly added table + slots. Fixed test for EMR_GRADIENTFILL triangle mode (rectangle still produces toxic EMF files.) + Fixed bug in gradientfill_swap on Solaris. + +0.0.7 2012-08-30 Added/fixed tests for hatched, DIB, and mono strokes. + Corrected error in U_EMREXTCREATEPEN_set. + +0.0.6 2012-08-21 Added/fixed tests for hatched, DIB, and mono fills. + +0.0.5 2012-08-08 Minor changes to uemf.c to suppress compiler warnings. Fixed + one bug in SET_CB_FROM_PXBMI macro (which was not triggered in testbed + because all images were the same size). + +0.0.4 2012-07-25 More tests in testbed.c. Found and fixed bugs in + U_POLYPOLYLINE and U_POLYPOLYGON related code. + +0.0.3 2012-07-24 Warnings related to printing size_t on 64 bit Linux. Correct + fix is to use "zd", but gcc -std=c99 does not support that on Solaris 9, + the only available big endian system. So use cast or the size_t to (int) + and stick with %d format specifier. This should be OK as the sizes involved + should not be all that large. + + Bug in core9 affecting U_EMRARC_swap(), and related, on Big Endian. + +0.0.2 2012-07-12 first release + diff --git a/src/libuemf/uemf.c b/src/libuemf/uemf.c index 3079c5095..55388cf53 100644 --- a/src/libuemf/uemf.c +++ b/src/libuemf/uemf.c @@ -1,7 +1,9 @@ /** - @file uemf.c Functions for manipulating EMF files and structures. + @file uemf.c + + @brief Functions for manipulating EMF files and structures. - [U_EMR*]_set all take data and return a pointer to memory holding the constructed record. + [U_EMR]_set all take data and return a pointer to memory holding the constructed record. The size of that record is also returned in recsize. It is also in the second int32 in the record, but may have been byte swapped and so not usable. If something goes wrong a NULL pointer is returned and recsize is set to 0. @@ -14,11 +16,11 @@ /* File: uemf.c -Version: 0.0.21 -Date: 20-FEB-2013 +Version: 0.0.25 +Date: 15-JAN-2014 Author: David Mathog, Biology Division, Caltech email: mathog@caltech.edu -Copyright: 2013 David Mathog and California Institute of Technology (Caltech) +Copyright: 2014 David Mathog and California Institute of Technology (Caltech) */ #ifdef __cplusplus @@ -41,9 +43,12 @@ extern "C" { #include //Not actually used, looking for collisions #endif #include "uemf.h" -/* one prototype from uemf_endian. Put it here because end user should never need to see it, sno + +//! \cond +/* one prototype from uemf_endian. Put it here because end user should never need to see it, so not in uemf.h or uemf_endian.h */ void U_swap2(void *ul, unsigned int count); +//! \endcond /** \brief Look up the name of the EMR record by type. Returns U_EMR_INVALID if out of range. @@ -54,7 +59,7 @@ void U_swap2(void *ul, unsigned int count); */ char *U_emr_names(unsigned int idx){ if(idx U_EMR_MAX){ idx = 0; } - static char *U_WMR_NAMES[U_EMR_MAX+1]={ + static char *U_EMR_NAMES[U_EMR_MAX+1]={ "U_EMR_INVALID", "U_EMR_HEADER", "U_EMR_POLYBEZIER", @@ -179,7 +184,7 @@ char *U_emr_names(unsigned int idx){ "U_EMR_COLORMATCHTOTARGETW", "U_EMR_CREATECOLORSPACEW" }; - return(U_WMR_NAMES[idx]); + return(U_EMR_NAMES[idx]); } @@ -463,7 +468,7 @@ uint32_t emr_properties(uint32_t type){ table[115] = 0xA0; // U_EMRSETLAYOUT 1 0 1 0 0 0 0 0 table[116] = 0x82; // U_EMRTRANSPARENTBLT 1 0 0 0 0 0 1 0 table[117] = 0xA0; // U_EMRUNDEF117 1 0 1 0 0 0 0 0 - table[118] = 0x82; // U_EMRGRADIENTFILL 1 0 0 0 0 0 1 0 + table[118] = 0x82; // U_EMRGRADIENTFILL 1 0 1 0 0 0 1 0 table[119] = 0xA0; // U_EMRSETLINKEDUFIS 1 0 1 0 0 0 0 0 table[120] = 0x20; // U_EMRSETTEXTJUSTIFICATION 0 0 1 0 0 0 0 0 table[121] = 0xA0; // U_EMRCOLORMATCHTOTARGETW 1 0 1 0 0 0 0 0 @@ -615,7 +620,7 @@ int emr_arc_points( \param h Height of pixel array \param stride Row stride of input pixel array in bytes \param colortype DIB BitCount Enumeration - \param use_ct If true use color table (only for 1-16 bit DIBs) + \param use_ct If true use color table (only for 1-16 bit DIBs). \param invert If DIB rows are in opposite order from RGBA rows */ int RGBA_to_DIB( @@ -695,7 +700,7 @@ int RGBA_to_DIB( b = *rptr++; a = *rptr++; if(use_ct){ - color = U_BGRA(r,g,b,a); // color has order in memory: b,g,r,a + color = U_BGRA(r,g,b,a); // color has order in memory: b,g,r,a, same as EMF+ ARGB index = -1; for(lct = *ct, k=0; kbiSizeImage; *ct = NULL; @@ -1535,7 +1543,6 @@ int drawing_size( return(0); } - /** \brief Set a U_COLORREF value from separate R,G,B values. \param red Red component @@ -1554,10 +1561,10 @@ U_COLORREF colorref3_set( /** \brief Set a U_COLORREF value from separate R,G,B, and Reserved values. - \param red Red component - \param green Green component - \param blue Blue component - \param blue Reserved component + \param red Red component + \param green Green component + \param blue Blue component + \param Reserved Reserved component */ U_COLORREF colorref4_set( @@ -5470,6 +5477,12 @@ char *U_EMRTRANSPARENTBLT_set( \param ulMode Gradientfill Enumeration (determines Triangle/Rectangle) \param TriVert Array of TriVertex objects \param GradObj Array of gradient objects (each has 2 [rect] or 3 [triangle] indices into TriVert array) + +There is an MS documentation or library problem for this record, as the size of the GradObj must always be set +as if it was an array of U_GRADIENT3 objects for both rect and triangle. For horizontal and vertical gradients +this means that there will be unused bytes at the end of the record. This is not what the documentation says, +but it is how MS's libraries work. + */ char *U_EMRGRADIENTFILL_set( const U_RECTL rclBounds, @@ -5481,6 +5494,7 @@ char *U_EMRGRADIENTFILL_set( ){ char *record; unsigned int cbTriVert,cbGradObj,off; + unsigned int cbGradObjAlloc; /* larger than cbGradObj, because of problem described above */ int irecsize; cbTriVert = sizeof(U_TRIVERTEX) * nTriVert; // all of the cb's will be a multiple of 4 bytes @@ -5488,8 +5502,9 @@ char *U_EMRGRADIENTFILL_set( else if(ulMode == U_GRADIENT_FILL_RECT_H || ulMode == U_GRADIENT_FILL_RECT_V){ cbGradObj = sizeof(U_GRADIENT4) * nGradObj; } else { return(NULL); } + cbGradObjAlloc = sizeof(U_GRADIENT3) * nGradObj; - irecsize = sizeof(U_EMRGRADIENTFILL) + cbTriVert + cbGradObj; + irecsize = sizeof(U_EMRGRADIENTFILL) + cbTriVert + cbGradObjAlloc; record = malloc(irecsize); if(record){ ((PU_EMR) record)->iType = U_EMR_GRADIENTFILL; @@ -5502,6 +5517,10 @@ char *U_EMRGRADIENTFILL_set( memcpy(record + off, TriVert, cbTriVert); off += cbTriVert; memcpy(record + off, GradObj, cbGradObj); + off += cbGradObj; + if(cbGradObjAlloc > cbGradObj){ + memset(record+off,0,cbGradObjAlloc - cbGradObj); + } } return(record); } @@ -5553,7 +5572,6 @@ char *U_EMRCREATECOLORSPACEW_set( } - #ifdef __cplusplus } #endif diff --git a/src/libuemf/uemf.h b/src/libuemf/uemf.h index 00c605d02..a75ba801b 100644 --- a/src/libuemf/uemf.h +++ b/src/libuemf/uemf.h @@ -1,5 +1,7 @@ /** - @file uemf.h Structures and functions prototypes for EMF files. + @file uemf.h + + @brief Structures, definitions, and function prototypes for EMF files. EMF file Record structure information has been derived from Mingw, Wine, and libEMF header files, and from Microsoft's EMF Information pdf, release date March 28,2012, link from here: @@ -11,13 +13,93 @@ */ +/** \mainpage libUEMF overview +\section ov Overview +Microsoft's WMF, EMF, and EMF+ metafile types are supported. In each case functions are provided for reading, constructing, writing, and printing +metafile records. The methods used to do that differ somewhat between metafiles, and the simplest +way to get started is to have a look at the example programs provided. The WMF, EMF, and EMF+ structs and functions are +marked with U_WMF, U_EMF, U_PMF and U_WMR, U_EMR, and U_PMR prefixes. (PMF because "+" is a reserved character +in many contexts, so U_EMF+NAME would be a problem.) Please be aware that normally both EMF and EMF+ files have the ".emf" +file extension, and that it is very common for such files to contain both an EMF and an EMF+ representation of the +drawing. + +\section example_sec Example Programs +testbed_emf.c Creates an EMF file test_libuemf.emf.\n +testbed_wmf.c Creates a WMF file test_libuemf.wmf.\n +testbed_pmf.c Creates an EMF+ file test_libuemf_p.emf.\n +reademf.c Reads an EMF or EMF+ file and emits a text summary of its records.\n +readwmf.c Reads a WMF file and emits a text summary of its records.\n +emf-inout.cpp.example Example code from Inkscape to convert graphics from EMF to SVG.\n +emf-print.cpp.example Example code from Inkscape to print a drawing to EMF.\n +wmf-inout.cpp.example Example code from Inkscape to convert graphics from WMF to SVG.\n +wmf-print.cpp.example Example code from Inkscape to print a drawing to WMF. + +\section doxy_limits Documentation issues +There are currently some unresolved issues with Doxygen that result in some structs +not being "defined". This comes up when several different types of structs have the same +layout. When this occurs the first one listed on the "typedef struct" is defined but all the +others will only be shown under "typedef struct" referring to the first one. This is why +clicking on U_RECTL in a function parameter jumps to a typedef struct page, why U_RECTL is shown +as plain text here, but U_RECT is shown as a link here, and clicking on it jumps directly +to its structure definition. + +An additional issue is that the Enumeration names used in WMF are different from those +used in EMF, even when the values are either identical or differ only slightly, and no method +has been found yet to link one to the other in Doxygen. At present the only way to look up +these WMF enumerations is by referencing the following table: + + EMF WMF WMF Manual + EMF Binary Raster Operation Enumeration BinaryRasterOperation Enumeration 2.1.1.2 + EMF Bitcount Enumeration BitCount Enumeration 2.1.1.3 + EMF LB_Style Enumeration BrushStyle Enumeration 2.1.1.4 + EMF LF_CharSet Enumeration CharacterSet Enumeration 2.1.1.5 + EMF DIBColors Enumeration ColorUsage Enumeration [has 1 extra value] 2.1.1.6 + EMF BI_Compression Enumeration Compression Enumeration [has 3 extra values] 2.1.1.7 + - FamilyFont Enumeration 2.1.1.8 + EMF FloodFill Enumeration FloodFill Enumeration 2.1.1.9 + EMF LF_Quality Enumeration FontQuality Enumeration 2.1.1.10 + EMF LCS_Intent Enumeration GamutMappingIntent Enumeration 2.1.1.11 + EMF HatchStyle Enumeration HatchStyle Enumeration 2.1.1.12 + EMF Mirroring Enumeration LayoutEnumeration 2.1.1.13 + - LogicalColorSpace Enumeration 2.1.1.14 + EMF Profile Enumeration LogicalColorSpaceV5 Enumeration 2.1.1.15 + EMF MapMode Enumeration MapModeEnumeration 2.1.1.16 + - MetaFilesEscape Enumeration 2.1.1.17 + - MetafileType Enumeration 2.1.1.18 + - MetafileVersion Enumeration 2.1.1.19 + EMF BackgroundMode Enumeration MixModeEnumeration 2.1.1.20 + EMF LF_OutPrecision Enumeration OutPrecision Enumeration 2.1.1.21 + - PaletteEntryFlag Enumeration 2.1.1.22 + EMF PenStyle Enumeration PenStyle Enumeration [not values >0xFFFF] 2.1.1.23 + - PitchFont Enumeration 2.1.1.24 + EMF PolygonFillMode Enumeration PolyFillMode Enumeration [first 2 only] 2.1.1.25 + - PostScriptCap Enumeration 2.1.1.26 + - PostScriptClipping Enumeration 2.1.1.27 + - PostFeatureSetting Enumeration 2.1.1.28 + - PostScrioptJoin Enumeration 2.1.1.29 + EMF StretchMode Enumeration StretchMode Enumeration 2.1.1.30 + EMF Ternary Raster Operation Enumeration TernaryRasterOperation Enumeration 2.1.1.31 + EMF LF_ClipPrecision Enumeration ClipPrecision Flags 2.1.2.1 + EMF ExtTextOutOptions Enumeration ExtTextOutOptions Flags [subset] 2.1.2.2 + EMF TextAlignment Enumeration TextAlignment Enumeration 2.1.2.3 + EMF TextAlignment Enumeration VertialTextAlignment Enumeration 2.1.2.4 + EMF LF_PitchAndFamily Enumeration PitchAndFamily Enumerations 2.2.2.14 + +\section refs Reference documentation + + Manual Date Link + EMF 3/28/2012 http://msdn2.microsoft.com/en-us/library/cc230514.aspx + EMF+ 7/5/2012 http://msdn.microsoft.com/en-us/library/cc230724.aspx + WMF 7/5/2012 http://msdn2.microsoft.com/en-us/library/cc250370.aspx +*/ + /* File: uemf.h -Version: 0.0.19 -Date: 20-FEB-2013 +Version: 0.0.25 +Date: 15-JAN-2014 Author: David Mathog, Biology Division, Caltech email: mathog@caltech.edu -Copyright: 2013 David Mathog and California Institute of Technology (Caltech) +Copyright: 2014 David Mathog and California Institute of Technology (Caltech) */ #ifndef _UEMF_ @@ -27,13 +109,16 @@ Copyright: 2013 David Mathog and California Institute of Technology (Caltech) extern "C" { #endif +#include +#include #include +#include #include #include "uemf_utf.h" #include "uemf_endian.h" - +/** \cond */ // *********************************************************************************** // defines not placed yet @@ -44,13 +129,477 @@ extern "C" { #define U_SYSPAL_NOSTATIC 2 #define U_ELF_VENDOR_SIZE 4 +/** \endcond */ + +// *************************************************************************** +/** \defgroup U_EMF_Miscellaneous_values EMF Miscellaneous Values + @{ +*/ +#define U_NONE 0 //!< Generic for nothing selected for all flag fields +#define U_PI 3.14159265358979323846 //!< pi +#define U_READ 1 //!< open file as "rb" +#define U_WRITE 0 //!< open file as "wb" +#define U_DV_SGNTR 0x08007664 //!< For U_DESIGNVECTOR Signature field +#define U_LP_VERSION 0x0300 //!< For U_LOGPALETTE palVersion field +#define U_RDH_RECTANGLES 1 //!< For U_RGNDATAHEADER iType field +#define U_RDH_OBJSIZE 0x20 //!< For U_RGNDATAHEADER dwSIze field +#define U_RGB_GAMMA_MIN (uint16_t)02500 //!< For U_COLORADJUSTMENT ca[Red|Green|Blue]Gamma fields +#define U_RGB_GAMMA_MAX (uint16_t)65000 //!< For U_COLORADJUSTMENT ca[Red|Green|Blue]Gamma fields +#define U_REFERENCE_WHITE_MIN (uint16_t)6000 //!< For U_COLORADJUSTMENT caReferenceWhite field +#define U_REFERENCE_WHITE_MAX (uint16_t)10000 //!< For U_COLORADJUSTMENT caReferenceWhite field +#define U_REFERENCE_BLACK_MIN (uint16_t)0 //!< For U_COLORADJUSTMENT caReferenceBlack field +#define U_REFERENCE_BLACK_MAX (uint16_t)4000 //!< For U_COLORADJUSTMENT caReferenceBlack field +#define U_COLOR_ADJ_MIN ((int16_t)-100) //!< For U_COLORADJUSTMENT ca[Contrast|Brightness|Colorfulness|RedGreenTint] fields +#define U_COLOR_ADJ_MAX (int16_t) 100 //!< For U_COLORADJUSTMENT ca[Contrast|Brightness|Colorfulness|RedGreenTint] fields +#define U_MAX_PATH 1024 //!< longest path name for a file +#define U_LCS_SIGNATURE 0x50534F43 //!< logColorSpace Signature +#define U_LCS_VERSION 0x400 //!< logColorSpace Version +#define U_REC_FREE 1 //!< use with emf_append +#define U_REC_KEEP 0 //!< use with emf_append +#define U_ROW_ORDER_INVERT 1 //!< For RGBA_to_DIB, invert row order in DIB relative to pixel array +#define U_ROW_ORDER_SAME 0 //!< For RGBA_to_DIB, same row order in DIB as in pixel array +#define U_CT_NO 0 //!< For RGBA_to_DIB, do not use color table +#define U_CT_BGRA 1 //!< For RGBA_to_DIB, use color table (16 bits or less only) BGRA colors, compatible with EMF+ ARGB +#define U_CT_ARGB 1 //!< For RGBA_to_DIB, use color table (16 bits or less only) BGRA colors, compatible with EMF+ ARGB +#define U_EMR_COMMENT_SPOOLFONTDEF 0x544F4E46 //!< For U_EMRCOMMENT record that is U_EMR_COMMENT_SPOOL, comment holds font definition informtion. +/** Solaris 8 has problems with round/roundf, just use this everywhere */ +#define U_ROUND(A) ( (A) > 0 ? floor((A)+0.5) : ( (A) < 0 ? -floor(-(A)+0.5) : (A) ) ) + +/** @} */ + + +typedef float U_FLOAT; //!< 32 bit float + +typedef uint32_t U_CBBITS; //!< Count of Bytes in object at corresponding U_OFF* +typedef uint32_t U_CBBITSMSK; //!< Count of Bytes in object at corresponding U_OFF* +typedef uint32_t U_CBBITSSRC; //!< Count of Bytes in object at corresponding U_OFF* +typedef uint32_t U_CBBMI; //!< Count of Bytes in object at corresponding U_OFF* +typedef uint32_t U_CBBMIMSK; //!< Count of Bytes in object at corresponding U_OFF* +typedef uint32_t U_CBBMISRC; //!< Count of Bytes in object at corresponding U_OFF* +typedef uint32_t U_CBDATA; //!< Count of Bytes in object at corresponding U_OFF* +typedef uint32_t U_CBNAME; //!< Count of Bytes in object at corresponding U_OFF* +typedef uint32_t U_CBPLENTRIES; //!< Count of Bytes in object at corresponding U_OFF* +typedef uint32_t U_CBPXLFMT; //!< Count of Bytes in object at corresponding U_OFF* +typedef uint32_t U_CBRGNDATA; //!< Count of Bytes in object at corresponding U_OFF* +typedef uint32_t U_CBSTR; //!< Count of Bytes in an 8 or 16 bit string + +typedef uint32_t U_OFFBITS; //!< Byte offset to TYPE, always measured from the start of the RECORD (not the struct) +typedef uint32_t U_OFFBITSMSK; //!< Byte offset to TYPE, always measured from the start of the RECORD (not the struct) +typedef uint32_t U_OFFBITSSRC; //!< Byte offset to TYPE, always measured from the start of the RECORD (not the struct) +typedef uint32_t U_OFFBMI; //!< Byte offset to TYPE, always measured from the start of the RECORD (not the struct) +typedef uint32_t U_OFFBMIMSK; //!< Byte offset to TYPE, always measured from the start of the RECORD (not the struct) +typedef uint32_t U_OFFBMISRC; //!< Byte offset to TYPE, always measured from the start of the RECORD (not the struct) +typedef uint32_t U_OFFDATA; //!< Byte offset to TYPE, always measured from the start of the RECORD (not the struct) +typedef uint32_t U_OFFDESC; //!< Byte offset to TYPE, always measured from the start of the RECORD (not the struct) +typedef uint32_t U_OFFDX; //!< Byte offset to TYPE, always measured from the start of the RECORD (not the struct) +typedef uint32_t U_OFFPLENTRIES; //!< Byte offset to TYPE, always measured from the start of the RECORD (not the struct) +typedef uint32_t U_OFFPXLFMT; //!< Byte offset to TYPE, always measured from the start of the RECORD (not the struct) +typedef uint32_t U_OFFSTR; //!< Byte offset to string of either 8 or 16 bit characters +typedef uint8_t U_DATA; //!< any binary sort of data, not otherwise classified. + +// "Types" For array components in structures, where not otherwise defined as a structure +typedef uint32_t U_FNTAXES; //!< Font Axes For U_DESIGNVECTOR +typedef uint32_t U_STYLEENTRY; //!< StyleEntry For U_EXTLOGPEN +typedef uint32_t U_POLYCOUNTS; //!< aPolyCounts For U_EMRPOLYPOLYLINE etc. + +// "Counts" for array components in structures +typedef uint32_t U_NUM_FNTAXES; //!< Number of U_FNTAXES +typedef uint32_t U_NUM_LOGPLTNTRY; //!< Number of U_LOGPLTENTRY +typedef uint32_t U_NUM_RECTL; //!< Number of U_RECTL +typedef uint32_t U_NUM_POINTL; //!< Number of U_POINTL +typedef uint32_t U_NUM_POINT16; //!< Number of U_POINT16 +typedef uint32_t U_NUM_STYLEENTRY; //!< Number of U_STYLEENTRY +typedef uint32_t U_NUM_POLYCOUNTS; //!< Number of U_POLYCOUNTS +typedef uint32_t U_NUM_EMRTEXT; //!< Number of U_EMRTEXT +typedef uint32_t U_NUM_STR; //!< Number of 8 or 16 bit characters in string +typedef uint32_t U_NUM_TRIVERTEX; //!< Number of U_TRIVERTEX +typedef uint32_t U_NUM_GRADOBJ; //!< Number of U_GRADIENT4 OR U_GRADIENT3 (determined at run time) +typedef uint32_t U_NUM_RGBQUAD; //!< Number of U_RGBQUAD (in bmciColors in U_BITMAPCOREINFO) + + + +/* ************************ WMF pieces used in EMF or EMF+ ****************************** */ + +/** \defgroup U_EMF_EMRSETROP2_iMode_Qualifiers EMF Binary Raster Operation Enumeration + + For U_EMRSETROP2 iMode field + Microsoft name: Binary Raster Operation Enumeration + WMF manual 2.1.1.2 + + These codes specify: + 1. an order of operands (composed of various orders and combinations of: Dest, Pen) + (There are 2, hence "Binary Raster Operation") + 2. an order of operators to apply to the operands (composed of Not, Xor, Or, And) + Only a few of the more common operations are provided here. + + The default is U_R2_COPYPEN. If this value is changed to something else all subsequenty + draw operations will use the altered logic. For instance, if it is set to U_R2_BLACK and + a red rectangle is drawn it will appear as a black rectangle. + + @{ +*/ +#define U_R2_BLACK 1 //!< BLACK +#define U_R2_NOTMERGEPEN 2 //!< NOTMERGEPEN +#define U_R2_MASKNOTPEN 3 //!< MASKNOTPEN +#define U_R2_NOTCOPYPEN 4 //!< NOTCOPYPEN +#define U_R2_MASKPENNOT 5 //!< MASKPENNOT +#define U_R2_NOT 6 //!< NOT +#define U_R2_XORPEN 7 //!< XORPEN +#define U_R2_NOTMASKPEN 8 //!< NOTMASKPEN +#define U_R2_MASKPEN 9 //!< MASKPEN +#define U_R2_NOTXORPEN 10 //!< NOTXORPEN +#define U_R2_NOP 11 //!< NOP +#define U_R2_MERGENOTPEN 12 //!< MERGENOTPEN +#define U_R2_COPYPEN 13 //!< COPYPEN +#define U_R2_MERGEPENNOT 14 //!< MERGEPENNOT +#define U_R2_MERGEPEN 15 //!< MERGEPEN +#define U_R2_WHITE 16 //!< WHITE +#define U_R2_LAST 16 //!< LAST +/** @} */ + +/** \defgroup U_EMF_BITMAPINFOHEADER_biBitCount_Qualifiers EMF BitCount Enumeration + For U_BITMAPINFOHEADER biBitCount field. + Microsoft name: Bitcount Enumeration + WMF manual 2.1.1.3 + @{ +*/ +#define U_BCBM_EXPLICIT 0 //!< Derived from JPG or PNG compressed image or ? +#define U_BCBM_MONOCHROME 1 //!< 2 colors. bmiColors array has two entries +#define U_BCBM_COLOR4 4 //!< 2^4 colors. bmiColors array has 16 entries +#define U_BCBM_COLOR8 8 //!< 2^8 colors. bmiColors array has 256 entries +#define U_BCBM_COLOR16 16 //!< 2^16 colors. bmiColors is not used. Pixels are 5 bits B,G,R with 1 unused bit +#define U_BCBM_COLOR24 24 //!< 2^24 colors. bmiColors is not used. Pixels are U_RGBTRIPLE. +#define U_BCBM_COLOR32 32 //!< 2^32 colors. bmiColors is not used. Pixels are U_RGBQUAD. Also use for EMF+ ARGB +/** @} */ + +/** \defgroup U_EMF_BITMAPINFOHEADER_biCompression_Qualifiers EMF BI_Compression Enumeration + For U_BITMAPINFOHEADER biCompression field + Microsoft name: Compression Enumeration + WMF manual 2.1.1.7 + @{ +*/ +#define U_BI_UNKNOWN -1 //!< not defined in EMF standard, not to be used in EMF files +#define U_BI_RGB 0 //!< Supported by libUEMF +#define U_BI_RLE8 1 //!< NOT supported by libUEMF +#define U_BI_RLE4 2 //!< NOT supported by libUEMF +#define U_BI_BITFIELDS 3 //!< Supported by libUEMF +#define U_BI_JPEG 4 //!< Supported by libUEMF +#define U_BI_PNG 5 //!< Supported by libUEMF +/** @} */ + +/** \defgroup U_EMF_LOGCOLORSPACE_lcsIntent_Qualifiers EMF LCS_Intent Enumeration + For U_LOGCOLORSPACEA/U_LOGCOLORSPACEW lcsIntent field + Microsoft name: LCS_Intent Enumeration + WMF manual 2.1.1.11 + @{ +*/ +#define U_LCS_GM_BUSINESS 0x00000001L //!< BUSINESS +#define U_LCS_GM_GRAPHICS 0x00000002L //!< GRAPHICS +#define U_LCS_GM_IMAGES 0x00000004L //!< IMAGES +#define U_LCS_GM_ABS_COLORIMETRIC 0x00000008L //!< ABS_COLORIMETRIC +/** @} */ + +/** \defgroup U_EMF_LOGCOLORSPACE_lcsCSType_Qualifiers EMF LCS_CSType Enumeration + For U_LOGCOLORSPACEA/U_LOGCOLORSPACEW lcsCSType field + Microsoft name: LCS_CSType Enumeration + WMF manual 2.1.1.14 + @{ +*/ +#define U_LCS_CALIBRATED_RGB 0x00000000L //!< CALIBRATED_RGB +#define U_LCS_DEVICE_RGB 0x00000001L //!< DEVICE_RGB +#define U_LCS_DEVICE_CMYK 0x00000002L //!< DEVICE_CMYK +/** @} */ + +/** \defgroup U_EMF_EMR_dwROP_Qualifiers EMF Ternary Raster Operation enumeration + + For U_EMR* dwROP fields. + Microsoft name: Ternary Raster Operation enumeration + WMF manual 2.1.1.31 + + These codes specify: + 1. an order of operands (composed of various orders and combinations of: Dest, Src, Pen) + (There are 3, hence "Ternary Raster Operation") + 2. an order of operators to apply to the operands (composed of Not, Xor, Or, And) + Only a few of the more common operations are provided here. + When the Operation does not use a Src operand the corresponding source bitmap may be + omitted from the record. + + For more details see: + http://wiki.winehq.org/TernaryRasterOps + + + @{ +*/ +#define U_SRCCOPY 0x00cc0020 //!< SRCCOPY +#define U_SRCPAINT 0x00ee0086 //!< SRCPAINT +#define U_SRCAND 0x008800c6 //!< SRCAND +#define U_SRCINVERT 0x00660046 //!< SRCINVERT +#define U_SRCERASE 0x00440328 //!< SRCERASE +#define U_NOTSRCCOPY 0x00330008 //!< NOTSRCCOPY +#define U_NOTSRCERASE 0x001100a6 //!< NOTSRCERASE +#define U_MERGECOPY 0x00c000ca //!< MERGECOPY +#define U_MERGEPAINT 0x00bb0226 //!< MERGEPAINT +#define U_PATCOPY 0x00f00021 //!< PATCOPY +#define U_PATPAINT 0x00fb0a09 //!< PATPAINT +#define U_PATINVERT 0x005a0049 //!< PATINVERT +#define U_DSTINVERT 0x00550009 //!< DSTINVERT +#define U_BLACKNESS 0x00000042 //!< BLACKNESS +#define U_WHITENESS 0x00ff0062 //!< WHITENESS +#define U_NOOP 0x00aa0029 //!< Many GDI programs end with a bitblt with this ROP == "D". Seems to work like flush() +#define U_NOMIRRORBITMAP 0x80000000 //!< If bit set, disable horizontal reflection of bitmap. +/** @} */ + +/** \defgroup U_EMF_EMRSETTEXTALIGN_iMode_Qualifiers EMF TextAlignment Enumeration + For U_EMRSETTEXTALIGN iMode field + Microsoft name: TextAlignment Enumeration + WMF Manual 2.1.2.3 + WMF Manual 2.1.2.4 + + Recall that EMF coordinates have UL closest to {0,0}, LR is below and to the right of UL and so has LARGER + {x,y} coordinates. In the following "TOP" is on the horizontal line defined by LR, as it has larger y coordinates, + which when viewing the EMF file, would actually be on the BOTTOM of the bounding rectangle. Similarly, left and right + are reversed. + + Microsoft documentation (WMF manual, section 2.1.2.3) says that the text starts on certain edges of the bounding rectangle. + That is apparently not true, whether the bounding rectangle is {0,0,-1,-1}, which is effectively no bounding rectangle, + or if a valid bounding rectangle is specified. In all cases the text (in Windows XP Preview) starts, has center at, or ends + at the center point. Vertical offsets seem to be defined analogously, but with respect to the height of the font. The bounding + rectangle defined for the U_EMRTEXT record appears to be ignored. + + Microsoft documentation (EMF manual,section 2.2.5) says that the same rectangle is used for "clipping or opaquing" by ExtTextOutA/W. + That does not seem to occur either. + + @{ +*/ +// Horizontal text flags +#define U_TA_DEFAULT 0x00 //!< default alignment +#define U_TA_NOUPDATECP 0x00 //!< Reference point does not move +#define U_TA_UPDATECP 0x01 //!< Reference point moves to end of next text drawn. +#define U_TA_LEFT 0x00 //!< Reference point is on left edge of bounding rectangle +#define U_TA_RIGHT 0x02 //!< Reference point is on right edge of bounding rectangle +#define U_TA_CENTER 0x06 //!< Reference point is on center vertical line of bounding rectangle +#define U_TA_TOP 0x00 //!< Reference point is on top edge of bounding rectangle +#define U_TA_BOTTOM 0x08 //!< Reference point is on bottom edge of bounding rectangle +#define U_TA_BASEBIT 0x10 //!< Reference point is on baseline of text if this bit is set, for 0x10 <-> 0x18 +#define U_TA_BASELINE 0x18 //!< Reference point is on baseline of text +#define U_TA_RTLREADING 0x100 //!< Set for Right to Left languages like Hebrew and Arabic +#define U_TA_MASK U_TA_BASELINE+U_TA_CENTER+U_TA_UPDATECP+U_TA_RTLREADING //!< Mask for these bits +// Vertical text flags +#define U_VTA_BASELINE U_TA_BASELINE //!< same meaning, but for vertical text +#define U_VTA_LEFT U_TA_BOTTOM //!< same meaning, but for vertical text +#define U_VTA_RIGHT U_TA_TOP //!< same meaning, but for vertical text +#define U_VTA_CENTER U_TA_CENTER //!< same meaning, but for vertical text +#define U_VTA_BOTTOM U_TA_RIGHT //!< same meaning, but for vertical text +#define U_VTA_TOP U_TA_LEFT //!< same meaning, but for vertical text +/** @} */ + +/** WMF manual 2.2.2.3 + \brief For U_BITMAPINFO bmiHeader field + + Microsoft name: BITMAPINFOHEADER Object +*/ +typedef struct { + uint32_t biSize; //!< Structure size in bytes + int32_t biWidth; //!< Bitmap width in pixels + int32_t biHeight; //!< Bitmap height in pixels, may be negative. + //!< abs(biHeight) is bitmap height + //!< bitmap may appear in two orientations: + //!< biHeight > 0 origin is LL corner, may be compressed, this is height after decompression. + //!< biHeight < 0 origin is UL corner, may not be compressed + uint16_t biPlanes; //!< Planes (must be 1) + uint16_t biBitCount; //!< BitCount Enumeration (determines number of RBG colors) + uint32_t biCompression; //!< BI_Compression Enumeration + uint32_t biSizeImage; //!< Image size in bytes or 0 = "default size (calculated from geometry?)" + int32_t biXPelsPerMeter; //!< X Resolution in pixels/meter + int32_t biYPelsPerMeter; //!< Y Resolution in pixels/meter + U_NUM_RGBQUAD biClrUsed; //!< Number of bmciColors in U_BITMAPINFO/U_BITMAPCOREINFO that are used by the bitmap + uint32_t biClrImportant; //!< Number of bmciColors needed (0 means all). +} U_BITMAPINFOHEADER, + *PU_BITMAPINFOHEADER; //!< WMF manual 2.2.2.3 + +/** WMF manual 2.2.2.6 + \brief For U_CIEXYZTRIPLE (all) fields + + Microsoft name: CIEXYZ Object +*/ +typedef struct { + int32_t ciexyzX; //!< CIE color space X component + int32_t ciexyzY; //!< CIE color space Y component + int32_t ciexyzZ; //!< CIE color space Z component +} U_CIEXYZ, + *PU_CIEXYZ; //!< WMF manual 2.2.2.6 + +/** WMF manual 2.2.2.7 + \brief For U_LOGCOLORSPACEA and U_LOGCOLORSPACEW lcsEndpints field + + defines a CIE colorspace. + Microsoft name: CIEXYZTRIPLE Object + +*/ +typedef struct { + U_CIEXYZ ciexyzRed; //!< CIE XYZ coord of red endpoint of colorspace + U_CIEXYZ ciexyzGreen; //!< CIE XYZ coord of green endpoint of colorspace + U_CIEXYZ ciexyzBlue; //!< CIE XYZ coord of blue endpoint of colorspace +} U_CIEXYZTRIPLE, + *PU_CIEXYZTRIPLE; //!< WMF manual 2.2.2.7 + +/** WMF manual 2.2.2.8 + \brief For U_BITMAPINFO crColor field + + NOTE that the color order is RGB reserved, flipped around from the preceding. + Microsoft name: COLORREF Object +*/ +typedef struct { + uint8_t Red; //!< Red color (0-255) + uint8_t Green; //!< Green color (0-255) + uint8_t Blue; //!< Blue color (0-255) + uint8_t Reserved; //!< Not used +} U_COLORREF, + *PU_COLORREF; //!< WMF manual 2.2.2.8 + +/** WMF manual 2.2.2.11 + \brief For U_LCS_GAMMARGB lcsGamma* fields + + Microsoft name:(unknown) +*/ +typedef struct { + unsigned ignoreHi :8; //!< not used + unsigned intPart :8; //!< integer part + unsigned fracPart :8; //!< fraction part + unsigned ignoreLo :8; //!< not used +} U_LCS_GAMMA, + *PU_LCS_GAMMA; //!< WMF manual 2.2.2.11 + +/** WMF manual 2.2.2.11 + \brief For U_LOGCOLORSPACEA and U_LOGCOLORSPACEW lcsGammaRGB field + + Microsoft name:(unknown) +*/ +typedef struct { + U_LCS_GAMMA lcsGammaRed; //!< Red Gamma + U_LCS_GAMMA lcsGammaGreen; //!< Green Gamma + U_LCS_GAMMA lcsGammaBlue; //!< Blue Gamma +} U_LCS_GAMMARGB, + *PU_LCS_GAMMARGB; //!< WMF manual 2.2.2.11 + +/** WMF manual 2.2.2.11 + \brief For U_EMRCREATECOLORSPACE lcs field + + Microsoft name: LOGCOLORSPACEA Object +*/ +typedef struct { + uint32_t lcsSignature; //!< must be U_LCS_SIGNATURE + uint32_t lcsVersion; //!< must be U_LCS_VERSION + uint32_t lcsSize; //!< Size in bytes of this structure + int32_t lcsCSType; //!< LCS_CSType Enumeration + int32_t lcsIntent; //!< LCS_Intent Enumeration + U_CIEXYZTRIPLE lcsEndpoints; //!< CIE XYZ color space endpoints + U_LCS_GAMMARGB lcsGammaRGB; //!< Gamma For RGB + char lcsFilename[U_MAX_PATH]; //!< Names an external color profile file, otherwise empty string +} U_LOGCOLORSPACEA, + *PU_LOGCOLORSPACEA; //!< WMF manual 2.2.2.11 + +/** WMF manual 2.2.2.12 + \brief For U_EMRCREATECOLORSPACEW lcs field + + Microsoft name: LOGCOLORSPACEW Object +*/ +typedef struct { + uint32_t lcsSignature; //!< must be U_LCS_SIGNATURE + uint32_t lcsVersion; //!< must be U_LCS_VERSION + uint32_t lcsSize; //!< Size in bytes of this structure + int32_t lcsCSType; //!< lcsCSType Enumeration + int32_t lcsIntent; //!< lcsIntent Enumeration + U_CIEXYZTRIPLE lcsEndpoints; //!< CIE XYZ color space endpoints + U_LCS_GAMMARGB lcsGammaRGB; //!< Gamma For RGB + uint16_t lcsFilename[U_MAX_PATH]; //!< Could name an external color profile file, otherwise empty string +} U_LOGCOLORSPACEW, + *PU_LOGCOLORSPACEW; //!< WMF manual 2.2.2.12 + +/** WMF manual 2.2.2.15 + \brief Used for any generic pair of uint32_t + + Microsoft name: POINTL Object +*/ +typedef struct { + int32_t x; //!< X value + int32_t y; //!< Y value +} U_PAIR, + U_POINT, //!< WMF manual 2.2.2.15 + U_POINTL, //!< WMF manual 2.2.2.15 + *PU_PAIR, //!< WMF manual 2.2.2.15 + *PU_POINT, //!< WMF manual 2.2.2.15 + *PU_POINTL; //!< WMF manual 2.2.2.15 + + +/** WMF manual 2.2.2.16 + \brief Point type for 16 bit EMR drawing functions. + + Microsoft name: POINTS Object. + Microsoft name: POINTS16 Object. +*/ +typedef struct { + int16_t x; //!< X size (16 bit) + int16_t y; //!< Y size (16 bit) +} U_POINT16, + *PU_POINT16; //!< WMF manual 2.2.2.16 + +/** WMF manual 2.2.2.19 + \brief Coordinates of the upper left, lower right corner. + + Note that the coordinate system is 0,0 in the upper left corner + of the screen an N,M in the lower right corner. + Microsoft name: RECTL Object +*/ +typedef struct { + int32_t left; //!< left coordinate + int32_t top; //!< top coordinate + int32_t right; //!< right coordinate + int32_t bottom; //!< bottom coordinate +} U_RECT, + U_RECTL, //!< WMF manual 2.2.2.19 + *PU_RECT, //!< WMF manual 2.2.2.19 + *PU_RECTL; //!< WMF manual 2.2.2.19 + +/** WMF manual 2.2.2.20 + \brief For U_BITMAPINFO bmiColors field + + NOTE that the color order is BGR, even though the name is RGB! + Microsoft name: RGBQUAD Object +*/ +typedef struct { + uint8_t Blue; //!< Blue color (0-255) + uint8_t Green; //!< Green color (0-255) + uint8_t Red; //!< Red color (0-255) + uint8_t Reserved; //!< Not used +} U_RGBQUAD, + *PU_RGBQUAD; //!< WMF manual 2.2.2.20 + +#define U_RCL_DEF (U_RECTL){0,0,-1,-1} //!< Use this when no bounds are needed. + +/** WMF manual 2.2.2.22 + \brief Pair of values indicating x and y sizes. + + Microsoft name: SIZE Object + Microsoft name: SIZEL Object +*/ +typedef struct { + int32_t cx; //!< X size + int32_t cy; //!< Y size +} U_SIZE, + U_SIZEL, //!< WMF manual 2.2.2.22 + *PU_SIZE, //!< WMF manual 2.2.2.22 + *PU_SIZEL; //!< WMF manual 2.2.2.22 + + +/* ************************ EMF or common to EMF and EMF+ ****************************** */ // *********************************************************************************** // Value enumerations and other predefined constants, alphabetical order by group -/** \defgroup Font_struct_widths Font name and style widths in characters +/** \defgroup U_EMF_FONT_STRUCT_WIDTHS EMF Font name and style widths in characters For U_LOGFONT and U_LOGFONT_PANOSE, @{ */ @@ -58,9 +607,10 @@ extern "C" { #define U_LF_FULLFACESIZE 64 //!< U_LOGFONT_PANOSE elfFullName field maximum width /** @} */ -/** \defgroup U_EMR_Qualifiers RecordType Enumeration - (RecordType Enumeration) +/** \defgroup U_EMF_EMR_Qualifiers EMF RecordType Enumeration + (RecordType Enumeration, EMF manual 2.1.1 ) For U_EMR iType field + EMF manual 2.1.1 @{ */ #define U_EMR_HEADER 1 //!< U_EMRHEADER record @@ -192,7 +742,8 @@ extern "C" { #define U_EMR_INVALID 0xFFFFFFFF //!< Not any valid U_EMF_ value /** @} */ -/** \defgroup U_DRAW_PROPERTIES draw properties + +/** \defgroup U_EMF_DRAW_PROPERTIES EMF draw properties Used in emr_properties() and wmr_properties. These are the bit definitions. @{ */ @@ -208,892 +759,791 @@ extern "C" { #define U_DRAW_NOFILL 0x200 //!< Object is not fillable (lines and arc, only used in WMF) /** @} */ -/** \defgroup U_EMRSETARCDIRECTION_Qualifiers ArcDirection Enumeration +/** \defgroup U_EMF_EMRSETARCDIRECTION_Qualifiers EMF ArcDirection Enumeration For U_EMRSETARCDIRECTION iArcDirection field + Microsoft name: ArcDirection Enumeration + EMF manual 2.1.2 @{ */ -#define U_AD_COUNTERCLOCKWISE 1 -#define U_AD_CLOCKWISE 2 +#define U_AD_COUNTERCLOCKWISE 1 //!< Draw arc counterclockwise. +#define U_AD_CLOCKWISE 2 //!< Draw arc clockwise. /** @} */ -/** \defgroup U_PANOSE_bArmStyle_Qualifiers ArmStyle Enumeration +/** \defgroup U_EMF_PANOSE_bArmStyle_Qualifiers EMF ArmStyle Enumeration For U_PANOSE bArmStyle field + Microsoft name: ArmStyle Enumeration + EMF manual 2.1.3 @{ */ -#define U_PAN_STRAIGHT_ARMS_HORZ 2 -#define U_PAN_STRAIGHT_ARMS_WEDGE 3 -#define U_PAN_STRAIGHT_ARMS_VERT 4 -#define U_PAN_STRAIGHT_ARMS_SINGLE_SERIF 5 -#define U_PAN_STRAIGHT_ARMS_DOUBLE_SERIF 6 -#define U_PAN_BENT_ARMS_HORZ 7 -#define U_PAN_BENT_ARMS_WEDGE 8 -#define U_PAN_BENT_ARMS_VERT 9 -#define U_PAN_BENT_ARMS_SINGLE_SERIF 10 -#define U_PAN_BENT_ARMS_DOUBLE_SERIF 11 +#define U_PAN_STRAIGHT_ARMS_HORZ 2 //!< straight arms horizontal +#define U_PAN_STRAIGHT_ARMS_WEDGE 3 //!< straight arms wedge +#define U_PAN_STRAIGHT_ARMS_VERT 4 //!< straight arms vertical +#define U_PAN_STRAIGHT_ARMS_SINGLE_SERIF 5 //!< straight arms singleserif +#define U_PAN_STRAIGHT_ARMS_DOUBLE_SERIF 6 //!< straight arms doubleserif +#define U_PAN_BENT_ARMS_HORZ 7 //!< bent arms horizontal +#define U_PAN_BENT_ARMS_WEDGE 8 //!< bent arms wedge +#define U_PAN_BENT_ARMS_VERT 9 //!< bent arms vertical +#define U_PAN_BENT_ARMS_SINGLE_SERIF 10 //!< bent arms singleserif +#define U_PAN_BENT_ARMS_DOUBLE_SERIF 11 //!< bent arms doubleserif /** @} */ -/** \defgroup U_EMRSETBKMODE_iMode_Qualifiers BackgroundMode enumeration +/** \defgroup U_EMF_EMRSETBKMODE_iMode_Qualifiers EMF BackgroundMode enumeration For U_EMRSETBKMODE iMode field + Microsoft name: BackgroundMode enumeration + EMF manual 2.1.4 @{ */ -#define U_TRANSPARENT 1 -#define U_OPAQUE 2 -/** @} */ - -/** \defgroup U_BITMAPINFOHEADER_biBitCount_Qualifiers BitCount Enumeration - For U_BITMAPINFOHEADER biBitCount field. - @{ -*/ -#define U_BCBM_EXPLICIT 0 //!< Derived from JPG or PNG compressed image or ? -#define U_BCBM_MONOCHROME 1 //!< 2 colors. bmiColors array has two entries -#define U_BCBM_COLOR4 4 //!< 2^4 colors. bmiColors array has 16 entries -#define U_BCBM_COLOR8 8 //!< 2^8 colors. bmiColors array has 256 entries -#define U_BCBM_COLOR16 16 //!< 2^16 colors. bmiColors is not used. Pixels are 5 bits B,G,R with 1 unused bit -#define U_BCBM_COLOR24 24 //!< 2^24 colors. bmiColors is not used. Pixels are U_RGBTRIPLE. -#define U_BCBM_COLOR32 32 //!< 2^32 colors. bmiColors is not used. Pixels are U_RGBQUAD. -/** @} */ - -/** \defgroup U_BITMAPINFOHEADER_biCompression_Qualifiers BI_Compression Enumeration - For U_BITMAPINFOHEADER biCompression field - @{ -*/ -#define U_BI_RGB 0 //!< This is the only one supported by UEMF at present -#define U_BI_RLE8 1 -#define U_BI_RLE4 2 -#define U_BI_BITFIELDS 3 -#define U_BI_JPEG 4 -#define U_BI_PNG 5 +#define U_TRANSPARENT 1 //!< Transparent background mode +#define U_OPAQUE 2 //!< Opaque background mode /** @} */ -/** \defgroup U_COLORADJUSTMENT_caFlags_Qualifiers ColorAdjustment Enumeration +/** \defgroup U_EMF_COLORADJUSTMENT_caFlags_Qualifiers EMF ColorAdjustment Enumeration For U_COLORADJUSTMENT caFlags field + Microsoft name: ColorAdjustment Enumeration + EMF manual 2.1.5 @{ */ -#define U_CA_NEGATIVE 0x0001 -#define U_CA_LOG_FILTER 0x0002 +#define U_CA_NEGATIVE 0x0001 //!< display Negative of image +#define U_CA_LOG_FILTER 0x0002 //!< display Logarithmi filter of image /** @} */ -/** \defgroup U_EMRCOLORMATCHTOTARGETW_dwFlags_Qualifiers ColorMatchToTarget Enumeration +/** \defgroup U_EMF_EMRCOLORMATCHTOTARGETW_dwFlags_Qualifiers EMF ColorMatchToTarget Enumeration For U_EMRCOLORMATCHTOTARGETW dwFlags field + Microsoft name: ColorMatchToTarget Enumeration + EMF manual 2.1.6 @{ */ -#define U_COLORMATCHTOTARGET_NOTEMBEDDED 0 -#define U_COLORMATCHTOTARGET_EMBEDDED 1 +#define U_COLORMATCHTOTARGET_NOTEMBEDDED 0 //!< Color match profile is not embedded in metafile +#define U_COLORMATCHTOTARGET_EMBEDDED 1 //!< Color match profile is embedded in metafile /** @} */ -/** \defgroup U_EMRCOLORMATCHTOTARGETW_dwAction_Qualifiers ColorSpace Enumeration +/** \defgroup U_EMF_EMRCOLORMATCHTOTARGETW_dwAction_Qualifiers EMF ColorSpace Enumeration For U_EMRCOLORMATCHTOTARGETW dwAction field + Microsoft name: ColorSpace Enumeration + EMF manual 2.1.7 @{ */ -#define U_CS_ENABLE 1 -#define U_CS_DISABLE 2 -#define U_CS_DELETE_TRANSFORM 3 +#define U_CS_ENABLE 1 //!< Enable color proofing. +#define U_CS_DISABLE 2 //!< Disable color proofing. +#define U_CS_DELETE_TRANSFORM 3 //!< Disable proofing and delete color transform. /** @} */ -/** \defgroup U_PANOSE_bContrast_Qualifiers Contrast Enumeration - For U_PANOSE bContrast field +/** \defgroup U_EMF_PANOSE_common_Qualifiers EMF PanoseCommon Enumeration + Used by all PAN_* enumerations, but only defined once here. + See also U_PAN_ALL1 after the U_PANOSE structure @{ */ -#define U_PAN_CONTRAST_NONE 2 -#define U_PAN_CONTRAST_VERY_LOW 3 -#define U_PAN_CONTRAST_LOW 4 -#define U_PAN_CONTRAST_MEDIUM_LOW 5 -#define U_PAN_CONTRAST_MEDIUM 6 -#define U_PAN_CONTRAST_MEDIUM_HIGH 7 -#define U_PAN_CONTRAST_HIGH 8 -#define U_PAN_CONTRAST_VERY_HIGH 9 +#define U_PAN_ANY 0 //!< Any (for any type of Panose enumeration) +#define U_PAN_NO_FIT 1 //!< No fit (for any type of Panose enumeration) /** @} */ -/** \defgroup U_DIBITS_iUsageSrc_Qualifiers DIBColors Enumeration - For U_EMRSETDIBITSTODEIVCE and U_EMRSTRETCHDIBITS iUsageSrc fields. +/** \defgroup U_EMF_PANOSE_bContrast_Qualifiers EMF Contrast Enumeration + For U_PANOSE bContrast field + Microsoft name: Contrast Enumeration + EMF manual 2.1.8 @{ */ -#define U_DIB_RGB_COLORS 0 -#define U_DIB_PAL_COLORS 1 +#define U_PAN_CONTRAST_NONE 2 //!< None +#define U_PAN_CONTRAST_VERY_LOW 3 //!< Very low +#define U_PAN_CONTRAST_LOW 4 //!< Low +#define U_PAN_CONTRAST_MEDIUM_LOW 5 //!< Medium low +#define U_PAN_CONTRAST_MEDIUM 6 //!< Medium +#define U_PAN_CONTRAST_MEDIUM_HIGH 7 //!< Medium high +#define U_PAN_CONTRAST_HIGH 8 //!< High +#define U_PAN_CONTRAST_VERY_HIGH 9 //!< Very high /** @} */ -/** \defgroup U_EMRCOMMENT_TYPES Comment record types - For U_EMRCOMMENT_* cIdent fields +/** \defgroup U_EMF_DIBITS_iUsageSrc_Qualifiers EMF DIBColors Enumeration + For U_EMRSETDIBITSTODEIVCE and U_EMRSTRETCHDIBITS iUsageSrc fields. + Microsoft name: DIBColors Enumeration + EMF manual 2.1.9 @{ */ -#define U_EMR_COMMENT_PUBLIC 0x43494447 -#define U_EMR_COMMENT_SPOOL 0x00000000 -#define U_EMR_COMMENT_SPOOLFONTDEF 0x544F4E46 -#define U_EMR_COMMENT_EMFPLUSRECORD 0x2B464D45 +#define U_DIB_RGB_COLORS 0 //!< color table contains colors +#define U_DIB_PAL_COLORS 1 //!< color table contains 16 bit indices into logical palette +#define U_DIB_PAL_INDICES 2 //!< no color table, pixel values are indices into logical palette /** @} */ -/** \defgroup U_EMR_COMMENT_PUBLIC EMRComment Enumeration +/** \defgroup U_EMF_EMR_COMMENT_PUBLIC EMF EMRComment Enumeration For U_EMRCOMMENT_PUBLIC pcIdent fields + Microsoft name: EMRComment Enumeration + EMF manual 2.1.10 @{ */ -#define U_EMR_COMMENT_WINDOWS_METAFILE 0x80000001 -#define U_EMR_COMMENT_BEGINGROUP 0x00000002 -#define U_EMR_COMMENT_ENDGROUP 0x00000003 -#define U_EMR_COMMENT_MULTIFORMATS 0x40000004 -#define U_EMR_COMMENT_UNICODE_STRING 0x00000040 -#define U_EMR_COMMENT_UNICODE_END 0x00000080 +#define U_EMR_COMMENT_WINDOWS_METAFILE 0x80000001 //!< Comment contains WMF +#define U_EMR_COMMENT_BEGINGROUP 0x00000002 //!< Comment begins group of EMF records +#define U_EMR_COMMENT_ENDGROUP 0x00000003 //!< Comment ends group of EMF records +#define U_EMR_COMMENT_MULTIFORMATS 0x40000004 //!< Comment contains some other representation of drawing +#define U_EMR_COMMENT_UNICODE_STRING 0x00000040 //!< Reserved +#define U_EMR_COMMENT_UNICODE_END 0x00000080 //!< Reserved /** @} */ -/** \defgroup U_EMRTEXT_foptions_Qualifiers ExtTextOutOptions Enumeration +/** \defgroup U_EMF_EMRTEXT_foptions_Qualifiers EMF ExtTextOutOptions Enumeration For U_EMRTEXT foptions field + Microsoft name: ExtTextOutOptions Enumeration + EMF manual 2.1.11 @{ */ -#define U_ETO_NONE 0x00000000 -#define U_ETO_GRAYED 0x00000001 -#define U_ETO_OPAQUE 0x00000002 -#define U_ETO_CLIPPED 0x00000004 -#define U_ETO_GLYPH_INDEX 0x00000010 -#define U_ETO_RTLREADING 0x00000080 -#define U_ETO_NO_RECT 0x00000100 -#define U_ETO_SMALL_CHARS 0x00000200 // For EMRSMALLTEXTOUT ONLY, does not affect EMRTEXTOUTA or EMRTEXTOUTW -#define U_ETO_NUMERICSLOCAL 0x00000400 -#define U_ETO_NUMERICSLATIN 0x00000800 -#define U_ETO_IGNORELANGUAGE 0x00001000 -#define U_ETO_PDY 0x00002000 -#define U_ETO_REVERSE_INDEX_MAP 0x00010000 -/** @} */ - -/** \defgroup U_PANOSE_bFamilyType_Qualifiers FamilyType Enumeration +#define U_ETO_NONE 0x00000000 //!< None +#define U_ETO_GRAYED 0x00000001 //!< Grayed +#define U_ETO_OPAQUE 0x00000002 //!< Fill rectangle with background color. +#define U_ETO_CLIPPED 0x00000004 //!< Clip text to rectangle. +#define U_ETO_GLYPH_INDEX 0x00000010 //!< Characters are glyph indices for the font. +#define U_ETO_RTLREADING 0x00000080 //!< Right to left text. +#define U_ETO_NO_RECT 0x00000100 //!< No bounding rectangle is specified. +#define U_ETO_SMALL_CHARS 0x00000200 //!< 8 bit characters instead of 16 bit. For EMRSMALLTEXTOUT ONLY, does not affect EMRTEXTOUTA or EMRTEXTOUTW +#define U_ETO_NUMERICSLOCAL 0x00000400 //!< Show numbers for the current locale. +#define U_ETO_NUMERICSLATIN 0x00000800 //!< Show numbers using European digits. +#define U_ETO_IGNORELANGUAGE 0x00001000 //!< Process Right to Left languages exactly as specified in the metafile. +#define U_ETO_PDY 0x00002000 //!< Both horizontal and vertical displacements are provided. +#define U_ETO_REVERSE_INDEX_MAP 0x00010000 //!< Reverse_index_map +/** @} */ + +/** \defgroup U_EMF_PANOSE_bFamilyType_Qualifiers EMF FamilyType Enumeration For U_PANOSE bFamilyType field + Microsoft name: FamilyType Enumeration + EMF manual 2.1.12 @{ */ -#define U_PAN_FAMILY_TEXT_DISPLAY 2 -#define U_PAN_FAMILY_SCRIPT 3 -#define U_PAN_FAMILY_DECORATIVE 4 -#define U_PAN_FAMILY_PICTORIAL 5 +#define U_PAN_FAMILY_TEXT_DISPLAY 2 //!< Text display +#define U_PAN_FAMILY_SCRIPT 3 //!< Script +#define U_PAN_FAMILY_DECORATIVE 4 //!< Decorative +#define U_PAN_FAMILY_PICTORIAL 5 //!< Pictorial /** @} */ -/** \defgroup U_EMREXTFLOODFILL_iMode_Qualifiers FloodFill Enumeration +/** \defgroup U_EMF_EMREXTFLOODFILL_iMode_Qualifiers EMF FloodFill Enumeration For U_EMREXTFLOODFILL iMode field + Microsoft name: FloodFill Enumeration + EMF manual 2.1.13 @{ */ -#define U_FLOODFILLBORDER 0x00000000 /* Color specified must be the same as the border - brush fill stops at this color */ -#define U_FLOODFILLSURFACE 0x00000001 /* Color specified must be different from the border - brush fills only this color */ +#define U_FLOODFILLBORDER 0x00000000 //!< Color specified must be the same as the border - brush fill stops at this color +#define U_FLOODFILLSURFACE 0x00000001 //!< Color specified must be different from the border - brush fills only this color /** @} */ -/** \defgroup U_DESIGNVECTOR_Signature_Qualifiers Signature Enumeration +/** \defgroup U_EMF_DESIGNVECTOR_Signature_Qualifiers EMF Signature Enumeration For U_DESIGNVECTOR Signature field + Microsoft name: Signature Enumeration + EMF manual 2.1.14 @{ */ -#define U_ENHMETA_SIGNATURE 0x464D4520 //!< also for U_EMRHEADER dSignature field -#define U_EPS_SIGNATURE 0x46535045 +#define U_ENHMETA_SIGNATURE 0x464D4520 //!< "EMF" signature also for U_EMRHEADER dSignature field. +#define U_EPS_SIGNATURE 0x46535045 //!< "FSPE" signature, indicates encapsulated postscript. /** @} */ -/** \defgroup U_EMRGRADIENTFILL_ulMode_Qualifiers GradientFill Enumeration +/** \defgroup U_EMF_EMRGRADIENTFILL_ulMode_Qualifiers EMF GradientFill Enumeration For U_EMRGRADIENTFILL ulMode field + Microsoft name: GradientFill Enumeration + EMF manual 2.1.15 @{ */ -#define U_GRADIENT_FILL_RECT_H 0x00000000 -#define U_GRADIENT_FILL_RECT_V 0x00000001 -#define U_GRADIENT_FILL_TRIANGLE 0x00000002 +#define U_GRADIENT_FILL_RECT_H 0x00000000 //!< Gradient is left to right. +#define U_GRADIENT_FILL_RECT_V 0x00000001 //!< Grident is top to bottom. +#define U_GRADIENT_FILL_TRIANGLE 0x00000002 //!< Gradient is between 3 vertices of a triangle. /** @} */ -/** \defgroup U_EMREXTTEXTOUT_iGraphicsMode_Qualifiers GraphicsMode Enumeration +/** \defgroup U_EMF_EMREXTTEXTOUT_iGraphicsMode_Qualifiers EMF GraphicsMode Enumeration For U_EMREXTTEXTOUTA/U_EMREXTTEXTOUTW and all other iGraphicsMode fields + Microsoft name: GraphicsMode Enumeration + EMF manual 2.1.16 @{ */ -#define U_GM_COMPATIBLE 1 -#define U_GM_ADVANCED 2 -#define U_GM_LAST 2 +#define U_GM_COMPATIBLE 1 //!< TrueType text ignores world to device transform except for Scale. Arcs ignore transform +#define U_GM_ADVANCED 2 //!< TrueType text and Arcs must conform to all of world to device transform. +#define U_GM_LAST 2 //!< Number of GraphicsMode Enumeration entries. /** @} */ -/** \defgroup U_LOGBRUSH_lbHatch_Qualifiers HatchStyle Enumeration +/** \defgroup U_EMF_LOGBRUSH_lbHatch_Qualifiers EMF HatchStyle Enumeration For U_LOGBRUSH lbHatch field + Microsoft name: HatchStyle Enumeration + EMF manual 2.1.17 @{ */ -#define U_HS_HORIZONTAL 0 -#define U_HS_VERTICAL 1 -#define U_HS_FDIAGONAL 2 -#define U_HS_BDIAGONAL 3 -#define U_HS_CROSS 4 -#define U_HS_DIAGCROSS 5 -#define U_HS_SOLIDCLR 6 -#define U_HS_DITHEREDCLR 7 -#define U_HS_SOLIDTEXTCLR 8 -#define U_HS_DITHEREDTEXTCLR 9 -#define U_HS_SOLIDBKCLR 10 -#define U_HS_DITHEREDBKCLR 11 -/** @} */ - -/** \defgroup U_EMRSETICMMODE_iMode_Qualifiers ICMMode Enumeration +#define U_HS_HORIZONTAL 0 //!< Horizontal. +#define U_HS_VERTICAL 1 //!< Vertical. +#define U_HS_FDIAGONAL 2 //!< Forward diagonal. +#define U_HS_BDIAGONAL 3 //!< Back diagonal. +#define U_HS_CROSS 4 //!< Cross. +#define U_HS_DIAGCROSS 5 //!< Diagonal cross. +#define U_HS_SOLIDCLR 6 //!< Solid color. +#define U_HS_DITHEREDCLR 7 //!< Dithered color. +#define U_HS_SOLIDTEXTCLR 8 //!< Solid text color. +#define U_HS_DITHEREDTEXTCLR 9 //!< Dithered text color. +#define U_HS_SOLIDBKCLR 10 //!< Solid background color. +#define U_HS_DITHEREDBKCLR 11 //!< Dithered background color. +/** @} */ + +/** \defgroup U_EMF_EMRSETICMMODE_iMode_Qualifiers EMF ICMMode Enumeration For EMF U_EMR_SETICMMODE iMode field + Microsoft name: ICMMode Enumeration + EMF manual 2.1.18 @{ */ -#define U_ICM_OFF 1 -#define U_ICM_ON 2 -#define U_ICM_QUERY 3 +#define U_ICM_OFF 1 //!< Off +#define U_ICM_ON 2 //!< On +#define U_ICM_QUERY 3 //!< Query /** @} */ -/** \defgroup U_COLORADJUSTMENT_caIlluminantIndex_Qualifiers Illuminant Enumeration +/** \defgroup U_EMF_COLORADJUSTMENT_caIlluminantIndex_Qualifiers EMF Illuminant Enumeration For U_COLORADJUSTMENT caIlluminantIndex field + Microsoft name: Illuminant Enumeration + EMF manual 2.1.19 @{ */ -#define U_ILLUMINANT_DEVICE_DEFAULT 0 -#define U_ILLUMINANT_A 1 -#define U_ILLUMINANT_B 2 -#define U_ILLUMINANT_C 3 -#define U_ILLUMINANT_D50 4 -#define U_ILLUMINANT_D55 5 -#define U_ILLUMINANT_D65 6 -#define U_ILLUMINANT_D75 7 -#define U_ILLUMINANT_F2 8 -#define U_ILLUMINANT_MAX_INDEX ILLUMINANT_F2 -#define U_ILLUMINANT_TUNGSTEN ILLUMINANT_A -#define U_ILLUMINANT_DAYLIGHT ILLUMINANT_C -#define U_ILLUMINANT_FLUORESCENT ILLUMINANT_F2 -#define U_ILLUMINANT_NTSC ILLUMINANT_C -/** @} */ - -/** \defgroup U_LOGBRUSH_lbStyle_Qualifiers LB_Style Enumeration - For U_LOGBRUSH lbStyle field - @{ -*/ -#define U_BS_SOLID 0 -#define U_BS_NULL 1 -#define U_BS_HOLLOW 1 -#define U_BS_HATCHED 2 -#define U_BS_PATTERN 3 -#define U_BS_INDEXED 4 -#define U_BS_DIBPATTERN 5 -#define U_BS_DIBPATTERNPT 6 -#define U_BS_PATTERN8X8 7 -#define U_BS_DIBPATTERN8X8 8 -#define U_BS_MONOPATTERN 9 -/** @} */ - -/** \defgroup _LOGCOLORSPACE_lcsCSType_Qualifiers LCS_CSType Enumeration - For U_LOGCOLORSPACEA/U_LOGCOLORSPACEW lcsCSType field - @{ -*/ -#define U_LCS_CALIBRATED_RGB 0x00000000L -#define U_LCS_DEVICE_RGB 0x00000001L -#define U_LCS_DEVICE_CMYK 0x00000002L -/** @} */ - -/** \defgroup U_LOGCOLORSPACE_lcsIntent_Qualifiers LCS_Intent Enumeration - For U_LOGCOLORSPACEA/U_LOGCOLORSPACEW lcsIntent field - @{ -*/ -#define U_LCS_GM_BUSINESS 0x00000001L -#define U_LCS_GM_GRAPHICS 0x00000002L -#define U_LCS_GM_IMAGES 0x00000004L -#define U_LCS_GM_ABS_COLORIMETRIC 0x00000008L -/** @} */ - -/** \defgroup U_PANOSE_bLetterForm_Qualifiers Letterform Enumeration +#define U_ILLUMINANT_DEVICE_DEFAULT 0 //!< Device default +#define U_ILLUMINANT_A 1 //!< A +#define U_ILLUMINANT_B 2 //!< B +#define U_ILLUMINANT_C 3 //!< C +#define U_ILLUMINANT_D50 4 //!< D50 +#define U_ILLUMINANT_D55 5 //!< D55 +#define U_ILLUMINANT_D65 6 //!< D65 +#define U_ILLUMINANT_D75 7 //!< D75 +#define U_ILLUMINANT_F2 8 //!< F2 +#define U_ILLUMINANT_MAX_INDEX ILLUMINANT_F2 //!< Max index +#define U_ILLUMINANT_TUNGSTEN ILLUMINANT_A //!< Tungsten +#define U_ILLUMINANT_DAYLIGHT ILLUMINANT_C //!< Daylight +#define U_ILLUMINANT_FLUORESCENT ILLUMINANT_F2 //!< Fluorescent +#define U_ILLUMINANT_NTSC ILLUMINANT_C //!< NTSC +/** @} */ + +/** \defgroup U_EMF_PANOSE_bLetterForm_Qualifiers EMF Letterform Enumeration For U_PANOSE bLetterForm field + Microsoft name: Letterform Enumeration + EMF manual 2.1.20 @{ */ -#define U_PAN_LETT_NORMAL_COMPACT 2 -#define U_PAN_LETT_NORMAL_WEIGHTED 3 -#define U_PAN_LETT_NORMAL_BOXED 4 -#define U_PAN_LETT_NORMAL_FLATTENED 5 -#define U_PAN_LETT_NORMAL_ROUNDED 6 -#define U_PAN_LETT_NORMAL_OFF_CENTER 7 -#define U_PAN_LETT_NORMAL_SQUARE 8 -#define U_PAN_LETT_OBLIQUE_COMPACT 9 -#define U_PAN_LETT_OBLIQUE_WEIGHTED 10 -#define U_PAN_LETT_OBLIQUE_BOXED 11 -#define U_PAN_LETT_OBLIQUE_FLATTENED 12 -#define U_PAN_LETT_OBLIQUE_ROUNDED 13 -#define U_PAN_LETT_OBLIQUE_OFF_CENTER 14 -#define U_PAN_LETT_OBLIQUE_SQUARE 15 -/** @} */ - -/** \defgroup U_LOGFONT_lfWeight_Qualifiers LF_Weight Enumeration - For U_LOGFONT lfWeight field +#define U_PAN_LETT_NORMAL_COMPACT 2 //!< Normal compact +#define U_PAN_LETT_NORMAL_WEIGHTED 3 //!< Normal weighted +#define U_PAN_LETT_NORMAL_BOXED 4 //!< Normal boxed +#define U_PAN_LETT_NORMAL_FLATTENED 5 //!< Normal flattened +#define U_PAN_LETT_NORMAL_ROUNDED 6 //!< Normal rounded +#define U_PAN_LETT_NORMAL_OFF_CENTER 7 //!< Normal off center +#define U_PAN_LETT_NORMAL_SQUARE 8 //!< Normal square +#define U_PAN_LETT_OBLIQUE_COMPACT 9 //!< Oblique compact +#define U_PAN_LETT_OBLIQUE_WEIGHTED 10 //!< Oblique weighted +#define U_PAN_LETT_OBLIQUE_BOXED 11 //!< Oblique boxed +#define U_PAN_LETT_OBLIQUE_FLATTENED 12 //!< Oblique flattened +#define U_PAN_LETT_OBLIQUE_ROUNDED 13 //!< Oblique rounded +#define U_PAN_LETT_OBLIQUE_OFF_CENTER 14 //!< Oblique off center +#define U_PAN_LETT_OBLIQUE_SQUARE 15 //!< Oblique square +/** @} */ + +/** \defgroup U_EMF_EMRSETMAPMODE_iMode_Qualifiers EMF MapMode Enumeration + For U_EMRSETMAPMODE iMode field + Microsoft name: MapMode Enumeration + EMF manual 2.1.21 @{ */ -#define U_FW_DONTCARE 0 -#define U_FW_THIN 100 -#define U_FW_EXTRALIGHT 200 -#define U_FW_ULTRALIGHT 200 -#define U_FW_LIGHT 300 -#define U_FW_NORMAL 400 -#define U_FW_REGULAR 400 -#define U_FW_MEDIUM 500 -#define U_FW_SEMIBOLD 600 -#define U_FW_DEMIBOLD 600 -#define U_FW_BOLD 700 -#define U_FW_EXTRABOLD 800 -#define U_FW_ULTRABOLD 800 -#define U_FW_HEAVY 900 -#define U_FW_BLACK 900 -/** @} */ - -/** \defgroup U_LOGFONT_lfItalic_Qualifiers LF_Italic Enumeration - For U_LOGFONT lfItalic field +#define U_MM_TEXT 1 //!< Text +#define U_MM_LOMETRIC 2 //!< Low metric +#define U_MM_HIMETRIC 3 //!< Hig hmetric +#define U_MM_LOENGLISH 4 //!< Low English +#define U_MM_HIENGLISH 5 //!< High English +#define U_MM_TWIPS 6 //!< Twips +#define U_MM_ISOTROPIC 7 //!< Isotropic +#define U_MM_ANISOTROPIC 8 //!< Anisotropic +#define U_MM_MIN U_MM_TEXT //!< smallest enumeration +#define U_MM_MAX U_MM_ANISOTROPIC //!< largest enumeration +#define U_MM_MAX_FIXEDSCALE U_MM_TWIPS //!< alternate definition +/** @} */ + +/** \defgroup U_EMF_MF_version EMF MetafileVersion Enumeration + For U_EMR_COMMENTS_METAFILE version field + Microsoft name: MetafileVersion Enumeration + EMF manual 2.1.22 @{ */ -#define U_FW_NOITALIC 0 -#define U_FW_ITALIC 1 +#define U_ENHMETA_VERSION 0x00010000 //!< U_EMRHEADER nVersion field /** @} */ -/** \defgroup U_LOGFONT_lfunderline_Qualifiers LF_Underline Enumeration - For U_LOGFONT lfunderline field +/** \defgroup U_EMF_PANOSE_bMidline_Qualifiers EMF MidLine Enumeration + For U_PANOSE bMidline field + Microsoft name: MidLine Enumeration + EMF manual 2.1.23 @{ */ -#define U_FW_NOUNDERLINE 0 -#define U_FW_UNDERLINE 1 -/** @} */ - -/** \defgroup U_LOGFONT_lfStrikeOut_Qualifiers LF_StrikeOut Enumeration - For U_LOGFONT lfStrikeOut field +#define U_PAN_MIDLINE_STANDARD_TRIMMED 2 //!< Midline standard trimmed +#define U_PAN_MIDLINE_STANDARD_POINTED 3 //!< Midline standard pointed +#define U_PAN_MIDLINE_STANDARD_SERIFED 4 //!< Midline standard serifed +#define U_PAN_MIDLINE_HIGH_TRIMMED 5 //!< Midline high trimmed +#define U_PAN_MIDLINE_HIGH_POINTED 6 //!< Midline high pointed +#define U_PAN_MIDLINE_HIGH_SERIFED 7 //!< Midline high serifed +#define U_PAN_MIDLINE_CONSTANT_TRIMMED 8 //!< Midline constant trimmed +#define U_PAN_MIDLINE_CONSTANT_POINTED 9 //!< Midline constant pointed +#define U_PAN_MIDLINE_CONSTANT_SERIFED 10 //!< Midline constant serifed +#define U_PAN_MIDLINE_LOW_TRIMMED 11 //!< Midline low trimmed +#define U_PAN_MIDLINE_LOW_POINTED 12 //!< Midline low pointed +#define U_PAN_MIDLINE_LOW_SERIFED 13 //!< Midline low serifed +/** @} */ + +/** \defgroup U_EMF_EMRMODIFYWORLDTRANSFORM_iMode_Qualifiers EMF ModifyWorldTransformMode Enumeration + For U_EMRMODIFYWORLDTRANSFORM iMode + Microsoft name: ModifyWorldTransformMode Enumeration + EMF manual 2.1.24 @{ */ -#define U_FW_NOSTRIKEOUT 0 -#define U_FW_STRIKEOUT 1 +#define U_MWT_IDENTITY 1 //!< Transform is identity. +#define U_MWT_LEFTMULTIPLY 2 //!< Left multiply transform. +#define U_MWT_RIGHTMULTIPLY 3 //!< Right multiply transform. +#define U_MWT_MIN U_MWT_IDENTITY //!< smallest enumeration. +#define U_MWT_MAX U_MWT_RIGHTMULTIPLY //!< largest enumeration. /** @} */ -/** \defgroup U_LOGFONT_lfCharSet_Qualifiers LF_CharSet Enumeration - For U_LOGFONT lfCharSet field - @{ -*/ -#define U_ANSI_CHARSET (uint8_t)0 /* CP1252, ansi-0, iso8859-{1,15} */ -#define U_DEFAULT_CHARSET (uint8_t)1 -#define U_SYMBOL_CHARSET (uint8_t)2 -#define U_SHIFTJIS_CHARSET (uint8_t)128 /* CP932 */ -#define U_HANGEUL_CHARSET (uint8_t)129 /* CP949, ksc5601.1987-0 */ -#define U_HANGUL_CHARSET U_HANGEUL_CHARSET -#define U_GB2312_CHARSET (uint8_t)134 /* CP936, gb2312.1980-0 */ -#define U_CHINESEBIG5_CHARSET (uint8_t)136 /* CP950, big5.et-0 */ -#define U_GREEK_CHARSET (uint8_t)161 /* CP1253 */ -#define U_TURKISH_CHARSET (uint8_t)162 /* CP1254, -iso8859-9 */ -#define U_HEBREW_CHARSET (uint8_t)177 /* CP1255, -iso8859-8 */ -#define U_ARABIC_CHARSET (uint8_t)178 /* CP1256, -iso8859-6 */ -#define U_BALTIC_CHARSET (uint8_t)186 /* CP1257, -iso8859-13 */ -#define U_RUSSIAN_CHARSET (uint8_t)204 /* CP1251, -iso8859-5 */ -#define U_EE_CHARSET (uint8_t)238 /* CP1250, -iso8859-2 */ -#define U_EASTEUROPE_CHARSET U_EE_CHARSET -#define U_THAI_CHARSET (uint8_t)222 /* CP874, iso8859-11, tis620 */ -#define U_JOHAB_CHARSET (uint8_t)130 /* korean (johab) CP1361 */ -#define U_MAC_CHARSET (uint8_t)77 -#define U_OEM_CHARSET (uint8_t)255 -/* I don't know if the values of *_CHARSET macros are defined in Windows - * or if we can choose them as we want. -- srtxg - */ -#define U_VISCII_CHARSET (uint8_t)240 /* viscii1.1-1 */ -#define U_TCVN_CHARSET (uint8_t)241 /* tcvn-0 */ -#define U_KOI8_CHARSET (uint8_t)242 /* koi8-{r,u,ru} */ -#define U_ISO3_CHARSET (uint8_t)243 /* iso8859-3 */ -#define U_ISO4_CHARSET (uint8_t)244 /* iso8859-4 */ -#define U_ISO10_CHARSET (uint8_t)245 /* iso8859-10 */ -#define U_CELTIC_CHARSET (uint8_t)246 /* iso8859-14 */ -/** @} */ - -/** \defgroup U_LOGFONT_lfOutPrecision_Qualifiers LF_OutPrecision Enumeration - For U_LOGFONT lfOutPrecision field +/** \defgroup U_EMF_LOGPEN_elpPenStyle_Qualifiers EMF PenStyle Enumeration + For U_LOGPEN lopnStyle and U_EXTLOGPEN elpPenStyle fields + Microsoft name: PenStyle Enumeration + EMF manual 2.1.25 @{ */ -#define U_OUT_DEFAULT_PRECIS 0 -#define U_OUT_STRING_PRECIS 1 -#define U_OUT_CHARACTER_PRECIS 2 -#define U_OUT_STROKE_PRECIS 3 -#define U_OUT_TT_PRECIS 4 -#define U_OUT_DEVICE_PRECIS 5 -#define U_OUT_RASTER_PRECIS 6 -#define U_OUT_TT_ONLY_PRECIS 7 -#define U_OUT_OUTLINE_PRECIS 8 -/** @} */ +#define U_PS_SOLID 0x00000000 //!< Solid line. +#define U_PS_DASH 0x00000001 //!< Dashed line. This only works when NO other U_PS is set. Line width is minimum no matter what pen is set to. +#define U_PS_DOT 0x00000002 //!< Dotted line. This only works when NO other U_PS is set. Line width is minimum no matter what pen is set to. +#define U_PS_DASHDOT 0x00000003 //!< Dash-Dot line. This only works when NO other U_PS is set. Line width is minimum no matter what pen is set to. +#define U_PS_DASHDOTDOT 0x00000004 //!< Dash-Dot-Dot line. This only works when NO other U_PS is set. Line width is minimum no matter what pen is set to. +#define U_PS_NULL 0x00000005 //!< Invisible line. +#define U_PS_INSIDEFRAME 0x00000006 //!< Draw line around drawing, then shrink drawing to fit within line taking its width into account. +#define U_PS_USERSTYLE 0x00000007 //!< User defined. +#define U_PS_ALTERNATE 0x00000008 //!< Every other pixel is drawn. +#define U_PS_STYLE_MASK 0x0000000f //!< Mask to select just the preceding line type fields. + +#define U_PS_ENDCAP_ROUND 0x00000000 //!< Round end cap. Only with U_PS_GEOMETRIC +#define U_PS_ENDCAP_SQUARE 0x00000100 //!< Square end cap. Only with U_PS_GEOMETRIC +#define U_PS_ENDCAP_FLAT 0x00000200 //!< Flat end cap. Only with U_PS_GEOMETRIC +#define U_PS_ENDCAP_MASK 0x00000f00 //!< Mask to select just the preceding ENDCAP fields. + +#define U_PS_JOIN_ROUND 0x00000000 //!< Rounded join. Only with U_PS_GEOMETRIC +#define U_PS_JOIN_BEVEL 0x00001000 //!< Beveled join. Only with U_PS_GEOMETRIC +#define U_PS_JOIN_MITER 0x00002000 //!< Mitered join. Only with U_PS_GEOMETRIC +#define U_PS_JOIN_MASK 0x0000f000 //!< Mask to select just the preceding JOIN fields. -/** \defgroup U_LOGFONT_lfClipPrecision_Qualifiers LF_ClipPrecision Enumeration - For U_LOGFONT lfClipPrecision field - @{ +#define U_PS_COSMETIC 0x00000000 //!< width may only be 1 pixel. (If set higher it is still drawn as 1). +#define U_PS_GEOMETRIC 0x00010000 //!< width may be >1 pixel, but style may only be U_PS_SOLID or U_PS_NULL. +#define U_PS_TYPE_MASK 0x000f0000 //!< Mask to select just the preceding TYPE fields. +/** @} */ +/** \defgroup U_EMF_EMRPOLY_iMode_Qualifiers EMF Point Enumeration + For U_EMRPOLYDRAW and U_EMRPOLAYDRAW16 abTypes fields. + Microsoft name: Point Enumeration + EMF manual 2.1.26 + @{ */ -#define U_CLIP_DEFAULT_PRECIS 0x00 -#define U_CLIP_CHARACTER_PRECIS 0x01 -#define U_CLIP_STROKE_PRECIS 0x02 -#define U_CLIP_MASK 0x0F -#define U_CLIP_LH_ANGLES 0x10 -#define U_CLIP_TT_ALWAYS 0x20 -#define U_CLIP_EMBEDDED 0x80 +#define U_PT_CLOSEFIGURE 0x0001 //!< Close figure +#define U_PT_LINETO 0x0002 //!< Line to +#define U_PT_BEZIERTO 0x0004 //!< Bezier to +#define U_PT_MOVETO 0x0006 //!< Move to /** @} */ -/** \defgroup U_LOGFONT_lfQuality_Qualifiers LF_Quality Enumeration - For For U_LOGFONT lfQuality field +/** \defgroup U_EMF_EMRSETPOLYFILLMODE_iMode_Qualifiers EMF PolygonFillMode Enumeration + For U_EMRSETPOLYFILLMODE iMode field + Microsoft name: PolygonFillMode Enumeration + EMF manual 2.1.27 @{ */ -#define U_DEFAULT_QUALITY 0 -#define U_DRAFT_QUALITY 1 -#define U_PROOF_QUALITY 2 -#define U_NONANTIALIASED_QUALITY 3 -#define U_ANTIALIASED_QUALITY 4 +#define U_ALTERNATE 1 //!< Alternate +#define U_WINDING 2 //!< Winding +#define U_POLYFILL_LAST 2 //!< Polyfill last /** @} */ -/** \defgroup U_LOGFONT_lfPitchAndFamily_Qualifiers LF_PitchAndFamily Enumeration - For U_LOGFONT lfPitchAndFamily field +/** \defgroup U_EMF_PANOSE_bProportion_Qualifiers EMF Proportion Enumeration + For U_PANOSE bProportion field + Microsoft name: Proportion Enumeration + EMF manual 2.1.28 @{ */ -#define U_DEFAULT_PITCH 0x00 -#define U_FIXED_PITCH 0x01 -#define U_VARIABLE_PITCH 0x02 -#define U_MONO_FONT 0x08 -#define U_FF_DONTCARE 0x00 -#define U_FF_ROMAN 0x10 -#define U_FF_SWISS 0x20 -#define U_FF_MODERN 0x30 -#define U_FF_SCRIPT 0x40 -#define U_FF_DECORATIVE 0x50 +#define U_PAN_PROP_OLD_STYLE 2 //!< Old style +#define U_PAN_PROP_MODERN 3 //!< Modern +#define U_PAN_PROP_EVEN_WIDTH 4 //!< Even width +#define U_PAN_PROP_EXPANDED 5 //!< Expanded +#define U_PAN_PROP_CONDENSED 6 //!< Condensed +#define U_PAN_PROP_VERY_EXPANDED 7 //!< Very expanded +#define U_PAN_PROP_VERY_CONDENSED 8 //!< Very condensed +#define U_PAN_PROP_MONOSPACED 9 //!< Monospaced /** @} */ -/** \defgroup U_EMRSETMAPMODE_iMode_Qualifiers MapMode Enumeration - For U_EMRSETMAPMODE iMode field +/** \defgroup U_EMF_EMRSELECTCLIP_iMode_Qualifiers EMF RegionMode Enumeration + For U_EMRSELECTCLIPPATH and U_EMREXTSELECTCLIPRGN iMode field + Microsoft name: RegionMode Enumeration + EMF manual 2.1.29 @{ */ -#define U_MM_TEXT 1 -#define U_MM_LOMETRIC 2 -#define U_MM_HIMETRIC 3 -#define U_MM_LOENGLISH 4 -#define U_MM_HIENGLISH 5 -#define U_MM_TWIPS 6 -#define U_MM_ISOTROPIC 7 -#define U_MM_ANISOTROPIC 8 -#define U_MM_MIN U_MM_TEXT -#define U_MM_MAX U_MM_ANISOTROPIC -#define U_MM_MAX_FIXEDSCALE U_MM_TWIPS +#define U_RGN_AND 1 //!< Region becomes intersection of existing region and new region. +#define U_RGN_OR 2 //!< Region becomes union of existing region and new region. +#define U_RGN_XOR 3 //!< Region becomes XOR of existing and new regions. +#define U_RGN_DIFF 4 //!< Region becomes part of existing region not in new region. +#define U_RGN_COPY 5 //!< Region becomes new region. +#define U_RGN_MIN U_RGN_AND //!< smallest enumeration. +#define U_RGN_MAX U_RGN_COPY //!< largest enumeration. /** @} */ - -/** \defgroup U_PANOSE_bMidline_Qualifiers MidLine Enumeration - For U_PANOSE bMidline field +/** \defgroup U_EMF_PANOSE_bSerifStyle_Qualifiers EMF SerifType Enumeration + For U_PANOSE bSerifStyle field + Microsoft name: SerifType Enumeration + EMF manual 2.1.30 @{ */ -#define U_PAN_MIDLINE_STANDARD_TRIMMED 2 -#define U_PAN_MIDLINE_STANDARD_POINTED 3 -#define U_PAN_MIDLINE_STANDARD_SERIFED 4 -#define U_PAN_MIDLINE_HIGH_TRIMMED 5 -#define U_PAN_MIDLINE_HIGH_POINTED 6 -#define U_PAN_MIDLINE_HIGH_SERIFED 7 -#define U_PAN_MIDLINE_CONSTANT_TRIMMED 8 -#define U_PAN_MIDLINE_CONSTANT_POINTED 9 -#define U_PAN_MIDLINE_CONSTANT_SERIFED 10 -#define U_PAN_MIDLINE_LOW_TRIMMED 11 -#define U_PAN_MIDLINE_LOW_POINTED 12 -#define U_PAN_MIDLINE_LOW_SERIFED 13 -/** @} */ - -/** \defgroup U_EMRSETLAYOUT_iMode_Qualifiers Mirroring Enumeration - For U_EMRSETLAYOUT iMode field +#define U_PAN_SERIF_COVE 2 //!< Serif cove +#define U_PAN_SERIF_OBTUSE_COVE 3 //!< Serif obtuse cove +#define U_PAN_SERIF_SQUARE_COVE 4 //!< Serif square cove +#define U_PAN_SERIF_OBTUSE_SQUARE_COVE 5 //!< Serif obtuse square cove +#define U_PAN_SERIF_SQUARE 6 //!< Serif square +#define U_PAN_SERIF_THIN 7 //!< Serif thin +#define U_PAN_SERIF_BONE 8 //!< Serif bone +#define U_PAN_SERIF_EXAGGERATED 9 //!< Serif exaggerated +#define U_PAN_SERIF_TRIANGLE 10 //!< Serif triangle +#define U_PAN_SERIF_NORMAL_SANS 11 //!< Serif normal sans +#define U_PAN_SERIF_OBTUSE_SANS 12 //!< Serif obtuse sans +#define U_PAN_SERIF_PERP_SANS 13 //!< Serif perp sans +#define U_PAN_SERIF_FLARED 14 //!< Serif flared +#define U_PAN_SERIF_ROUNDED 15 //!< Serif rounded +/** @} */ + +/** \defgroup U_EMF_EMRSELECTOBJECT_ihObject_Qualifiers EMF StockObject Enumeration + For U_EMRSELECTOBJECT ihObject field. + Microsoft name: StockObject Enumeration + EMF manual 2.1.31 @{ */ -#define U_LAYOUT_LTR 0x00000000 -#define U_LAYOUT_RTL 0x00000001 -#define U_LAYOUT_BITMAPORIENTATIONPRESERVED 0x00000008 -#define U_NOMIRRORBITMAP 0x80000000 -/** @} */ - -/** \defgroup U_EMRMODIFYWORLDTRANSFORM_iMode_Qualifiers ModifyWorldTransformMode Enumeration - For U_EMRMODIFYWORLDTRANSFORM iMode +#define U_STOCK_OBJECT 0x80000000 //!< Stock object +#define U_WHITE_BRUSH 0x80000000 //!< White brush +#define U_LTGRAY_BRUSH 0x80000001 //!< Ltgray brush +#define U_GRAY_BRUSH 0x80000002 //!< Gray brush +#define U_DKGRAY_BRUSH 0x80000003 //!< Dkgray brush +#define U_BLACK_BRUSH 0x80000004 //!< Black brush +#define U_NULL_BRUSH 0x80000005 //!< Null brush +#define U_HOLLOW_BRUSH 0x80000005 //!< Hollow brush +#define U_WHITE_PEN 0x80000006 //!< White pen +#define U_BLACK_PEN 0x80000007 //!< Black pen +#define U_NULL_PEN 0x80000008 //!< Null pen +#define U_OEM_FIXED_FONT 0x8000000A //!< Oem fixed font +#define U_ANSI_FIXED_FONT 0x8000000B //!< Ansi fixed font +#define U_ANSI_VAR_FONT 0x8000000C //!< Ansi var font +#define U_SYSTEM_FONT 0x8000000D //!< System font +#define U_DEVICE_DEFAULT_FONT 0x8000000E //!< Device default font +#define U_DEFAULT_PALETTE 0x8000000F //!< Default palette +#define U_SYSTEM_FIXED_FONT 0x80000010 //!< System fixed font +#define U_DEFAULT_GUI_FONT 0x80000011 //!< Default GUI font +#define U_STOCK_LAST 0x80000011 //!< Stock last +/** @} */ + +/** \defgroup U_EMF_EMRSETSTRETCHBLTMODE_iMode_Qualifiers EMF StretchMode Enumeration + For EMF U_EMRSETSTRETCHBLTMODE iMode field + Microsoft name: StretchMode Enumeration + EMF manual 2.1.32 and footnote 52 on page 297 @{ */ -#define U_MWT_IDENTITY 1 -#define U_MWT_LEFTMULTIPLY 2 -#define U_MWT_RIGHTMULTIPLY 3 -#define U_MWT_MIN U_MWT_IDENTITY -#define U_MWT_MAX U_MWT_RIGHTMULTIPLY +#define U_BLACKONWHITE 1 //!< AND the destination and source pixels. +#define U_WHITEONBLACK 2 //!< OR the destination and source pixels. +#define U_COLORONCOLOR 3 //!< Replace the destination pixels with the source pixels. +#define U_HALFTONE 4 //!< Replace a block of destination pixels with a half-tone representation of the source pixel. +#define U_MAXSTRETCHBLTMODE 4 //!< largest enumeration. +#define U_STRETCH_ANDSCANS 1 //!< AND the destination and source pixels. +#define U_STRETCH_ORSCANS 2 //!< OR the destination and source pixels. +#define U_STRETCH_DELETESCANS 3 //!< Replace the destination pixels with the source pixels. +#define U_STRETCH_HALFTONE 4 //!< Replace a block of destination pixels with a half-tone representation of the source pixel. /** @} */ -/** \defgroup U_PANOSE_common_Qualifiers PanoseCommon Enumeration - Used by all PAN_* enumerations, but only defined once here. - See also U_PAN_ALL1 after the U_PANOSE structure +/** \defgroup U_EMF_PANOSE_bStrokeVariation_Qualifiers EMF StrokeVariation Enumeration + For U_PANOSE bStrokeVariation field + Microsoft name: StrokeVariation Enumeration + EMF manual 2.1.33 @{ */ -#define U_PAN_ANY 0 -#define U_PAN_NO_FIT 1 +#define U_PAN_STROKE_GRADUAL_DIAG 2 //!< Gradual diagonal. +#define U_PAN_STROKE_GRADUAL_TRAN 3 //!< Gradual transitional. +#define U_PAN_STROKE_GRADUAL_VERT 4 //!< Gradual vertical. +#define U_PAN_STROKE_GRADUAL_HORZ 5 //!< Gradual horizontal. +#define U_PAN_STROKE_RAPID_VERT 6 //!< Rapid vertical. +#define U_PAN_STROKE_RAPID_HORZ 7 //!< Rapid horizontal. +#define U_PAN_STROKE_INSTANT_VERT 8 //!< Instant vertical. /** @} */ -/** \defgroup U_PANOSE_index PanoseIndex Enumeration - Fositions of each field in U_PANOSE structure. +/** \defgroup U_EMF_PANOSE_bWeight_Qualifiers EMF Weight Enumeration + For U_PANOSE bWeight field + EMF manual 2.1.34 @{ */ -#define U_PANOSE_COUNT 10 -#define U_PANOSE_FAMILYTYPE_INDEX 0 -#define U_PAN_SERIFSTYLE_INDEX 1 -#define U_PAN_WEIGHT_INDEX 2 -#define U_PAN_PROPORTION_INDEX 3 -#define U_PAN_CONTRAST_INDEX 4 -#define U_PAN_STROKEVARIATION_INDEX 5 -#define U_PAN_ARMSTYLE_INDEX 6 -#define U_PAN_LETTERFORM_INDEX 7 -#define U_PAN_MIDLINE_INDEX 8 -#define U_PAN_XHEIGHT_INDEX 9 +#define U_PAN_WEIGHT_VERY_LIGHT 2 //!< Very light +#define U_PAN_WEIGHT_LIGHT 3 //!< Light +#define U_PAN_WEIGHT_THIN 4 //!< Thin +#define U_PAN_WEIGHT_BOOK 5 //!< Book +#define U_PAN_WEIGHT_MEDIUM 6 //!< Medium +#define U_PAN_WEIGHT_DEMI 7 //!< Demi +#define U_PAN_WEIGHT_BOLD 8 //!< Bold +#define U_PAN_WEIGHT_HEAVY 9 //!< Heavy +#define U_PAN_WEIGHT_BLACK 10 //!< Black +#define U_PAN_WEIGHT_NORD 11 //!< Nord /** @} */ -/** \defgroup U_*LOGPEN_elpPenStyle_Qualifiers PenStyle Enumeration - For U_LOGPEN lopnStyle and U_EXTLOGPEN elpPenStyle fields +/** \defgroup U_EMF_PANOSE_bXHeight_Qualifiers EMF XHeight Enumeration + For U_PANOSE bXHeight field + EMF manual 2.1.35 @{ */ -#define U_PS_SOLID 0x00000000 -#define U_PS_DASH 0x00000001 //!< This only works when NO other U_PS is set. Line width is minimum no matter what pen is set to. -#define U_PS_DOT 0x00000002 //!< This only works when NO other U_PS is set. Line width is minimum no matter what pen is set to. -#define U_PS_DASHDOT 0x00000003 //!< This only works when NO other U_PS is set. Line width is minimum no matter what pen is set to. -#define U_PS_DASHDOTDOT 0x00000004 //!< This only works when NO other U_PS is set. Line width is minimum no matter what pen is set to. -#define U_PS_NULL 0x00000005 -#define U_PS_INSIDEFRAME 0x00000006 -#define U_PS_USERSTYLE 0x00000007 -#define U_PS_ALTERNATE 0x00000008 -#define U_PS_STYLE_MASK 0x0000000f - -#define U_PS_ENDCAP_ROUND 0x00000000 //!< These are only with U_PS_GEOMETRIC -#define U_PS_ENDCAP_SQUARE 0x00000100 -#define U_PS_ENDCAP_FLAT 0x00000200 -#define U_PS_ENDCAP_MASK 0x00000f00 - -#define U_PS_JOIN_ROUND 0x00000000 //!< These are only with U_PS_GEOMETRIC -#define U_PS_JOIN_BEVEL 0x00001000 -#define U_PS_JOIN_MITER 0x00002000 -#define U_PS_JOIN_MASK 0x0000f000 - -#define U_PS_COSMETIC 0x00000000 //!< width may only be 1 pixel. (If set higher it is still drawn as 1). -#define U_PS_GEOMETRIC 0x00010000 //!< width may be >1 pixel, but style may only be U_PS_SOLID or U_PS_NULL. -#define U_PS_TYPE_MASK 0x000f0000 +#define U_PAN_XHEIGHT_CONSTANT_SMALL 2 //!< Constant small +#define U_PAN_XHEIGHT_CONSTANT_STANDARD 3 //!< Constant standard +#define U_PAN_XHEIGHT_CONSTANT_LARGE 4 //!< Constant large +#define U_PAN_XHEIGHT_DUCKING_SMALL 5 //!< Ducking small +#define U_PAN_XHEIGHT_DUCKING_STANDARD 6 //!< Ducking standard +#define U_PAN_XHEIGHT_DUCKING_LARGE 7 //!< Ducking large /** @} */ -/** \defgroup U_PIXELFORMATDESCRIPTOR_dwFlags_Qualifiers PFD_dwFlags Enumeration - For U_PIXELFORMATDESCRIPTOR dwFlags field +/** \defgroup U_EMF_LOGFONT_lfWeight_Qualifiers EMF LF_Weight Enumeration + For U_LOGFONT lfWeight field + EMF manual 2.2.13, footnote 61 (on page 297) @{ */ -#define U_PFD_DOUBLEBUFFER 0x00000001 -#define U_PFD_STEREO 0x00000002 -#define U_PFD_DRAW_TO_WINDOW 0x00000004 -#define U_PFD_DRAW_TO_BITMAP 0x00000008 -#define U_PFD_SUPPORT_GDI 0x00000010 -#define U_PFD_SUPPORT_OPENGL 0x00000020 -#define U_PFD_GENERIC_FORMAT 0x00000040 -#define U_PFD_NEED_PALETTE 0x00000080 -#define U_PFD_NEED_SYSTEM_PALETTE 0x00000100 -#define U_PFD_SWAP_EXCHANGE 0x00000200 -#define U_PFD_SWAP_COPY 0x00000400 -#define U_PFD_SWAP_LAYER_BUFFERS 0x00000800 -#define U_PFD_GENERIC_ACCELERATED 0x00001000 -/** @} */ - -/** \defgroup U_PIXELFORMATDESCRIPTOR_iLayerType_Qualifiers PFD_iLayerType Enumeration - For U_PIXELFORMATDESCRIPTOR iLayerType field +#define U_FW_DONTCARE 0 //!< Don't care +#define U_FW_THIN 100 //!< Thin +#define U_FW_EXTRALIGHT 200 //!< Extra light +#define U_FW_ULTRALIGHT 200 //!< Ultra light +#define U_FW_LIGHT 300 //!< Light +#define U_FW_NORMAL 400 //!< Normal +#define U_FW_REGULAR 400 //!< Regular +#define U_FW_MEDIUM 500 //!< Medium +#define U_FW_SEMIBOLD 600 //!< Semibold +#define U_FW_DEMIBOLD 600 //!< Demibold +#define U_FW_BOLD 700 //!< Bold +#define U_FW_EXTRABOLD 800 //!< Extrabold +#define U_FW_ULTRABOLD 800 //!< Ultrabold +#define U_FW_HEAVY 900 //!< Heavy +#define U_FW_BLACK 900 //!< Black +/** @} */ + +/** \defgroup U_EMF_LOGFONT_lfItalic_Qualifiers EMF LF_Italic Enumeration + For U_LOGFONT lfItalic field + Microsoft name: LF_Italic Enumeration + EMF manual 2.2.13 @{ */ -#define U_PFD_MAIN_PLANE 0 -#define U_PFD_OVERLAY_PLANE 1 -#define U_PFD_UNDERLAY_PLANE (-1) +#define U_FW_NOITALIC 0 //!< Do not use italics. +#define U_FW_ITALIC 1 //!< Use italics. /** @} */ -/** \defgroup U_PIXELFORMATDESCRIPTOR_iPixelType_Qualifiers PFD_iPixelType Enumeration - For U_PIXELFORMATDESCRIPTOR iPixelType field +/** \defgroup U_EMF_LOGFONT_lfunderline_Qualifiers EMF LF_Underline Enumeration + For U_LOGFONT lfunderline field + Microsoft name: LF_Underline Enumeration + EMF manual 2.2.13 @{ */ -#define U_PFD_TYPE_RGBA 0 -#define U_PFD_TYPE_COLORINDEX 1 +#define U_FW_NOUNDERLINE 0 //!< Do not use underline. +#define U_FW_UNDERLINE 1 //!< Use underline. /** @} */ -/** \defgroup U_EMRPOLY_iMode_Qualifiers Point Enumeration - For U_EMRPOLYDRAW and U_EMRPOLAYDRAW16 abTypes fields. - @{ +/** \defgroup U_EMF_LOGFONT_lfStrikeOut_Qualifiers EMF LF_StrikeOut Enumeration + For U_LOGFONT lfStrikeOut field + EMF manual 2.2.13 + @{ */ -#define U_PT_CLOSEFIGURE 0x0001 -#define U_PT_LINETO 0x0002 -#define U_PT_BEZIERTO 0x0004 -#define U_PT_MOVETO 0x0006 +#define U_FW_NOSTRIKEOUT 0 //!< Do not use strikeout. +#define U_FW_STRIKEOUT 1 //!< Use strikeout. /** @} */ -/** \defgroup U_EMRSETPOLYFILLMODE_iMode_Qualifiers PolygonFillMode Enumeration - For U_EMRSETPOLYFILLMODE iMode field +/** \defgroup U_EMF_LOGFONT_lfCharSet_Qualifiers EMF LF_CharSet Enumeration + For U_LOGFONT lfCharSet field + EMF manual 2.2.13 & WMF manual 2.1.15 @{ */ -#define U_ALTERNATE 1 -#define U_WINDING 2 -#define U_POLYFILL_LAST 2 -/** @} */ - -/** \defgroup U_BITMAPV5HEADER_bV5CSType_Qualifiers Profile Enumeration - For U_BITMAPV5HEADER bV5CSType field +#define U_ANSI_CHARSET (uint8_t)0 //!< CP1252, ansi-0, iso8859-{1,15} +#define U_DEFAULT_CHARSET (uint8_t)1 //!< Default character set. +#define U_SYMBOL_CHARSET (uint8_t)2 //!< Symbol character set. +#define U_SHIFTJIS_CHARSET (uint8_t)128 //!< CP932 +#define U_HANGEUL_CHARSET (uint8_t)129 //!< CP949, ksc5601.1987-0 +#define U_HANGUL_CHARSET U_HANGEUL_CHARSET //!< CP949, ksc5601.1987-0 +#define U_GB2312_CHARSET (uint8_t)134 //!< CP936, gb2312.1980-0 +#define U_CHINESEBIG5_CHARSET (uint8_t)136 //!< CP950, big5.et-0 +#define U_GREEK_CHARSET (uint8_t)161 //!< CP1253 +#define U_TURKISH_CHARSET (uint8_t)162 //!< CP1254, -iso8859-9 +#define U_HEBREW_CHARSET (uint8_t)177 //!< CP1255, -iso8859-8 +#define U_ARABIC_CHARSET (uint8_t)178 //!< CP1256, -iso8859-6 +#define U_BALTIC_CHARSET (uint8_t)186 //!< CP1257, -iso8859-13 +#define U_RUSSIAN_CHARSET (uint8_t)204 //!< CP1251, -iso8859-5 +#define U_EE_CHARSET (uint8_t)238 //!< CP1250, -iso8859-2 +#define U_EASTEUROPE_CHARSET U_EE_CHARSET //!< CP1250, -iso8859-2 +#define U_THAI_CHARSET (uint8_t)222 //!< CP874, iso8859-11, tis620 +#define U_JOHAB_CHARSET (uint8_t)130 //!< korean (johab) CP1361 +#define U_MAC_CHARSET (uint8_t)77 //!< Macintosh character set. +#define U_OEM_CHARSET (uint8_t)255 //!< OEM character set. +#define U_VISCII_CHARSET (uint8_t)240 //!< viscii1.1-1 +#define U_TCVN_CHARSET (uint8_t)241 //!< tcvn-0 +#define U_KOI8_CHARSET (uint8_t)242 //!< koi8-{r,u,ru} +#define U_ISO3_CHARSET (uint8_t)243 //!< iso8859-3 +#define U_ISO4_CHARSET (uint8_t)244 //!< iso8859-4 +#define U_ISO10_CHARSET (uint8_t)245 //!< iso8859-10 +#define U_CELTIC_CHARSET (uint8_t)246 //!< iso8859-14 +/** @} */ + +/** \defgroup U_EMF_LOGFONT_lfOutPrecision_Qualifiers EMF LF_OutPrecision Enumeration + For U_LOGFONT lfOutPrecision field + EMF manual 2.2.13 & WMF manual 2.1.1.21 @{ */ -#define U_PROFILE_LINKED 'LINK' -#define U_PROFILE_EMBEDDED 'MBED' +#define U_OUT_DEFAULT_PRECIS 0 //!< Default precision +#define U_OUT_STRING_PRECIS 1 //!< String precision +#define U_OUT_CHARACTER_PRECIS 2 //!< Character precision +#define U_OUT_STROKE_PRECIS 3 //!< Stroke precision +#define U_OUT_TT_PRECIS 4 //!< Tt precision +#define U_OUT_DEVICE_PRECIS 5 //!< Device precision +#define U_OUT_RASTER_PRECIS 6 //!< Raster precision +#define U_OUT_TT_ONLY_PRECIS 7 //!< Tt_only precision +#define U_OUT_OUTLINE_PRECIS 8 //!< Outline precision /** @} */ -/** \defgroup U_PANOSE_bProportion_Qualifiers Proportion Enumeration - For U_PANOSE bProportion field +/** \defgroup U_EMF_LOGFONT_lfClipPrecision_Qualifiers EMF LF_ClipPrecision Enumeration + For U_LOGFONT lfClipPrecision field + EMF manual 2.2.13 & WMF manual 2.1.2.1 @{ */ -#define U_PAN_PROP_OLD_STYLE 2 -#define U_PAN_PROP_MODERN 3 -#define U_PAN_PROP_EVEN_WIDTH 4 -#define U_PAN_PROP_EXPANDED 5 -#define U_PAN_PROP_CONDENSED 6 -#define U_PAN_PROP_VERY_EXPANDED 7 -#define U_PAN_PROP_VERY_CONDENSED 8 -#define U_PAN_PROP_MONOSPACED 9 +#define U_CLIP_DEFAULT_PRECIS 0x00 //!< Use default clipping precision. +#define U_CLIP_CHARACTER_PRECIS 0x01 //!< Use character clipping precision +#define U_CLIP_STROKE_PRECIS 0x02 //!< (Source documentation is vague about what this means.) +#define U_CLIP_MASK 0x0F //!< MASK for bits in preceding. +#define U_CLIP_LH_ANGLES 0x10 //!< Set: font rotation by coordinate system, Clear: device fonts (only) rotate counterclockwise. +#define U_CLIP_TT_ALWAYS 0x20 //!< Reserved. +#define U_CLIP_EMBEDDED 0x80 //!< Font embedding is required. (Method for doing so is not documented in EMF or WMF.) /** @} */ -/** \defgroup U_EMR_dwROP_Qualifiers Ternary Raster Operation enumeration - For U_EMR* dwROP fields. - - These codes specify: - 1. an order of operands (composed of various orders and combinations of: Dest, Src, Pen) - (There are 3, hence "Ternary Raster Operation") - 2. an order of operators to apply to the operands (composed of Not, Xor, Or, And) - Only a few of the more common operations are provided here. - When the Operation does not use a Src operand the corresponding source bitmap may be - omitted from the record. - - For more details see: - http://wiki.winehq.org/TernaryRasterOps +/** \defgroup U_EMF_LOGFONT_lfQuality_Qualifiers EMF LF_Quality Enumeration + For For U_LOGFONT lfQuality field + EMF manual 2.2.13 & WMF manual 2.1.1.10 @{ */ -#define U_SRCCOPY 0xcc0020 -#define U_SRCPAINT 0xee0086 -#define U_SRCAND 0x8800c6 -#define U_SRCINVERT 0x660046 -#define U_SRCERASE 0x440328 -#define U_NOTSRCCOPY 0x330008 -#define U_NOTSRCERASE 0x1100a6 -#define U_MERGECOPY 0xc000ca -#define U_MERGEPAINT 0xbb0226 -#define U_PATCOPY 0xf00021 -#define U_PATPAINT 0xfb0a09 -#define U_PATINVERT 0x5a0049 -#define U_DSTINVERT 0x550009 -#define U_BLACKNESS 0x000042 -#define U_WHITENESS 0xff0062 -#define U_NOOP 0xaa0029 /* Many GDI programs end with a bitblt with this ROP == "D". Seems to work like flush() */ -/** @} */ - -/** \defgroup U_EMRSETROP2_iMode_Qualifiers Binary Raster Operation Enumeration - For U_EMRSETROP2 iMode field - - These codes specify: - 1. an order of operands (composed of various orders and combinations of: Dest, Pen) - (There are 2, hence "Binary Raster Operation") - 2. an order of operators to apply to the operands (composed of Not, Xor, Or, And) - Only a few of the more common operations are provided here. +#define U_DEFAULT_QUALITY 0 //!< Default quality +#define U_DRAFT_QUALITY 1 //!< Draft quality +#define U_PROOF_QUALITY 2 //!< Proof quality +#define U_NONANTIALIASED_QUALITY 3 //!< Nonantialiased quality +#define U_ANTIALIASED_QUALITY 4 //!< Antialiased quality +/** @} */ - The default is U_R2_COPYPEN. If this value is changed to something else all subsequenty - draw operations will use the altered logic. For instance, if it is set to U_R2_BLACK and - a red rectangle is drawn it will appear as a black rectangle. - - @{ -*/ -#define U_R2_BLACK 1 -#define U_R2_NOTMERGEPEN 2 -#define U_R2_MASKNOTPEN 3 -#define U_R2_NOTCOPYPEN 4 -#define U_R2_MASKPENNOT 5 -#define U_R2_NOT 6 -#define U_R2_XORPEN 7 -#define U_R2_NOTMASKPEN 8 -#define U_R2_MASKPEN 9 -#define U_R2_NOTXORPEN 10 -#define U_R2_NOP 11 -#define U_R2_MERGENOTPEN 12 -#define U_R2_COPYPEN 13 -#define U_R2_MERGEPENNOT 14 -#define U_R2_MERGEPEN 15 -#define U_R2_WHITE 16 -#define U_R2_LAST 16 -/** @} */ - -/** \defgroup U_EMRSELECTCLIP_iMode_Qualifiers RegionMode Enumeration - For U_EMRSELECTCLIPPATH and U_EMREXTSELECTCLIPRGN iMode field +/** \defgroup U_EMF_LOGFONT_lfPitchAndFamily_Qualifiers EMF LF_PitchAndFamily Enumeration + For U_LOGFONT lfPitchAndFamily field + EMF manual 2.2.13 & WMF manual 2.2.2.14 @{ */ -#define U_RGN_AND 1 -#define U_RGN_OR 2 -#define U_RGN_XOR 3 -#define U_RGN_DIFF 4 -#define U_RGN_COPY 5 -#define U_RGN_MIN U_RGN_AND -#define U_RGN_MAX U_RGN_COPY +#define U_DEFAULT_PITCH 0x00 //!< Default pitch +#define U_FIXED_PITCH 0x01 //!< Fixed pitch +#define U_VARIABLE_PITCH 0x02 //!< Variable pitch +#define U_MONO_FONT 0x08 //!< Mono font +#define U_FF_DONTCARE 0x00 //!< Font family don't care +#define U_FF_ROMAN 0x10 //!< Font family Roman +#define U_FF_SWISS 0x20 //!< Font family Swiss +#define U_FF_MODERN 0x30 //!< Font family Modern +#define U_FF_SCRIPT 0x40 //!< Font family Script +#define U_FF_DECORATIVE 0x50 //!< Font family Decorative /** @} */ -/** \defgroup U_PANOSE_bSerifStyle_Qualifiers SerifType Enumeration - For U_PANOSE bSerifStyle field - @{ -*/ -#define U_PAN_SERIF_COVE 2 -#define U_PAN_SERIF_OBTUSE_COVE 3 -#define U_PAN_SERIF_SQUARE_COVE 4 -#define U_PAN_SERIF_OBTUSE_SQUARE_COVE 5 -#define U_PAN_SERIF_SQUARE 6 -#define U_PAN_SERIF_THIN 7 -#define U_PAN_SERIF_BONE 8 -#define U_PAN_SERIF_EXAGGERATED 9 -#define U_PAN_SERIF_TRIANGLE 10 -#define U_PAN_SERIF_NORMAL_SANS 11 -#define U_PAN_SERIF_OBTUSE_SANS 12 -#define U_PAN_SERIF_PERP_SANS 13 -#define U_PAN_SERIF_FLARED 14 -#define U_PAN_SERIF_ROUNDED 15 -/** @} */ - -/** \defgroup U_EMRSELECTOBJECT_ihObject_Qualifiers StockObject Enumeration - For U_EMRSELECTOBJECT ihObject field. - @{ -*/ -#define U_STOCK_OBJECT 0x80000000 -#define U_WHITE_BRUSH 0x80000000 -#define U_LTGRAY_BRUSH 0x80000001 -#define U_GRAY_BRUSH 0x80000002 -#define U_DKGRAY_BRUSH 0x80000003 -#define U_BLACK_BRUSH 0x80000004 -#define U_NULL_BRUSH 0x80000005 -#define U_HOLLOW_BRUSH 0x80000005 -#define U_WHITE_PEN 0x80000006 -#define U_BLACK_PEN 0x80000007 -#define U_NULL_PEN 0x80000008 -#define U_OEM_FIXED_FONT 0x8000000A -#define U_ANSI_FIXED_FONT 0x8000000B -#define U_ANSI_VAR_FONT 0x8000000C -#define U_SYSTEM_FONT 0x8000000D -#define U_DEVICE_DEFAULT_FONT 0x8000000E -#define U_DEFAULT_PALETTE 0x8000000F -#define U_SYSTEM_FIXED_FONT 0x80000010 -#define U_DEFAULT_GUI_FONT 0x80000011 -#define U_STOCK_LAST 0x80000011 -/** @} */ - -/** \defgroup U_EMRSETSTRETCHBLTMODE_iMode_Qualifiers StretchMode Enumeration - For EMF U_EMRSETSTRETCHBLTMODE iMode field +/** \defgroup U_EMF_LOGBRUSH_lbStyle_Qualifiers EMF LB_Style Enumeration + For U_LOGBRUSH lbStyle field + EMF manual 2.2.20 @{ */ -#define U_BLACKONWHITE 1 -#define U_WHITEONBLACK 2 -#define U_COLORONCOLOR 3 -#define U_HALFTONE 4 -#define U_MAXSTRETCHBLTMODE 4 -#define U_STRETCH_ANDSCANS 1 -#define U_STRETCH_ORSCANS 2 -#define U_STRETCH_DELETESCANS 3 -#define U_STRETCH_HALFTONE 4 +#define U_BS_SOLID 0 //!< Solid brush. +#define U_BS_NULL 1 //!< Null brush. +#define U_BS_HOLLOW 1 //!< Hollow brush. +#define U_BS_HATCHED 2 //!< Hatched brush. +#define U_BS_PATTERN 3 //!< Pattern brush. +#define U_BS_INDEXED 4 //!< Indexed brush. +#define U_BS_DIBPATTERN 5 //!< Dibpattern brush. +#define U_BS_DIBPATTERNPT 6 //!< Dibpatternpt brush. +#define U_BS_PATTERN8X8 7 //!< Pattern 8x8 brush. +#define U_BS_DIBPATTERN8X8 8 //!< Dibpattern 8x8 brush. +#define U_BS_MONOPATTERN 9 //!< Monopattern brush. /** @} */ -/** \defgroup U_PANOSE_bStrokeVariation_Qualifiers StrokeVariation Enumeration - For U_PANOSE bStrokeVariation field +/** \defgroup U_EMF_PANOSE_index EMF PanoseIndex Enumeration + Fositions of each field in U_PANOSE structure. + Microsoft name: (none) + EMF manual 2.2.21 @{ */ -#define U_PAN_STROKE_GRADUAL_DIAG 2 -#define U_PAN_STROKE_GRADUAL_TRAN 3 -#define U_PAN_STROKE_GRADUAL_VERT 4 -#define U_PAN_STROKE_GRADUAL_HORZ 5 -#define U_PAN_STROKE_RAPID_VERT 6 -#define U_PAN_STROKE_RAPID_HORZ 7 -#define U_PAN_STROKE_INSTANT_VERT 8 +#define U_PAN_FAMILYTYPE_INDEX 0 //!< Familytype index +#define U_PAN_SERIFSTYLE_INDEX 1 //!< Serifstyle index +#define U_PAN_WEIGHT_INDEX 2 //!< Weight index +#define U_PAN_PROPORTION_INDEX 3 //!< Proportion index +#define U_PAN_CONTRAST_INDEX 4 //!< Contrast index +#define U_PAN_STROKEVARIATION_INDEX 5 //!< Strokevariation index +#define U_PAN_ARMSTYLE_INDEX 6 //!< Armstyle index +#define U_PAN_LETTERFORM_INDEX 7 //!< Letterform index +#define U_PAN_MIDLINE_INDEX 8 //!< Midline index +#define U_PAN_XHEIGHT_INDEX 9 //!< Xheight index +#define U_PAN_COUNT 10 //!< Count /** @} */ -/** \defgroup U_EMRSETTEXTALIGN_iMode_Qualifiers TextAlignment Enumeration - For U_EMRSETTEXTALIGN iMode field - - Recall that EMF coordinates have UL closest to {0,0}, LR is below and to the right of UL and so has LARGER - {x,y} coordinates. In the following "TOP" is on the horizontal line defined by LR, as it has larger y coordinates, - which when viewing the EMF file, would actually be on the BOTTOM of the bounding rectangle. Similarly, left and right - are reversed. - - Microsoft documentation (WMF manual, section 2.1.2.3) says that the text starts on certain edges of the bounding rectangle. - That is apparently not true, whether the bounding rectangle is {0,0,-1,-1}, which is effectively no bounding rectangle, - or if a valid bounding rectangle is specified. In all cases the text (in Windows XP Preview) starts, has center at, or ends - at the center point. Vertical offsets seem to be defined analogously, but with respect to the height of the font. The bounding - rectangle defined for the U_EMRTEXT record appears to be ignored. - - Microsoft documentation (EMF manual,section 2.2.5) says that the same rectangle is used for "clipping or opaquing" by ExtTextOutA/W. - That does not seem to occur either. +/** \defgroup U_EMF_PIXELFORMATDESCRIPTOR_iLayerType_Qualifiers EMF PFD_iLayerType Enumeration + For U_PIXELFORMATDESCRIPTOR iLayerType field + Microsoft name: (none) + EMF manual 2.2.22 @{ */ -// Horizontal text flags -#define U_TA_DEFAULT 0x00 // default alignment -#define U_TA_NOUPDATECP 0x00 // Reference point does not move -#define U_TA_UPDATECP 0x01 // Reference point moves to end of next text drawn. -#define U_TA_LEFT 0x00 // Reference point is on left edge of bounding rectangle -#define U_TA_RIGHT 0x02 // Reference point is on right edge of bounding rectangle -#define U_TA_CENTER 0x06 // Reference point is on center vertical line of bounding rectangle -#define U_TA_TOP 0x00 // Reference point is on top edge of bounding rectangle -#define U_TA_BOTTOM 0x08 // Reference point is on bottom edge of bounding rectangle -#define U_TA_BASEBIT 0x10 // Reference point is on baseline of text if this bit is set, for 0x10 <-> 0x18 -#define U_TA_BASELINE 0x18 // Reference point is on baseline of text -#define U_TA_RTLREADING 0x100 // Set for Right to Left languages like Hebrew and Arabic -#define U_TA_MASK U_TA_BASELINE+U_TA_CENTER+U_TA_UPDATECP+U_TA_RTLREADING -// Vertical text flags -#define U_VTA_BASELINE U_TA_BASELINE // for vertical text -#define U_VTA_LEFT U_TA_BOTTOM -#define U_VTA_RIGHT U_TA_TOP -#define U_VTA_CENTER U_TA_CENTER -#define U_VTA_BOTTOM U_TA_RIGHT -#define U_VTA_TOP U_TA_LEFT +#define U_PFD_MAIN_PLANE 0 //!< Main plane +#define U_PFD_OVERLAY_PLANE 1 //!< Overlay plane +#define U_PFD_UNDERLAY_PLANE (-1) //!< Underlay plane /** @} */ -/** \defgroup U_PANOSE_bWeight_Qualifiers Weight Enumeration - For U_PANOSE bWeight field +/** \defgroup U_EMF_PIXELFORMATDESCRIPTOR_iPixelType_Qualifiers EMF PFD_iPixelType Enumeration + For U_PIXELFORMATDESCRIPTOR iPixelType field + Microsoft name: (none) + EMF manual 2.2.22 @{ */ -#define U_PAN_WEIGHT_VERY_LIGHT 2 -#define U_PAN_WEIGHT_LIGHT 3 -#define U_PAN_WEIGHT_THIN 4 -#define U_PAN_WEIGHT_BOOK 5 -#define U_PAN_WEIGHT_MEDIUM 6 -#define U_PAN_WEIGHT_DEMI 7 -#define U_PAN_WEIGHT_BOLD 8 -#define U_PAN_WEIGHT_HEAVY 9 -#define U_PAN_WEIGHT_BLACK 10 -#define U_PAN_WEIGHT_NORD 11 +#define U_PFD_TYPE_RGBA 0 //!< Pixel contains an RGBA value. +#define U_PFD_TYPE_COLORINDEX 1 //!< Pixel contains an index into the color table. /** @} */ -/** \defgroup U_PANOSE_bXHeight_Qualifiers XHeight Enumeration - For U_PANOSE bXHeight field +/** \defgroup U_EMF_PIXELFORMATDESCRIPTOR_dwFlags_Qualifiers EMF PFD_dwFlags Enumeration + For U_PIXELFORMATDESCRIPTOR dwFlags field + EMF manual 2.2.22 + @{ +*/ +#define U_PFD_DOUBLEBUFFER 0x00000001 //!< Doublebuffer +#define U_PFD_STEREO 0x00000002 //!< Stereo +#define U_PFD_DRAW_TO_WINDOW 0x00000004 //!< Draw to window +#define U_PFD_DRAW_TO_BITMAP 0x00000008 //!< Draw to bitmap +#define U_PFD_SUPPORT_GDI 0x00000010 //!< Support gdi +#define U_PFD_SUPPORT_OPENGL 0x00000020 //!< Support opengl +#define U_PFD_GENERIC_FORMAT 0x00000040 //!< Generic format +#define U_PFD_NEED_PALETTE 0x00000080 //!< Need palette +#define U_PFD_NEED_SYSTEM_PALETTE 0x00000100 //!< Need system palette +#define U_PFD_SWAP_EXCHANGE 0x00000200 //!< Swap exchange +#define U_PFD_SWAP_COPY 0x00000400 //!< Swap copy +#define U_PFD_SWAP_LAYER_BUFFERS 0x00000800 //!< Swap layer buffers +#define U_PFD_GENERIC_ACCELERATED 0x00001000 //!< Generic accelerated +/** @} */ + +/** \defgroup U_EMF_EMRCOMMENT_TYPES EMF Comment record types + For U_EMRCOMMENT_* cIdent fields + EMF manual 2.3.3 @{ */ -#define U_PAN_XHEIGHT_CONSTANT_SMALL 2 -#define U_PAN_XHEIGHT_CONSTANT_STANDARD 3 -#define U_PAN_XHEIGHT_CONSTANT_LARGE 4 -#define U_PAN_XHEIGHT_DUCKING_SMALL 5 -#define U_PAN_XHEIGHT_DUCKING_STANDARD 6 -#define U_PAN_XHEIGHT_DUCKING_LARGE 7 +#define U_EMR_COMMENT_PUBLIC 0x43494447 //!< Public comment. +#define U_EMR_COMMENT_SPOOL 0x00000000 //!< Spool comment. +#define U_EMR_COMMENT_EMFPLUSRECORD 0x2B464D45 //!< EMF+ record comment. /** @} */ -/** \defgroup U_BLEND_Op_Qualifiers Blend Enumeration - For U_BLEND Op field +/** \defgroup U_EMF_EMRSETLAYOUT_iMode_Qualifiers EMF Mirroring Enumeration + For U_EMRSETLAYOUT iMode field + EMF manual 2.3.11.17 @{ */ -#define U_AC_SRC_GLOBAL 0 -#define U_AC_SRC_CONST 0 -#define U_AC_SRC_ALPHA 1 +#define U_LAYOUT_LTR 0x00000000 //!< Left to right lsyout. +#define U_LAYOUT_RTL 0x00000001 //!< Right to left layout. +#define U_LAYOUT_BITMAPORIENTATIONPRESERVED 0x00000008 //!< Do not flip bitmaps if layout is right to left. /** @} */ -// *************************************************************************** -/** \defgroup Miscellaneous_values Miscellaneous Values +/** \defgroup U_EMF_BLEND_Op_Qualifiers EMF Blend Enumeration + For U_BLEND Op field @{ */ -#define U_NONE 0 //!< Generic for nothing selected for all flag fields -#define U_PI 3.14159265358979323846 //!< pi -#define U_READ 1 -#define U_WRITE 0 -#define U_ENHMETA_VERSION 0x00010000 //!< U_EMRHEADER nVersion field -#define U_DV_SGNTR 0x08007664 //!< For U_DESIGNVECTOR Signature field -#define U_LP_VERSION 0x0300 //!< For U_LOGPALETTE palVersion field -#define U_RDH_RECTANGLES 1 //!< For U_RGNDATAHEADER iType field -#define U_RDH_OBJSIZE 0x20 //!< For U_RGNDATAHEADER dwSIze field -#define U_RGB_GAMMA_MIN (uint16_t)02500 //!< For U_COLORADJUSTMENT ca[Red|Green|Blue]Gamma fields -#define U_RGB_GAMMA_MAX (uint16_t)65000 //!< For U_COLORADJUSTMENT ca[Red|Green|Blue]Gamma fields -#define U_REFERENCE_WHITE_MIN (uint16_t)6000 //!< For U_COLORADJUSTMENT caReferenceWhite field -#define U_REFERENCE_WHITE_MAX (uint16_t)10000 //!< For U_COLORADJUSTMENT caReferenceWhite field -#define U_REFERENCE_BLACK_MIN (uint16_t)0 //!< For U_COLORADJUSTMENT caReferenceBlack field -#define U_REFERENCE_BLACK_MAX (uint16_t)4000 //!< For U_COLORADJUSTMENT caReferenceBlack field -#define U_COLOR_ADJ_MIN ((int16_t)-100) //!< For U_COLORADJUSTMENT ca[Contrast|Brightness|Colorfulness|RedGreenTint] fields -#define U_COLOR_ADJ_MAX (int16_t) 100 //!< For U_COLORADJUSTMENT ca[Contrast|Brightness|Colorfulness|RedGreenTint] fields -#define U_MAX_PATH 1024 //!< longest path name for a file -#define U_LCS_SIGNATURE 0x50534F43 //!< logColorSpace Signature -#define U_LCS_VERSION 0x400 //!< logColorSpace Version -#define U_REC_FREE 1 //!< used with emf_append -#define U_REC_KEEP 0 //!< used with emf_append -/** Solaris 8 has problems with round/roundf, just use this everywhere */ -#define U_ROUND(A) ( (A) > 0 ? floor((A)+0.5) : ( (A) < 0 ? -floor(-(A)+0.5) : (A) ) ) - +#define U_AC_SRC_GLOBAL 0 //!< Global +#define U_AC_SRC_CONST 0 //!< Const +#define U_AC_SRC_ALPHA 1 //!< Alpha /** @} */ + // *************************************************************************** // Macros -/** \defgroup Common_macros Common Macros +/** \defgroup U_EMF_Common_macros EMF Common Macros @{ */ // Note, many of these were originally defined using C99 (type){val,val,val} format, but that turned out to @@ -1125,12 +1575,11 @@ extern "C" { #define U_RGBAGetB(rgb) (rgb.Blue ) //!< Color RGB Blue #define U_RGBAGetA(rgb) (rgb.Reserved) //!< Color RGBA A/reserved - // color type conversions -#define U_RGB2BGR(rgb) (U_RGBQUAD){ U_RGBAGetB(rgb),U_RGBAGetG(rgb),U_RGBAGetR(rgb),0} //!< Set any BGR color from an RGB color -#define U_BGR2RGB(rgb) (U_COLORREF){U_BGRAGetR(rgb),U_BGRAGetG(rgb),U_BGRAGetB(rgb),0} //!< Set any RGB color from an BGR color -#define U_RGBA2BGRA(rgb) (U_RGBQUAD){ U_RGBAGetB(rgb),U_RGBAGetG(rgb),U_RGBAGetR(rgb),U_RGBAGetA(rgb)} //!< Set any BGRA color from an RGBA color -#define U_BGRA2RGBA(rgb) (U_COLORREF){U_BGRAGetR(rgb),U_BGRAGetG(rgb),U_BGRAGetB(rgb),U_BGRAGetA(rgb)} //!< Set any RGBA color from an BGRA color +#define U_RGB2BGR(rgb) U_BGR(U_RGBAGetR(rgb),U_RGBAGetG(rgb),U_RGBAGetB(rgb)) //!< Set any BGR color from an RGB color +#define U_BGR2RGB(rgb) U_RGB(U_BGRAGetR(rgb),U_BGRAGetG(rgb),U_BGRAGetB(rgb)) //!< Set any RGB color from an BGR color +#define U_RGBA2BGRA(rgb) U_BGRA(U_RGBAGetR(rgb),U_RGBAGetG(rgb),U_RGBAGetB(rgb),U_RGBAGetA(rgb)} //!< Set any BGRA color from an RGBA color +#define U_BGRA2RGBA(rgb) U_RGBA(U_BGRAGetR(rgb),U_BGRAGetG(rgb),U_BGRAGetB(rgb),U_BGRAGetA(rgb)} //!< Set any RGBA color from an BGRA color // Color CMYK Get/Set Macros #define U_CMYK(c,m,y,k)\ @@ -1156,173 +1605,40 @@ extern "C" { // Utility macros #define UP4(A) (4 * ((A + 3 ) / 4)) //!< Round up to nearest multiple of 4 -/** @} */ - -typedef float U_FLOAT; - -typedef uint32_t U_CBBITS; // Describes byte count of TYPE -typedef uint32_t U_CBBITSMSK; -typedef uint32_t U_CBBITSSRC; -typedef uint32_t U_CBBMI; -typedef uint32_t U_CBBMIMSK; -typedef uint32_t U_CBBMISRC; -typedef uint32_t U_CBDATA; -typedef uint32_t U_CBNAME; -typedef uint32_t U_CBPLENTRIES; -typedef uint32_t U_CBPXLFMT; -typedef uint32_t U_CBRGNDATA; -typedef uint32_t U_CBSTR; // bytes in an 8 or 16 bit string - -typedef uint32_t U_OFFBITS; // Describes byte offset to TYPE, always measured from the start of the RECORD (not the struct) -typedef uint32_t U_OFFBITSMSK; -typedef uint32_t U_OFFBITSSRC; -typedef uint32_t U_OFFBMI; -typedef uint32_t U_OFFBMIMSK; -typedef uint32_t U_OFFBMISRC; -typedef uint32_t U_OFFDATA; -typedef uint32_t U_OFFDESC; -typedef uint32_t U_OFFDX; -typedef uint32_t U_OFFPLENTRIES; -typedef uint32_t U_OFFPXLFMT; -typedef uint32_t U_OFFSTR; // String of either 8 or 16 bit characters -typedef uint8_t U_DATA; // any binary sort of data, not otherwise classified. - -// "Types" For array components in structures, where not otherwise defined as a structure -typedef uint32_t U_FNTAXES; // Font Axes For U_DESIGNVECTOR -typedef uint32_t U_STYLEENTRY; // StyleEntry For U_EXTLOGPEN -typedef uint32_t U_POLYCOUNTS; // aPolyCounts For U_EMRPOLYPOLYLINE etc. - -// "Counts" for array components in structures -typedef uint32_t U_NUM_FNTAXES; // Number of U_FNTAXES -typedef uint32_t U_NUM_LOGPLTNTRY; // Number of U_LOGPLTENTRY -typedef uint32_t U_NUM_RECTL; // Number of U_RECTL -typedef uint32_t U_NUM_POINTL; // Number of U_POINTL -typedef uint32_t U_NUM_POINT16; // Number of U_POINT16 -typedef uint32_t U_NUM_STYLEENTRY; // Number of U_STYLEENTRY -typedef uint32_t U_NUM_POLYCOUNTS; // Number of U_POLYCOUNTS -typedef uint32_t U_NUM_EMRTEXT; // Number of U_EMRTEXT -typedef uint32_t U_NUM_STR; // Number of 8 or 16 bit characters in string -typedef uint32_t U_NUM_TRIVERTEX; // Number of U_TRIVERTEX -typedef uint32_t U_NUM_GRADOBJ; // Number of U_GRADIENT4 OR U_GRADIENT3 (determined at run time) -typedef uint32_t U_NUM_RGBQUAD; // Number of U_RGBQUAD (in bmciColors in U_BITMAPCOREINFO) - - -/** - \brief Pair of values indicating x and y sizes. - Microsoft name: SIZE Object - Microsoft name: SIZEL Object -*/ -typedef struct { - int32_t cx; //!< X size - int32_t cy; //!< Y size -} U_SIZE, U_SIZEL, *PU_SIZE, *PU_SIZEL; - -/** - \brief Used for any generic pair of floats - Microsoft name: (none) -*/ -typedef struct { - float x; //!< X value - float y; //!< Y value -} U_PAIRF, *PU_PAIRF; - -/** - \brief Used for any generic pair of uint32_t - Microsoft name: POINT Object -*/ -typedef struct { - int32_t x; //!< X value - int32_t y; //!< Y value -} U_PAIR, *PU_PAIR, U_POINT, *PU_POINT, U_POINTL, *PU_POINTL; - -/** - \brief Point type for 16 bit EMR drawing functions. - Microsoft name: POINTS Object - Microsoft name: POINTS16 Object -*/ -typedef struct { - int16_t x; //!< X size (16 bit) - int16_t y; //!< Y size (16 bit) -} U_POINT16, *PU_POINT16; - -/** - \brief Coordinates of the upper left, lower right corner. - Note that the coordinate system is 0,0 in the upper left corner - of the screen an N,M in the lower right corner. - Microsoft name: RECT Object -*/ -typedef struct { - int32_t left; //!< left coordinate - int32_t top; //!< top coordinate - int32_t right; //!< right coordinate - int32_t bottom; //!< bottom coordinate -} U_RECT, *PU_RECT, - U_RECTL, *PU_RECTL; - -#define U_RCL_DEF (U_RECTL){0,0,-1,-1} //!< Use this when no bounds are needed. - -/* ************************************************************ - EMF structures OTHER than those corresponding to complete U_EMR_* records - ************************************************************ */ - -/** - \brief For U_BITMAPINFO bmiColors field - NOTE that the color order is BGR, even though the name is RGB! - Microsoft name: RGBQUAD Object -*/ -typedef struct { - uint8_t Blue; //!< Blue color (0-255) - uint8_t Green; //!< Green color (0-255) - uint8_t Red; //!< Red color (0-255) - uint8_t Reserved; //!< Not used -} U_RGBQUAD, *PU_RGBQUAD; +/** @} */ -/** - \brief For U_BITMAPINFO crColor field - NOTE that the color order is RGB reserved, flipped around from the preceding. - Microsoft name: COLORREF Object -*/ -typedef struct { - uint8_t Red; //!< Red color (0-255) - uint8_t Green; //!< Green color (0-255) - uint8_t Blue; //!< Blue color (0-255) - uint8_t Reserved; //!< Not used -} U_COLORREF, *PU_COLORREF; +/** Any generic pair of floats. -/** - \brief For U_POINT28_4 x and y fields. - Microsoft name: BitFIX28_4 Object. + Microsoft name: (none) */ typedef struct { - signed IntValue :28; //!< Signed integral bit field - unsigned FracValue :4; //!< Unsigned integral bit field -} U_BITFIX28_4, *PU_BITFIX28_4; + float x; //!< X value + float y; //!< Y value +} U_PAIRF, + *PU_PAIRF; //!< Any generic pair of floats. Microsoft name: (none) -/** - \brief For U_LCS_GAMMARGB lcsGamma* fields - Microsoft name:(unknown) Object -*/ -typedef struct { - unsigned ignoreHi :8; //!< not used - unsigned intPart :8; //!< integer part - unsigned fracPart :8; //!< fraction part - unsigned ignoreLo :8; //!< not used -} U_LCS_GAMMA, *PU_LCS_GAMMA; -/** - \brief For U_LOGCOLORSPACEA and U_LOGCOLORSPACEW lcsGammaRGB field - Microsoft name:(unknown) Object +/* ************************************************************ + EMF structures OTHER than those corresponding to complete U_EMR_* records + ************************************************************ */ + +/** + \brief For U_POINT28_4 x and y fields. + + EMF manual 2.2.1, Microsoft name: BitFIX28_4 Object. */ typedef struct { - U_LCS_GAMMA lcsGammaRed; //!< Red Gamma - U_LCS_GAMMA lcsGammaGreen; //!< Green Gamma - U_LCS_GAMMA lcsGammaBlue; //!< Blue Gamma -} U_LCS_GAMMARGB, *PU_LCS_GAMMARGB; + signed IntValue :28; //!< Signed integral bit field + unsigned FracValue :4; //!< Unsigned integral bit field +} U_BITFIX28_4, + *PU_BITFIX28_4; //!< EMF manual 2.2.1 /** \brief For U_EMRSETOLORADJUSTMENT ColorAdjustment field + + EMF manual 2.2.2, Microsoft name: ColorAdjustment Object + Note, range constants are: RGB_GAMMA_[MIN|MAX],REFERENCE_[WHITE|BLACK]_[MIN|MAX],COLOR_ADJ_[MIN|MAX] - Microsoft name: ColorAdjustment Object */ typedef struct { uint16_t caSize; //!< Size of this structure in bytes @@ -1337,35 +1653,44 @@ typedef struct { int16_t caBrightness; //!< Brightness adjustment (range:-100:100, 0 is no correction) int16_t caColorfulness; //!< Colorfulness adjustment (range:-100:100, 0 is no correction) int16_t caRedGreenTint; //!< Tine adjustment (range:-100:100, 0 is no correction) -} U_COLORADJUSTMENT, *PU_COLORADJUSTMENT; +} U_COLORADJUSTMENT, + *PU_COLORADJUSTMENT; //!< EMF manual 2.2.2 -/** +/** EMF manual 2.2.3 \brief For ? (not implemented yet) + Microsoft name: DesignVector Object */ typedef struct { uint32_t Signature; //!< Must be 0x08007664 (AKA: DV_SGNTR) U_NUM_FNTAXES NumAxes; //!< Number of elements in Values, 0-16 U_FNTAXES Values[1]; //!< Optional. Array of font axes for opentype font -} U_DESIGNVECTOR,*PU_DESIGNVECTOR; +} U_DESIGNVECTOR, + *PU_DESIGNVECTOR; //!< EMF manual 2.2.3 -/** +/** \brief For U_EMR_COMMENT_MULTIFORMATS record, where an array of these is used - Microsoft name: EmrFormat Object + + EMF manual 2.2.4, Microsoft name: EmrFormat Object */ typedef struct { uint32_t signature; //!< FormatSignature Enumeration uint32_t nVersion; //!< Must be 1 if signature is EPS, else ignored U_CBDATA cbData; //!< Data size in bytes U_OFFDATA offData; //!< Offset in bytes to the Data from the start of the RECORD -} U_EMRFORMAT, *PU_EMRFORMAT; +} U_EMRFORMAT, + *PU_EMRFORMAT; //!< EMF manual 2.2.4 + +/** -/** \brief For U_EMR[POLY]EXTTEXTOUT[A|W] emrtext field + + EMF manual 2.2.5, Microsoft name: EmrText Object + Differs from implementation in Mingw and Wine in that the core struct has a fixed size. Optional and movable components must be handled with offsets. - Microsoft name: EmrText Object Following invariant core there may/must be: + U_RECTL rcl; (Optional, absent when fOptions & U_ETO_NO_RECT) grayed/clipping/opaque rectangle U_OFFDX offDx; (required) but position isn't static. Offset in bytes to the character spacing array measured @@ -1376,38 +1701,43 @@ typedef struct { char string (required) String buffer holding nChars (padded to a multiple of 4 bytes in length). uint32_t Dx[1] (required) character spacing, array with one entry per glyph. - */ typedef struct { U_POINTL ptlReference; //!< String start coordinates U_NUM_STR nChars; //!< Number of characters in the string U_OFFSTR offString; //!< Offset in bytes to the string from the start of the RECORD uint32_t fOptions; //!< ExtTextOutOptions Enumeration -} U_EMRTEXT, *PU_EMRTEXT; +} U_EMRTEXT, + *PU_EMRTEXT; //!< EMF manual 2.2.5 -/** +/** \brief For U_EPS_DATA Points field - Microsoft name: Point28_4 Object + + EMF manual 2.2.23, Microsoft name: Point28_4 Object, out of order, needed for 2.2.6 */ typedef struct { U_BITFIX28_4 x; //!< X coordinate U_BITFIX28_4 y; //!< Y coordinate -} U_POINT28_4, *PU_POINT28_4; +} U_POINT28_4, + *PU_POINT28_4; //!< EMF manual 2.2.23 -/** +/** \brief For embedding EPS in EMF via U_EMRFORMAT offData array in U_EMR_COMMENT_MULTIFORMATS - Microsoft name: EpsData Object + + EMF manual 2.2.6, Microsoft name: EpsData Object */ typedef struct { uint32_t sizeData; //!< Size in bytes of this object uint32_t version; //!< Must be 1 U_POINT28_4 Points[3]; //!< Defines parallelogram, UL, UR, LL corners, LR is derived. U_RECTL PostScriptData; //!< Record may include optional clipping/opaque rectangle -} U_EPS_DATA, *PU_EPS_DATA; +} U_EPS_DATA, + *PU_EPS_DATA; //!< EMF manual 2.2.6 -/** +/** \brief For GRADIENT_[TRIANGLE|U_RECT] - Microsoft name: TriVertex Object + + EMF manual 2.2.26, Microsoft name: TriVertex Object, out of order, needed for 2.2.7 */ typedef struct { int32_t x; //!< X coord @@ -1416,48 +1746,59 @@ typedef struct { uint16_t Green; //!< Green component uint16_t Blue; //!< Bule component uint16_t Alpha; //!< Alpha Transparency -} U_TRIVERTEX, *PU_TRIVERTEX; +} U_TRIVERTEX, + *PU_TRIVERTEX; //!< EMF manual 2.2.26 +/** + \brief For U_EMRGRADIENTFILL GradObj field + + EMF manual 2.2.7, Microsoft name: GradientRectangle Object +*/ +typedef struct { + uint32_t UpperLeft; //!< Index of UL corner in an array of U_TRIVERTEX objects + uint32_t LowerRight; //!< Index of LR corner in an array of U_TRIVERTEX objects +} U_GRADIENT4, + *PU_GRADIENT4; //!< EMF manual 2.2.7 /** \brief For U_EMRGRADIENTFILL GradObj field + EMF manual 2.2.8, Microsoft name: GradientTriangle Object + Gradient object notes. The next two structures are used to define the shape with reference to an existing array of points stored in an array of TriVertex objects in the U_EMRGRADIENTFILL record. The tricky part is that these two structures are different sizes. In some implementations (MingW) the array is cast to uint32_t and basically the cast is then ignored. For libUEMF we leave this out of the structure entirely and get to it with offsets. - - Microsoft name: GradientTriangle Object */ typedef struct { uint32_t Vertex1; //!< Index of Vertex1 in an array of U_TRIVERTEX objects uint32_t Vertex2; //!< Index of Vertex2 in an array of U_TRIVERTEX objects uint32_t Vertex3; //!< Index of Vertex3 in an array of U_TRIVERTEX objects -} U_GRADIENT3, *PU_GRADIENT3; +} U_GRADIENT3, + *PU_GRADIENT3; //!< EMF manual 2.2.8 -/** - \brief For U_EMRGRADIENTFILL GradObj field - Microsoft name: GradientRectangle Object -*/ -typedef struct { - uint32_t UpperLeft; //!< Index of UL corner in an array of U_TRIVERTEX objects - uint32_t LowerRight; //!< Index of LR corner in an array of U_TRIVERTEX objects -} U_GRADIENT4, *PU_GRADIENT4; +//Microsoft name: Header object, EMF manual 2.2.9 defined below with record structs +//Microsoft name: HeaderExtension1 object, EMF manual 2.2.10 defined below with record structs +//Microsoft name: HeaderExtension1 object, EMF manual 2.2.11 defined below with record structs /** \brief For U_EMRCREATEBRUSHINDIRECT lb field - Microsoft name: LogBrushEx Object + + EMF manual 2.2.12, Microsoft name: LogBrushEx Object */ typedef struct { //!< In MS documentation this is LogBrushEx Object uint32_t lbStyle; //!< LB_Style Enumeration U_COLORREF lbColor; //!< Brush color uint32_t lbHatch; //!< HatchStyle Enumeration -} U_LOGBRUSH, *PU_LOGBRUSH; -typedef U_LOGBRUSH U_PATTERN, *PU_PATTERN; +} U_LOGBRUSH, + U_PATTERN, //!< EMF manual 2.2.12 + *PU_LOGBRUSH, //!< EMF manual 2.2.12 + *PU_PATTERN; //!< EMF manual 2.2.12 /** \brief For U_LOGFONT_PANOSE elfLogFont field - Microsoft name: LogFont Object + + EMF manual 2.2.13, Microsoft name: LogFont Object */ typedef struct { int32_t lfHeight; //!< Height in Logical units @@ -1474,12 +1815,18 @@ typedef struct { uint8_t lfQuality; //!< LF_Quality Enumeration uint8_t lfPitchAndFamily; //!< LF_PitchAndFamily Enumeration uint16_t lfFaceName[U_LF_FACESIZE]; //!< Name of font. If 0 origin is LL corner, may be compressed, this is height after decompression. - //!< biHeight < 0 origin is UL corner, may not be compressed - uint16_t biPlanes; //!< Planes (must be 1) - uint16_t biBitCount; //!< BitCount Enumeration (determines number of RBG colors) - uint32_t biCompression; //!< BI_Compression Enumeration - uint32_t biSizeImage; //!< Image size in bytes or 0 = "default size (calculated from geometry?)" - int32_t biXPelsPerMeter; //!< X Resolution in pixels/meter - int32_t biYPelsPerMeter; //!< Y Resolution in pixels/meter - U_NUM_RGBQUAD biClrUsed; //!< Number of bmciColors in U_BITMAPINFO/U_BITMAPCOREINFO that are used by the bitmap - uint32_t biClrImportant; //!< Number of bmciColors needed (0 means all). -} U_BITMAPINFOHEADER, *PU_BITMAPINFOHEADER; +} U_EXTLOGPEN, + *PU_EXTLOGPEN; //!< EMF manual 2.2.20 /** \brief For U_EMR_* OffBmi* fields + + WMF Manual 2.2.2.9, Microsoft name: (none). + Description of a Bitmap which in some cases is a Device Independent Bitmap (DIB) - Microsoft name: BITMAPINFO Object */ typedef struct { U_BITMAPINFOHEADER bmiHeader; //!< Geometry and pixel properties U_RGBQUAD bmiColors[1]; //!< Color table. 24 bit images do not use color table values. -} U_BITMAPINFO, *PU_BITMAPINFO; +} U_BITMAPINFO, + *PU_BITMAPINFO; //!< WMF Manual 2.2.2.9 /** \brief U_EMRALPHABLEND Blend field + + EMF Manual 2.3.1.1, Microsoft name: BLENDFUNCTION field of EMR_ALPHABLEND record. */ typedef struct { uint8_t Operation; //!< Must be 0 uint8_t Flags; //!< Must be 0 uint8_t Global; //!< Alpha for whole thing if Op is U_AC_SRC_GLOBAL (AKA U_AC_SRC_GLOBAL) uint8_t Op; //!< Blend Enumeration -} U_BLEND, *PU_BLEND; +} U_BLEND, + *PU_BLEND; //!< EMF Manual 2.3.1.1 # /** @@ -1736,43 +2043,53 @@ typedef struct { uint32_t iType; //!< Type of EMR record uint32_t nSize; //!< Size of entire record in bytes (multiple of 4). uint32_t dParm[1]; //!< Data in record -} U_ENHMETARECORD, *PU_ENHMETARECORD; +} U_ENHMETARECORD, + *PU_ENHMETARECORD; //!< General form of an EMF record. -/** First two fields of all EMF records +/** First two fields of all EMF records, + First two fields of all EMF+ records (1 or more within an EMF comment) For accessing iType and nSize files in all U_EMR* records Microsoft name: EMR Object */ typedef struct { uint32_t iType; //!< Type of EMR record uint32_t nSize; //!< Size of entire record in bytes (multiple of 4). -} U_EMR, *PU_EMR; +} U_EMR, + *PU_EMR; //!< First two fields of all EMF records, +/** Generic EMR record with two 32 bit values. + Microsoft name: (none) +*/ typedef struct { U_EMR emr; //!< U_EMR U_PAIR pair; //!< pair of 32 bit values -} U_EMRGENERICPAIR, *PU_EMRGENERICPAIR; +} U_EMRGENERICPAIR, + *PU_EMRGENERICPAIR; //!< Generic EMR record with two 32 bit values. Microsoft name: (none) // *********************************************************************************** -// The following have U_EMR_# records +// The following have U_EMR_# records. They are ordered by their record index, not by EMF manual position. /* Index 1 */ /** - \brief The firstU_ENHMETARECORD record in the metafile. - - Microsoft names instead: Header, HeaderExtension1, and HeaderExtension2 objects. These are - used nowhere else, so they are combined here, along with the first two fields which were not listed in the Header. - - Note also that three fields in this file (nBytes, nRecords, nHandles) must be (re)set after the entire EMF - is constructed, since typically they are not known until then. bOpenGL may or may not be knowable when this - header is written. - - Note also that rclBounds and rclFrame are supposed to be the region bounding the drawn content within the - EMF. This is generally smaller than the size from szlDevice. However, since libUEMF does not actually draw - anything it has no way of knowing what these values are. Instead when it creates a header it sets these to - match the szl* fields. + \brief The first U_ENHMETARECORD record in the metafile. + + EMF manual 2.2.9, Microsoft name: Header object, HeaderExtension1 object, HeaderExtension2 object + + Microsoft names instead: Header, HeaderExtension1, and HeaderExtension2 objects. These are + used nowhere else, so they are combined here, along with the first two fields which were not listed in the Header. + + Note also that three fields in this file (nBytes, nRecords, nHandles) must be (re)set after the entire EMF + is constructed, since typically they are not known until then. bOpenGL may or may not be knowable when this + header is written. + + Note also that rclBounds and rclFrame are supposed to be the region bounding the drawn content within the + EMF. This is generally smaller than the size from szlDevice. However, since libUEMF does not actually draw + anything it has no way of knowing what these values are. Instead when it creates a header it sets these to + match the szl* fields. + */ typedef struct { U_EMR emr; //!< U_EMR @@ -1785,360 +2102,519 @@ typedef struct { uint16_t nHandles; //!< Number of graphics objects used in the Metafile uint16_t sReserved; //!< Must be 0 uint32_t nDescription; //!< Characters in the Description field, 0 if no description - uint32_t offDescription; //!< Offset in bytes to Description field + uint32_t offDescription; //!< Offset in bytes to optional UTF-16BE string Description field uint32_t nPalEntries; //!< Number of Palette entries (in U_EMR_EOF record). U_SIZEL szlDevice; //!< Reference device size in pixels U_SIZEL szlMillimeters; //!< Reference device size in 0.01 mm /** Fields for winver >= win95 */ U_CBPXLFMT cbPixelFormat; //!< Size in bytes of PixelFormatDescriptor, 0 if no PFD - U_OFFPXLFMT offPixelFormat; //!< Offset in bytes to PixelFormatDescriptor from the start of the RECORD, 0 if no PFD + U_OFFPXLFMT offPixelFormat; //!< Offset in bytes to optional PixelFormatDescriptor from the start of the RECORD, 0 if no PFD uint32_t bOpenGL; //!< nonZero if OpenGL commands are included /** Fields for winver >= win98 */ U_SIZEL szlMicrometers; //!< Size of the display device in micrometer - //!< Record may include optional Description, UTF-16BE string - //!< Record may include optional PxlFmtDescriptor, U_PIXELFORMATDESCRIPTOR -} U_EMRHEADER, *PU_EMRHEADER; +} U_EMRHEADER, + *PU_EMRHEADER; //!< EMF manual 2.2.9 -/* Index 2,3,4,5,6*/ +/* Index 2,3,4,5,6 */ +/** EMF manual 2.3.5.16 +*/ typedef struct { U_EMR emr; //!< U_EMR U_RECTL rclBounds; //!< bounding rectangle in device units U_NUM_POINTL cptl; //!< Number of points to draw U_POINTL aptl[1]; //!< array of points -} U_EMRPOLYBEZIER, *PU_EMRPOLYBEZIER, - U_EMRPOLYGON, *PU_EMRPOLYGON, - U_EMRPOLYLINE, *PU_EMRPOLYLINE, - U_EMRPOLYBEZIERTO, *PU_EMRPOLYBEZIERTO, - U_EMRPOLYLINETO, *PU_EMRPOLYLINETO; +} U_EMRPOLYBEZIER, + U_EMRPOLYGON, //!< EMF manual 2.3.5.22 + U_EMRPOLYLINE, //!< EMF manual 2.3.5.24 + U_EMRPOLYBEZIERTO, //!< EMF manual 2.3.5.18 + U_EMRPOLYLINETO, //!< EMF manual 2.3.5.26 + *PU_EMRPOLYBEZIER, //!< EMF manual 2.3.5.16 + *PU_EMRPOLYGON, //!< EMF manual 2.3.5.22 + *PU_EMRPOLYLINE, //!< EMF manual 2.3.5.24 + *PU_EMRPOLYBEZIERTO, //!< EMF manual 2.3.5.18 + *PU_EMRPOLYLINETO; //!< EMF manual 2.3.5.26 /* Index 7,8 */ +/** EMF manual 2.3.5.30 + + After this struct the record also contains an array of points:\n + U_POINTL aptl[1]; +*/ typedef struct { U_EMR emr; //!< U_EMR U_RECTL rclBounds; //!< bounding rectangle in device units U_NUM_POLYCOUNTS nPolys; //!< Number of elements in aPolyCounts U_NUM_POINTL cptl; //!< Total number of points (over all poly) U_POLYCOUNTS aPolyCounts[1]; //!< Number of points in each poly (sequential) -// This will appear somewhere but is not really part of the core structure. -// U_POINTL aptl[1]; //!< array of points -} U_EMRPOLYPOLYLINE, *PU_EMRPOLYPOLYLINE, - U_EMRPOLYPOLYGON, *PU_EMRPOLYPOLYGON; +} U_EMRPOLYPOLYLINE, + U_EMRPOLYPOLYGON, //!< EMF manual 2.3.5.28 + *PU_EMRPOLYPOLYLINE, //!< EMF manual 2.3.5.30 + *PU_EMRPOLYPOLYGON; //!< EMF manual 2.3.5.28 /* Index 9,11 (numbers interleave with next one) */ +/** EMF manual 2.3.11.30 +*/ typedef struct { U_EMR emr; //!< U_EMR U_SIZEL szlExtent; //!< H & V extent in logical units -} U_EMRSETWINDOWEXTEX, *PU_EMRSETWINDOWEXTEX, - U_EMRSETVIEWPORTEXTEX, *PU_EMRSETVIEWPORTEXTEX; +} U_EMRSETWINDOWEXTEX, + U_EMRSETVIEWPORTEXTEX, //!< EMF manual manual 2.3.11.28 + *PU_EMRSETWINDOWEXTEX, //!< EMF manual manual 2.3.11.30 + *PU_EMRSETVIEWPORTEXTEX; //!< EMF manual manual 2.3.11.28 /* Index 10,12,13 */ +/** EMF manual 2.3.11.31 +*/ typedef struct { U_EMR emr; //!< U_EMR U_POINTL ptlOrigin; //!< H & V origin in logical units -} U_EMRSETWINDOWORGEX, *PU_EMRSETWINDOWORGEX, - U_EMRSETVIEWPORTORGEX, *PU_EMRSETVIEWPORTORGEX, - U_EMRSETBRUSHORGEX, *PU_EMRSETBRUSHORGEX; +} U_EMRSETWINDOWORGEX, + U_EMRSETVIEWPORTORGEX, //!< EMF manual 2.3.11.29 + U_EMRSETBRUSHORGEX, //!< EMF manual 2.3.11.12 + *PU_EMRSETWINDOWORGEX, //!< EMF manual 2.3.11.31 + *PU_EMRSETVIEWPORTORGEX, //!< EMF manual 2.3.11.29 + *PU_EMRSETBRUSHORGEX; //!< EMF manual 2.3.11.12 + + +/* Index 14 */ +/** EMF manual 3.2.4.1 -/* Index 14 -*/ -/** This is a very odd structure because the nSizeLast follows an optional variable size field. Consequently -even though nSizeLast has a name it cannot actually be accessed by it! Following the core appear these fields: +even though nSizeLast has a name it cannot actually be accessed by it! Following the core structure +appear these fields:\n U_LOGPLTNTRY PalEntries[1]; Record may include optional array of PalEntries uint32_t nSizeLast; Mandatory, but position isn't fixed. Must have same value as emr.nSize in header record + */ typedef struct { U_EMR emr; //!< U_EMR U_CBPLENTRIES cbPalEntries; //!< Number of palette entries U_OFFPLENTRIES offPalEntries; //!< Offset in bytes to array of palette entries -} U_EMREOF, *PU_EMREOF; +} U_EMREOF, + *PU_EMREOF; //!< EMF manual 3.2.4.1 /* Index 15 */ +/** EMF manual 2.3.5.36 +*/ typedef struct { U_EMR emr; //!< U_EMR U_POINTL ptlPixel; //!< Pixel coordinates (logical) U_COLORREF crColor; //!< Pixel color -} U_EMRSETPIXELV, *PU_EMRSETPIXELV; +} U_EMRSETPIXELV, + *PU_EMRSETPIXELV; //!< EMF manual 2.3.5.36 /* Index 16 */ +/** EMF manual 2.3.11.20 +*/ typedef struct { U_EMR emr; //!< U_EMR uint32_t dwFlags; //!< must be 1 -} U_EMRSETMAPPERFLAGS, *PU_EMRSETMAPPERFLAGS; +} U_EMRSETMAPPERFLAGS, + *PU_EMRSETMAPPERFLAGS; //!< EMF manual 2.3.11.20 -/* Index 17,18,19,20,21,22,67,98,115 */ +/* Index 17,18,19,20,21,22,67,98,115 +*/ +/** EMF manual 2.3.11.19 MapMode enumeration +*/ typedef struct { U_EMR emr; //!< U_EMR uint32_t iMode; //!< enumeration varies with type -} U_EMRSETMAPMODE, *PU_EMRSETMAPMODE, //!< MapMode enumeration - U_EMRSETBKMODE, *PU_EMRSETBKMODE, //!< BackgroundMode Enumeration - U_EMRSETPOLYFILLMODE, *PU_EMRSETPOLYFILLMODE, //!< PolygonFillMode Enumeration - U_EMRSETROP2, *PU_EMRSETROP2, //!< Binary Raster Operation Enumeration - U_EMRSETSTRETCHBLTMODE, *PU_EMRSETSTRETCHBLTMODE, //!< StretchMode Enumeration - U_EMRSETTEXTALIGN, *PU_EMRSETTEXTALIGN, //!< TextAlignment enumeration - U_EMRSELECTCLIPPATH, *PU_EMRSELECTCLIPPATH, //!< RegionMode Enumeration - U_EMRSETICMMODE, *PU_EMRSETICMMODE, //!< ICMMode Enumeration - U_EMRSETLAYOUT, *PU_EMRSETLAYOUT; //!< Mirroring Enumeration +} U_EMRSETMAPMODE, + U_EMRSETBKMODE, //!< EMF manual 2.3.11.11 BackgroundMode Enumeration + U_EMRSETPOLYFILLMODE, //!< EMF manual 2.3.11.22 PolygonFillMode Enumeration + U_EMRSETROP2, //!< EMF manual 2.3.11.23 Binary Raster Operation Enumeration + U_EMRSETSTRETCHBLTMODE, //!< EMF manual 2.3.11.24 StretchMode Enumeration + U_EMRSETTEXTALIGN, //!< EMF manual 2.3.11.25 TextAlignment enumeration + U_EMRSELECTCLIPPATH, //!< EMF manual 2.3.2.5 RegionMode Enumeration + U_EMRSETICMMODE, //!< EMF manual 2.3.11.14 ICMMode Enumeration + U_EMRSETLAYOUT, //!< EMF manual 2.3.11.17 Mirroring Enumeration + *PU_EMRSETMAPMODE, //!< EMF manual 2.3.11.19 MapMode enumeration + *PU_EMRSETBKMODE, //!< EMF manual 2.3.11.11 BackgroundMode Enumeration + *PU_EMRSETPOLYFILLMODE, //!< EMF manual 2.3.11.22 PolygonFillMode Enumeration + *PU_EMRSETROP2, //!< EMF manual 2.3.11.23 Binary Raster Operation Enumeration + *PU_EMRSETSTRETCHBLTMODE, //!< EMF manual 2.3.11.24 StretchMode Enumeration + *PU_EMRSETTEXTALIGN, //!< EMF manual 2.3.11.25 TextAlignment enumeration + *PU_EMRSELECTCLIPPATH, //!< EMF manual 2.3.2.5 RegionMode Enumeration + *PU_EMRSETICMMODE, //!< EMF manual 2.3.11.14 ICMMode Enumeration + *PU_EMRSETLAYOUT; //!< EMF manual 2.3.11.17 Mirroring Enumeration /* Index 23 */ +/** EMF manual 2.3.11.13 +*/ typedef struct { U_EMR emr; //!< U_EMR U_COLORADJUSTMENT ColorAdjustment; //!< Color Adjustment -} U_EMRSETCOLORADJUSTMENT, *PU_EMRSETCOLORADJUSTMENT; +} U_EMRSETCOLORADJUSTMENT, + *PU_EMRSETCOLORADJUSTMENT; //!< EMF manual 2.3.11.13 /* Index 24, 25 */ +/** EMF manual 2.3.11.26 +*/ typedef struct { U_EMR emr; //!< U_EMR U_COLORREF crColor; //!< Color -} U_EMRSETTEXTCOLOR, *PU_EMRSETTEXTCOLOR, - U_EMRSETBKCOLOR, *PU_EMRSETBKCOLOR; +} U_EMRSETTEXTCOLOR, + U_EMRSETBKCOLOR, //!< EMF manual 2.3.11.10 + *PU_EMRSETTEXTCOLOR, //!< EMF manual 2.3.11.26 + *PU_EMRSETBKCOLOR; //!< EMF manual 2.3.11.10 /* Index 26 */ +/** EMF manual 2.3.2.4 +*/ typedef struct { U_EMR emr; //!< U_EMR U_POINTL ptlOffset; //!< Clipping region -} U_EMROFFSETCLIPRGN, *PU_EMROFFSETCLIPRGN; +} U_EMROFFSETCLIPRGN, + *PU_EMROFFSETCLIPRGN; //!< EMF manual 2.3.2.4 /* Index 27, 54 */ +/** +EMF manual 2.3.11.4 +EMF manual 2.3.5.13 +*/ typedef struct { U_EMR emr; //!< U_EMR U_POINTL ptl; //!< Point coordinates -} U_EMRMOVETOEX, *PU_EMRMOVETOEX, - U_EMRLINETO, *PU_EMRLINETO; +} U_EMRMOVETOEX, + U_EMRLINETO, //!< EMF manual 2.3.5.13 + *PU_EMRMOVETOEX, //!< EMF manual 2.3.11.4 + *PU_EMRLINETO; //!< EMF manual 2.3.5.13 /* Index 28,33,52,59,60,61,65,66,68 */ +/** EMF manual 2.3.2 +*/ typedef struct { U_EMR emr; //!< U_EMR } - U_EMRSETMETARGN, *PU_EMRSETMETARGN, - U_EMRSAVEDC, *PU_EMRSAVEDC, - U_EMRREALIZEPALETTE, *PU_EMRREALIZEPALETTE, - U_EMRBEGINPATH, *PU_EMRBEGINPATH, - U_EMRENDPATH, *PU_EMRENDPATH, - U_EMRCLOSEFIGURE, *PU_EMRCLOSEFIGURE, - U_EMRFLATTENPATH, *PU_EMRFLATTENPATH, - U_EMRWIDENPATH, *PU_EMRWIDENPATH, - U_EMRABORTPATH, *PU_EMRABORTPATH; - -/* Index 29,30 */ + U_EMRSETMETARGN, + U_EMRSAVEDC, //!< EMF manual 2.3.11 + U_EMRREALIZEPALETTE, //!< EMF manual 2.3.10 + U_EMRBEGINPATH, //!< EMF manual 2.3.10 + U_EMRENDPATH, //!< EMF manual 2.3.10 + U_EMRCLOSEFIGURE, //!< EMF manual 2.3.10 + U_EMRFLATTENPATH, //!< EMF manual 2.3.10 + U_EMRWIDENPATH, //!< EMF manual 2.3.10 + U_EMRABORTPATH, //!< EMF manual 2.3.10 + *PU_EMRSETMETARGN, //!< EMF manual 2.3.2 + *PU_EMRSAVEDC, //!< EMF manual 2.3.11 + *PU_EMRREALIZEPALETTE, //!< EMF manual 2.3.10 + *PU_EMRBEGINPATH, //!< EMF manual 2.3.10 + *PU_EMRENDPATH, //!< EMF manual 2.3.10 + *PU_EMRCLOSEFIGURE, //!< EMF manual 2.3.10 + *PU_EMRFLATTENPATH, //!< EMF manual 2.3.10 + *PU_EMRWIDENPATH, //!< EMF manual 2.3.10 + *PU_EMRABORTPATH; //!< EMF manual 2.3.10 + +/* Index 29,30 */ +/** EMF manual 2.3.2.1 +*/ typedef struct { U_EMR emr; //!< U_EMR U_RECTL rclClip; //!< Clipping Region -} U_EMREXCLUDECLIPRECT, *PU_EMREXCLUDECLIPRECT, - U_EMRINTERSECTCLIPRECT, *PU_EMRINTERSECTCLIPRECT; +} U_EMREXCLUDECLIPRECT, + U_EMRINTERSECTCLIPRECT, //!< EMF manual 2.3.2.3 + *PU_EMREXCLUDECLIPRECT, //!< EMF manual 2.3.2.1 + *PU_EMRINTERSECTCLIPRECT; //!< EMF manual 2.3.2.3 /* Index 31,32 */ +/** EMF manual 2.3.11.7 +*/ typedef struct { U_EMR emr; //!< U_EMR int32_t xNum; //!< Horizontal multiplier (!=0) int32_t xDenom; //!< Horizontal divisor (!=0) int32_t yNum; //!< Vertical multiplier (!=0) int32_t yDenom; //!< Vertical divisor (!=0) -} U_EMRSCALEVIEWPORTEXTEX, *PU_EMRSCALEVIEWPORTEXTEX, - U_EMRSCALEWINDOWEXTEX, *PU_EMRSCALEWINDOWEXTEX; +} U_EMRSCALEVIEWPORTEXTEX, + U_EMRSCALEWINDOWEXTEX, //!< EMF manual 2.3.11.8 + *PU_EMRSCALEVIEWPORTEXTEX, //!< EMF manual 2.3.11.7 + *PU_EMRSCALEWINDOWEXTEX; //!< EMF manual 2.3.11.8 /* Index 33 (see 28) */ -/* Index 34 */ +/* Index 34 */ +/** EMF manual 2.3.11.6 +*/ typedef struct { U_EMR emr; //!< U_EMR int32_t iRelative; //!< DC to restore. -1 is preceding -} U_EMRRESTOREDC, *PU_EMRRESTOREDC; +} U_EMRRESTOREDC, + *PU_EMRRESTOREDC; //!< EMF manual 2.3.11.6 /* Index 35 */ +/** EMF manual 2.3.12.2 +*/ typedef struct { U_EMR emr; //!< U_EMR U_XFORM xform; //!< Transform -} U_EMRSETWORLDTRANSFORM, *PU_EMRSETWORLDTRANSFORM; +} U_EMRSETWORLDTRANSFORM, + *PU_EMRSETWORLDTRANSFORM; //!< EMF manual 2.3.12.2 /* Index 36 */ +/** EMF manual 2.3.12.1 +*/ typedef struct { U_EMR emr; //!< U_EMR U_XFORM xform; //!< Transform uint32_t iMode; //!< ModifyWorldTransformMode Enumeration -} U_EMRMODIFYWORLDTRANSFORM, *PU_EMRMODIFYWORLDTRANSFORM; +} U_EMRMODIFYWORLDTRANSFORM, + *PU_EMRMODIFYWORLDTRANSFORM; //!< EMF manual 2.3.12.1 /* Index 37,40 */ +/** EMF manual 2.3.8.3 +*/ typedef struct { U_EMR emr; //!< U_EMR uint32_t ihObject; //!< Number of a stock or created object -} U_EMRDELETEOBJECT, *PU_EMRDELETEOBJECT, - U_EMRSELECTOBJECT, *PU_EMRSELECTOBJECT; +} U_EMRDELETEOBJECT, + U_EMRSELECTOBJECT, //!< EMF manual 2.3.8.5 + *PU_EMRDELETEOBJECT, //!< EMF manual 2.3.8.3 + *PU_EMRSELECTOBJECT; //!< EMF manual 2.3.8.5 /* Index 38 */ +/** EMF manual 2.3.7.7 +*/ typedef struct { U_EMR emr; //!< U_EMR uint32_t ihPen; //!< Index to place object in EMF object table (this entry must not yet exist) U_LOGPEN lopn; //!< Pen properties -} U_EMRCREATEPEN, *PU_EMRCREATEPEN; +} U_EMRCREATEPEN, + *PU_EMRCREATEPEN; //!< EMF manual 2.3.7.7 -/* Index 39 */ +/* Index 39 */ +/** EMF manual 2.3.7.1 +*/ typedef struct { U_EMR emr; //!< U_EMR uint32_t ihBrush; //!< Index to place object in EMF object table (this entry must not yet exist) U_LOGBRUSH lb; //!< Brush properties -} U_EMRCREATEBRUSHINDIRECT, *PU_EMRCREATEBRUSHINDIRECT; +} U_EMRCREATEBRUSHINDIRECT, + *PU_EMRCREATEBRUSHINDIRECT; //!< EMF manual 2.3.7.1 /* Index 40 see 37 */ -/* Index 41 */ +/* Index 41 */ +/** EMF manual 2.3.5.1 +*/ typedef struct { U_EMR emr; //!< U_EMR U_POINTL ptlCenter; //!< Center in logical units uint32_t nRadius; //!< Radius in logical units U_FLOAT eStartAngle; //!< Starting angle in degrees (counter clockwise from x axis) U_FLOAT eSweepAngle; //!< Sweep angle in degrees -} U_EMRANGLEARC, *PU_EMRANGLEARC; +} U_EMRANGLEARC, + *PU_EMRANGLEARC; //!< EMF manual 2.3.5.1 -/* Index 42,43 */ +/* Index 42,43 */ +/** EMF manual 2.3.5.5 +*/ typedef struct { U_EMR emr; //!< U_EMR U_RECTL rclBox; //!< bounding rectangle in logical units -} U_EMRELLIPSE, *PU_EMRELLIPSE, - U_EMRRECTANGLE, *PU_EMRRECTANGLE; +} U_EMRELLIPSE, + U_EMRRECTANGLE, //!< EMF manual 2.3.5.5 + *PU_EMRELLIPSE, //!< EMF manual 2.3.5.5 + *PU_EMRRECTANGLE; //!< EMF manual 2.3.5.34 -/* Index 44 */ +/* Index 44 */ +/** EMF manual 2.3.5.35 +*/ typedef struct { U_EMR emr; //!< U_EMR U_RECTL rclBox; //!< bounding rectangle in logical units U_SIZEL szlCorner; //!< W & H in logical units of ellipse used to round corner -} U_EMRROUNDRECT, *PU_EMRROUNDRECT; +} U_EMRROUNDRECT, + *PU_EMRROUNDRECT; //!< EMF manual 2.3.5.35 -/* Index 45, 46 ,47, 55 */ +/* Index 45, 46 ,47, 55 */ +/** EMF manual 2.3.5.2 +*/ typedef struct { U_EMR emr; //!< U_EMR U_RECTL rclBox; //!< bounding rectangle in logical units U_POINTL ptlStart; //!< Start point in logical units U_POINTL ptlEnd; //!< End point in logical units -} U_EMRARC, *PU_EMRARC, - U_EMRCHORD, *PU_EMRCHORD, - U_EMRPIE, *PU_EMRPIE, - U_EMRARCTO, *PU_EMRARCTO; +} U_EMRARC, + U_EMRCHORD, //!< EMF manual 2.3.5.4 + U_EMRPIE, //!< EMF manual 2.3.5.15 + U_EMRARCTO, //!< EMF manual 2.3.5.3 + *PU_EMRARC, //!< EMF manual 2.3.5.2 + *PU_EMRCHORD, //!< EMF manual 2.3.5.4 + *PU_EMRPIE, //!< EMF manual 2.3.5.15 + *PU_EMRARCTO; //!< EMF manual 2.3.5.3 -/* Index 48 */ +/* Index 48 */ +/** EMF manual 2.3.8.6 +*/ typedef struct { U_EMR emr; //!< U_EMR uint32_t ihPal; //!< Index of a Palette object in the EMF object table -} U_EMRSELECTPALETTE, *PU_EMRSELECTPALETTE; +} U_EMRSELECTPALETTE, + *PU_EMRSELECTPALETTE; //!< EMF manual 2.3.8.6 -/* Index 49 */ +/* Index 49 */ +/** EMF manual 2.3.7.6 +*/ typedef struct { U_EMR emr; //!< U_EMR uint32_t ihPal; //!< Index to place object in EMF object table (this entry must not yet exist) U_LOGPALETTE lgpl; //!< Palette properties -} U_EMRCREATEPALETTE, *PU_EMRCREATEPALETTE; +} U_EMRCREATEPALETTE, + *PU_EMRCREATEPALETTE; //!< EMF manual 2.3.7.6 /* Index 50 */ +/** EMF manual 2.3.8.8 +*/ typedef struct { U_EMR emr; //!< U_EMR uint32_t ihPal; //!< Index of a Palette object in the EMF object table uint32_t iStart; //!< First Palette entry in selected object to set U_NUM_LOGPLTNTRY cEntries; //!< Number of Palette entries in selected object to set U_LOGPLTNTRY aPalEntries[1]; //!< Values to set with -} U_EMRSETPALETTEENTRIES, *PU_EMRSETPALETTEENTRIES; +} U_EMRSETPALETTEENTRIES, + *PU_EMRSETPALETTEENTRIES; //!< EMF manual 2.3.8.8 /* Index 51 */ +/** EMF manual 2.3.8.4 +*/ typedef struct { U_EMR emr; //!< U_EMR uint32_t ihPal; //!< Index of a Palette object in the EMF object table uint32_t cEntries; //!< Number to expand or truncate the Palette entry list to. -} U_EMRRESIZEPALETTE, *PU_EMRRESIZEPALETTE; +} U_EMRRESIZEPALETTE, + *PU_EMRRESIZEPALETTE; //!< EMF manual 2.3.8.4 /* Index 52 (see 28) */ /* Index 53 */ +/** EMF manual 2.3.5.6 +*/ typedef struct { U_EMR emr; //!< U_EMR U_POINTL ptlStart; //!< Start point in logical units U_COLORREF crColor; //!< Color to fill with uint32_t iMode; //!< FloodFill Enumeration -} U_EMREXTFLOODFILL, *PU_EMREXTFLOODFILL; +} U_EMREXTFLOODFILL, + *PU_EMREXTFLOODFILL; //!< EMF manual 2.3.5.6 /* Index 54 (see 27) */ /* Index 55 (see 45) */ -/* Index 56 */ +/* Index 56 */ +/** EMF manual 2.3.5.20 +*/ typedef struct { U_EMR emr; //!< U_EMR U_RECTL rclBounds; //!< Bounding rectangle in device units U_NUM_POINTL cptl; //!< Number of U_POINTL objects U_POINTL aptl[1]; //!< Array of U_POINTL objects uint8_t abTypes[1]; //!< Array of Point Enumeration -} U_EMRPOLYDRAW, *PU_EMRPOLYDRAW; +} U_EMRPOLYDRAW, + *PU_EMRPOLYDRAW; //!< EMF manual 2.3.5.20 -/* Index 57 */ +/* Index 57 */ +/** EMF manual 2.3.11.9 +*/ typedef struct { U_EMR emr; //!< U_EMR uint32_t iArcDirection; //!< ArcDirection Enumeration -} U_EMRSETARCDIRECTION, *PU_EMRSETARCDIRECTION; +} U_EMRSETARCDIRECTION, + *PU_EMRSETARCDIRECTION; //!< EMF manual 2.3.11.9 + +/* Index 58 */ +/** EMF manual 2.3.11.21 -/* Index 58 IMPORTANT!!!! The Microsoft structure uses a float for the miterlimit but the EMF file record uses an unsigned int. The latter form is used in this structure. */ typedef struct { U_EMR emr; //!< U_EMR uint32_t eMiterLimit; //!< Miter limit (max value of mitered length / line width) -} U_EMRSETMITERLIMIT, *PU_EMRSETMITERLIMIT; +} U_EMRSETMITERLIMIT, + *PU_EMRSETMITERLIMIT; //!< EMF manual 2.3.11.21 /* Index 59,60,61 (see 28) */ -/* Index 62,63,64 */ +/* Index 62,63,64 */ +/** EMF manual 2.3.5.9 +*/ typedef struct { U_EMR emr; //!< U_EMR U_RECTL rclBounds; //!< Bounding rectangle in device units -} U_EMRFILLPATH, *PU_EMRFILLPATH, - U_EMRSTROKEANDFILLPATH, *PU_EMRSTROKEANDFILLPATH, - U_EMRSTROKEPATH, *PU_EMRSTROKEPATH; +} U_EMRFILLPATH, + U_EMRSTROKEANDFILLPATH, //!< EMF manual 2.3.5.38 + U_EMRSTROKEPATH, //!< EMF manual 2.3.5.39 + *PU_EMRFILLPATH, //!< EMF manual 2.3.5.9 + *PU_EMRSTROKEANDFILLPATH, //!< EMF manual 2.3.5.38 + *PU_EMRSTROKEPATH; //!< EMF manual 2.3.5.39 /* Index 65,66 (see 28) */ /* Index 67 (see 17) */ /* Index 68 (see 28) */ /* Index 69 (not a defined U_EMR record type ) */ -/* Index 70 */ + +/* Index 70 */ +/** EMF manual 2.3.3.1 +*/ typedef struct { U_EMR emr; //!< U_EMR U_CBDATA cbData; //!< Number of bytes in comment uint8_t Data[1]; //!< Comment (any binary data, interpretation is program specific) -} U_EMRCOMMENT, *PU_EMRCOMMENT; //!< AKA GDICOMMENT +} U_EMRCOMMENT, + *PU_EMRCOMMENT; //!< EMF manual 2.3.3.1, AKA GDICOMMENT /* variant comment types */ +/** EMF manual 2.3.3.2 +*/ typedef struct { U_EMR emr; //!< U_EMR U_CBDATA cbData; //!< Number of bytes in comment uint32_t cIdent; //!< Comment identifier, must be U_EMR_COMMENT_EMFPLUSRECORD uint8_t Data[1]; //!< EMF Plus record -} U_EMRCOMMENT_EMFPLUS, *PU_EMRCOMMENT_EMFPLUS; //!< EMF Plus comment +} U_EMRCOMMENT_EMFPLUS, + *PU_EMRCOMMENT_EMFPLUS; //!< EMF manual 2.3.3.2, EMF Plus comment +/** EMF manual 2.3.3.3 +*/ typedef struct { U_EMR emr; //!< U_EMR U_CBDATA cbData; //!< Number of bytes in comment uint32_t cIdent; //!< Comment identifier, must be U_EMR_COMMENT_SPOOL uint32_t esrIdent; //!< EMFSpoolRecordIdentifier, may be U_EMR_COMMENT_SPOOLFONTDEF uint8_t Data[1]; //!< EMF Spool records -} U_EMRCOMMENT_SPOOL, *PU_EMRCOMMENT_SPOOL; //!< EMF Spool comment +} U_EMRCOMMENT_SPOOL, + *PU_EMRCOMMENT_SPOOL; //!< EMF manual 2.3.3.3, EMF Spool comment +/** EMF manual 2.3.3.4 +*/ typedef struct { U_EMR emr; //!< U_EMR U_CBDATA cbData; //!< Number of bytes in comment uint32_t cIdent; //!< Comment identifier, must be U_EMR_COMMENT_PUBLIC uint32_t pcIdent; //!< Public Comment Identifier, from EMRComment Enumeration uint8_t Data[1]; //!< Public comment data -} U_EMRCOMMENT_PUBLIC, *PU_EMRCOMMENT_PUBLIC; //!< EMF Public comment +} U_EMRCOMMENT_PUBLIC, + *PU_EMRCOMMENT_PUBLIC; //!< EMF manual 2.3.3.4, EMF Public comment -/* Index 71 */ +/* Index 71 */ +/** EMF manual 2.3.5.10 +*/ typedef struct { U_EMR emr; //!< U_EMR U_RECTL rclBounds; //!< Bounding rectangle in device units U_CBRGNDATA cbRgnData; //!< Size in bytes of Region data uint32_t ihBrush; //!< Index of a Brush object in the EMF object table U_RGNDATA RgnData[1]; //!< Variable size U_RGNDATA structure -} U_EMRFILLRGN, *PU_EMRFILLRGN; +} U_EMRFILLRGN, + *PU_EMRFILLRGN; //!< EMF manual 2.3.5.10 /* Index 72 */ +/** EMF manual 2.3.5.11 +*/ typedef struct { U_EMR emr; //!< U_EMR U_RECTL rclBounds; //!< Bounding rectangle in device units @@ -2146,26 +2622,36 @@ typedef struct { uint32_t ihBrush; //!< Index of a Brush object in the EMF object table U_SIZEL szlStroke; //!< W & H of Brush stroke U_RGNDATA RgnData[1]; //!< Variable size U_RGNDATA structure -} U_EMRFRAMERGN, *PU_EMRFRAMERGN; +} U_EMRFRAMERGN, + *PU_EMRFRAMERGN; //!< EMF manual 2.3.5.11 /* Index 73,74 */ +/** EMF manual 2.3.11.3 +*/ typedef struct { U_EMR emr; //!< U_EMR U_RECTL rclBounds; //!< Bounding rectangle in device units U_CBRGNDATA cbRgnData; //!< Size in bytes of Region data U_RGNDATA RgnData[1]; //!< Variable size U_RGNDATA structure -} U_EMRINVERTRGN, *PU_EMRINVERTRGN, - U_EMRPAINTRGN, *PU_EMRPAINTRGN; +} U_EMRINVERTRGN, + U_EMRPAINTRGN, //!< EMF manual 2.3.5.14 + *PU_EMRINVERTRGN, //!< EMF manual 2.3.11.3 + *PU_EMRPAINTRGN; //!< EMF manual 2.3.5.14 /* Index 75 */ +/** EMF manual 2.3.2.2 +*/ typedef struct { U_EMR emr; //!< U_EMR U_CBRGNDATA cbRgnData; //!< Size in bytes of Region data uint32_t iMode; //!< RegionMode Enumeration U_RGNDATA RgnData[1]; //!< Variable size U_RGNDATA structure -} U_EMREXTSELECTCLIPRGN, *PU_EMREXTSELECTCLIPRGN; +} U_EMREXTSELECTCLIPRGN, + *PU_EMREXTSELECTCLIPRGN; //!< EMF manual 2.3.2.2 /* Index 76 */ +/** EMF manual 2.3.1.2 +*/ typedef struct { U_EMR emr; //!< U_EMR U_RECTL rclBounds; //!< Bounding rectangle in device units @@ -2181,9 +2667,12 @@ typedef struct { U_OFFBITSSRC offBitsSrc; //!< Offset in bytes to the bitmap (within bitmapbuffer) U_CBBITS cbBitsSrc; //!< Size in bytes of bitmap //!< Record may include optional bitmapbuffer -} U_EMRBITBLT, *PU_EMRBITBLT; +} U_EMRBITBLT, + *PU_EMRBITBLT; //!< EMF manual 2.3.1.2 /* Index 77 */ +/** EMF manual 2.3.1.6 +*/ typedef struct { U_EMR emr; //!< U_EMR U_RECTL rclBounds; //!< Bounding rectangle in device units @@ -2200,9 +2689,12 @@ typedef struct { U_CBBITS cbBitsSrc; //!< Size in bytes of bitmap U_POINTL cSrc; //!< Src W & H in logical units //!< Record may include optional bitmapbuffer -} U_EMRSTRETCHBLT, *PU_EMRSTRETCHBLT; +} U_EMRSTRETCHBLT, + *PU_EMRSTRETCHBLT; //!< EMF manual 2.3.1.6 -/* Index 78 */ +/* Index 78 */ +/** EMF manual 2.3.1.3 +*/ typedef struct { U_EMR emr; //!< U_EMR U_RECTL rclBounds; //!< Bounding rectangle in device units @@ -2224,9 +2716,12 @@ typedef struct { U_OFFBITSMSK offBitsMask; //!< Offset in bytes to the mask bitmap (within maskbitmapbuffer) U_CBBITSMSK cbBitsMask; //!< Size in bytes of bitmap //!< Record may include optional Source and mask bitmapbuffers -} U_EMRMASKBLT, *PU_EMRMASKBLT; +} U_EMRMASKBLT, + *PU_EMRMASKBLT; //!< EMF manual 2.3.1.3 /* Index 79 */ +/** EMF manual 2.3.1.4 +*/ typedef struct { U_EMR emr; //!< U_EMR U_RECTL rclBounds; //!< Bounding rectangle in device units @@ -2247,9 +2742,12 @@ typedef struct { U_OFFBITSMSK offBitsMask; //!< Offset in bytes to the mask bitmap (within maskbitmapbuffer) U_CBBITSMSK cbBitsMask; //!< Size in bytes of bitmap //!< Record may include optional Source and mask bitmapbuffers -} U_EMRPLGBLT, *PU_EMRPLGBLT; +} U_EMRPLGBLT, + *PU_EMRPLGBLT; //!< EMF manual 2.3.1.4 /* Index 80 */ +/** EMF manual 2.3.1.5 +*/ typedef struct { U_EMR emr; //!< U_EMR U_RECTL rclBounds; //!< Bounding rectangle in device units @@ -2264,9 +2762,12 @@ typedef struct { uint32_t iStartScan; //!< First scan line uint32_t cScans; //!< Number of scan lines //!< Record may includes optional bitmapbuffer -} U_EMRSETDIBITSTODEVICE, *PU_EMRSETDIBITSTODEVICE; +} U_EMRSETDIBITSTODEVICE, + *PU_EMRSETDIBITSTODEVICE; //!< EMF manual 2.3.1.5 /* Index 81 */ +/** EMF manual 2.3.1.7 +*/ typedef struct { U_EMR emr; //!< U_EMR U_RECTL rclBounds; //!< Bounding rectangle in device units @@ -2281,18 +2782,23 @@ typedef struct { uint32_t dwRop; //!< Ternary Raster Operation enumeration U_POINTL cDest; //!< Destination W & H in logical units //!< Record may includes optional bitmapbuffer -} U_EMRSTRETCHDIBITS, *PU_EMRSTRETCHDIBITS; +} U_EMRSTRETCHDIBITS, + *PU_EMRSTRETCHDIBITS; //!< EMF manual 2.3.1.7 /* Index 82 */ +/** EMF manual 2.3.7.8 +*/ typedef struct { U_EMR emr; //!< U_EMR uint32_t ihFont; //!< Index of the font in the EMF object table U_LOGFONT_PANOSE elfw; //!< Font parameters, either U_LOGFONT or U_LOGFONT_PANOSE, the latter is bigger so use that type here -} U_EMREXTCREATEFONTINDIRECTW, *PU_EMREXTCREATEFONTINDIRECTW; +} U_EMREXTCREATEFONTINDIRECTW, + *PU_EMREXTCREATEFONTINDIRECTW; //!< EMF manual 2.3.7.8 -/* Index 83,84 */ -/** -Variable and optional fields may follow core structure in record: +/* Index 83,84 */ +/** EMF manual 2.3.5.7 + +Variable and optional fields may follow core structure in record:\n U_RECTL rcl; absent when fOptions & U_ETO_NO_RECT) grayed/clipping/opaque rectangle @@ -2307,25 +2813,33 @@ typedef struct { U_FLOAT exScale; //!< scale to 0.01 mm units ( only if iGraphicsMode & U_GM_COMPATIBLE) U_FLOAT eyScale; //!< scale to 0.01 mm units ( only if iGraphicsMode & U_GM_COMPATIBLE) U_EMRTEXT emrtext; //!< Text parameters -// U_RECTL rcl; absent when fOptions & U_ETO_NO_RECT) grayed/clipping/opaque rectangle -// U_OFFDX offDx; (required) but position isn't static. Offset in bytes to the character spacing array from the start of the RECORD -// Record may include optional Dx, character spacing, array of uint32_t -} U_EMREXTTEXTOUTA, *PU_EMREXTTEXTOUTA, - U_EMREXTTEXTOUTW, *PU_EMREXTTEXTOUTW; +} U_EMREXTTEXTOUTA, + U_EMREXTTEXTOUTW, //!< EMF manual 2.3.5.8 + *PU_EMREXTTEXTOUTA, //!< EMF manual 2.3.5.7 + *PU_EMREXTTEXTOUTW; //!< EMF manual 2.3.5.8 /* Index 85,86,87,88,89 */ +/** EMF manual 2.3.5.17 +*/ typedef struct { U_EMR emr; //!< U_EMR U_RECTL rclBounds; //!< Bounding rectangle in device units U_NUM_POINT16 cpts; //!< Number of POINT16 in array U_POINT16 apts[1]; //!< Array of POINT16 -} U_EMRPOLYBEZIER16,*PU_EMRPOLYBEZIER16, - U_EMRPOLYGON16,*PU_EMRPOLYGON16, - U_EMRPOLYLINE16,*PU_EMRPOLYLINE16, - U_EMRPOLYBEZIERTO16,*PU_EMRPOLYBEZIERTO16, - U_EMRPOLYLINETO16,*PU_EMRPOLYLINETO16; - +} U_EMRPOLYBEZIER16, + U_EMRPOLYGON16, //!< EMF manual 2.3.5.23 + U_EMRPOLYLINE16, //!< EMF manual 2.3.5.25 + U_EMRPOLYBEZIERTO16, //!< EMF manual 2.3.5.19 + U_EMRPOLYLINETO16, //!< EMF manual 2.3.5.27 + *PU_EMRPOLYBEZIER16, //!< EMF manual 2.3.5.17 + *PU_EMRPOLYGON16, //!< EMF manual 2.3.5.23 + *PU_EMRPOLYLINE16, //!< EMF manual 2.3.5.25 + *PU_EMRPOLYBEZIERTO16, //!< EMF manual 2.3.5.19 + *PU_EMRPOLYLINETO16; //!< EMF manual 2.3.5.27 + /* Index 90,91 */ +/** EMF manual 2.3.5.31 +*/ typedef struct { U_EMR emr; //!< U_EMR U_RECTL rclBounds; //!< Bounding rectangle in device units @@ -2333,20 +2847,27 @@ typedef struct { U_NUM_POINT16 cpts; //!< Total number of points (over all poly) U_POLYCOUNTS aPolyCounts[1]; //!< Number of points in each poly (sequential) // This will appear somewhere but is not really part of the core structure. -// U_POINT16 apts[1]; //!< array of point16 -} U_EMRPOLYPOLYLINE16,*PU_EMRPOLYPOLYLINE16, - U_EMRPOLYPOLYGON16,*PU_EMRPOLYPOLYGON16; +// U_POINT16 apts[1]; //!< array of point16 +} U_EMRPOLYPOLYLINE16, + U_EMRPOLYPOLYGON16, //!< EMF manual 2.3.5.29 + *PU_EMRPOLYPOLYLINE16, //!< EMF manual 2.3.5.31 + *PU_EMRPOLYPOLYGON16; //!< EMF manual 2.3.5.29 /* Index 92 */ +/** EMF manual 2.3.5.21 +*/ typedef struct { U_EMR emr; //!< U_EMR U_RECTL rclBounds; //!< Bounding rectangle in device units U_NUM_POINT16 cpts; //!< Total number of points (over all poly) U_POINT16 apts[1]; //!< array of points uint8_t abTypes[1]; //!< Array of Point Enumeration -} U_EMRPOLYDRAW16,*PU_EMRPOLYDRAW16; +} U_EMRPOLYDRAW16, + *PU_EMRPOLYDRAW16; //!< EMF manual 2.3.5.21 -/* Index 93 */ +/* Index 93 */ +/** EMF manual 2.3.7.5 +*/ typedef struct { U_EMR emr; //!< U_EMR uint32_t ihBrush; //!< Index to place object in EMF object table (this entry must not yet exist) @@ -2356,9 +2877,12 @@ typedef struct { U_OFFBITS offBits; //!< Offset in bytes to the DIB bitmap data (within DIBbitmapbuffer U_CBBITS cbBits; //!< Size in bytes of DIB bitmap //!< Record may include optional DIB bitmapbuffer -} U_EMRCREATEMONOBRUSH, *PU_EMRCREATEMONOBRUSH; +} U_EMRCREATEMONOBRUSH, + *PU_EMRCREATEMONOBRUSH; //!< EMF manual 2.3.7.5 -/* Index 94 */ +/* Index 94 */ +/** EMF manual 2.3.7.4 +*/ typedef struct { U_EMR emr; //!< U_EMR uint32_t ihBrush; //!< Index to place object in EMF object table (this entry must not yet exist) @@ -2368,9 +2892,12 @@ typedef struct { U_OFFBITS offBits; //!< Offset in bytes to the DIB bitmap data (within DIB bitmapbuffer U_CBBITS cbBits; //!< Size in bytes of DIB bitmap //!< Record may include optional DIB bitmapbuffer -} U_EMRCREATEDIBPATTERNBRUSHPT, *PU_EMRCREATEDIBPATTERNBRUSHPT; +} U_EMRCREATEDIBPATTERNBRUSHPT, + *PU_EMRCREATEDIBPATTERNBRUSHPT; //!< EMF manual 2.3.7.4 /* Index 95 */ +/** EMF manual 2.3.7.9 +*/ typedef struct { U_EMR emr; //!< U_EMR uint32_t ihPen; //!< Index to place object in EMF object table (this entry must not yet exist) @@ -2380,9 +2907,12 @@ typedef struct { U_CBBITS cbBits; //!< Size in bytes of DIB bitmap U_EXTLOGPEN elp; //!< Pen parameters (Size is Variable!!!!) //!< Record may include optional DIB bitmap -} U_EMREXTCREATEPEN, *PU_EMREXTCREATEPEN; +} U_EMREXTCREATEPEN, + *PU_EMREXTCREATEPEN; //!< EMF manual 2.3.7.9 -/* Index 96.97 */ +/* Index 96.97 */ +/** EMF manual 2.3.5.32 +*/ typedef struct { U_EMR emr; //!< U_EMR U_RECTL rclBounds; //!< Bounding rectangle in device units @@ -2391,63 +2921,89 @@ typedef struct { U_FLOAT eyScale; //!< scale to 0.01 mm units ( only if iGraphicsMode & U_GM_COMPATIBLE) U_NUM_EMRTEXT cStrings; //!< Number of U_EMRTEXT in array U_EMRTEXT emrtext[1]; //!< Text parameters -} U_EMRPOLYTEXTOUTA, *PU_EMRPOLYTEXTOUTA, - U_EMRPOLYTEXTOUTW, *PU_EMRPOLYTEXTOUTW; +} U_EMRPOLYTEXTOUTA, + U_EMRPOLYTEXTOUTW, //!< EMF manual 2.3.5.33 + *PU_EMRPOLYTEXTOUTA, //!< EMF manual 2.3.5.32 + *PU_EMRPOLYTEXTOUTW; //!< EMF manual 2.3.5.33 /* Index 98 (see 17) */ /* Index 99 */ +/** EMF manual 2.3.7.2 +*/ typedef struct { U_EMR emr; //!< U_EMR uint32_t ihCS; //!< Index to place object in EMF object table (this entry must not yet exist) U_LOGCOLORSPACEA lcs; //!< ColorSpace parameters -} U_EMRCREATECOLORSPACE, *PU_EMRCREATECOLORSPACE; +} U_EMRCREATECOLORSPACE, + *PU_EMRCREATECOLORSPACE; //!< EMF manual 2.3.7.2 /* Index 100,101 */ +/** EMF manual 2.3.8.2 +*/ typedef struct { U_EMR emr; //!< U_EMR uint32_t ihCS; //!< Index of object in EMF object table -} U_EMRDELETECOLORSPACE, *PU_EMRDELETECOLORSPACE, - U_EMRSETCOLORSPACE, *PU_EMRSETCOLORSPACE; +} U_EMRDELETECOLORSPACE, + U_EMRSETCOLORSPACE, //!< EMF manual 2.3.8.7 + *PU_EMRDELETECOLORSPACE, //!< EMF manual 2.3.8.2 + *PU_EMRSETCOLORSPACE; //!< EMF manual 2.3.8.7 /* Index 102 */ +/** EMF manual 2.3.9.2 +*/ typedef struct { U_EMR emr; //!< U_EMR U_CBDATA cbData; //!< Size of OpenGL data in bytes U_DATA Data[1]; //!< OpenGL data -} U_EMRGLSRECORD, *PU_EMRGLSRECORD; +} U_EMRGLSRECORD, + *PU_EMRGLSRECORD; //!< EMF manual 2.3.9.2 /* Index 103 */ +/** EMF manual 2.3.9.1 +*/ typedef struct { U_EMR emr; //!< U_EMR U_RECTL rclBounds; //!< Bounding rectangle in device units U_CBDATA cbData; //!< Size of OpenGL data in bytes U_DATA Data[1]; //!< OpenGL data -} U_EMRGLSBOUNDEDRECORD, *PU_EMRGLSBOUNDEDRECORD; +} U_EMRGLSBOUNDEDRECORD, + *PU_EMRGLSBOUNDEDRECORD; //!< EMF manual 2.3.9.1 /* Index 104 */ +/** EMF manual 2.3.11.5 +*/ typedef struct { U_EMR emr; //!< U_EMR U_PIXELFORMATDESCRIPTOR pfd; //!< PixelFormatDescriptor -} U_EMRPIXELFORMAT, *PU_EMRPIXELFORMAT; +} U_EMRPIXELFORMAT, + *PU_EMRPIXELFORMAT; //!< EMF manual 2.3.11.5 /* Index 105 */ +/** EMF manual 2.3.6.1 +*/ typedef struct { U_EMR emr; //!< U_EMR U_CBDATA cjIn; //!< Number of bytes to send to printer driver U_DATA Data[1]; //!< Data to send -} U_EMRDRAWESCAPE, *PU_EMRDRAWESCAPE; +} U_EMRDRAWESCAPE, + *PU_EMRDRAWESCAPE; //!< EMF manual 2.3.6.1 /* Index 106 */ +/** EMF manual 2.3.6.2 +*/ typedef struct { U_EMR emr; //!< U_EMR U_CBDATA cjIn; //!< Number of bytes to send to printer driver U_DATA Data[1]; //!< Data to send -} U_EMREXTESCAPE, *PU_EMREXTESCAPE; +} U_EMREXTESCAPE, + *PU_EMREXTESCAPE; //!< EMF manual 2.3.6.2 /* Index 107 (not implemented ) */ /* Index 108 */ +/** EMF manual 2.3.5.37 +*/ typedef struct { U_EMR emr; //!< U_EMR U_POINTL Dest; //!< Where to draw the text @@ -2459,22 +3015,34 @@ typedef struct { //!< the tail end of this record is variable. //!< U_RECTL rclBounds; Record may include optional Bounding rectangle (absent when: fuOPtions & ETO_NO_U_RECT) //!< uint32_t TextString; text to output (fuOptions & ETO_SMALL_CHARS ? 8 bit : 16 bit) -} U_EMRSMALLTEXTOUT, *PU_EMRSMALLTEXTOUT; +} U_EMRSMALLTEXTOUT, + *PU_EMRSMALLTEXTOUT; //!< EMF manual 2.3.5.37 -/* Index 109 (not implemented ) */ +/* Index 109 (not implemented ) +EMF manual 2.3.11.2 +*/ /* Index 110 */ +/** EMF manual 2.3.6.3 +*/ typedef struct { U_EMR emr; //!< U_EMR U_CBDATA cbDriver; //!< Number of bytes in driver name (note, BYTES, not CHARACTERS) U_CBDATA cbData; //!< Number of bytes in data uint16_t Driver[1]; //!< Driver name in uint16_t characters, null terminated uint8_t Data[1]; //!< Data for printer driver -} U_EMRNAMEDESCAPE, *PU_EMRNAMEDESCAPE; +} U_EMRNAMEDESCAPE, + *PU_EMRNAMEDESCAPE; //!< EMF manual 2.3.6.3 -/* Index 111-113 (not implemented ) */ +/* Index 111-113 (not implemented ) + EMF manual 2.3.8.1 + EMF manual 2.3.11.15 + EMF manual 2.3.11.16 +*/ /* Index 114 */ +/** EMF manual 2.3.1.1 +*/ typedef struct { U_EMR emr; //!< U_EMR U_RECTL rclBounds; //!< Bounding rectangle in device units @@ -2491,11 +3059,14 @@ typedef struct { U_CBBITS cbBitsSrc; //!< Size in bytes of bitmap U_POINTL cSrc; //!< Source W & H in logical units //!< Record may include optional DIB bitmap -} U_EMRALPHABLEND, *PU_EMRALPHABLEND; +} U_EMRALPHABLEND, + *PU_EMRALPHABLEND; //!< EMF manual 2.3.1.1 /* Index 115 (see 17) */ -/* Index 116 */ +/* Index 116 */ +/** EMF manual 2.3.1.8 +*/ typedef struct { U_EMR emr; //!< U_EMR U_RECTL rclBounds; //!< Bounding rectangle in device units @@ -2512,11 +3083,14 @@ typedef struct { U_CBBITS cbBitsSrc; //!< Size in bytes of bitmap U_POINTL cSrc; //!< Source W & H in logical units //!< Record may includes optional bitmapbuffer -} U_EMRTRANSPARENTBLT, *PU_EMRTRANSPARENTBLT; +} U_EMRTRANSPARENTBLT, + *PU_EMRTRANSPARENTBLT; //!< EMF manual 2.3.1.8 /* Index 117 (not a defined U_EMR record type ) */ /* Index 118 */ +/** EMF manual 2.3.5.12 +*/ typedef struct { U_EMR emr; //!< U_EMR U_RECTL rclBounds; //!< Bounding rectangle in device units @@ -2526,21 +3100,30 @@ typedef struct { //parts that are required but which are not included in the core structure // U_TRIVERTEX TriVert[1]; Array of TriVertex objects // uint32_t GradObj[1]; Array of gradient objects (each has 2 or 3 indices into TriVert array) -} U_EMRGRADIENTFILL, *PU_EMRGRADIENTFILL; +} U_EMRGRADIENTFILL, + *PU_EMRGRADIENTFILL; //!< EMF manual 2.3.5.12 -/* Index 119,120 (not implemented ) */ +/* Index 119,120 (not implemented ) +EMF manual 2.3.11.18 +EMF manual 2.3.11.27 +*/ /* Index 121 */ +/** EMF manual 2.3.11.1 +*/ typedef struct { U_EMR emr; //!< U_EMR uint32_t dwAction; //!< ColorSpace Enumeration uint32_t dwFlags; //!< ColorMatchToTarget Enumeration - U_CBNAME cbName; //!< Number of bytes in in UTF16 name of the color profile + U_CBNAME cbName; //!< Number of bytes in UTF16 name of the color profile U_CBDATA cbData; //!< Number of bytes of the target profile uint8_t Data[1]; //!< Data of size cbName+cbData: Name in UTF16 then color profile data -} U_EMRCOLORMATCHTOTARGETW, *PU_EMRCOLORMATCHTOTARGETW; +} U_EMRCOLORMATCHTOTARGETW, + *PU_EMRCOLORMATCHTOTARGETW; //!< EMF manual 2.3.11.1 /* Index 122 */ +/** EMF manual 2.3.7.3 +*/ typedef struct { U_EMR emr; //!< U_EMR uint32_t ihCS; //!< Index of the logical color space object in the EMF object table @@ -2548,11 +3131,15 @@ typedef struct { uint32_t dwFlags; //!< If low bit set Data is present U_CBDATA cbData; //!< Number of bytes of theData field. uint8_t Data[1]; //!< (Optional, dwFlags & 1) color profile data -} U_EMRCREATECOLORSPACEW, *PU_EMRCREATECOLORSPACEW; +} U_EMRCREATECOLORSPACEW, + *PU_EMRCREATECOLORSPACEW; //!< EMF manual 2.3.7.3 // ************************************************************************************************ // Utility function structures +/** + Storage for keeping track of properties of the growing EMF file as records are added. +*/ typedef struct { FILE *fp; //!< Open file size_t allocated; //!< Size of the buffer @@ -2592,11 +3179,13 @@ typedef struct { double M12; //!< Matrix element 1,2 double M21; //!< Matrix element 2,1 double M22; //!< Matrix element 2,2 -} U_MAT2X2, *PU_MAT2X2; +} U_MAT2X2, + *PU_MAT2X2; //!< 2 x 2 matrix, used by xform_alt_set() function. // ************************************************************************************************ // Prototypes +//! \cond int memprobe(const void *buf, size_t size); void wchar8show(const char *src); void wchar16show(const uint16_t *src); @@ -2868,8 +3457,9 @@ char *U_EMRSMALLTEXTOUT_set(const U_POINTL Dest, const U_NUM_STR cChars, const u // U_EMRFORCEUFIMAPPING_set 109 Not implemented // U_EMRNAMEDESCAPE_set 110 Not implemented // U_EMRCOLORCORRECTPALETTE_set 111 Not implemented -// U_EMRSETICMPROFILEA_set 112 Not implemented -// U_EMRSETICMPROFILEW_set 113 Not implemented +// U_EMRSETICMPROFILEA_set 112 Not implemented +// U_EMRSETICMPROFILEW_set 113 Not implemented + char *U_EMRALPHABLEND_set(const U_RECTL rclBounds, const U_POINTL Dest, const U_POINTL cDest, const U_POINTL Src, const U_POINTL cSrc, const U_XFORM xformSrc, const U_COLORREF crBkColorSrc, const uint32_t iUsageSrc, @@ -2889,6 +3479,8 @@ char *U_EMRGRADIENTFILL_set(const U_RECTL rclBounds, const U_NUM_TRIVERTEX nTriV char *U_EMRCREATECOLORSPACEW_set(const uint32_t ihCS, const U_LOGCOLORSPACEW lcs, const uint32_t dwFlags, const U_CBDATA cbData, const uint8_t *Data); +//! \endcond + #ifdef __cplusplus } #endif diff --git a/src/libuemf/uemf_endian.c b/src/libuemf/uemf_endian.c index cdae07a3d..f025416c3 100644 --- a/src/libuemf/uemf_endian.c +++ b/src/libuemf/uemf_endian.c @@ -1,5 +1,7 @@ /** - @file uemf_endian.c Functions for converting EMF records between Big Endian and Little Endian + @file uemf_endian.c + + @brief Functions for converting EMF records between Big Endian and Little Endian byte orders. EMF files use Little Endian order. On a Big Endian machine the data must be converted to/from Little Endian when it is writen to/read from a file. @@ -16,12 +18,12 @@ */ /* -File: uemf_endian.h -Version: 0.0.12 -Date: 14-FEB-2013 +File: uemf_endian.c +Version: 0.0.14 +Date: 15-JAN-2014 Author: David Mathog, Biology Division, Caltech email: mathog@caltech.edu -Copyright: 2013 David Mathog and California Institute of Technology (Caltech) +Copyright: 2014 David Mathog and California Institute of Technology (Caltech) */ #ifdef __cplusplus @@ -35,7 +37,7 @@ extern "C" { #include "uemf_endian.h" // hide almost everuything in here from Doxygen -//! @cond +//! \cond /* ********************************************************************************************** These functions convert standard objects used in the EMR records. @@ -1095,7 +1097,7 @@ void U_EMRABORTPATH_swap(char *record, int torev){ } // U_EMRUNDEF69 69 -#define U_EMRUNDEF69_swap U_EMRNOTIMPLEMENTED_swap +#define U_EMRUNDEF69_swap(A,B) U_EMRNOTIMPLEMENTED_swap(A,B) //!< Not implemented. // U_EMRCOMMENT 70 Comment (any binary data, interpretation is program specific) void U_EMRCOMMENT_swap(char *record, int torev){ @@ -1458,9 +1460,9 @@ void U_EMREXTCREATEPEN_swap(char *record, int torev){ } // U_EMRPOLYTEXTOUTA 96 NOT IMPLEMENTED, denigrated after Windows NT -#define U_EMRPOLYTEXTOUTA_swap U_EMRNOTIMPLEMENTED_swap +#define U_EMRPOLYTEXTOUTA_swap(A,B) U_EMRNOTIMPLEMENTED_swap(A,B) //!< Not implemented. // U_EMRPOLYTEXTOUTW 97 NOT IMPLEMENTED, denigrated after Windows NT -#define U_EMRPOLYTEXTOUTW_swap U_EMRNOTIMPLEMENTED_swap +#define U_EMRPOLYTEXTOUTW_swap(A,B) U_EMRNOTIMPLEMENTED_swap(A,B) //!< Not implemented. // U_EMRSETICMMODE 98 void U_EMRSETICMMODE_swap(char *record, int torev){ @@ -1486,9 +1488,9 @@ void U_EMRDELETECOLORSPACE_swap(char *record, int torev){ } // U_EMRGLSRECORD 102 Not implemented -#define U_EMRGLSRECORD_swap U_EMRNOTIMPLEMENTED_swap +#define U_EMRGLSRECORD_swap(A,B) U_EMRNOTIMPLEMENTED_swap(A,B) //!< Not implemented. // U_EMRGLSBOUNDEDRECORD 103 Not implemented -#define U_EMRGLSBOUNDEDRECORD_swap U_EMRNOTIMPLEMENTED_swap +#define U_EMRGLSBOUNDEDRECORD_swap(A,B) U_EMRNOTIMPLEMENTED_swap(A,B) //!< Not implemented. // U_EMRPIXELFORMAT 104 void U_EMRPIXELFORMAT_swap(char *record, int torev){ @@ -1498,11 +1500,11 @@ void U_EMRPIXELFORMAT_swap(char *record, int torev){ } // U_EMRDRAWESCAPE 105 Not implemented -#define U_EMRDRAWESCAPE_swap U_EMRNOTIMPLEMENTED_swap +#define U_EMRDRAWESCAPE_swap(A,B) U_EMRNOTIMPLEMENTED_swap(A,B) //!< Not implemented. // U_EMREXTESCAPE 106 Not implemented -#define U_EMREXTESCAPE_swap U_EMRNOTIMPLEMENTED_swap +#define U_EMREXTESCAPE_swap(A,B) U_EMRNOTIMPLEMENTED_swap(A,B) //!< Not implemented. // U_EMRUNDEF107 107 Not implemented -#define U_EMRUNDEF107_swap U_EMRNOTIMPLEMENTED_swap +#define U_EMRUNDEF107_swap(A,B) U_EMRNOTIMPLEMENTED_swap(A,B) //!< Not implemented. // U_EMRSMALLTEXTOUT 108 void U_EMRSMALLTEXTOUT_swap(char *record, int torev){ @@ -1526,15 +1528,15 @@ void U_EMRSMALLTEXTOUT_swap(char *record, int torev){ } // U_EMRFORCEUFIMAPPING 109 Not implemented -#define U_EMRFORCEUFIMAPPING_swap U_EMRNOTIMPLEMENTED_swap +#define U_EMRFORCEUFIMAPPING_swap(A,B) U_EMRNOTIMPLEMENTED_swap(A,B) //!< Not implemented. // U_EMRNAMEDESCAPE 110 Not implemented -#define U_EMRNAMEDESCAPE_swap U_EMRNOTIMPLEMENTED_swap +#define U_EMRNAMEDESCAPE_swap(A,B) U_EMRNOTIMPLEMENTED_swap(A,B) //!< Not implemented. // U_EMRCOLORCORRECTPALETTE 111 Not implemented -#define U_EMRCOLORCORRECTPALETTE_swap U_EMRNOTIMPLEMENTED_swap +#define U_EMRCOLORCORRECTPALETTE_swap(A,B) U_EMRNOTIMPLEMENTED_swap(A,B) //!< Not implemented. // U_EMRSETICMPROFILEA 112 Not implemented -#define U_EMRSETICMPROFILEA_swap U_EMRNOTIMPLEMENTED_swap +#define U_EMRSETICMPROFILEA_swap(A,B) U_EMRNOTIMPLEMENTED_swap(A,B) //!< Not implemented. // U_EMRSETICMPROFILEW 113 Not implemented -#define U_EMRSETICMPROFILEW_swap U_EMRNOTIMPLEMENTED_swap +#define U_EMRSETICMPROFILEW_swap(A,B) U_EMRNOTIMPLEMENTED_swap(A,B) //!< Not implemented. // U_EMRALPHABLEND 114 void U_EMRALPHABLEND_swap(char *record, int torev){ @@ -1553,7 +1555,7 @@ void U_EMRTRANSPARENTBLT_swap(char *record, int torev){ // U_EMRUNDEF117 117 Not implemented -#define U_EMRUNDEF117_swap U_EMRNOTIMPLEMENTED_swap +#define U_EMRUNDEF117_swap(A,B) U_EMRNOTIMPLEMENTED_swap(A,B) //!< Not implemented. // U_EMRGRADIENTFILL 118 void U_EMRGRADIENTFILL_swap(char *record, int torev){ int nTriVert=0; @@ -1589,11 +1591,11 @@ void U_EMRGRADIENTFILL_swap(char *record, int torev){ } // U_EMRSETLINKEDUFIS 119 Not implemented -#define U_EMRSETLINKEDUFIS_swap U_EMRNOTIMPLEMENTED_swap +#define U_EMRSETLINKEDUFIS_swap(A,B) U_EMRNOTIMPLEMENTED_swap(A,B) //!< Not implemented. // U_EMRSETTEXTJUSTIFICATION120 Not implemented (denigrated) -#define U_EMRSETTEXTJUSTIFICATION_swap U_EMRNOTIMPLEMENTED_swap +#define U_EMRSETTEXTJUSTIFICATION_swap(A,B) U_EMRNOTIMPLEMENTED_swap(A,B) //!< Not implemented. // U_EMRCOLORMATCHTOTARGETW 121 Not implemented -#define U_EMRCOLORMATCHTOTARGETW_swap U_EMRNOTIMPLEMENTED_swap +#define U_EMRCOLORMATCHTOTARGETW_swap(A,B) U_EMRNOTIMPLEMENTED_swap(A,B) //!< Not implemented. // U_EMRCREATECOLORSPACEW 122 void U_EMRCREATECOLORSPACEW_swap(char *record, int torev){ @@ -1605,7 +1607,7 @@ void U_EMRCREATECOLORSPACEW_swap(char *record, int torev){ // ordered bytes: Data } -//! @endcond +//! \endcond /** @@ -1619,7 +1621,7 @@ void U_EMRCREATECOLORSPACEW_swap(char *record, int torev){ or immediately after reading the data from a file. */ int U_emf_endian(char *contents, size_t length, int torev){ - size_t off; + uint32_t off; uint32_t OK, recnum, iType; char *record; PU_ENHMETARECORD pEmr; diff --git a/src/libuemf/uemf_endian.h b/src/libuemf/uemf_endian.h index 9866aacaf..317968c34 100644 --- a/src/libuemf/uemf_endian.h +++ b/src/libuemf/uemf_endian.h @@ -1,5 +1,7 @@ /** - @file uemf_endian.h Prototype for function for converting EMF records between Big Endian and Little Endian + @file uemf_endian.h + + @brief Defintions and prototype for function for converting EMF records between Big Endian and Little Endian byte orders. */ /* @@ -18,17 +20,36 @@ Copyright: 2012 David Mathog and California Institute of Technology (Caltech) extern "C" { #endif -/* There is no way for the preprocessor, in general, to figure out endianness. So the command line must define +/** \defgroup U_Endian Byte order identification + + There is no way for the preprocessor, in general, to figure out endianness. So the command line must define WORDS_BIGENDIAN for a big endian machine. Otherwise we assume is is little endian. If it is something - else this code won't work in any case. */ + else this code won't work in any case. + + @{ +*/ + #ifdef WORDS_BIGENDIAN -#define U_BYTE_SWAP 1 +#define U_BYTE_SWAP 1 //!< byte swapping into metafile is required +#define U_IS_BE 1 //!< this machine is big endian +#define U_IS_LE 0 //!< this machine is not little endian #else -#define U_BYTE_SWAP 0 +#define U_BYTE_SWAP 0 //!< byte swapping into metafile is not required +#define U_IS_BE 0 //!< this machine is not big endian +#define U_IS_LE 1 //!< this machine is little endian #endif +#define U_XE 0 //!< do not rearrange endian for target +#define U_LE 1 //!< target is Little Endian +#define U_BE 2 //!< target is Big Endian +#define U_RP 4 //!< replicate first instance +#define U_XX 0xFF //!< may be used to terminate a list of these target entries +/** @} */ + +//! \cond // prototypes int U_emf_endian(char *contents, size_t length, int torev); +//! \endcond #ifdef __cplusplus } diff --git a/src/libuemf/uemf_print.c b/src/libuemf/uemf_print.c index b7cbf9a14..aa574bd73 100644 --- a/src/libuemf/uemf_print.c +++ b/src/libuemf/uemf_print.c @@ -1,11 +1,13 @@ /** - @file uemf_print.c Functions for printing EMF records + @file uemf_print.c + + @brief Functions for printing EMF records */ /* File: uemf_print.c -Version: 0.0.12 -Date: 04-FEB-2013 +Version: 0.0.15 +Date: 17-OCT-2013 Author: David Mathog, Biology Division, Caltech email: mathog@caltech.edu Copyright: 2013 David Mathog and California Institute of Technology (Caltech) @@ -20,6 +22,14 @@ extern "C" { #include /* for offsetof() macro */ #include #include "uemf.h" +#include "upmf_print.h" + +//! \cond +#define UNUSED(x) (void)(x) + +/* one needed prototype */ +void U_swap4(void *ul, unsigned int count); +//! \endcond /** \brief Print some number of hex bytes @@ -395,7 +405,7 @@ void blend_print( void extlogpen_print( PU_EXTLOGPEN elp ){ - unsigned i; + unsigned int i; U_STYLEENTRY *elpStyleEntry; printf("elpPenStyle:0x%8.8X " ,elp->elpPenStyle ); printf("elpWidth:%u " ,elp->elpWidth ); @@ -407,7 +417,7 @@ void extlogpen_print( printf("elpStyleEntry:"); elpStyleEntry = (uint32_t *) elp->elpStyleEntry; for(i=0;ielpNumEntries;i++){ - printf("%u:%u ",i,elpStyleEntry[i]); + printf("%d:%u ",i,elpStyleEntry[i]); } } } @@ -420,7 +430,7 @@ void extlogpen_print( void logpen_print( U_LOGPEN lp ){ - printf("lopnStyle:%u " ,lp.lopnStyle ); + printf("lopnStyle:0x%8.8X " ,lp.lopnStyle ); printf("lopnWidth:"); pointl_print( lp.lopnWidth ); printf("lopnColor:"); colorref_print(lp.lopnColor ); } @@ -478,13 +488,13 @@ void rgndataheader_print( void rgndata_print( PU_RGNDATA rd ){ - unsigned i; + unsigned int i; PU_RECTL rects; printf("rdh:"); rgndataheader_print(rd->rdh ); if(rd->rdh.nCount){ rects = (PU_RECTL) &(rd->Buffer); for(i=0;irdh.nCount;i++){ - printf("%u:",i); rectl_print(rects[i]); + printf("%d:",i); rectl_print(rects[i]); } } } @@ -497,7 +507,7 @@ void coloradjustment_print( U_COLORADJUSTMENT ca ){ printf("caSize:%u " ,ca.caSize ); - printf("caFlags:%u " ,ca.caFlags ); + printf("caFlags:0x%4.4X " ,ca.caFlags ); printf("caIlluminantIndex:%u " ,ca.caIlluminantIndex); printf("caRedGamma:%u " ,ca.caRedGamma ); printf("caGreenGamma:%u " ,ca.caGreenGamma ); @@ -519,7 +529,7 @@ void pixelformatdescriptor_print( ){ printf("nSize:%u " ,pfd.nSize ); printf("nVersion:%u " ,pfd.nVersion ); - printf("dwFlags:%u " ,pfd.dwFlags ); + printf("dwFlags:0x%8.8X " ,pfd.dwFlags ); printf("iPixelType:%u " ,pfd.iPixelType ); printf("cColorBits:%u " ,pfd.cColorBits ); printf("cRedBits:%u " ,pfd.cRedBits ); @@ -556,7 +566,7 @@ void emrtext_print( const char *record, int type ){ - unsigned i, off; + unsigned int i,off; char *string; PU_EMRTEXT pemt = (PU_EMRTEXT) emt; // constant part @@ -573,7 +583,7 @@ void emrtext_print( free(string); } } - printf("fOptions:%u " ,pemt->fOptions ); + printf("fOptions:0x%8.8X " ,pemt->fOptions ); off = sizeof(U_EMRTEXT); if(!(pemt->fOptions & U_ETO_NO_RECT)){ printf("rcl"); rectl_print( *((U_RECTL *)(emt+off)) ); @@ -609,35 +619,35 @@ by end user code and to further that end prototypes are NOT provided and they ar // Functions with the same form starting with U_EMRPOLYBEZIER_print void core1_print(const char *name, const char *contents){ - unsigned i; - (void) name; + unsigned int i; + UNUSED(name); PU_EMRPOLYLINETO pEmr = (PU_EMRPOLYLINETO) (contents); printf(" rclBounds: "); rectl_print(pEmr->rclBounds); printf("\n"); printf(" cptl: %d\n",pEmr->cptl ); printf(" Points: "); for(i=0;icptl; i++){ - printf("[%u]:",i); pointl_print(pEmr->aptl[i]); + printf("[%d]:",i); pointl_print(pEmr->aptl[i]); } printf("\n"); } // Functions with the same form starting with U_EMRPOLYPOLYLINE_print void core2_print(const char *name, const char *contents){ - unsigned i; - (void) name; + unsigned int i; + UNUSED(name); PU_EMRPOLYPOLYGON pEmr = (PU_EMRPOLYPOLYGON) (contents); printf(" rclBounds: "); rectl_print(pEmr->rclBounds); printf("\n"); printf(" nPolys: %d\n",pEmr->nPolys ); printf(" cptl: %d\n",pEmr->cptl ); printf(" Counts: "); for(i=0;inPolys; i++){ - printf(" [%u]:%d ",i,pEmr->aPolyCounts[i] ); + printf(" [%d]:%d ",i,pEmr->aPolyCounts[i] ); } printf("\n"); PU_POINTL paptl = (PU_POINTL)((char *)pEmr->aPolyCounts + sizeof(uint32_t)* pEmr->nPolys); printf(" Points: "); for(i=0;icptl; i++){ - printf(" [%u]:",i); pointl_print(paptl[i]); + printf(" [%d]:",i); pointl_print(paptl[i]); } printf("\n"); } @@ -645,8 +655,8 @@ void core2_print(const char *name, const char *contents){ // Functions with the same form starting with U_EMRSETMAPMODE_print void core3_print(const char *name, const char *label, const char *contents){ + UNUSED(name); PU_EMRSETMAPMODE pEmr = (PU_EMRSETMAPMODE)(contents); - (void) name; if(!strcmp(label,"crColor:")){ printf(" %-15s ",label); colorref_print(*(U_COLORREF *)&(pEmr->iMode)); printf("\n"); } @@ -660,22 +670,22 @@ void core3_print(const char *name, const char *label, const char *contents){ // Functions taking a single U_RECT or U_RECTL, starting with U_EMRELLIPSE_print, also U_EMRFILLPATH_print, void core4_print(const char *name, const char *contents){ + UNUSED(name); PU_EMRELLIPSE pEmr = (PU_EMRELLIPSE)( contents); - (void) name; printf(" rclBox: "); rectl_print(pEmr->rclBox); printf("\n"); } // Functions with the same form starting with U_EMRPOLYBEZIER16_print void core6_print(const char *name, const char *contents){ - unsigned i; - (void) name; + UNUSED(name); + unsigned int i; PU_EMRPOLYBEZIER16 pEmr = (PU_EMRPOLYBEZIER16) (contents); printf(" rclBounds: "); rectl_print(pEmr->rclBounds); printf("\n"); printf(" cpts: %d\n",pEmr->cpts ); printf(" Points: "); PU_POINT16 papts = (PU_POINT16)(&(pEmr->apts)); for(i=0; icpts; i++){ - printf(" [%u]:",i); point16_print(papts[i]); + printf(" [%d]:",i); point16_print(papts[i]); } printf("\n"); } @@ -686,8 +696,8 @@ void core6_print(const char *name, const char *contents){ // print routines must supply the names of the two arguments. These cannot be null. If the second one is // empty the values are printed as a pair {x,y}, otherwise each is printed with its own label on a separate line. void core7_print(const char *name, const char *field1, const char *field2, const char *contents){ + UNUSED(name); PU_EMRGENERICPAIR pEmr = (PU_EMRGENERICPAIR) (contents); - (void) name; if(*field2){ printf(" %-15s %d\n",field1,pEmr->pair.x); printf(" %-15s %d\n",field2,pEmr->pair.y); @@ -699,8 +709,8 @@ void core7_print(const char *name, const char *field1, const char *field2, const // For U_EMREXTTEXTOUTA and U_EMREXTTEXTOUTW, type=0 for the first one void core8_print(const char *name, const char *contents, int type){ + UNUSED(name); PU_EMREXTTEXTOUTA pEmr = (PU_EMREXTTEXTOUTA) (contents); - (void) name; printf(" iGraphicsMode: %u\n",pEmr->iGraphicsMode ); printf(" rclBounds: "); rectl_print(pEmr->rclBounds); printf("\n"); printf(" exScale: %f\n",pEmr->exScale ); @@ -712,8 +722,8 @@ void core8_print(const char *name, const char *contents, int type){ // Functions that take a rect and a pair of points, starting with U_EMRARC_print void core9_print(const char *name, const char *contents){ + UNUSED(name); PU_EMRARC pEmr = (PU_EMRARC) (contents); - (void) name; printf(" rclBox: "); rectl_print(pEmr->rclBox); printf("\n"); printf(" ptlStart: "); pointl_print(pEmr->ptlStart); printf("\n"); printf(" ptlEnd: "); pointl_print(pEmr->ptlEnd); printf("\n"); @@ -721,21 +731,21 @@ void core9_print(const char *name, const char *contents){ // Functions with the same form starting with U_EMRPOLYPOLYLINE16_print void core10_print(const char *name, const char *contents){ - unsigned i; + UNUSED(name); + unsigned int i; PU_EMRPOLYPOLYLINE16 pEmr = (PU_EMRPOLYPOLYLINE16) (contents); - (void) name; printf(" rclBounds: "); rectl_print(pEmr->rclBounds); printf("\n"); printf(" nPolys: %d\n",pEmr->nPolys ); printf(" cpts: %d\n",pEmr->cpts ); printf(" Counts: "); for(i=0;inPolys; i++){ - printf(" [%u]:%d ",i,pEmr->aPolyCounts[i] ); + printf(" [%d]:%d ",i,pEmr->aPolyCounts[i] ); } printf("\n"); printf(" Points: "); PU_POINT16 papts = (PU_POINT16)((char *)pEmr->aPolyCounts + sizeof(uint32_t)* pEmr->nPolys); for(i=0; icpts; i++){ - printf(" [%u]:",i); point16_print(papts[i]); + printf(" [%d]:",i); point16_print(papts[i]); } printf("\n"); @@ -743,17 +753,17 @@ void core10_print(const char *name, const char *contents){ // Functions with the same form starting with U_EMRINVERTRGN_print and U_EMRPAINTRGN_print, void core11_print(const char *name, const char *contents){ - unsigned i,roff; + UNUSED(name); + unsigned int i,roff; PU_EMRINVERTRGN pEmr = (PU_EMRINVERTRGN) (contents); - (void) name; printf(" rclBounds: "); rectl_print(pEmr->rclBounds); printf("\n"); printf(" cbRgnData: %d\n",pEmr->cbRgnData); // This one is a pain since each RGNDATA may be a different size, so it isn't possible to index through them. roff=0; i=1; char *prd = (char *) &(pEmr->RgnData); - while(roff + 28 < pEmr->emr.nSize){ // up to the end of the record - printf(" RegionData:%u",i); + while(roff + sizeof(U_RGNDATAHEADER) < pEmr->cbRgnData){ // stop at end of the record 4*4 = header + 4*4=rect + printf(" RegionData:%d",i); rgndata_print((PU_RGNDATA) (prd + roff)); roff += (((PU_RGNDATA)prd)->rdh.dwSize + ((PU_RGNDATA)prd)->rdh.nRgnSize - 16); printf("\n"); @@ -763,8 +773,8 @@ void core11_print(const char *name, const char *contents){ // common code for U_EMRCREATEMONOBRUSH_print and U_EMRCREATEDIBPATTERNBRUSHPT_print, void core12_print(const char *name, const char *contents){ + UNUSED(name); PU_EMRCREATEMONOBRUSH pEmr = (PU_EMRCREATEMONOBRUSH) (contents); - (void) name; printf(" ihBrush: %u\n",pEmr->ihBrush ); printf(" iUsage : %u\n",pEmr->iUsage ); printf(" offBmi : %u\n",pEmr->offBmi ); @@ -780,8 +790,8 @@ void core12_print(const char *name, const char *contents){ // common code for U_EMRALPHABLEND_print and U_EMRTRANSPARENTBLT_print, void core13_print(const char *name, const char *contents){ + UNUSED(name); PU_EMRALPHABLEND pEmr = (PU_EMRALPHABLEND) (contents); - (void) name; printf(" rclBounds: "); rectl_print( pEmr->rclBounds); printf("\n"); printf(" Dest: "); pointl_print(pEmr->Dest); printf("\n"); printf(" cDest: "); pointl_print(pEmr->cDest); printf("\n"); @@ -814,8 +824,8 @@ They are listed in order by the corresponding U_EMR_* index number. \param contents pointer to a buffer holding all EMR records */ void U_EMRNOTIMPLEMENTED_print(const char *name, const char *contents){ - (void) name; - (void) contents; + UNUSED(name); + UNUSED(contents); printf(" Not Implemented!\n"); } @@ -1016,7 +1026,7 @@ void U_EMRSETPIXELV_print(const char *contents){ */ void U_EMRSETMAPPERFLAGS_print(const char *contents){ PU_EMRSETMAPPERFLAGS pEmr = (PU_EMRSETMAPPERFLAGS)(contents); - printf(" dwFlags: %u\n",pEmr->dwFlags); + printf(" dwFlags: 0x%8.8X\n",pEmr->dwFlags); } @@ -1128,7 +1138,7 @@ void U_EMRMOVETOEX_print(const char *contents){ \param contents pointer to a buffer holding all EMR records */ void U_EMRSETMETARGN_print(const char *contents){ - (void) contents; + UNUSED(contents); } // U_EMREXCLUDECLIPRECT 29 @@ -1174,7 +1184,7 @@ void U_EMRSCALEWINDOWEXTEX_print(const char *contents){ \param contents pointer to a buffer holding all EMR records */ void U_EMRSAVEDC_print(const char *contents){ - (void) contents; + UNUSED(contents); } // U_EMRRESTOREDC 34 @@ -1353,7 +1363,7 @@ void U_EMRCREATEPALETTE_print(const char *contents){ \param contents pointer to a buffer holding all EMR records */ void U_EMRSETPALETTEENTRIES_print(const char *contents){ - unsigned i; + unsigned int i; PU_EMRSETPALETTEENTRIES pEmr = (PU_EMRSETPALETTEENTRIES)(contents); printf(" ihPal: %u\n",pEmr->ihPal); printf(" iStart: %u\n",pEmr->iStart); @@ -1362,7 +1372,7 @@ void U_EMRSETPALETTEENTRIES_print(const char *contents){ printf(" PLTEntries:"); PU_LOGPLTNTRY aPalEntries = (PU_LOGPLTNTRY) &(pEmr->aPalEntries); for(i=0; icEntries; i++){ - printf("%u:",i); logpltntry_print(aPalEntries[i]); + printf("%d:",i); logpltntry_print(aPalEntries[i]); } printf("\n"); } @@ -1383,7 +1393,7 @@ void U_EMRRESIZEPALETTE_print(const char *contents){ \param contents pointer to a buffer holding all EMR records */ void U_EMRREALIZEPALETTE_print(const char *contents){ - (void) contents; + UNUSED(contents); } // U_EMREXTFLOODFILL 53 @@ -1422,19 +1432,19 @@ void U_EMRARCTO_print(const char *contents){ \param contents pointer to a buffer holding all EMR records */ void U_EMRPOLYDRAW_print(const char *contents){ - unsigned i; + unsigned int i; PU_EMRPOLYDRAW pEmr = (PU_EMRPOLYDRAW)(contents); printf(" rclBounds: "); rectl_print( pEmr->rclBounds); printf("\n"); printf(" cptl: %d\n",pEmr->cptl ); printf(" Points: "); for(i=0;icptl; i++){ - printf(" [%u]:",i); + printf(" [%d]:",i); pointl_print(pEmr->aptl[i]); } printf("\n"); printf(" Types: "); for(i=0;icptl; i++){ - printf(" [%u]:%u ",i,pEmr->abTypes[i]); + printf(" [%d]:%u ",i,pEmr->abTypes[i]); } printf("\n"); } @@ -1464,7 +1474,7 @@ void U_EMRSETMITERLIMIT_print(const char *contents){ \param contents pointer to a buffer holding all EMR records */ void U_EMRBEGINPATH_print(const char *contents){ - (void) contents; + UNUSED(contents); } // U_EMRENDPATH 60 @@ -1473,7 +1483,7 @@ void U_EMRBEGINPATH_print(const char *contents){ \param contents pointer to a buffer holding all EMR records */ void U_EMRENDPATH_print(const char *contents){ - (void) contents; + UNUSED(contents); } // U_EMRCLOSEFIGURE 61 @@ -1482,7 +1492,7 @@ void U_EMRENDPATH_print(const char *contents){ \param contents pointer to a buffer holding all EMR records */ void U_EMRCLOSEFIGURE_print(const char *contents){ - (void) contents; + UNUSED(contents); } // U_EMRFILLPATH 62 @@ -1518,7 +1528,7 @@ void U_EMRSTROKEPATH_print(const char *contents){ \param contents pointer to a buffer holding all EMR records */ void U_EMRFLATTENPATH_print(const char *contents){ - (void) contents; + UNUSED(contents); } // U_EMRWIDENPATH 66 @@ -1527,7 +1537,7 @@ void U_EMRFLATTENPATH_print(const char *contents){ \param contents pointer to a buffer holding all EMR records */ void U_EMRWIDENPATH_print(const char *contents){ - (void) contents; + UNUSED(contents); } // U_EMRSELECTCLIPPATH 67 @@ -1545,41 +1555,57 @@ void U_EMRSELECTCLIPPATH_print(const char *contents){ \param contents pointer to a buffer holding all EMR records */ void U_EMRABORTPATH_print(const char *contents){ - (void) contents; + UNUSED(contents); } // U_EMRUNDEF69 69 -#define U_EMRUNDEF69_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRUNDEF69",A) +#define U_EMRUNDEF69_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRUNDEF69",A) //!< Not implemented. // U_EMRCOMMENT 70 Comment (any binary data, interpretation is program specific) /** \brief Print a pointer to a U_EMR_COMMENT record. - \param contents pointer to a buffer holding all EMR records + \param contents pointer to a location in memory holding the comment record + \param blimit size in bytes of the comment record + \param off offset in bytes to the first byte in this record + + EMF+ records, if any, are stored in EMF comment records. */ -void U_EMRCOMMENT_print(const char *contents){ +void U_EMRCOMMENT_print(const char *contents, const char *blimit, size_t off){ char *string; char *src; - uint32_t cIdent,cbData; - PU_EMRCOMMENT pEmr = (PU_EMRCOMMENT)(contents); + uint32_t cIdent,cIdent2,cbData; + size_t loff; + int recsize; + static int recnum=0; + + PU_EMRCOMMENT pEmr = (PU_EMRCOMMENT)(contents); /* There are several different types of comments */ cbData = pEmr->cbData; printf(" cbData: %d\n",cbData ); - src = (char *)(&pEmr->Data); // default + src = (char *)&(pEmr->Data); // default if(cbData >= 4){ + /* Since the comment is just a big bag of bytes the emf endian code cannot safely touch + any of its payload. This is the only record type with that limitation. Try to determine + what the contents are even if more byte swapping is required. */ cIdent = *(uint32_t *)(src); + if(U_BYTE_SWAP){ U_swap4(&(cIdent),1); } if( cIdent == U_EMR_COMMENT_PUBLIC ){ printf(" cIdent: Public\n"); PU_EMRCOMMENT_PUBLIC pEmrp = (PU_EMRCOMMENT_PUBLIC) pEmr; - printf(" pcIdent: %8.8x\n",pEmrp->pcIdent); + cIdent2 = pEmrp->pcIdent; + if(U_BYTE_SWAP){ U_swap4(&(cIdent2),1); } + printf(" pcIdent: 0x%8.8x\n",cIdent2); src = (char *)&(pEmrp->Data); cbData -= 8; } else if(cIdent == U_EMR_COMMENT_SPOOL ){ printf(" cIdent: Spool\n"); PU_EMRCOMMENT_SPOOL pEmrs = (PU_EMRCOMMENT_SPOOL) pEmr; - printf(" esrIdent: %8.8x\n",pEmrs->esrIdent); + cIdent2 = pEmrs->esrIdent; + if(U_BYTE_SWAP){ U_swap4(&(cIdent2),1); } + printf(" esrIdent: 0x%8.8x\n",cIdent2); src = (char *)&(pEmrs->Data); cbData -= 8; } @@ -1587,7 +1613,15 @@ void U_EMRCOMMENT_print(const char *contents){ printf(" cIdent: EMF+\n"); PU_EMRCOMMENT_EMFPLUS pEmrpl = (PU_EMRCOMMENT_EMFPLUS) pEmr; src = (char *)&(pEmrpl->Data); - cbData -= 4; + loff = 16; /* Header size of the header part of an EMF+ comment record */ + while(loff < cbData + 12){ // EMF+ records may not fill the entire comment, cbData value includes cIdent, but not U_EMR or cbData + recsize = U_pmf_onerec_print(src, blimit, recnum, loff + off); + if(recsize<=0)break; + loff += recsize; + src += recsize; + recnum++; + } + return; } else { printf(" cIdent: not (Public or Spool or EMF+)\n"); @@ -1600,7 +1634,6 @@ void U_EMRCOMMENT_print(const char *contents){ printf(" Data: <%s>\n",string); free(string); } - } // U_EMRFILLRGN 71 @@ -1609,7 +1642,7 @@ void U_EMRCOMMENT_print(const char *contents){ \param contents pointer to a buffer holding all EMR records */ void U_EMRFILLRGN_print(const char *contents){ - unsigned i,roff; + int i,roff; PU_EMRFILLRGN pEmr = (PU_EMRFILLRGN)(contents); printf(" rclBounds: "); rectl_print(pEmr->rclBounds); printf("\n"); printf(" cbRgnData: %u\n",pEmr->cbRgnData); @@ -1618,8 +1651,8 @@ void U_EMRFILLRGN_print(const char *contents){ roff=0; i=1; char *prd = (char *) &(pEmr->RgnData); - while(roff + 28 < pEmr->emr.nSize){ // up to the end of the record - printf(" RegionData[%u]: ",i); rgndata_print((PU_RGNDATA) (prd + roff)); printf("\n"); + while(roff + sizeof(U_RGNDATAHEADER) < pEmr->emr.nSize){ // up to the end of the record + printf(" RegionData[%d]: ",i); rgndata_print((PU_RGNDATA) (prd + roff)); printf("\n"); roff += (((PU_RGNDATA)prd)->rdh.dwSize + ((PU_RGNDATA)prd)->rdh.nRgnSize - 16); } } @@ -1630,7 +1663,7 @@ void U_EMRFILLRGN_print(const char *contents){ \param contents pointer to a buffer holding all EMR records */ void U_EMRFRAMERGN_print(const char *contents){ - unsigned i,roff; + int i,roff; PU_EMRFRAMERGN pEmr = (PU_EMRFRAMERGN)(contents); printf(" rclBounds: "); rectl_print(pEmr->rclBounds); printf("\n"); printf(" cbRgnData: %u\n",pEmr->cbRgnData); @@ -1640,8 +1673,8 @@ void U_EMRFRAMERGN_print(const char *contents){ roff=0; i=1; char *prd = (char *) &(pEmr->RgnData); - while(roff + 28 < pEmr->emr.nSize){ // up to the end of the record - printf(" RegionData[%u]: ",i); rgndata_print((PU_RGNDATA) (prd + roff)); printf("\n"); + while(roff + sizeof(U_RGNDATAHEADER) < pEmr->emr.nSize){ // up to the end of the record + printf(" RegionData[%d]: ",i); rgndata_print((PU_RGNDATA) (prd + roff)); printf("\n"); roff += (((PU_RGNDATA)prd)->rdh.dwSize + ((PU_RGNDATA)prd)->rdh.nRgnSize - 16); } } @@ -1670,14 +1703,14 @@ void U_EMRPAINTRGN_print(const char *contents){ \param contents pointer to a buffer holding all EMR records */ void U_EMREXTSELECTCLIPRGN_print(const char *contents){ - unsigned i,roff; + int i,roff; PU_EMREXTSELECTCLIPRGN pEmr = (PU_EMREXTSELECTCLIPRGN) (contents); printf(" cbRgnData: %u\n",pEmr->cbRgnData); printf(" iMode: %u\n",pEmr->iMode); // This one is a pain since each RGNDATA may be a different size, so it isn't possible to index through them. char *prd = (char *) &(pEmr->RgnData); i=roff=0; - while(roff + 16 < pEmr->emr.nSize){ // stop at end of the record + while(roff + sizeof(U_RGNDATAHEADER) < pEmr->cbRgnData){ // stop at end of the record 4*4 = header + 4*4=rect printf(" RegionData[%d]: ",i++); rgndata_print((PU_RGNDATA) (prd + roff)); printf("\n"); roff += (((PU_RGNDATA)prd)->rdh.dwSize + ((PU_RGNDATA)prd)->rdh.nRgnSize - 16); } @@ -1693,7 +1726,7 @@ void U_EMRBITBLT_print(const char *contents){ printf(" rclBounds: "); rectl_print( pEmr->rclBounds); printf("\n"); printf(" Dest: "); pointl_print(pEmr->Dest); printf("\n"); printf(" cDest: "); pointl_print(pEmr->cDest); printf("\n"); - printf(" dwRop : %u\n", pEmr->dwRop ); + printf(" dwRop : 0x%8.8X\n", pEmr->dwRop ); printf(" Src: "); pointl_print(pEmr->Src); printf("\n"); printf(" xformSrc: "); xform_print( pEmr->xformSrc); printf("\n"); printf(" crBkColorSrc: "); colorref_print( pEmr->crBkColorSrc); printf("\n"); @@ -1719,7 +1752,7 @@ void U_EMRSTRETCHBLT_print(const char *contents){ printf(" rclBounds: "); rectl_print( pEmr->rclBounds); printf("\n"); printf(" Dest: "); pointl_print(pEmr->Dest); printf("\n"); printf(" cDest: "); pointl_print(pEmr->cDest); printf("\n"); - printf(" dwRop : %u\n", pEmr->dwRop ); + printf(" dwRop : 0x%8.8X\n", pEmr->dwRop ); printf(" Src: "); pointl_print(pEmr->Src); printf("\n"); printf(" xformSrc: "); xform_print( pEmr->xformSrc); printf("\n"); printf(" crBkColorSrc: "); colorref_print( pEmr->crBkColorSrc); printf("\n"); @@ -1746,7 +1779,7 @@ void U_EMRMASKBLT_print(const char *contents){ printf(" rclBounds: "); rectl_print( pEmr->rclBounds); printf("\n"); printf(" Dest: "); pointl_print(pEmr->Dest); printf("\n"); printf(" cDest: "); pointl_print(pEmr->cDest); printf("\n"); - printf(" dwRop : %u\n", pEmr->dwRop ); + printf(" dwRop : 0x%8.8X\n", pEmr->dwRop ); printf(" Src: "); pointl_print(pEmr->Src); printf("\n"); printf(" xformSrc: "); xform_print( pEmr->xformSrc); printf("\n"); printf(" crBkColorSrc: "); colorref_print( pEmr->crBkColorSrc); printf("\n"); @@ -1857,7 +1890,7 @@ void U_EMRSTRETCHDIBITS_print(const char *contents){ printf(" offBitsSrc: %u\n", pEmr->offBitsSrc ); printf(" cbBitsSrc: %u\n", pEmr->cbBitsSrc ); printf(" iUsageSrc: %u\n", pEmr->iUsageSrc ); - printf(" dwRop : %u\n", pEmr->dwRop ); + printf(" dwRop : 0x%8.8X\n", pEmr->dwRop ); printf(" cDest: "); pointl_print(pEmr->cDest); printf("\n"); } @@ -1967,19 +2000,19 @@ void U_EMRPOLYPOLYGON16_print(const char *contents){ \param contents pointer to a buffer holding all EMR records */ void U_EMRPOLYDRAW16_print(const char *contents){ - unsigned i; + unsigned int i; PU_EMRPOLYDRAW16 pEmr = (PU_EMRPOLYDRAW16)(contents); printf(" rclBounds: "); rectl_print( pEmr->rclBounds); printf("\n"); printf(" cpts: %d\n",pEmr->cpts ); printf(" Points: "); for(i=0;icpts; i++){ - printf(" [%u]:",i); + printf(" [%d]:",i); point16_print(pEmr->apts[i]); } printf("\n"); printf(" Types: "); for(i=0;icpts; i++){ - printf(" [%u]:%u ",i,pEmr->abTypes[i]); + printf(" [%d]:%u ",i,pEmr->abTypes[i]); } printf("\n"); } @@ -2024,9 +2057,9 @@ void U_EMREXTCREATEPEN_print(const char *contents){ } // U_EMRPOLYTEXTOUTA 96 NOT IMPLEMENTED, denigrated after Windows NT -#define U_EMRPOLYTEXTOUTA_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRPOLYTEXTOUTA",A) +#define U_EMRPOLYTEXTOUTA_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRPOLYTEXTOUTA",A) //!< Not implemented. // U_EMRPOLYTEXTOUTW 97 NOT IMPLEMENTED, denigrated after Windows NT -#define U_EMRPOLYTEXTOUTW_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRPOLYTEXTOUTW",A) +#define U_EMRPOLYTEXTOUTW_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRPOLYTEXTOUTW",A) //!< Not implemented. // U_EMRSETICMMODE 98 /** @@ -2067,9 +2100,9 @@ void U_EMRDELETECOLORSPACE_print(const char *contents){ } // U_EMRGLSRECORD 102 Not implemented -#define U_EMRGLSRECORD_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRGLSRECORD",A) +#define U_EMRGLSRECORD_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRGLSRECORD",A) //!< Not implemented. // U_EMRGLSBOUNDEDRECORD 103 Not implemented -#define U_EMRGLSBOUNDEDRECORD_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRGLSBOUNDEDRECORD",A) +#define U_EMRGLSBOUNDEDRECORD_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRGLSBOUNDEDRECORD",A) //!< Not implemented. // U_EMRPIXELFORMAT 104 /** @@ -2082,11 +2115,11 @@ void U_EMRPIXELFORMAT_print(const char *contents){ } // U_EMRDRAWESCAPE 105 Not implemented -#define U_EMRDRAWESCAPE_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRDRAWESCAPE",A) +#define U_EMRDRAWESCAPE_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRDRAWESCAPE",A) //!< Not implemented. // U_EMREXTESCAPE 106 Not implemented -#define U_EMREXTESCAPE_print(A) U_EMRNOTIMPLEMENTED_print("U_EMREXTESCAPE",A) +#define U_EMREXTESCAPE_print(A) U_EMRNOTIMPLEMENTED_print("U_EMREXTESCAPE",A) //!< Not implemented. // U_EMRUNDEF107 107 Not implemented -#define U_EMRUNDEF107_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRUNDEF107",A) +#define U_EMRUNDEF107_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRUNDEF107",A) //!< Not implemented. // U_EMRSMALLTEXTOUT 108 /** @@ -2119,15 +2152,15 @@ void U_EMRSMALLTEXTOUT_print(const char *contents){ } // U_EMRFORCEUFIMAPPING 109 Not implemented -#define U_EMRFORCEUFIMAPPING_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRFORCEUFIMAPPING",A) +#define U_EMRFORCEUFIMAPPING_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRFORCEUFIMAPPING",A) //!< Not implemented. // U_EMRNAMEDESCAPE 110 Not implemented -#define U_EMRNAMEDESCAPE_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRNAMEDESCAPE",A) +#define U_EMRNAMEDESCAPE_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRNAMEDESCAPE",A) //!< Not implemented. // U_EMRCOLORCORRECTPALETTE 111 Not implemented -#define U_EMRCOLORCORRECTPALETTE_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRCOLORCORRECTPALETTE",A) +#define U_EMRCOLORCORRECTPALETTE_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRCOLORCORRECTPALETTE",A) //!< Not implemented. // U_EMRSETICMPROFILEA 112 Not implemented -#define U_EMRSETICMPROFILEA_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRSETICMPROFILEA",A) +#define U_EMRSETICMPROFILEA_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRSETICMPROFILEA",A) //!< Not implemented. // U_EMRSETICMPROFILEW 113 Not implemented -#define U_EMRSETICMPROFILEW_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRSETICMPROFILEW",A) +#define U_EMRSETICMPROFILEW_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRSETICMPROFILEW",A) //!< Not implemented. // U_EMRALPHABLEND 114 /** @@ -2157,14 +2190,14 @@ void U_EMRTRANSPARENTBLT_print(const char *contents){ } // U_EMRUNDEF117 117 Not implemented -#define U_EMRUNDEF117_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRUNDEF117",A) +#define U_EMRUNDEF117_print(A) U_EMRNOTIMPLEMENTED_print("U_EMRUNDEF117",A) //!< Not implemented. // U_EMRGRADIENTFILL 118 /** \brief Print a pointer to a U_EMR_GRADIENTFILL record. \param contents pointer to a buffer holding all EMR records */ void U_EMRGRADIENTFILL_print(const char *contents){ - unsigned i; + unsigned int i; PU_EMRGRADIENTFILL pEmr = (PU_EMRGRADIENTFILL)(contents); printf(" rclBounds: "); rectl_print( pEmr->rclBounds); printf("\n"); printf(" nTriVert: %u\n", pEmr->nTriVert ); @@ -2197,11 +2230,11 @@ void U_EMRGRADIENTFILL_print(const char *contents){ } // U_EMRSETLINKEDUFIS 119 Not implemented -#define U_EMRSETLINKEDUFIS_print(A) U_EMRNOTIMPLEMENTED_print("U_EMR_SETLINKEDUFIS",A) +#define U_EMRSETLINKEDUFIS_print(A) U_EMRNOTIMPLEMENTED_print("U_EMR_SETLINKEDUFIS",A) //!< Not implemented. // U_EMRSETTEXTJUSTIFICATION120 Not implemented (denigrated) -#define U_EMRSETTEXTJUSTIFICATION_print(A) U_EMRNOTIMPLEMENTED_print("U_EMR_SETTEXTJUSTIFICATION",A) +#define U_EMRSETTEXTJUSTIFICATION_print(A) U_EMRNOTIMPLEMENTED_print("U_EMR_SETTEXTJUSTIFICATION",A) //!< Not implemented. // U_EMRCOLORMATCHTOTARGETW 121 Not implemented -#define U_EMRCOLORMATCHTOTARGETW_print(A) U_EMRNOTIMPLEMENTED_print("U_EMR_COLORMATCHTOTARGETW",A) +#define U_EMRCOLORMATCHTOTARGETW_print(A) U_EMRNOTIMPLEMENTED_print("U_EMR_COLORMATCHTOTARGETW",A) //!< Not implemented. // U_EMRCREATECOLORSPACEW 122 /** @@ -2209,16 +2242,16 @@ void U_EMRGRADIENTFILL_print(const char *contents){ \param contents pointer to a buffer holding all EMR records */ void U_EMRCREATECOLORSPACEW_print(const char *contents){ - unsigned i; + unsigned int i; PU_EMRCREATECOLORSPACEW pEmr = (PU_EMRCREATECOLORSPACEW)(contents); printf(" ihCS: %u\n", pEmr->ihCS ); printf(" ColorSpace: "); logcolorspacew_print(pEmr->lcs); printf("\n"); - printf(" dwFlags: %u\n", pEmr->dwFlags ); + printf(" dwFlags: 0x%8.8X\n", pEmr->dwFlags ); printf(" cbData: %u\n", pEmr->cbData ); - printf(" Data: "); + printf(" Data(hexvalues):"); if(pEmr->dwFlags & 1){ for(i=0; icbData; i++){ - printf("[%u]:%2.2X ",i,pEmr->Data[i]); + printf("[%d]:%2.2X ",i,pEmr->Data[i]); } } printf("\n"); @@ -2234,9 +2267,9 @@ void U_EMRCREATECOLORSPACEW_print(const char *contents){ */ int U_emf_onerec_print(const char *contents, const char *blimit, int recnum, size_t off){ PU_ENHMETARECORD lpEMFR = (PU_ENHMETARECORD)(contents + off); - unsigned size; + unsigned int size; - printf("%-30srecord:%5d type:%3d offset:%8d size:%8d\n",U_emr_names(lpEMFR->iType),recnum,lpEMFR->iType,(int) off,lpEMFR->nSize); + printf("%-30srecord:%5d type:%-4d offset:%8d rsize:%8d\n",U_emr_names(lpEMFR->iType),recnum,lpEMFR->iType,(int) off,lpEMFR->nSize); size = lpEMFR->nSize; contents += off; @@ -2317,7 +2350,7 @@ int U_emf_onerec_print(const char *contents, const char *blimit, int recnum, siz case U_EMR_SELECTCLIPPATH: U_EMRSELECTCLIPPATH_print(contents); break; case U_EMR_ABORTPATH: U_EMRABORTPATH_print(contents); break; case U_EMR_UNDEF69: U_EMRUNDEF69_print(contents); break; - case U_EMR_COMMENT: U_EMRCOMMENT_print(contents); break; + case U_EMR_COMMENT: U_EMRCOMMENT_print(contents, blimit, off); break; case U_EMR_FILLRGN: U_EMRFILLRGN_print(contents); break; case U_EMR_FRAMERGN: U_EMRFRAMERGN_print(contents); break; case U_EMR_INVERTRGN: U_EMRINVERTRGN_print(contents); break; diff --git a/src/libuemf/uemf_print.h b/src/libuemf/uemf_print.h index 238e0e659..896de659e 100644 --- a/src/libuemf/uemf_print.h +++ b/src/libuemf/uemf_print.h @@ -1,5 +1,7 @@ /** - @file uemf_print.h Functions for printing records from EMF files. + @file uemf_print.h + + @brief Prototypes for functions for printing records from EMF files. */ /* @@ -18,6 +20,7 @@ Copyright: 2013 David Mathog and California Institute of Technology (Caltech) extern "C" { #endif +//! \cond /* prototypes for objects used in EMR records */ void hexbytes_print(uint8_t *buf,unsigned int num); void colorref_print(U_COLORREF color); @@ -55,112 +58,114 @@ void emrtext_print(const char *emt, const char *record, int type); /* prototypes for EMR records */ void U_EMRNOTIMPLEMENTED_print(const char *name, const char *contents, int recnum, int off); -void U_EMRHEADER_print(const char *contents, int recnum, int off); -void U_EMRPOLYBEZIER_print(const char *contents, int recnum, int off); -void U_EMRPOLYGON_print(const char *contents, int recnum, int off); -void U_EMRPOLYLINE_print(const char *contents, int recnum, int off); -void U_EMRPOLYBEZIERTO_print(const char *contents, int recnum, int off); -void U_EMRPOLYLINETO_print(const char *contents, int recnum, int off); -void U_EMRPOLYPOLYLINE_print(const char *contents, int recnum, int off); -void U_EMRPOLYPOLYGON_print(const char *contents, int recnum, int off); -void U_EMRSETWINDOWEXTEX_print(const char *contents, int recnum, int off); -void U_EMRSETWINDOWORGEX_print(const char *contents, int recnum, int off); -void U_EMRSETVIEWPORTEXTEX_print(const char *contents, int recnum, int off); -void U_EMRSETVIEWPORTORGEX_print(const char *contents, int recnum, int off); -void U_EMRSETBRUSHORGEX_print(const char *contents, int recnum, int off); -void U_EMREOF_print(const char *contents, int recnum, int off); -void U_EMRSETPIXELV_print(const char *contents, int recnum, int off); -void U_EMRSETMAPPERFLAGS_print(const char *contents, int recnum, int off); -void U_EMRSETMAPMODE_print(const char *contents, int recnum, int off); -void U_EMRSETBKMODE_print(const char *contents, int recnum, int off); -void U_EMRSETPOLYFILLMODE_print(const char *contents, int recnum, int off); -void U_EMRSETROP2_print(const char *contents, int recnum, int off); -void U_EMRSETSTRETCHBLTMODE_print(const char *contents, int recnum, int off); -void U_EMRSETTEXTALIGN_print(const char *contents, int recnum, int off); -void U_EMRSETCOLORADJUSTMENT_print(const char *contents, int recnum, int off); -void U_EMRSETTEXTCOLOR_print(const char *contents, int recnum, int off); -void U_EMRSETBKCOLOR_print(const char *contents, int recnum, int off); -void U_EMROFFSETCLIPRGN_print(const char *contents, int recnum, int off); -void U_EMRMOVETOEX_print(const char *contents, int recnum, int off); -void U_EMRSETMETARGN_print(const char *contents, int recnum, int off); -void U_EMREXCLUDECLIPRECT_print(const char *contents, int recnum, int off); -void U_EMRINTERSECTCLIPRECT_print(const char *contents, int recnum, int off); -void U_EMRSCALEVIEWPORTEXTEX_print(const char *contents, int recnum, int off); -void U_EMRSCALEWINDOWEXTEX_print(const char *contents, int recnum, int off); -void U_EMRSAVEDC_print(const char *contents, int recnum, int off); -void U_EMRRESTOREDC_print(const char *contents, int recnum, int off); -void U_EMRSETWORLDTRANSFORM_print(const char *contents, int recnum, int off); -void U_EMRMODIFYWORLDTRANSFORM_print(const char *contents, int recnum, int off); -void U_EMRSELECTOBJECT_print(const char *contents, int recnum, int off); -void U_EMRCREATEPEN_print(const char *contents, int recnum, int off); -void U_EMRCREATEBRUSHINDIRECT_print(const char *contents, int recnum, int off); -void U_EMRDELETEOBJECT_print(const char *contents, int recnum, int off); -void U_EMRANGLEARC_print(const char *contents, int recnum, int off); -void U_EMRELLIPSE_print(const char *contents, int recnum, int off); -void U_EMRRECTANGLE_print(const char *contents, int recnum, int off); -void U_EMRROUNDRECT_print(const char *contents, int recnum, int off); -void U_EMRARC_print(const char *contents, int recnum, int off); -void U_EMRCHORD_print(const char *contents, int recnum, int off); -void U_EMRPIE_print(const char *contents, int recnum, int off); -void U_EMRSELECTPALETTE_print(const char *contents, int recnum, int off); -void U_EMRCREATEPALETTE_print(const char *contents, int recnum, int off); -void U_EMRSETPALETTEENTRIES_print(const char *contents, int recnum, int off); -void U_EMRRESIZEPALETTE_print(const char *contents, int recnum, int off); -void U_EMRREALIZEPALETTE_print(const char *contents, int recnum, int off); -void U_EMREXTFLOODFILL_print(const char *contents, int recnum, int off); -void U_EMRLINETO_print(const char *contents, int recnum, int off); -void U_EMRARCTO_print(const char *contents, int recnum, int off); -void U_EMRPOLYDRAW_print(const char *contents, int recnum, int off); -void U_EMRSETARCDIRECTION_print(const char *contents, int recnum, int off); -void U_EMRSETMITERLIMIT_print(const char *contents, int recnum, int off); -void U_EMRBEGINPATH_print(const char *contents, int recnum, int off); -void U_EMRENDPATH_print(const char *contents, int recnum, int off); -void U_EMRCLOSEFIGURE_print(const char *contents, int recnum, int off); -void U_EMRFILLPATH_print(const char *contents, int recnum, int off); -void U_EMRSTROKEANDFILLPATH_print(const char *contents, int recnum, int off); -void U_EMRSTROKEPATH_print(const char *contents, int recnum, int off); -void U_EMRFLATTENPATH_print(const char *contents, int recnum, int off); -void U_EMRWIDENPATH_print(const char *contents, int recnum, int off); -void U_EMRSELECTCLIPPATH_print(const char *contents, int recnum, int off); -void U_EMRABORTPATH_print(const char *contents, int recnum, int off); -void U_EMRCOMMENT_print(const char *contents, int recnum, int off); -void U_EMRFILLRGN_print(const char *contents, int recnum, int off); -void U_EMRFRAMERGN_print(const char *contents, int recnum, int off); -void U_EMRINVERTRGN_print(const char *contents, int recnum, int off); -void U_EMRPAINTRGN_print(const char *contents, int recnum, int off); -void U_EMREXTSELECTCLIPRGN_print(const char *contents, int recnum, int off); -void U_EMRBITBLT_print(const char *contents, int recnum, int off); -void U_EMRSTRETCHBLT_print(const char *contents, int recnum, int off); -void U_EMRMASKBLT_print(const char *contents, int recnum, int off); -void U_EMRPLGBLT_print(const char *contents, int recnum, int off); -void U_EMRSETDIBITSTODEVICE_print(const char *contents, int recnum, int off); -void U_EMRSTRETCHDIBITS_print(const char *contents, int recnum, int off); -void U_EMREXTCREATEFONTINDIRECTW_print(const char *contents, int recnum, int off); -void U_EMREXTTEXTOUTA_print(const char *contents, int recnum, int off); -void U_EMREXTTEXTOUTW_print(const char *contents, int recnum, int off); -void U_EMRPOLYBEZIER16_print(const char *contents, int recnum, int off); -void U_EMRPOLYGON16_print(const char *contents, int recnum, int off); -void U_EMRPOLYLINE16_print(const char *contents, int recnum, int off); -void U_EMRPOLYBEZIERTO16_print(const char *contents, int recnum, int off); -void U_EMRPOLYLINETO16_print(const char *contents, int recnum, int off); -void U_EMRPOLYPOLYLINE16_print(const char *contents, int recnum, int off); -void U_EMRPOLYPOLYGON16_print(const char *contents, int recnum, int off); -void U_EMRPOLYDRAW16_print(const char *contents, int recnum, int off); -void U_EMRCREATEMONOBRUSH_print(const char *contents, int recnum, int off); -void U_EMRCREATEDIBPATTERNBRUSHPT_print(const char *contents, int recnum, int off); -void U_EMREXTCREATEPEN_print(const char *contents, int recnum, int off); -void U_EMRSETICMMODE_print(const char *contents, int recnum, int off); -void U_EMRCREATECOLORSPACE_print(const char *contents, int recnum, int off); -void U_EMRSETCOLORSPACE_print(const char *contents, int recnum, int off); -void U_EMRDELETECOLORSPACE_print(const char *contents, int recnum, int off); -void U_EMRPIXELFORMAT_print(const char *contents, int recnum, int off); -void U_EMRSMALLTEXTOUT_print(const char *contents, int recnum, int off); -void U_EMRALPHABLEND_print(const char *contents, int recnum, int off); -void U_EMRSETLAYOUT_print(const char *contents, int recnum, int off); -void U_EMRTRANSPARENTBLT_print(const char *contents, int recnum, int off); -void U_EMRGRADIENTFILL_print(const char *contents, int recnum, int off); -void U_EMRCREATECOLORSPACEW_print(const char *contents, int recnum, int off); +void U_EMRHEADER_print(const char *contents); +void U_EMRPOLYBEZIER_print(const char *contents); +void U_EMRPOLYGON_print(const char *contents); +void U_EMRPOLYLINE_print(const char *contents); +void U_EMRPOLYBEZIERTO_print(const char *contents); +void U_EMRPOLYLINETO_print(const char *contents); +void U_EMRPOLYPOLYLINE_print(const char *contents); +void U_EMRPOLYPOLYGON_print(const char *contents); +void U_EMRSETWINDOWEXTEX_print(const char *contents); +void U_EMRSETWINDOWORGEX_print(const char *contents); +void U_EMRSETVIEWPORTEXTEX_print(const char *contents); +void U_EMRSETVIEWPORTORGEX_print(const char *contents); +void U_EMRSETBRUSHORGEX_print(const char *contents); +void U_EMREOF_print(const char *contents); +void U_EMRSETPIXELV_print(const char *contents); +void U_EMRSETMAPPERFLAGS_print(const char *contents); +void U_EMRSETMAPMODE_print(const char *contents); +void U_EMRSETBKMODE_print(const char *contents); +void U_EMRSETPOLYFILLMODE_print(const char *contents); +void U_EMRSETROP2_print(const char *contents); +void U_EMRSETSTRETCHBLTMODE_print(const char *contents); +void U_EMRSETTEXTALIGN_print(const char *contents); +void U_EMRSETCOLORADJUSTMENT_print(const char *contents); +void U_EMRSETTEXTCOLOR_print(const char *contents); +void U_EMRSETBKCOLOR_print(const char *contents); +void U_EMROFFSETCLIPRGN_print(const char *contents); +void U_EMRMOVETOEX_print(const char *contents); +void U_EMRSETMETARGN_print(const char *contents); +void U_EMREXCLUDECLIPRECT_print(const char *contents); +void U_EMRINTERSECTCLIPRECT_print(const char *contents); +void U_EMRSCALEVIEWPORTEXTEX_print(const char *contents); +void U_EMRSCALEWINDOWEXTEX_print(const char *contents); +void U_EMRSAVEDC_print(const char *contents); +void U_EMRRESTOREDC_print(const char *contents); +void U_EMRSETWORLDTRANSFORM_print(const char *contents); +void U_EMRMODIFYWORLDTRANSFORM_print(const char *contents); +void U_EMRSELECTOBJECT_print(const char *contents); +void U_EMRCREATEPEN_print(const char *contents); +void U_EMRCREATEBRUSHINDIRECT_print(const char *contents); +void U_EMRDELETEOBJECT_print(const char *contents); +void U_EMRANGLEARC_print(const char *contents); +void U_EMRELLIPSE_print(const char *contents); +void U_EMRRECTANGLE_print(const char *contents); +void U_EMRROUNDRECT_print(const char *contents); +void U_EMRARC_print(const char *contents); +void U_EMRCHORD_print(const char *contents); +void U_EMRPIE_print(const char *contents); +void U_EMRSELECTPALETTE_print(const char *contents); +void U_EMRCREATEPALETTE_print(const char *contents); +void U_EMRSETPALETTEENTRIES_print(const char *contents); +void U_EMRRESIZEPALETTE_print(const char *contents); +void U_EMRREALIZEPALETTE_print(const char *contents); +void U_EMREXTFLOODFILL_print(const char *contents); +void U_EMRLINETO_print(const char *contents); +void U_EMRARCTO_print(const char *contents); +void U_EMRPOLYDRAW_print(const char *contents); +void U_EMRSETARCDIRECTION_print(const char *contents); +void U_EMRSETMITERLIMIT_print(const char *contents); +void U_EMRBEGINPATH_print(const char *contents); +void U_EMRENDPATH_print(const char *contents); +void U_EMRCLOSEFIGURE_print(const char *contents); +void U_EMRFILLPATH_print(const char *contents); +void U_EMRSTROKEANDFILLPATH_print(const char *contents); +void U_EMRSTROKEPATH_print(const char *contents); +void U_EMRFLATTENPATH_print(const char *contents); +void U_EMRWIDENPATH_print(const char *contents); +void U_EMRSELECTCLIPPATH_print(const char *contents); +void U_EMRABORTPATH_print(const char *contents); +void U_EMRCOMMENT_print(const char *contents, const char *blimit, size_t off); +void U_EMRFILLRGN_print(const char *contents); +void U_EMRFRAMERGN_print(const char *contents); +void U_EMRINVERTRGN_print(const char *contents); +void U_EMRPAINTRGN_print(const char *contents); +void U_EMREXTSELECTCLIPRGN_print(const char *contents); +void U_EMRBITBLT_print(const char *contents); +void U_EMRSTRETCHBLT_print(const char *contents); +void U_EMRMASKBLT_print(const char *contents); +void U_EMRPLGBLT_print(const char *contents); +void U_EMRSETDIBITSTODEVICE_print(const char *contents); +void U_EMRSTRETCHDIBITS_print(const char *contents); +void U_EMREXTCREATEFONTINDIRECTW_print(const char *contents); +void U_EMREXTTEXTOUTA_print(const char *contents); +void U_EMREXTTEXTOUTW_print(const char *contents); +void U_EMRPOLYBEZIER16_print(const char *contents); +void U_EMRPOLYGON16_print(const char *contents); +void U_EMRPOLYLINE16_print(const char *contents); +void U_EMRPOLYBEZIERTO16_print(const char *contents); +void U_EMRPOLYLINETO16_print(const char *contents); +void U_EMRPOLYPOLYLINE16_print(const char *contents); +void U_EMRPOLYPOLYGON16_print(const char *contents); +void U_EMRPOLYDRAW16_print(const char *contents); +void U_EMRCREATEMONOBRUSH_print(const char *contents); +void U_EMRCREATEDIBPATTERNBRUSHPT_print(const char *contents); +void U_EMREXTCREATEPEN_print(const char *contents); +void U_EMRSETICMMODE_print(const char *contents); +void U_EMRCREATECOLORSPACE_print(const char *contents); +void U_EMRSETCOLORSPACE_print(const char *contents); +void U_EMRDELETECOLORSPACE_print(const char *contents); +void U_EMRPIXELFORMAT_print(const char *contents); +void U_EMRSMALLTEXTOUT_print(const char *contents); +void U_EMRALPHABLEND_print(const char *contents); +void U_EMRSETLAYOUT_print(const char *contents); +void U_EMRTRANSPARENTBLT_print(const char *contents); +void U_EMRGRADIENTFILL_print(const char *contents); +void U_EMRCREATECOLORSPACEW_print(const char *contents); int U_emf_onerec_print(const char *contents, char *blimit, int recnum, int off); +//! \endcond + #ifdef __cplusplus } diff --git a/src/libuemf/uemf_utf.c b/src/libuemf/uemf_utf.c index 48d2510f0..f329e74d9 100644 --- a/src/libuemf/uemf_utf.c +++ b/src/libuemf/uemf_utf.c @@ -1,5 +1,7 @@ /** - @file uemf_utf.c Functions for manipulating UTF and various types of text. + @file uemf_utf.c + + @brief Functions for manipulating UTF and various types of text. Compile with "U_VALGRIND" defined defined to enable code which lets valgrind check each record for @@ -32,10 +34,12 @@ extern "C" { #include // for U_ROUND() #include "uemf_utf.h" +//! \cond /* Prototypes for functions used here and defined in uemf_endian.c, but which are not supposed to be used in end user code. */ void U_swap2(void *ul, unsigned int count); +//! \endcond /* ******************************************************************************************** */ diff --git a/src/libuemf/uemf_utf.h b/src/libuemf/uemf_utf.h index e42de23e6..68452b687 100644 --- a/src/libuemf/uemf_utf.h +++ b/src/libuemf/uemf_utf.h @@ -1,5 +1,7 @@ /** - @file uemf_utf.h for manipulating UTF and various types of text. + @file uemf_utf.h + + @brief Prototypes for functions that manipulate UTF and various types of text. */ diff --git a/src/libuemf/upmf.c b/src/libuemf/upmf.c new file mode 100644 index 000000000..742b8b0f7 --- /dev/null +++ b/src/libuemf/upmf.c @@ -0,0 +1,8057 @@ +/** + @file upmf.c + + @brief Functions for manipulating EMF+ files and structures. + + EMF+ is much more object based than is EMF or WMF, so the U_PMR_*_set and most U_PMF_*_set functions + return a pointer to a PseudoObject. PseudoObjects are structs that contain a data field to hold the + object in EMF+ file byte order, size information, and some type information. This is sufficient to allow + complex records to be built up from the various sorts of nested objects which they normally contain. + If something goes wrong a NULL pointer is returned and recsize is set to 0. + + EMF+ does not use a separate set of endian functions, _get and _set routines convert from/to + the EMF+ file byte order on the fly. + + WARNING: Microsoft's EMF+ documentation is little-endian for everything EXCEPT + bitfields, which are big-endian. See EMF+ manual section 1.3.2 + That documentation also uses 0 as the MOST significant bit, N-1 as the least. + This code is little-endian throughout, and 0 is the LEAST significant bit + +*/ + +/* +File: upmf.c +Version: 0.0.4 +Date: 27-NOV-2013 +Author: David Mathog, Biology Division, Caltech +email: mathog@caltech.edu +Copyright: 2013 David Mathog and California Institute of Technology (Caltech) +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include +#include +#include +#include +#include // for INT_MAX, INT_MIN +#include // for sin, cos, tan2, use U_ROUND() instead of roundf() +#include /* for offsetof() macro */ +#if 0 +#include //Not actually used, looking for collisions +#include //Not actually used, looking for collisions +#include //Not actually used, looking for collisions +#endif +#include "upmf.h" // includes uemf.h +#include "uemf_endian.h" // for U_swap* functions + +//! \cond + +/// things Doxygen should not process +/* remove this after debugging is completed */ +void dumphex(uint8_t *buf,unsigned int num){ + for(; num; num--,buf++){ + printf("%2.2X",*buf); + } +} + + +/* Prototypes for functions used here and defined in uemf_endian.c, but which are not supposed +to be used in end user code. */ + +void U_swap2(void *ul, unsigned int count); +void U_swap4(void *ul, unsigned int count); +//! \endcond + +/** + \brief Utility function for writing one or more EMF+ records in a PseudoObject to the EMF output file + \param po U_PSEUDO_OBJ to write + \param sum U_PSEUDO_OBJ to use for scratch space + \param et EMFTRACK used to write records to EMF file +*/ +void U_PMR_write(U_PSEUDO_OBJ *po, U_PSEUDO_OBJ *sum, EMFTRACK *et){ + char *rec; + sum->Used = 0; /* clean it out, retaining allocated memory */ + sum = U_PO_append(sum, "EMF+", 4); /* indicates that this comment holds an EMF+ record */ + sum = U_PO_append(sum, po->Data, po->Used); /* the EMF+ record itself */ + rec = U_EMRCOMMENT_set(sum->Used, sum->Data); /* stuff it into the EMF comment */ + (void) emf_append((PU_ENHMETARECORD)rec, et, 1); /* write it to the EMF file */ + U_PO_free(&po); /* delete the PseudoObjects */ +} + +/** + \brief Utility function to draw a line. + \return 1 on success, 0 on error. + \param PenID Index of U_PMF_PEN object to use in the EMF+ object table (0-63, inclusive) + \param PathID Index of U_PMF_PATH object to use in the EMF+ object table (0-63, inclusive) + \param Start U_PMF_POINTF coordinates of start of line. + \param End U_PMF_POINTF coordinates of end of line. + \param Dashed Set if the line is dashed, clear if it is not. + \param sum PseudoObject used for scratch space + \param et EMFTRACK used to write records to EMF file + +*/ +int U_PMR_drawline(uint32_t PenID, uint32_t PathID, U_PMF_POINTF Start, U_PMF_POINTF End, int Dashed, U_PSEUDO_OBJ *sum, EMFTRACK *et){ + U_DPSEUDO_OBJ *dpath; + U_PSEUDO_OBJ *poPath; + U_PSEUDO_OBJ *po; + int status=0; + int PTP_value = ( Dashed ? U_PTP_DashMode : U_PTP_None); + dpath = U_PATH_create(0, NULL, 0, 0); /* create an empty path*/ + if(dpath){ + if(U_PATH_moveto(dpath, Start, PTP_value) && U_PATH_lineto(dpath, End, PTP_value)){ + poPath = U_PMF_PATH_set2(U_PMF_GRAPHICSVERSIONOBJ_set(2), dpath); + if(poPath){ + po = U_PMR_OBJECT_PO_set(PathID, poPath); + U_PO_free(&poPath); + if(po){ + U_PMR_write(po, sum, et); + po = U_PMR_DRAWPATH_set(PathID, PenID); + if(po){ + U_PMR_write(po, sum, et); + status = 1; + } + } + } + } + U_DPO_free(&dpath); + } + return(status); +} + +/** + \brief Utility function for drawing strings onto the baseline in one call. + \return 1 on success, 0 on error. + \param string Text to draw in UTF-8 format + \param Vpos StringAlignment Enumeration. Always drawn on baseline, but using one of these three modes. + \param FontID Index of U_PMF_FONT object to use in the EMF+ object table (0-63, inclusive) + \param BrushID U_PSEUDO_OBJ containing a U_PMF_ARGB or a U_PMF_4NUM. Color or U_PMF_BRUSH object in the EMF+ object table (0-63, inclusive) + \param FormatID index of U_PMF_STRINGFORMAT object to use in the EMF+ Object Table. + \param Sfs StringFormat structure. Ignored values: StringAlignment, LineAlign, Flags + \param FontName Name of font to draw with + \param Height Height of font in pixels (positive) + \param fip U_FontInfoParams (ascent, descent, and so forth) + \param FontFlags FontStyle Flags + \param x X position in pixels of left side of EM box of first character + \param y Y position in pixels of baseline of first character + \param sum PseudoObject used for scratch space + \param et EMFTRACK used to write records to EMF file + + EMF+ manual 2.3.4.14, Microsoft name: EmfPlusDrawString Record, Index 0x1C + + For most fonts Ascent and Descent are used to adjust the bounding box to properly position the + baseline. Some fonts, like Verdana, are strange and they position the baseline on the bottom of + the bounding box if that box has the same height as the font. For those fonts specify 0.0 for + both Ascent and Descent. +*/ +int U_PMR_drawstring( const char *string, int Vpos, uint32_t FontID, const U_PSEUDO_OBJ *BrushID, uint32_t FormatID, + U_PMF_STRINGFORMAT Sfs, const char *FontName, U_FLOAT Height, U_FontInfoParams *fip, uint32_t FontFlags, + U_FLOAT x, U_FLOAT y, U_PSEUDO_OBJ *sum, EMFTRACK *et){ + U_PSEUDO_OBJ *po; + U_PSEUDO_OBJ *poSF; + U_PSEUDO_OBJ *poFont; + U_PSEUDO_OBJ *poRect; + U_FLOAT rx,ry,rw,rh,rd; + uint16_t *UFontName; + uint16_t *Text16; + int slen; + int status = 0; + double aval, dval; + + Sfs.Flags = U_SF_NoFitBlackBox + U_SF_NoClip; + + if(Vpos < U_SA_Near || Vpos > U_SA_Far)return(0); + Sfs.StringAlignment = U_SA_Near; // Horizontal + Sfs.LineAlign = Vpos; // Vertical + + UFontName = U_Utf8ToUtf16le(FontName, 0, NULL); + slen = strlen(FontName); + poFont = U_PMF_FONT_set(U_PMF_GRAPHICSVERSIONOBJ_set(2), Height, U_UT_World, FontFlags, slen, UFontName); + if(poFont){ + po = U_PMR_OBJECT_PO_set(FontID, poFont); /* font to use */ + if(po){ + U_PMR_write(po, sum, et); + + poSF = U_PMF_STRINGFORMAT_set(&Sfs, NULL); + if(poSF){ + po = U_PMR_OBJECT_PO_set(FormatID, poSF); + U_PO_free(&poSF); + if(po){ + U_PMR_write(po, sum, et); + + rw = 4*Height*slen; /* This could probably be any value */ + rh = Height; + rx = x; + if(fip->LineGap > -fip->Descent){ aval = fip->yMax; } // sylfaen, palatino + else { aval = fip->Ascent; } // others + if(fip->LineGap && (fip->LineGap < -fip->Descent)){ dval = ((double) (fip->Descent - fip->LineGap)) / ((double) fip->EmSize); } //shruti and some others + else { dval = ((double) fip->Descent ) / ((double) fip->EmSize); } + switch(Vpos){ + case U_SA_Near: + rd = Height * aval / ((double) fip->EmSize); + break; + case U_SA_Center: + rd = 0.5 * ( Height * aval / ((double) fip->EmSize) + Height * ( 1.0 + dval)); + break; + case U_SA_Far: + rd = Height * ( 1.0 + dval); + break; + } + ry = y - rd; /* draw from upper left corner, which is shifted to put baseline on y */ + poRect = U_PMF_RECTF4_set(rx, ry, rw, rh); +#if 0 +(void) U_PMR_drawline(OBJ_PEN_BLACK_1,OBJ_PATH_1, (U_PMF_POINTF){x-100, ry}, (U_PMF_POINTF){x+100, ry}, 0, sum, et); +(void) U_PMR_drawline(OBJ_PEN_BLACK_1,OBJ_PATH_1, (U_PMF_POINTF){x-100, ry+rh}, (U_PMF_POINTF){x+100, ry+rh}, 0, sum, et); +(void) U_PMR_drawline(OBJ_PEN_BLACK_1,OBJ_PATH_1, (U_PMF_POINTF){x-100, ry}, (U_PMF_POINTF){x-100, ry + Height * (double) fip->Ascent / ((double) fip->EmSize)}, 0, sum, et); +(void) U_PMR_drawline(OBJ_PEN_BLACK_1,OBJ_PATH_1, (U_PMF_POINTF){x- 90, ry}, (U_PMF_POINTF){x- 90, ry - Height * (double) fip->Descent / ((double) fip->EmSize)}, 0, sum, et); +(void) U_PMR_drawline(OBJ_PEN_BLACK_1,OBJ_PATH_1, (U_PMF_POINTF){x- 80, ry}, (U_PMF_POINTF){x- 80, ry + Height * (double) fip->yMax / ((double) fip->EmSize)}, 0, sum, et); +(void) U_PMR_drawline(OBJ_PEN_BLACK_1,OBJ_PATH_1, (U_PMF_POINTF){x- 70, ry}, (U_PMF_POINTF){x- 70, ry - Height * (double) fip->yMin / ((double) fip->EmSize)}, 0, sum, et); +(void) U_PMR_drawline(OBJ_PEN_BLACK_1,OBJ_PATH_1, (U_PMF_POINTF){x- 60, ry}, (U_PMF_POINTF){x- 60, ry + Height * (double) fip->LineGap / ((double) fip->EmSize)}, 0, sum, et); +(void) U_PMR_drawline(OBJ_PEN_BLACK_1,OBJ_PATH_1, (U_PMF_POINTF){x- 50, ry}, (U_PMF_POINTF){x- 50, ry + Height * ( 1.0 - (((double) (fip->LineGap - fip->Descent)) / ((double) fip->EmSize)) )}, 0, sum, et); +#endif + + Text16 = U_Utf8ToUtf16le(string, 0, NULL); + slen = strlen(string); + po = U_PMR_DRAWSTRING_set(FontID, BrushID, FormatID, slen, poRect, Text16); + if(po){ + U_PMR_write(po, sum, et); + status = 1; /* Success!!! */ + } + U_PO_free(&poRect); + free(Text16); + } + } + } + U_PO_free(&poFont); + } + free(UFontName); + return(status); +} + +/** + \brief Allocate and construct an array of U_POINT16 objects from a set of U_PMF_POINTF objects, endianness in and out is LE + \returns pointer to an array of U_POINT16 structures. + \param points pointer to the source U_POINT structures + \param count number of members in points + + If a coordinate is out of range it saturates at boundary. +*/ +U_PMF_POINT *POINTF_To_POINT16_LE(U_PMF_POINTF *points, int count){ + U_PMF_POINT *newpts; + U_PMF_POINTF ptfl; + int i; + newpts = (U_PMF_POINT *) malloc(count * sizeof(U_PMF_POINT)); + + for(i=0; i U_PMR_MAX){ idx = 0; } + static char *U_PMR_NAMES[U_PMR_MAX+1]={ + "U_PMR_INVALID", + "U_PMR_Header", + "U_PMR_EndOfFile", + "U_PMR_Comment", + "U_PMR_GetDC", + "U_PMR_MultiFormatStart", + "U_PMR_MultiFormatSection", + "U_PMR_MultiFormatEnd", + "U_PMR_Object", + "U_PMR_Clear", + "U_PMR_FillRects", + "U_PMR_DrawRects", + "U_PMR_FillPolygon", + "U_PMR_DrawLines", + "U_PMR_FillEllipse", + "U_PMR_DrawEllipse", + "U_PMR_FillPie", + "U_PMR_DrawPie", + "U_PMR_DrawArc", + "U_PMR_FillRegion", + "U_PMR_FillPath", + "U_PMR_DrawPath", + "U_PMR_FillClosedCurve", + "U_PMR_DrawClosedCurve", + "U_PMR_DrawCurve", + "U_PMR_DrawBeziers", + "U_PMR_DrawImage", + "U_PMR_DrawImagePoints", + "U_PMR_DrawString", + "U_PMR_SetRenderingOrigin", + "U_PMR_SetAntiAliasMode", + "U_PMR_SetTextRenderingHint", + "U_PMR_SetTextContrast", + "U_PMR_SetInterpolationMode", + "U_PMR_SetPixelOffsetMode", + "U_PMR_SetCompositingMode", + "U_PMR_SetCompositingQuality", + "U_PMR_Save", + "U_PMR_Restore", + "U_PMR_BeginContainer", + "U_PMR_BeginContainerNoParams", + "U_PMR_EndContainer", + "U_PMR_SetWorldTransform", + "U_PMR_ResetWorldTransform", + "U_PMR_MultiplyWorldTransform", + "U_PMR_TranslateWorldTransform", + "U_PMR_ScaleWorldTransform", + "U_PMR_RotateWorldTransform", + "U_PMR_SetPageTransform", + "U_PMR_ResetClip", + "U_PMR_SetClipRect", + "U_PMR_SetClipPath", + "U_PMR_SetClipRegion", + "U_PMR_OffsetClip", + "U_PMR_DrawDriverstring", + "U_PMR_StrokeFillPath", + "U_PMR_SerializableObject", + "U_PMR_SetTSGraphics", + "U_PMR_SetTSClip" + }; + return(U_PMR_NAMES[idx]); +} + +/** + \brief Convert from PseudoObject OID to ObjectType enumeration. + \returns OT value on success, 0 if no match + \param OID PseudoObject OID (based on EMF+ manual chapter number. ) + + Only OTs that may be stored in the EMF+ object table are supported. +*/ + +int U_OID_To_OT(uint32_t OID){ + int otype; + if( OID==U_PMF_BRUSH_OID ){ otype = U_OT_Brush; } + else if(OID==U_PMF_PEN_OID ){ otype = U_OT_Pen; } + else if(OID==U_PMF_PATH_OID ){ otype = U_OT_Path; } + else if(OID==U_PMF_REGION_OID ){ otype = U_OT_Region; } + else if(OID==U_PMF_IMAGE_OID ){ otype = U_OT_Image; } + else if(OID==U_PMF_FONT_OID ){ otype = U_OT_Font; } + else if(OID==U_PMF_STRINGFORMAT_OID ){ otype = U_OT_StringFormat; } + else if(OID==U_PMF_IMAGEATTRIBUTES_OID){ otype = U_OT_ImageAttributes; } + else if(OID==U_PMF_CUSTOMLINECAP_OID ){ otype = U_OT_CustomLineCap; } + else { otype = U_OT_Invalid; } + return(otype); +} + +/** + \brief Convert from PseudoObject OID to BrushType enumeration. + \returns BT value on success, -1 if no match + \param OID PseudoObject OID (based on EMF+ manual chapter number. ) + + Only OIDs that map to BT's are supported. +*/ + +int U_OID_To_BT(uint32_t OID){ + int otype; + if( OID==U_PMF_HATCHBRUSHDATA_OID ){ otype = U_BT_HatchFill; } + else if(OID==U_PMF_LINEARGRADIENTBRUSHDATA_OID ){ otype = U_BT_LinearGradient; } + else if(OID==U_PMF_PATHGRADIENTBRUSHDATA_OID ){ otype = U_BT_PathGradient; } + else if(OID==U_PMF_SOLIDBRUSHDATA_OID ){ otype = U_BT_SolidColor; } + else if(OID==U_PMF_TEXTUREBRUSHDATA_OID ){ otype = U_BT_TextureFill; } + else { otype = -1; } + return(otype); +} + +/** + \brief Convert from PseudoObject OID to CustomLineCapDataType Enumeration. + \returns BT value on success, -1 if no match + \param OID PseudoObject OID (based on EMF+ manual chapter number. ) + + Only OIDs that map to CLCDT's are supported. +*/ + +int U_OID_To_CLCDT(uint32_t OID){ + int otype; + if( OID==U_PMF_CUSTOMLINECAPDATA_OID ){ otype = U_CLCDT_Default; } + else if(OID==U_PMF_CUSTOMLINECAPARROWDATA_OID ){ otype = U_CLCDT_AdjustableArrow; } + else { otype = -1; } + return(otype); +} + +/** + \brief Convert from PseudoObject OID to ImageDataType Enumeration. + \returns BT value on success, -1 if no match + \param OID PseudoObject OID (based on EMF+ manual chapter number. ) + + Only OIDs that map to IDT's are supported. +*/ + +int U_OID_To_IDT(uint32_t OID){ + int otype; + if( OID==U_PMF_BITMAP_OID ){ otype = U_IDT_Bitmap; } + else if(OID==U_PMF_METAFILE_OID ){ otype = U_IDT_Metafile; } + else { otype = -1; } + return(otype); +} + +/** + \brief Convert from PseudoObject OID to RegionNodeDataType Enumeration. + \returns BT value on success, -1 if no match + \param OID PseudoObject OID (based on EMF+ manual chapter number. ) + + Only OIDs that map to RNDT's are supported. +*/ + +int U_OID_To_RNDT(uint32_t OID){ + int otype; + if( OID==U_PMF_REGIONNODECHILDNODES_OID ){ otype = U_RNDT_Kids; } /* there are 5 types, which must be specified separately */ + else if(OID==U_PMF_RECTF_OID ){ otype = U_RNDT_Rect; } + else if(OID==U_PMF_REGIONNODEPATH_OID ){ otype = U_RNDT_Path; } + else { otype = -1; } + return(otype); +} + +/** + \brief Append data to an U_OBJ_ACCUM structure. + \param oa pointer to the U_OBJ_ACCUM structure + \param data data to add + \param size bytes in data + \param Type object type + \param Id Object ID + \returns 0 on success, !0 on error. -1 on Type change, -2 on Id change + + Safe to test for Id, Type changes by calling with size=0. +*/ +int U_OA_append(U_OBJ_ACCUM *oa, const char *data, int size, int Type, int Id){ + int tail; + if(!oa)return(2); + if(oa->used){ + if(oa->Type != Type)return(-1); + if(oa->Id != Id)return(-2); + } + tail = oa->used; + if(oa->used + size >= oa->space){ + oa->space += size; + oa->accum = (char *) realloc(oa->accum, oa->space); + if(!oa->accum)return(1); + } + memcpy(oa->accum + tail,data,size); + oa->used += size; + oa->Type = Type; + oa->Id = Id; + return(0); +} + + +/** + \brief Clear an U_OBJ_ACCUM structure. Accumulated storage is retained. + \param oa pointer to the U_OBJ_ACCUM structure + \returns 0 on success, !0 on error. +*/ +int U_OA_clear(U_OBJ_ACCUM *oa){ + if(!oa)return(2); + oa->used=0; + /* Type and Id may be ignored as they are reset on the first append */ + return(0); +} + +/** + \brief Release an U_OBJ_ACCUM structure. Accumulated storage is free'd. + \param oa pointer to the U_OBJ_ACCUM structure + \returns 0 on success, !0 on error. +*/ +int U_OA_release(U_OBJ_ACCUM *oa){ + if(!oa)return(2); + oa->used=0; + oa->space = 0; + if(oa->accum)free(oa->accum); + oa->accum=NULL; + return(0); +} + +/** + \brief Create and set an U_PSEUDO_OBJ + \returns pointer to the U_PSEUDO_OBJ, NULL on error + \param Data Data to copy into the PseudoObject's data. If NULL, space is allocated, but is cleared instead of filled. + \param Size Number of bytes to allocate for Data (may be >Use if padding is present) + \param Use Number of data bytes in Data (whether or not Data is actually copied) + \param Type Type numbers are from manual section: 1.2.3.47 -> 0x01020347 + + If Data is NULL and Size is 0 an empty PseudoObject is created. One byte of storage + is allocated for Data, Size is set to 1, and Used to 0. + + If Data is NULL and Size is !0 a zero filled PseudoObject is created. + + If Data is !Null and Size is !0 a data filled PseudoObject is created. +*/ +U_PSEUDO_OBJ *U_PO_create(char *Data, size_t Size, size_t Use, uint32_t Type){ + if(Use>Size)return(NULL); + size_t tSize = (Size ? Size : 1); + U_PSEUDO_OBJ *po = (U_PSEUDO_OBJ *)malloc(sizeof(U_PSEUDO_OBJ)); + if(po){ + po->Data = malloc(tSize); + if(po->Data){ + po->Size = tSize; + po->Used = Use; + po->Type = Type; + if(Data){ memcpy(po->Data, Data, Use); } /* if Use < Size uninitialized bytes will be present! */ + else { memset(po->Data, 0, tSize); } + } + else { + free(po); + po=NULL; + } + } + return(po); +} + +/** + \brief Append data to a U_PSEUDO_OBJ object and return it + \returns pointer to the U_PSEUDO_OBJ object, NULL on error + \param po PseudoObject to append to. Cannot be NULL. + \param Data Data to copy into the PseudoObject's data. If NULL, space is allocated (if necessary) and cleared instead of filled. + \param Size Number of data bytes in Data +*/ +U_PSEUDO_OBJ *U_PO_append(U_PSEUDO_OBJ *po, const char *Data, size_t Size){ + /* po cannot be NULL,as in U_PO_po_append(), because there would be no way to determine the TYPE of the resulting PO */ + if(po){ + if(po->Used + Size > po->Size){ + po->Size = po->Used + Size; + po->Data = realloc(po->Data, po->Size); + } + if(po->Data){ + if(Data){ memcpy(po->Data + po->Used, Data, Size); } + else { memset(po->Data + po->Used, 0, Size); } + po->Used += Size; + } + if(!po->Data){ + free(po); + po=NULL; + } + } + return(po); +} + +/** + \brief Append data to a U_PSEUDO_OBJ object and return it + \returns pointer to the U_PSEUDO_OBJ object, NULL on error + \param po PseudoObject to append to. May be NULL. + \param Src PseudoObject to append. + \param StripE Set: leading Elements in Src->Data is not copied, Clear: it is copied. +*/ +U_PSEUDO_OBJ *U_PO_po_append(U_PSEUDO_OBJ *po, U_PSEUDO_OBJ *Src, int StripE){ + if(!Src){ return(NULL); } + char *Data = Src->Data; + size_t Size = Src->Size; + if(StripE){ Size -= 4; } + if(!po){ + po = U_PO_create(NULL, 0, 0, Src->Type); /* create an empty pseudoobject */ + } + if(po){ + if(po->Data){ + if(po->Used + Size > po->Size){ + po->Size = po->Used + Size; + po->Data = realloc(po->Data, po->Size); + } + if(po->Data){ + if(Data){ + if(StripE){ memcpy(po->Data + po->Used, Data + 4, Size); } /* Size is already 4 less, skip the leading Elements value */ + else { memcpy(po->Data + po->Used, Data, Size); } /* copy everything */ + } + else { memset(po->Data + po->Used, 0, Size); } /* set everything */ + po->Used += Size; + } + } + if(!po->Data){ + free(po); + po=NULL; + } + } + return(po); +} + +/** + \brief Free an U_PSEUDO_OBJ structure. All associated memory is released. + \param po Address of a pointer to the U_PSEUDO_OBJ structure, Pointer is set to NULL. + \returns 1 on success, 0 on error. +*/ +int U_PO_free(U_PSEUDO_OBJ **po){ + if(!po)return(0); + if(!*po)return(1); + if((*po)->Data)free((*po)->Data); + free(*po); + *po=NULL; + return(1); +} + +/** \brief create a PseudoObject with data in the correct byte order for an EMF+ file. + \returns The PseudoObject on success, NULL on error. + + \param Type the type of the PseudoObject that is created. Allowed values are in U_PID_Values. + \param List an array of U_SERIAL_DESC structures containing the data to store. + + The U_PMF_SERIAL_set() function should not ever be called directly by end user code. + + Each U_SERIAL_DESC element in List consists of Data fields and a description of that data. List is terminated + by the first U_SERIAL_DESC element having a TE value of U_XX. + + Data fields: an array of a basic type of Units bytes repeated Reps times with the target byte order + described in TE. + + Ptrs: Address of the first byte of the data fields. + + Units: Number of bytes of in each data field unit + + Reps: Number of repeats of the unit in data fields. + If a Ptr is NULL, and Units*Reps is not zero, then Units*Reps 0x00 bytes are stored. + If a Ptr is NULL, and Units*Reps is zero, this U_SERIAL_DESC is ignored. + if a Ptr is NOT NULL, and Units * Reps is not zero, then the data is stored in the indicated byte order. + If a Ptr is NOT NULL, and Units or Reps is zero an error is signaled. + + TE: (Target Endian) the byte order in which to store each unit of a data field as defined in U_Endian. + Byte swapping is only enabled when Units is 2 or 4. In addition to the byte order values U_XE, U_LE, + and U_BE, and the array terminator U_XX, the value may also be U_RP. U_RP means there is only a + single unit in the data fields, but it is to be copied to the target Reps times. That is, the data + was passed in with a form of run length encoding. + + Creates an empty PseudoObject if all pointers are NULL and all sizes are zero. + */ +U_PSEUDO_OBJ *U_PMF_SERIAL_set(uint32_t Type, const U_SERIAL_DESC *List){ + U_PSEUDO_OBJ *po=NULL; + size_t Total=0; + size_t FSize; + char *cptr; + char *hptr; + const U_SERIAL_DESC *lptr; + if(!List)return(NULL); + for(lptr=List; lptr->TE != U_XX; lptr++){ + if(!(lptr->Units * lptr->Reps) && lptr->Ptr)return(po); + Total += lptr->Units * lptr->Reps; + } + po = U_PO_create(NULL, Total, Total, Type); + if(po){ + cptr = po->Data; + for(lptr=List; lptr->TE != U_XX; lptr++){ + FSize = lptr->Units * lptr->Reps; + if(FSize){ /* Ptr is not NULL, that would have been detected already */ + hptr = cptr; + if(lptr->TE & U_RP){ U_PMF_REPCPY_DSTSHIFT(&cptr, lptr->Ptr, lptr->Units, lptr->Reps); } + else { U_PMF_MEMCPY_DSTSHIFT(&cptr, lptr->Ptr, FSize); } + if(((lptr->TE & U_LE) && U_IS_BE) || ((lptr->TE & U_BE) && U_IS_LE)){ + if(lptr->Units==2){ U_swap2(hptr,lptr->Reps); } + else if(lptr->Units==4){ U_swap4(hptr,lptr->Reps); } + } + } + } + } + return(po); +} + +/** + \brief Create U_DPSEUDO_OBJ's for the Points and Types of a path + \param Elements Number of elements in Points. May be zero, which creates an empty path. + \param Points Array of U_PMF_POINTF values. + \param First Apply to first point, unsigned byte, lower 4 bits hold the PathPointType flag upper 4 bits hold the PathPointType enumeration. Must have U_PPT_Start set. + \param Others Apply to all other points, unsigned byte, lower 4 bits hold the PathPointType flag upper 4 bits hold the PathPointType enumeration. Must have U_PPT_Line or U_PPT_Bezier set. + \returns pointer to the DU_PSEUDO_OBJ object, NULL on error +*/ +U_DPSEUDO_OBJ *U_PATH_create(int Elements, const U_PMF_POINTF *Points, uint8_t First, uint8_t Others){ + if(Elements){ + if(!Points){ return(NULL); } + if( (First & U_PPT_MASK) != U_PPT_Start ){ return(NULL); } + if(!(Others & U_PPT_Bezier)){ return(NULL); } /* will pass if either line or bezier is set */ + } + + U_DPSEUDO_OBJ *Path = (U_DPSEUDO_OBJ *)malloc(sizeof(U_DPSEUDO_OBJ)); + const U_SERIAL_DESC List[] = { {NULL,0,0,U_XX} }; + if(Path){ + Path->Elements = Elements; + Path->poPoints = U_PMF_SERIAL_set(U_PMF_RAW_OID, List); /* Empty PO to hold points as raw data */ + if(!Elements){ + Path->poTypes = U_PMF_SERIAL_set(U_PMF_RAW_OID, List); /* Empty PO to hold types as raw data */ + } + else { + Path->poPoints = U_PO_append(Path->poPoints, (char *)Points, Elements*sizeof(U_PMF_POINTF)); + if(Path->poPoints){ + U_PSEUDO_OBJ *tpo = U_PMF_PATHPOINTTYPE_set2(Elements, First | U_PPT_Start, Others); /* PO holding types, has leading Elements value */ + Path->poTypes = U_PO_po_append(NULL, tpo, U_PMF_DROP_ELEMENTS); /* remove the leading Elements value*/ + U_PO_free(&tpo); + if(!Path->poTypes){ U_PO_free(&Path->poPoints); } + } + if(!Path->poPoints){ U_DPO_free(&Path); } + } + } + return(Path); +} + +/** + \brief Free U_DPSEUDO_OBJ's + \returns 1 on success, 0 on error. +*/ +int U_DPO_free(U_DPSEUDO_OBJ **dpo){ + if(!dpo){ return(0); } + if(!*dpo){ return(1); } + U_DPSEUDO_OBJ *kpo = *dpo; + if(kpo->poPoints){ U_PO_free(&kpo->poPoints); } + if(kpo->poTypes){ U_PO_free(&kpo->poTypes); } + free(*dpo); + *dpo=NULL; + return(1); +} + +/** + \brief Clear U_DPSEUDO_OBJ's. Memory is retained, Elements and Used values are set to 0. + \returns 1 on success, 0 on error. + + It is much more efficient to clear a DPO and reuse it than to free that DPO and create another. +*/ +int U_DPO_clear(U_DPSEUDO_OBJ *dpo){ + if(!dpo){ return(0); } + if(dpo->poPoints){ dpo->poPoints->Used = 0; } + if(dpo->poTypes){ dpo->poTypes->Used = 0; } + dpo->Elements = 0; + return(1); +} + +/** + \brief Append a "moveto" point to a path + \param Path Address of a DoublePseudoObject holding the path to append to. + \param Point Point to move to. + \param Flags Flags may be (U_PTP_None, U_PTP_DashMode, U_PTP_PathMarker, U_PTP_NoBit, U_PTP_CloseSubpath) + \returns 1 on success, 0 on error. +*/ +int U_PATH_moveto(U_DPSEUDO_OBJ *Path, U_PMF_POINTF Point, uint8_t Flags){ + if(!Path){ return(0); } + U_PSEUDO_OBJ *tpo; + uint8_t Type = (Flags & U_PTP_NotClose) | U_PPT_Start; + + tpo = U_PMF_POINTF_set(1, &Point); + if(!tpo){ return(0); } + Path->poPoints = U_PO_po_append(Path->poPoints, tpo, U_PMF_DROP_ELEMENTS); + U_PO_free(&tpo); + + tpo = U_PMF_PATHPOINTTYPE_set(1, &Type); + if(!tpo){ return(0); } + Path->poTypes = U_PO_po_append(Path->poTypes, tpo, U_PMF_DROP_ELEMENTS); + U_PO_free(&tpo); + + Path->Elements++; + return(1); +} + +/** + \brief Append a "lineto" point to a path + \param Path Address of a DoublePseudoObject holding the path to append to. + \param Point U_PMF_POINTF point to draw to. + \param Flags Flags may be (U_PTP_None, U_PTP_DashMode, U_PTP_PathMarker, U_PTP_NoBit, U_PTP_CloseSubpath) + \returns 1 on success, 0 on error. +*/ +int U_PATH_lineto(U_DPSEUDO_OBJ *Path, U_PMF_POINTF Point, uint8_t Flags){ + if(!Path || !Path->Elements){ return(0); } /* must be at least one point to extend from */ + if(Path->poTypes->Data[Path->Elements - 1] & U_PTP_CloseSubpath){ return(0); } /* cannot extend a closed subpath */ + U_PSEUDO_OBJ *tpo; + uint8_t Type = (Flags & U_PTP_NotClose) | U_PPT_Line; + tpo = U_PMF_POINTF_set(1, &Point); + if(!tpo){ return(0); } + Path->poPoints = U_PO_po_append(Path->poPoints, tpo, U_PMF_DROP_ELEMENTS); + U_PO_free(&tpo); + + tpo = U_PMF_PATHPOINTTYPE_set(1, &Type); + if(!tpo){ return(0); } + Path->poTypes = U_PO_po_append(Path->poTypes, tpo, U_PMF_DROP_ELEMENTS); + U_PO_free(&tpo); + + Path->Elements++; + return(1); +} + +/** + \brief Set the closepath bit in the last point + \param Path Address of a DoublePseudoObject holding the path to act upon. + \returns 1 on success, 0 on error. +*/ +int U_PATH_closepath(U_DPSEUDO_OBJ *Path){ + if(!Path || !Path->poTypes){ return(0); } + uint32_t Elements = Path->Elements; + uint8_t *Type = (uint8_t *)(Path->poTypes->Data) + Elements - 1; + if(*Type & U_PPT_Start){ return(0); } /* single point closed path makes no sense */ + *Type = *Type | U_PTP_CloseSubpath; + return(1); +} + +/** + \brief Append a "polylineto" set of point to a path + \param Path Address of a DoublePseudoObject holding the path to append to. + \param Elements number of Points and Flags + \param Points Line points. + \param Flags Flags (U_PTP_None, U_PTP_DashMode, U_PTP_PathMarker, U_PTP_NoBit, but NOT U_PTP_CloseSubpath) + \param StartSeg If set, use U_PPT_Start PathPointType enumeration for first point, otherwise use U_PPT_Line. + \returns 1 on success, 0 on error. +*/ +int U_PATH_polylineto(U_DPSEUDO_OBJ *Path, uint32_t Elements, const U_PMF_POINTF *Points, uint8_t Flags, uint8_t StartSeg){ + if(!Path || !Points){ return(0); } + if(!Elements){ return(1); } /* harmless - do nothing */ + U_PSEUDO_OBJ *tpo; + uint8_t First, Others; + + tpo = U_PMF_POINTF_set(Elements, Points); + Path->poPoints = U_PO_po_append(Path->poPoints, tpo, U_PMF_DROP_ELEMENTS); + U_PO_free(&tpo); + if(StartSeg){ First = (Flags & U_PTP_NotClose) | U_PPT_Start; } + else { First = (Flags & U_PTP_NotClose) | U_PPT_Line; } + Others = (Flags & U_PTP_NotClose) | U_PPT_Line; + tpo = U_PMF_PATHPOINTTYPE_set2(Elements, First, Others); + if(!tpo){ return(0); } + Path->poTypes = U_PO_po_append(Path->poTypes, tpo, U_PMF_DROP_ELEMENTS); + U_PO_free(&tpo); + + Path->Elements += Elements; + return(1); +} + + +/** + \brief Append a "polybezierto" set of point to a path + \param Path Address of a DoublePseudoObject holding the path to append to. + \param Elements number of Points + \param Points Bezier points. Optional starting point, then N sets of 3, example: [P1] (Q12A Q12B P2) (Q23A Q23B P3). + \param Flags Flags (U_PTP_None, U_PTP_DashMode, U_PTP_PathMarker, U_PTP_NoBit, but NOT U_PTP_CloseSubpath) + \param StartSeg If set, use U_PPT_Start PathPointType enumeration for first point, otherwise use U_PPT_Bezier. + \returns 1 on success, 0 on error. + + If Start is set Elements must be 1 + multiple of 3. Ie, P1 Q12A Q12B P2 Q23A Q23B P3 + + If Start is clear Elements must be a multiple of 3. Ie, (P1, already in path) Q12A Q12B P2 Q23A Q23B P3 +*/ +int U_PATH_polybezierto(U_DPSEUDO_OBJ *Path, uint32_t Elements, const U_PMF_POINTF *Points, uint8_t Flags, uint8_t StartSeg){ + if(!Path || !Points){ return(0); } + if(!Elements){ + if(StartSeg){ return(0); } /* cannot have both a NEW segment and ZERO points */ + else{ return(1); } /* harmless - do nothing */ + } + if(StartSeg && ((Elements - 1) % 3)){ return(0); } /* new segment must be 1 + N*3 points */ + if(!StartSeg && (Elements % 3)){ return(0); } /* extend segment must be N*3 points */ + U_PSEUDO_OBJ *tpo; + uint8_t First, Others; + + tpo = U_PMF_POINTF_set(Elements, Points); + Path->poPoints = U_PO_po_append(Path->poPoints, tpo, U_PMF_DROP_ELEMENTS); + U_PO_free(&tpo); + + if(StartSeg){ First = (Flags & U_PTP_NotClose) | U_PPT_Start; } + else { First = (Flags & U_PTP_NotClose) | U_PPT_Bezier; } + Others = (Flags & U_PTP_NotClose) | U_PPT_Bezier; + tpo = U_PMF_PATHPOINTTYPE_set2(Elements, First, Others); + if(!tpo){ return(0); } + Path->poTypes = U_PO_po_append(Path->poTypes, tpo, U_PMF_DROP_ELEMENTS); + U_PO_free(&tpo); + + Path->Elements += Elements; + return(1); +} + +/** + \brief Append a "polygon" set of points to a path. + \param Path Address of a DoublePseudoObject holding the path to append to. + \param Elements number of Points and Flags + \param Points Line points. + \param Flags Flags (U_PTP_None, U_PTP_DashMode, U_PTP_PathMarker, U_PTP_NoBit, but NOT U_PTP_CloseSubpath) + \returns 1 on success, 0 on error. +*/ +int U_PATH_polygon(U_DPSEUDO_OBJ *Path, uint32_t Elements, const U_PMF_POINTF *Points, uint8_t Flags){ + int status = U_PATH_polylineto(Path, Elements, Points, Flags, U_SEG_NEW); + if(status){ + status = U_PATH_closepath(Path); + } + return(status); +} + +//! \cond +// These are not exposed in the API +/* Parameterized Ellipse coordinates */ +U_PMF_POINTF U_eparam(U_FLOAT a, U_FLOAT b, U_PMF_POINTF *center, double Ang, double Theta){ + U_PMF_POINTF point; + point.X = center->X + a*cos(Theta)*cos(Ang) - b*sin(Theta)*sin(Ang); + point.Y = center->Y + a*sin(Theta)*cos(Ang) + b*cos(Theta)*sin(Ang); + return(point); +} + +/* Parameterized Ellipse derivative */ +U_PMF_POINTF U_eparam2(U_FLOAT a, U_FLOAT b, double Ang, double Theta){ + U_PMF_POINTF point; + point.X = -a*cos(Theta)*sin(Ang) - b*sin(Theta)*cos(Ang); + point.Y = -a*sin(Theta)*sin(Ang) + b*cos(Theta)*cos(Ang); + return(point); +} + +double U_aparam(double Ang1, double Ang2){ + double Alpha; + double t2; + t2 = tan((Ang2 - Ang1)/2.0); + t2 *= t2; + Alpha = sin(Ang2 - Ang1) * (sqrt(4 + 3*t2) -1.0)/3.0; + return(Alpha); +} + +/* Parameterized Bezier point Q1 or Q2 derivative */ +U_PMF_POINTF U_qparam(double Alpha, double a, double b, U_PMF_POINTF *Point, double Ang, double Theta, int mode){ + U_PMF_POINTF Q, Prime; + Prime = U_eparam2(a,b,Ang,Theta); + if(mode==1){ /* Q1, anything else is Q2*/ + Q.X = Point->X + Alpha * Prime.X; + Q.Y = Point->Y + Alpha * Prime.Y; + } + else { + Q.X = Point->X - Alpha * Prime.X; + Q.Y = Point->Y - Alpha * Prime.Y; + } + return(Q); +} +//! \endcond + +/** + \brief Append an "arcto" set of points to a path (Bezier points are calculated, and these are appended + \param Path Address of a pointer to the U_PSEUDO_OBJ that holds points + \param Start Start angle, >=0.0, degrees clockwise from 3:00 + \param Sweep Sweep angle, -360<= angle <=360, degrees clockwise from Start + \param Rot Rotation angle to apply to coordinate system (Start and Rect), positive is degrees clockwise + \param Rect U_PMF_RECTF that defines the bounding rectangle. + \param Flags Flags (U_PTP_None, U_PTP_DashMode, U_PTP_PathMarker, U_PTP_NoBit, but NOT U_PTP_CloseSubpath) + \param StartSeg If set, the arc starts a new segment, if clear, continue the existing segment. Starting a new segment does not automatically apply U_PATH_closepath to the existing path. + \returns 1 on success, 0 on error. + + Based on Luc Maisonobe's work, http://www.spaceroots.org/documents/ellipse/ +*/ +int U_PATH_arcto(U_DPSEUDO_OBJ *Path, U_FLOAT Start, U_FLOAT Sweep, U_FLOAT Rot, U_PMF_RECTF *Rect, uint8_t Flags, int StartSeg){ + U_PMF_POINTF Bz[3]; + U_PMF_POINTF Center; + U_PMF_POINTF P1,P2; + double a, b; + int done = 0; + int fpoint = 0; + double L1, L2; /* These are degrees CounterClockwise from 3:00 */ + double Ang1, Ang2; /* These are parametric angles, derived from L1, L2*/ + double Alpha; /* Dimensionless number used for Q1, Q2 */ + double Theta; /* Rot in radians */ + double Slop; /* do not let rounding errors cause spurious end points */ + if(!Path){ return(0); } + if((Sweep > 360.0) || (Sweep < -360.0)){ return(0); } + /* Start should be between 0 and 360 degrees, but it does not really matter because sin, and cos will accept anything */ + /* the sign on Sweep and Start is correct bacause LM's derivation has y positive up, but GDI+ has y positive down. */ + a = Rect->Width/2.0; + b = Rect->Height/2.0; + if(!a || !b){ return(0); } + Center.X = Rect->X + a; + Center.Y = Rect->Y + b; + /* convert to radians */ + Start = (2.0 * U_PI * Start)/360.0; + Sweep = (2.0 * U_PI * Sweep)/360.0; + Theta = (2.0 * U_PI * Rot )/360.0; + Slop = Sweep/100000.0; + L1 = Start; + + while(!done){ + if(Sweep < 0){ + L2 = L1 - U_PI/2.0; + if(L2 <= Sweep + Start - Slop){ L2 = Sweep + Start; done = 1; } + else {done = 0; } + } + else { + L2 = L1 + U_PI/2.0; + if(L2 >= Sweep + Start + Slop){ L2 = Sweep + Start; done = 1; } + else {done = 0; } + } + Ang1 = atan2(sin(L1)/b, cos(L1)/a); + Ang2 = atan2(sin(L2)/b, cos(L2)/a); + Alpha = U_aparam(Ang1, Ang2); + P1 = U_eparam(a, b, &Center, Ang1, Theta); /* P1 */ + P2 = U_eparam(a, b, &Center, Ang2, Theta); /* P2 */ + Bz[0] = U_qparam(Alpha, a, b, &P1, Ang1, Theta, 1); /* Q1 */ + Bz[1] = U_qparam(Alpha, a, b, &P2, Ang2, Theta, 2); /* Q2 */ + Bz[2] = P2; + if(!fpoint){ + if(StartSeg){ U_PATH_moveto(Path, P1, Flags); } + else { U_PATH_lineto(Path, P1, Flags); } + fpoint = 1; + } + U_PATH_polybezierto(Path, 3, Bz, Flags, U_SEG_OLD ); + L1 = L2; + } + return(1); +} + +/** + \brief Allocate and construct an array of U_PMF_POINTF objects which have been subjected to a U_XFORM + \returns pointer to an array of U_PMF_POINTF structures. + \param points pointer to the source U_PMF_POINTF structures + \param count number of members in points + \param xform U_XFORM to apply + +*/ +U_PMF_POINTF *pointfs_transform(U_PMF_POINTF *points, int count, U_XFORM xform){ + U_PMF_POINTF *newpts=NULL;; + int i; + float X,Y; + newpts = (U_PMF_POINTF *) malloc(count * sizeof(U_PMF_POINTF)); + if(newpts){ + for(i=0; i 1.0e-10 || (A) < -1.0e-10 ? (A) : 0.0) //! \hideinitializer +//! \endcond + U_PMF_TRANSFORMMATRIX tm; + double dang = Angle * 2*U_PI /360.0; + double scale; + double cd,sd; + if((Periods <=0.0) || (w <= 0.0) || (h <= 0.0)){ + tm.m11 = tm.m12 = tm.m21 = tm.m22 = tm.dX = tm.dY = 0.0; + } + else { + /* + scale is gradient period divided by w + The scale value sets the gradient period to match exactly with the inscribed (w,h) rectangle + in the direction specified by the angle. + The numberator of scale is the max of the four dot product values of the rotated X basis unit vector with (w,h), + with each of the vectors {w,h}, {-w,h}, {-w,-h}, {w,h}. Those vectors run from each corner in turn + to the opposite corner. The one most parallel to the rotated unit vector will have both terms positive. + + Trig results like cos(pi/2) are not stable between platforms due to minor differences in the + implementation. Detect these and make them zero, which then allows binary comparison of output files. + Otherwise the binary comparisons between platforms would fail because of a bunch of insignificant digits. + */ + cd = CLOSE_TO_IS_REALLY_ZERO(cos(dang)); + sd = CLOSE_TO_IS_REALLY_ZERO(sin(dang)); + scale = (w*fabs(cd) + h*fabs(sd))/(w*Periods); + tm.m11 = scale * cd; + tm.m12 = -scale * sd; + tm.m21 = scale * sd; + tm.m22 = scale * cd; + /* offset is to one corner of the square, depending on which quadrant the rotation selects. */ + if(cos(dang)>=0){ + tm.dX = x; + if(sin(dang)>=0){tm.dY = y + h; } // LL corner + else { tm.dY = y; } // UL corner + } + else { + tm.dX = x + w; + if(sin(dang)>=0){ tm.dY = y + h; } // LR corner + else { tm.dY = y; } // UR corner + } + } + return tm; +#undef CLOSE_TO_IS_REALLY_ZERO +} +/** + \brief Create a U_PSEUDO_OBJ containing a U_PMR_FILLPATH and U_PMR_DRAWPATH records. + \returns pointer to U_PSEUDO_OBJ or NULL on error. + \param PathID U_PMF_PATH object in the EMF+ object table (0-63, inclusive) + \param PenID U_PMF_PEN object in the EMF+ object table (0-63, inclusive) + \param BrushID U_PSEUDO_OBJ containing a U_PMF_ARGB or a U_PMF_4NUM. Color or U_PMF_BRUSH object in the EMF+ object table (0-63, inclusive) +*/ +U_PSEUDO_OBJ *U_PMR_drawfill(uint32_t PathID, uint32_t PenID, const U_PSEUDO_OBJ *BrushID){ + U_PSEUDO_OBJ *po = U_PMR_FILLPATH_set(PathID, BrushID); + if(po){ + U_PSEUDO_OBJ *tpo = U_PMR_DRAWPATH_set(PathID, PenID); + po = U_PO_po_append(po, tpo, U_PMF_KEEP_ELEMENTS); + U_PO_free(&tpo); + } + return(po); +} + + + +/** + \brief Extract a single data field from a source. + \returns 1 on success, 0 on error. + \param Src where the data is coming from. It is incremented by the number of bytes retrieved. + \param Dst where the data will be stored. This must either be NULL (in which case the Src + is advanced and nothing is stored, or it must be allocated to Reps * Units bytes!!!! + \param Units number of bytes in each unit of the data field + \param Reps number of repeats of units in the data field. + If a Ptr is NULL, then Units*Reps 0 bytes are stored. + If a Ptr is NOT NULL, and Units or Reps, is zero an error is signaled. + If a Ptr is NULL and Units*Reps is 0, nothing happens. + \param SE logical (Source Endian). Only relevant for Sizes of 2 or 4 + Indicates when Bytes may need to be rearranged when they are retrieved. + U_XE no change (this is used when the data has already been set to the proper orientation or it is not known) + U_LE source is Little Endian + U_BE source is Big Endian. + U_XX error + +*/ +int U_PMF_SERIAL_get(const char **Src, void *Dst, size_t Units, size_t Reps, int SE){ + if(!Src || !*Src || SE == U_XX){ return(0); } + U_PMF_MEMCPY_SRCSHIFT(Dst, Src, Units * Reps); + if(!Dst){ return(1); } /* "fake" get, no data was retrieved, so we are done */ + if(SE == U_XE){ return(1); } + if(SE == U_LE && U_IS_LE){ return(1); } + if(SE == U_BE && U_IS_BE){ return(1); } + /* need to swap */ + if( Units==2){ U_swap2(Dst,Reps); } + else if(Units==4){ U_swap4(Dst,Reps); } + return(1); +} + +/** + \brief Conditionally extract an array of data from a source, allocating space to hold it. + \returns 1 on success, 0 on error. + \param Src where the data is coming from. It is incremented by the number of bytes retrieved. + \param Dst Caller must free. Where the pointer to the data will be stored. Reps * Units bytes will be allocated, + \param Units number of bytes in each unit of the data field + \param Reps number of repeats of units in the data field. + If a Ptr is NULL, then Units*Reps 0 bytes are stored. + If a Ptr is NOT NULL, and Units or Reps, is zero an error is signaled. + If a Ptr is NULL and Units*Reps is 0, nothing happens. + \param SE logical (Source Endian). Only relevant for Sizes of 2 or 4 + Indicates when Bytes may need to be rearranged when they are retrieved. + U_XE no change (this is used when the data has already been set to the proper orientation or it is not known) + U_LE source is Little Endian + U_BE source is Big Endian. + U_XX error + \param Cond Store the data into *Dst if true, set *Dst to NULL otherwise. + +*/ +int U_PMF_SERIAL_array_copy_get(const char **Src, void **Dst, size_t Units, size_t Reps, int SE, int Cond){ + if(!Src || !*Src || !Dst || SE == U_XX){ return(0); } + if(!Cond){ + *Src += Units * Reps; + *Dst = NULL; + return(1); + } + *Dst = malloc(Units * Reps); + if(!*Dst){ return(1); } /* "fake" get, no data was retrieved, so we are done */ + U_PMF_MEMCPY_SRCSHIFT(*Dst, Src, Units * Reps); + if(SE == U_XE){ return(1); } + if(SE == U_LE && U_IS_LE){ return(1); } + if(SE == U_BE && U_IS_BE){ return(1); } + /* need to swap */ + if( Units==2){ U_swap2(*Dst,Reps); } + else if(Units==4){ U_swap4(*Dst,Reps); } + return(1); +} + + + +/** + \brief Calculate the length in bytes of a relative path object composed of U_PMF_INTEGER7 and U_PMF_INTER15 values + \return >=0 length == success, <0 error + \param contents Start of a relative path consisting of int7 and int15 X,Y pairs. + \param Elements number of relative X,Y pairs in the object +*/ +int U_PMF_LEN_REL715(const char *contents, int Elements){ + int length=0; + Elements *= 2; /* N pairs = 2N values */ + for( ; Elements; Elements--){ + /* X or Y value */ + if(*contents & U_TEST_INT7){ contents +=2; length +=2; } //int15 + else { contents +=1; length +=1; } //int7 + } + return(length); +} + +/** + \brief Calculate the length in bytes of objects which are a 4 byte Count followed by Count * float bytes + \return >=0 length == success, <0 error + Object types whose size may be derived with this function are: + U_PMF_COMPOUNDLINEDATA + U_PMF_DASHEDLINEDATA +*/ +int U_PMF_LEN_FLOATDATA(const char *contents){ + int Size; + U_PMF_SERIAL_get(&contents, &Size, 4, 1, U_LE); + Size = 4*Size + 4; + return(Size); +} + +/** + \brief Calculate the length in bytes of objects which are a 4 byte count followed by count bytes + \return >=0 length == success, <0 error + Object types whose size may be derived with this function are: + U_PMF_BOUNDARYPATHDATA + U_PMF_BOUNDARYPOINTDATA + U_PMF_CUSTOMSTARTCAPDATA + U_PMF_PATH + U_PMF_LINEPATH + U_PMF_REGIONNODEPATH +*/ +int U_PMF_LEN_BYTEDATA(const char *contents){ + int Size; + U_PMF_SERIAL_get(&contents, &Size, 4, 1, U_LE); + Size += 4; + return(Size); +} + +/** + \brief Create a string containing the curly bracket form of the 16 byte GUID value + \return number of bytes in record, 0 on error + \param GUID pointer to the 16 unsigned bytes + \return string in curly bracket form. + http://msdn.microsoft.com/en-us/library/cc230316.aspx + + Text form is Data1-Data2-Data3-Data4, the first 3 are stored as little endian integers, the last as a string (big endian). +*/ +char *U_PMF_CURLYGUID_set(uint8_t *GUID){ + char *string=malloc(64); + if(string){ + sprintf(string,"{%2.2X%2.2X%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X%2.2X%2.2X%2.2X%2.2X}", + GUID[3],GUID[2],GUID[1],GUID[0], + GUID[5],GUID[4], + GUID[7],GUID[6], + GUID[8],GUID[9], + GUID[10],GUID[11],GUID[12],GUID[13],GUID[14],GUID[15] + ); + } + return(string); +} + +/** + \brief Identify a known curly GUID + \param string Curly GUID form. + \return EmageEffects Enumerator + + EMF+ manual 2.1.3.1, Microsoft name: ImageEffects Identifier +*/ +int U_PMF_KNOWNCURLYGUID_set(const char *string){ + int status; + if( !strcmp(string,"{633C80A4-1843-482B-9EF2-BE2834C5FDD4}")){ status = U_IEE_BlurEffectGuid; } + else if(!strcmp(string,"{D3A1DBE1-8EC4-4C17-9F4C-EA97AD1C343D}")){ status = U_IEE_BrightnessContrastEffectGuid; } + else if(!strcmp(string,"{537E597D-251E-48DA-9664-29CA496B70F8}")){ status = U_IEE_ColorBalanceEffectGuid; } + else if(!strcmp(string,"{DD6A0022-58E4-4A67-9D9B-D48EB881A53D}")){ status = U_IEE_ColorCurveEffectGuid; } + else if(!strcmp(string,"{A7CE72A9-0F7F-40D7-B3CC-D0C02D5C3212}")){ status = U_IEE_ColorLookupTableEffectGuid; } + else if(!strcmp(string,"{718F2615-7933-40E3-A511-5F68FE14DD74}")){ status = U_IEE_ColorMatrixEffectGuid; } + else if(!strcmp(string,"{8B2DD6C3-EB07-4D87-A5F0-7108E26A9C5F}")){ status = U_IEE_HueSaturationLightnessEffectGuid;} + else if(!strcmp(string,"{99C354EC-2A31-4F3A-8C34-17A803B33A25}")){ status = U_IEE_LevelsEffectGuid; } + else if(!strcmp(string,"{74D29D05-69A4-4266-9549-3CC52836B632}")){ status = U_IEE_RedEyeCorrectionEffectGuid; } + else if(!strcmp(string,"{63CBF3EE-C526-402C-8F71-62C540BF5142}")){ status = U_IEE_SharpenEffectGuid; } + else if(!strcmp(string,"{1077AF00-2848-4441-9489-44AD4C2D7A2C}")){ status = U_IEE_TintEffectGuid; } + else { status = U_IEE_Unknown; } + return(status); +} + +/** \brief Load a GUID from text format into EMF+ file binary format. + \param string Curly GUID as text, minus the barckets and dashes. + \return GUID in EMF+ file binary format. + + +This accepts a string that is 16 bytes long = 32 characters hex (no dash spaces or brackets) as text. +Text form is; Data1|Data2|Data3|Data4, first three are stored as little endian integers of 4,2,2 bytes, respectively, +last is stored like a string (big endian), after conversion from text hex to binary. + +This function is not normally called by end user code. +*/ +uint8_t *U_LOAD_GUID(char *string){ + uint32_t Data1,tData2,tData3,tByte; + uint16_t Data2,Data3; + char *Data4 = string + 16; + uint8_t *hold = malloc(16); + char *lf = (char *) hold; + int i; + if(hold){ + Data1=tData2=tData3=0; + if(3 != sscanf(string + 0,"%8X",&Data1) + + sscanf(string + 8,"%4X",&tData2) + + sscanf(string + 12,"%4X",&tData3)){ + free(lf); + return(NULL); + } + Data2=tData2; + Data3=tData3; + U_PMF_MEMCPY_DSTSHIFT(&lf, &Data1, 4); + U_PMF_MEMCPY_DSTSHIFT(&lf, &Data2, 2); + U_PMF_MEMCPY_DSTSHIFT(&lf, &Data3, 2); + if(U_IS_BE){ /* these fields are stored little endian */ + U_swap4(hold,1); + U_swap2(hold+4,2); + } + /* remainder is converted byte by byte and stored in that order */ + for(i=0;i<8;i++,Data4+=2,lf++){ + if(1 != sscanf(Data4,"%2X",&tByte)){ + free(lf); + return(NULL); + } + *lf=tByte; + } + } + return(hold); +} + +/** + \brief Generate the 16 byte form from OID of the ImageEffects Identifier + \param OID OID of the ImageEffects Identifier + \return pointer to 16 byte buffer holding the long GUID binary form, or NULL on error. + + EMF+ manual 2.1.3.1, Microsoft name: ImageEffects Identifier +*/ +uint8_t *U_OID_To_GUID(uint32_t OID){ + uint8_t *lf = NULL; + if( OID == U_PMF_IE_BLUR_OID ){ lf = U_LOAD_GUID("633C80A41843482B9EF2BE2834C5FDD4"); } + else if(OID == U_PMF_IE_BRIGHTNESSCONTRAST_OID ){ lf = U_LOAD_GUID("D3A1DBE18EC44C179F4CEA97AD1C343D"); } + else if(OID == U_PMF_IE_COLORBALANCE_OID ){ lf = U_LOAD_GUID("537E597D251E48DA966429CA496B70F8"); } + else if(OID == U_PMF_IE_COLORCURVE_OID ){ lf = U_LOAD_GUID("DD6A002258E44A679D9BD48EB881A53D"); } + else if(OID == U_PMF_IE_COLORLOOKUPTABLE_OID ){ lf = U_LOAD_GUID("A7CE72A90F7F40D7B3CCD0C02D5C3212"); } + else if(OID == U_PMF_IE_COLORMATRIX_OID ){ lf = U_LOAD_GUID("718F2615793340E3A5115F68FE14DD74"); } + else if(OID == U_PMF_IE_HUESATURATIONLIGHTNESS_OID){ lf = U_LOAD_GUID("8B2DD6C3EB074D87A5F07108E26A9C5F"); } + else if(OID == U_PMF_IE_LEVELS_OID ){ lf = U_LOAD_GUID("99C354EC2A314F3A8C3417A803B33A25"); } + else if(OID == U_PMF_IE_REDEYECORRECTION_OID ){ lf = U_LOAD_GUID("74D29D0569A4426695493CC52836B632"); } + else if(OID == U_PMF_IE_SHARPEN_OID ){ lf = U_LOAD_GUID("63CBF3EEC526402C8F7162C540BF5142"); } + else if(OID == U_PMF_IE_TINT_OID ){ lf = U_LOAD_GUID("1077AF0028484441948944AD4C2D7A2C"); } + return(lf); +} + +/** + \brief copy data and shift source pointer by the amount of data moved + \param Dst Destination in memory + \param Src Source in memory + \param Size Number of bytes to move +*/ +void U_PMF_MEMCPY_SRCSHIFT(void *Dst, const char **Src, size_t Size){ + if(Dst)memcpy(Dst, *Src, Size); + *Src += Size; +} + +/** + \brief copy data and shift destination pointer by the amount of data moved + \param Dst Destination in memory (this must not be NULL) + \param Src Source in memory (if this is NULL, fill with that many zero bytes instead) + \param Size Number of bytes to move +*/ +void U_PMF_MEMCPY_DSTSHIFT(char **Dst, const void *Src, size_t Size){ + if(Src){ memcpy(*Dst, Src, Size); } + else { memset(*Dst, 0, Size); } + *Dst += Size; +} + +/** + \brief Copy the single instance at Src repeatedly to Dst. + \param Dst Destination in memory + \param Src Source in memory (if this is NULL, fill with that many zero bytes instead) + \param Size number of bytes in single instance that is template. + \param Reps Number of instances of the template to opy +*/ +void U_PMF_REPCPY_DSTSHIFT(char **Dst, const void *Src, size_t Size, size_t Reps){ + for(;Reps;Reps--){ + if(Src){ memcpy(*Dst, Src, Size); } + else { memset(*Dst, 0, Size); } + *Dst += Size; + } +} + +/** + \brief save pointer to data and shift source pointer by the amount of data moved + \param Dst Destination in memory + \param Src Source in memory or NULL. If NULL Dst is set to NULL. + \param Size Number of bytes to move +*/ +void U_PMF_PTRSAV_SHIFT(const char **Dst, const char **Src, size_t Size){ + if(*Src){ + if(Dst)*Dst = *Src; + *Src += Size; + } + else { + if(Dst)*Dst = NULL; + } +} + +/** + \brief save pointer to data and shift source pointer by the amount of data moved + \return 1 on sucess, 0 on error + \param Dst Destination in memory + \param Src Source in memory or NULL. If NULL Dst is set to NULL. + \param Doit Assign if true, otherwise, set to NULL +*/ +int U_PMF_PTRSAV_COND(const char **Dst, const char *Src, int Doit){ + if(!Dst){ return(0); } + if(Src && Doit){ *Dst = Src; } + else { *Dst = NULL; } + return(1); +} + +/** + \brief Get the 16 bit unsigned Flags field from a header. + \param contents Record from which to extract data, will be incremented by header size. + \return Flags field + In many records the only value needed from the header is Flags. Rather than mapping + the entire Header and returning it, in these instances this function may be called to + just get this one value. +*/ +uint16_t U_PMF_HEADERFLAGS_get(const char *contents){ + uint16_t Flags; + const char *cptr = contents + offsetof(U_PMF_CMN_HDR,Flags); + U_PMF_SERIAL_get(&cptr, &Flags, 2, 1, U_LE); /* EMF+ manual documents it as BE, but this code implements it as LE*/ + return(Flags); +} + +/** + \brief Retrieve whichever header fields are requested. NULL pointers do not retrieve. + \param contents Record from which to extract data, will be incremented by header size. + \param Type Record type + \param Flags Record flags + \param Size Records size + \param Datasize Data size + \return 1 on success, 0 on failure. +*/ +int U_PMF_HEADERFIELDS_get(const char *contents, + uint16_t *Type, uint16_t *Flags, uint32_t *Size, uint32_t *Datasize){ + if(!contents){ return(0); } + U_PMF_SERIAL_get(&contents, Type, 2, 1, U_LE); + U_PMF_SERIAL_get(&contents, Flags, 2, 1, U_LE); /* EMF+ manual documents it as BE, but this code implements it as LE*/ + U_PMF_SERIAL_get(&contents, Size, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Datasize, 4, 1, U_LE); + return(1); +} + +/** + \brief Get the entire EMF+ record header. + \param contents Record from which to extract data, will be offset by header size. + \param Header Location to store data (may be NULL) + \returns 1 + If Header is Null, nothing is stored but contents is still offset. +*/ +int U_PMF_CMN_HDR_get(const char **contents, U_PMF_CMN_HDR *Header){ + if(!contents || !*contents){ return(0); } + if(Header){ + U_PMF_SERIAL_get(contents, &(Header->Type), 2, 1, U_LE); + U_PMF_SERIAL_get(contents, &(Header->Flags), 2, 1, U_LE); /* EMF+ manual documents it as BE, but this code implements it as LE*/ + U_PMF_SERIAL_get(contents, &(Header->Size), 4, 1, U_LE); + U_PMF_SERIAL_get(contents, &(Header->DataSize), 4, 1, U_LE); + } + else { + *contents += sizeof(U_PMF_CMN_HDR); + } + return(1); +} + +/** + \brief Return the size of a PenData object from an EMF+ record. + \param PenData Address in memory where the PenData object starts. + \returns size of the object in bytes +*/ +int U_PMF_LEN_PENDATA(const char *PenData){ + uint32_t Flags; + int length=12; /* Flags, Unit, Width */ + U_PMF_SERIAL_get(&PenData, &Flags, 4, 1, U_LE); + PenData += 8; /* skip Unit and Width */ + length += U_PMF_LEN_OPTPENDATA(PenData, Flags); + return(length); +} + +/** + \brief Return the size of an OptPenData object from an EMF+ record. + \param PenData Address in memory where the PenData object starts. + \param Flags PenData Flags that indicate which fields are present. + \returns size of the object in bytes +*/ +int U_PMF_LEN_OPTPENDATA(const char *PenData, uint32_t Flags){ + int length=0; + if(Flags & U_PD_Transform){ length += sizeof(U_PMF_TRANSFORMMATRIX); } + if(Flags & U_PD_StartCap){ length += sizeof(int32_t); } + if(Flags & U_PD_EndCap){ length += sizeof(int32_t); } + if(Flags & U_PD_Join){ length += sizeof(uint32_t); } + if(Flags & U_PD_MiterLimit){ length += sizeof(U_FLOAT); } + if(Flags & U_PD_LineStyle){ length += sizeof(int32_t); } + if(Flags & U_PD_DLCap){ length += sizeof(int32_t); } + if(Flags & U_PD_DLOffset){ length += sizeof(int32_t); } + if(Flags & U_PD_DLData){ length += U_PMF_LEN_FLOATDATA(PenData + length); } + if(Flags & U_PD_NonCenter){ length += sizeof(int32_t); } + if(Flags & U_PD_CLData){ length += U_PMF_LEN_FLOATDATA(PenData + length); } + if(Flags & U_PD_CustomStartCap){ length += U_PMF_LEN_BYTEDATA(PenData + length); } + if(Flags & U_PD_CustomEndCap){ length += U_PMF_LEN_BYTEDATA(PenData + length); } + return(length); +} + +/** + \brief Create and set a U_PMF_BRUSH PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Version EmfPlusGraphicsVersion object + \param Bd U_PSEUDO_OBJ containing one of the 5 types of Brush data + + EMF+ manual 2.2.1.1, Microsoft name: EmfPlusBrush Object +*/ +U_PSEUDO_OBJ *U_PMF_BRUSH_set(uint32_t Version, const U_PSEUDO_OBJ *Bd){ + if(!Bd){ return(NULL); } + int32_t Type = U_OID_To_BT(Bd->Type); + if(Type < 0){ return(NULL); } + const U_SERIAL_DESC List[] = { + {&Version, 4, 1, U_LE}, + {&Type, 4, 1, U_LE}, + {Bd->Data, Bd->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_BRUSH_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_CUSTOMLINECAP PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Version EmfPlusGraphicsVersion object + \param Ld U_PSEUDO_OBJ containing one of the 2 types of Linecap data + + EMF+ manual 2.2.1.2, Microsoft name: EmfPlusCustomLineCap Object +*/ +U_PSEUDO_OBJ *U_PMF_CUSTOMLINECAP_set(uint32_t Version, const U_PSEUDO_OBJ *Ld){ + if(!Ld){ return(NULL); } + int32_t Type = U_OID_To_CLCDT(Ld->Type); + if(Type<0){ return(NULL); } + const U_SERIAL_DESC List[] = { + {&Version, 4, 1, U_LE}, + {&Type, 4, 1, U_LE}, + {Ld->Data, Ld->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_CUSTOMLINECAP_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_FONT PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Version EmfPlusGraphicsVersion object + \param EmSize em size in units of SizeUnit + \param SizeUnit UnitType enumeration + \param FSFlags FontStyle flags + \param Length Number of Unicode Characters in FamilyName + \param Font Unicode (UTF-16LE) fontname + + EMF+ manual 2.2.1.3, Microsoft name: EmfPlusFont Object +*/ +U_PSEUDO_OBJ *U_PMF_FONT_set(uint32_t Version, U_FLOAT EmSize, uint32_t SizeUnit, + int32_t FSFlags, uint32_t Length, const uint16_t *Font){ + uint32_t cbFont = 2 * wchar16len(Font); /* this need not be 2*Length parameter */ + uint32_t pad = (0x3 & cbFont ? 2 : 0); + const U_SERIAL_DESC List[] = { + {&Version, 4, 1, U_LE}, + {&EmSize, 4, 1, U_LE}, + {&SizeUnit,4, 1, U_LE}, + {&FSFlags, 4, 1, U_LE}, + {NULL, 4, 1, U_LE}, /* NULL is for Reserved field */ + {&Length, 4, 1, U_LE}, + {Font, cbFont, 1, U_LE}, + {NULL, pad, (pad ? 1 : 0), (pad ? U_XE : U_XX)}, /* Entire record must be a multiple of 4 */ + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_FONT_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_IMAGE PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Version EmfPlusGraphicsVersion object + \param Id U_PSEUDO_OBJ containing one of the 2 types of image data + + EMF+ manual 2.2.1.4, Microsoft name: EmfPlusImage Object +*/ +U_PSEUDO_OBJ *U_PMF_IMAGE_set(uint32_t Version, const U_PSEUDO_OBJ *Id){ + if(!Id){ return(NULL); } + int32_t Type = U_OID_To_IDT(Id->Type); + if(Type<0){ return(NULL);} + const U_SERIAL_DESC List[] = { + {&Version, 4, 1, U_LE}, + {&Type, 4, 1, U_LE}, + {Id->Data, Id->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_IMAGE_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_IMAGEATTRIBUTES PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Version EmfPlusGraphicsVersion object + \param WrapMode WrapMode object + \param ClampColor EmfPlusARGB object + \param ObjectClamp ObjectClamp Identifiers + + EMF+ manual 2.2.1.5, Microsoft name: EmfPlusImageAttributes Object +*/ +U_PSEUDO_OBJ *U_PMF_IMAGEATTRIBUTES_set(uint32_t Version, uint32_t WrapMode, uint32_t ClampColor, uint32_t ObjectClamp){ + uint32_t Reserved=0; + const U_SERIAL_DESC List[] = { + {&Version, 4, 1, U_LE}, + {&Reserved, 4, 1, U_LE}, + {&WrapMode, 4, 1, U_LE}, + {&ClampColor, 4, 1, U_LE}, + {&ObjectClamp, 4, 1, U_LE}, + {&Reserved, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_IMAGEATTRIBUTES_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_PATH PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Version EmfPlusGraphicsVersion object + \param Points U_PSEUDO_OBJ containing array of points (of type PMFPointR, PMFPoint, or PMFPointF, determined by U_PPF_P and U_PPF_C bits in Flags) + \param Types U_PSEUDO_OBJ containing array of types (U_PMF_PATHPOINTTYPE or U_PMF_PATHPOINTTYPERLE, determined by U_PPF_R big in Flags) + + EMF+ manual 2.2.1.6, Microsoft name: EmfPlusPath Object +*/ +U_PSEUDO_OBJ *U_PMF_PATH_set(uint32_t Version, const U_PSEUDO_OBJ *Points, const U_PSEUDO_OBJ *Types){ + int ctype, RelAbs, rtype; + int pad; + if(Points){ + if( Points->Type == U_PMF_POINTR_OID){ RelAbs = 1; ctype = 0; } + else if(Points->Type == (U_PMF_POINT_OID | U_PMF_ARRAY_OID)){ RelAbs = 0; ctype = 1; } + else if(Points->Type == (U_PMF_POINTF_OID | U_PMF_ARRAY_OID)){ RelAbs = 0; ctype = 0; } + else { return(NULL); } + } + else { return(NULL); } + if(Types){ + if( Types->Type == (U_PMF_PATHPOINTTYPERLE_OID | U_PMF_ARRAY_OID)){ rtype = 1; } + else if(Types->Type == (U_PMF_PATHPOINTTYPE_OID | U_PMF_ARRAY_OID)){ rtype = 0; } + else { return(NULL); } + } + else { return(NULL); } + uint16_t Flags = (rtype ? U_PPF_R : 0) | (ctype ? U_PPF_C : 0)| (RelAbs ? U_PPF_P : 0); + pad = (0x3 & (Points->Used + Types->Used)); + if(pad){ pad = 4 - pad; } + const U_SERIAL_DESC List[] = { + {&Version, 4, 1, U_LE }, + {Points->Data, 4, 1, U_XE }, /* Elements from Points */ + {&Flags, 2, 1, U_LE }, + {NULL, 2, 1, U_LE }, /* Reserved field */ + {Points->Data + 4, Points->Used - 4, 1, U_XE }, /* omit Points Elements */ + {Types->Data +4, Types->Used - 4, 1, U_XE }, /* omit Types Elements */ + {NULL, pad, (pad ? 1 : 0), (pad ? U_XE : U_XX)}, /* if no padding is needed the Units will be zero and nothing will happen */ + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_PATH_OID, List); + return(po); +} + + +/** + \brief Create and set a U_PMF_PATH PseudoObject that uses U_PMF_POINTF coordinates + \return Pointer to PseudoObject, NULL on error + \param Version EmfPlusGraphicsVersion object + \param Path U_DPSEUDO_OBJ containing a path. + + EMF+ manual 2.2.1.6, Microsoft name: EmfPlusPath Object +*/ +U_PSEUDO_OBJ *U_PMF_PATH_set2(uint32_t Version, const U_DPSEUDO_OBJ *Path){ + if(!Path || !Path->Elements){ return(NULL); } + uint16_t Flags = 0; + int pad = (0x3 & Path->Elements); + if(pad){ pad = 4 - pad; } + const U_SERIAL_DESC List[] = { + {&Version, 4, 1, U_LE }, + {&Path->Elements, 4, 1, U_LE }, + {&Flags, 2, 1, U_LE }, + {NULL, 2, 1, U_LE }, /* Reserved field */ + {Path->poPoints->Data, 4, 2*Path->Elements,U_XE }, /* raw OID, so no leading Elements to omit */ + {Path->poTypes->Data, 1, Path->Elements, U_XE }, /* raw OID, so no leading Elements to omit */ + {NULL, pad, (pad ? 1 : 0), (pad ? U_XE : U_XX)}, /* if no padding is needed the Units will be zero and nothing will happen */ + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_PATH_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_PATH PseudoObject that uses U_PMF_POINT (int 16) coordinates + \return Pointer to PseudoObject, NULL on error + \param Version EmfPlusGraphicsVersion object + \param Path U_DPSEUDO_OBJ containing a path. + + EMF+ manual 2.2.1.6, Microsoft name: EmfPlusPath Object +*/ +U_PSEUDO_OBJ *U_PMF_PATH_set3(uint32_t Version, const U_DPSEUDO_OBJ *Path){ + if(!Path || !Path->Elements){return(NULL); } + uint16_t Flags = U_PPF_C; + int pad = (0x3 & Path->Elements); + if(pad){ pad = 4 - pad; } + U_PMF_POINT *Points16 = POINTF_To_POINT16_LE((U_PMF_POINTF *)Path->poPoints->Data, Path->Elements); + if(!Points16){ return(NULL); } + const U_SERIAL_DESC List[] = { + {&Version, 4, 1, U_LE }, + {&Path->Elements, 4, 1, U_LE }, + {&Flags, 2, 1, U_LE }, + {NULL, 2, 1, U_LE }, /* Reserved field */ + {Points16, 2, 2*Path->Elements,U_XE }, /* raw data, so no leading Elements to omit */ + {Path->poTypes->Data, 1, Path->Elements, U_XE }, /* raw data, so no leading Elements to omit */ + {NULL, pad, (pad ? 1 : 0), (pad ? U_XE : U_XX)}, /* if no padding is needed the Units will be zero and nothing will happen */ + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_PATH_OID, List); + free(Points16); + return(po); +} + +/** + \brief Create and set a U_PMF_PEN PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Version EmfPlusGraphicsVersion object + \param PenData U_PSEUDO_OBJ containing U_PMF_PENDATA object + \param Brush U_PSEUDO_OBJ containing U_PMF_BRUSH object + + EMF+ manual 2.2.1.7, Microsoft name: EmfPlusPen Object +*/ +U_PSEUDO_OBJ *U_PMF_PEN_set(uint32_t Version, const U_PSEUDO_OBJ *PenData, const U_PSEUDO_OBJ *Brush){ + if(!PenData || (PenData->Type != U_PMF_PENDATA_OID)){ return(NULL); } + if(!Brush || (Brush->Type != U_PMF_BRUSH_OID) ){ return(NULL); } + const U_SERIAL_DESC List[] = { + {&Version, 4, 1, U_LE}, + {NULL, 4, 1, U_LE}, + {PenData->Data, PenData->Used, 1, U_XE}, + {Brush->Data, Brush->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_PEN_OID, List); + return(po); +} + + +/** + \brief Create and set a U_PMF_REGION PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Version EmfPlusGraphicsVersion object + \param Count Number of CHILD nodes. This is one less than the total number of U_PMF_REGIONNODE objects in Nodes. + \param Nodes U_PSEUDO_OBJ containing U_PMF_REGIONNODE object (Nodes defining region, may be a single element or a binary tree) + + EMF+ manual 2.2.1.8, Microsoft name: EmfPlusRegion Object +*/ +U_PSEUDO_OBJ *U_PMF_REGION_set(uint32_t Version, uint32_t Count, const U_PSEUDO_OBJ *Nodes){ + if(Nodes->Type != U_PMF_REGIONNODE_OID)return(NULL); + const U_SERIAL_DESC List[] = { + {&Version, 4, 1, U_LE}, + {&Count, 4, 1, U_LE}, + {Nodes->Data, Nodes->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_REGION_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_STRINGFORMAT PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Sfs pointer to U_PMF_STRINGFORMAT structure, with no variable part + \param Sfd (optional) U_PSEUDO_OBJ containing U_PMF_STRINGFORMATDATA object + + EMF+ manual 2.2.1.9, Microsoft name: EmfPlusStringFormat Object +*/ +U_PSEUDO_OBJ *U_PMF_STRINGFORMAT_set(U_PMF_STRINGFORMAT *Sfs, const U_PSEUDO_OBJ *Sfd){ + if(Sfd){ + if((!Sfs->TabStopCount && !Sfs->RangeCount) || (Sfd->Type != U_PMF_STRINGFORMATDATA_OID))return(NULL); + } + else { + if(Sfs->TabStopCount || Sfs->RangeCount)return(NULL); + } + const U_SERIAL_DESC List[] = { + {&Sfs->Version, 4, 1, U_LE}, + {&Sfs->Flags, 4, 1, U_LE}, + {&Sfs->Language, 4, 1, U_LE}, + {&Sfs->StringAlignment, 4, 1, U_LE}, + {&Sfs->LineAlign, 4, 1, U_LE}, + {&Sfs->DigitSubstitution, 4, 1, U_LE}, + {&Sfs->DigitLanguage, 4, 1, U_LE}, + {&Sfs->FirstTabOffset, 4, 1, U_LE}, + {&Sfs->HotkeyPrefix, 4, 1, U_LE}, + {&Sfs->LeadingMargin, 4, 1, U_LE}, + {&Sfs->TrailingMargin, 4, 1, U_LE}, + {&Sfs->Tracking, 4, 1, U_LE}, + {&Sfs->Trimming, 4, 1, U_LE}, + {&Sfs->TabStopCount, 4, 1, U_LE}, + {&Sfs->RangeCount, 4, 1, U_LE}, + {(Sfd ? Sfd->Data : NULL), (Sfd ? Sfd->Used : 0), 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_STRINGFORMAT_OID, List); + return(po); +} + +/** + \brief Create and set a PMF_4NUM PseudoObject (used for BrushID's) + \return Pointer to PseudoObject, NULL on error + \param BrushID U_PMF_BRUSH object in the EMF+ object table (0-63, inclusive) + +*/ +U_PSEUDO_OBJ *U_PMF_4NUM_set(uint32_t BrushID){ + if(BrushID>63){ return(NULL); } + const U_SERIAL_DESC List[] = { + {&BrushID, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_4NUM_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_ARGB PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Alpha Alpha (0-255) + \param Red Red color (0-255) + \param Green Green color (0-255) + \param Blue Blue color (0-255) + + EMF+ manual 2.2.2.1, Microsoft name: EmfPlusARGB Object +*/ +U_PSEUDO_OBJ *U_PMF_ARGB_set(uint8_t Alpha, uint8_t Red, uint8_t Green, uint8_t Blue){ + const U_SERIAL_DESC List[] = { + {&Blue, 1, 1, U_XE}, + {&Green, 1, 1, U_XE}, + {&Red, 1, 1, U_XE}, + {&Alpha, 1, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_ARGB_OID, List); + return(po); +} + +/** + \brief Create and set an Array of U_PMF_ARGB valus in a PseudoObject + \return Pointer to PseudoObject containing the count, followed by the array of colors, NULL on error + \param Count Number of entries in Colors + \param Colors Array of ARGB values + + EMF+ manual 2.2.2.1, Microsoft name: EmfPlusARGB Object +*/ +U_PSEUDO_OBJ *U_PMF_ARGBN_set(uint32_t Count, U_PMF_ARGB *Colors){ + const U_SERIAL_DESC List[] = { + {&Count, 4, 1, U_LE}, + {Colors, 4, Count, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_ARGB_OID | U_PMF_ARRAY_OID, List); + return(po); +} + +/** + \brief Set a U_PMF_ARGB object + \return Object + \param Alpha Alpha (0-255) + \param Red Red color (0-255) + \param Green Green color (0-255) + \param Blue Blue color (0-255) + + EMF+ manual 2.2.2.1, Microsoft name: EmfPlusARGB Object +*/ +U_PMF_ARGB U_PMF_ARGBOBJ_set(uint8_t Alpha, uint8_t Red, uint8_t Green, uint8_t Blue){ + U_PMF_ARGB argb; + char *ptr = (char *) &argb; + U_PMF_MEMCPY_DSTSHIFT(&ptr, &Blue, 1); + U_PMF_MEMCPY_DSTSHIFT(&ptr, &Green, 1); + U_PMF_MEMCPY_DSTSHIFT(&ptr, &Red, 1); + U_PMF_MEMCPY_DSTSHIFT(&ptr, &Alpha, 1); + return(argb); +} + +/** + \brief Create and set a U_PMF_BITMAP PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Bs pointer to U_PMF_BITMAP structure, with no variable part + \param Bm U_PSEUDO_OBJ containing an U_PMF_BITMAPDATA or U_PMF_COMPRESSEDIMAGE object + + EMF+ manual 2.2.2.2, Microsoft name: EmfPlusBitmap Object +*/ +U_PSEUDO_OBJ *U_PMF_BITMAP_set(const U_PMF_BITMAP *Bs, const U_PSEUDO_OBJ *Bm){ + if(Bm->Type != U_PMF_BITMAPDATA_OID && + Bm->Type != U_PMF_COMPRESSEDIMAGE_OID )return(NULL); + uint32_t Pad = UP4(Bm->Used) - Bm->Used; /* undocumented padding, must be present for at least PNG */ + const U_SERIAL_DESC List[] = { + {Bs, 4, 5, U_LE}, + {Bm->Data, Bm->Used, 1, U_XE}, + {NULL, (Pad ? Pad : 0), (Pad ? 1 : 0), U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_BITMAP_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_BITMAPDATA PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Ps (optional) U_PSEUDO_OBJ containing a U_PMF_PALETTE structure + \param cbBm Bytes in Bm + \param Bm An array of bytes, meaning depends on fields in U_PMF_BITMAP object and the PixelFormat enumeration. + + EMF+ manual 2.2.2.3, Microsoft name: EmfPlusBitmapData Object +*/ +U_PSEUDO_OBJ *U_PMF_BITMAPDATA_set( const U_PSEUDO_OBJ *Ps, int cbBm, const char *Bm){ + if(Ps && (Ps->Type != U_PMF_PALETTE_OID))return(NULL); + const U_SERIAL_DESC List[] = { + {(Ps ? Ps->Data : NULL), (Ps ? Ps->Used : 0), (Ps ? 1 : 0), U_LE}, + {Bm, cbBm, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_BITMAPDATA_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_BLENDCOLORS PseudoObject + \return Pointer to PseudoObject, NULL on Positions and Colors + \param Elements number of elements in Positions, must agree with the number of Colors. + \param Positions positions along gradient line. The first position MUST be 0.0 and the last MUST be 1.0. + \param Colors U_PSEUDO_OBJ containing an array of U_PMF_ARGB objects: object colors at positions on gradient line + + EMF+ manual 2.2.2.4, Microsoft name: EmfPlusBlendColors Object +*/ +U_PSEUDO_OBJ *U_PMF_BLENDCOLORS_set(uint32_t Elements, const U_FLOAT *Positions, const U_PSEUDO_OBJ *Colors){ + if(!Colors || !Positions || Colors->Type != (U_PMF_ARGB_OID | U_PMF_ARRAY_OID)){ return(NULL); } + uint32_t CElements = (Colors->Used - 4)/4; + if(CElements != Elements){ return(NULL); } + const U_SERIAL_DESC List[] = { + {&CElements, 4, 1, U_LE}, + {Positions, 4, CElements, U_LE}, + {Colors->Data + 4, Colors->Used - 4, 1, U_XE}, /* omit Elements part of this PseudoObject */ + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_BLENDCOLORS_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_BLENDCOLORS PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Elements members in osition, inluding Start and End (0.0 - 1.0) + \param StartColor Start Color (U_PMF_ARGB) + \param EndColor End Color (U_PMF_ARGB) + + EMF+ manual 2.2.2.5, Microsoft name: EmfPlusBlendFactors Object + + + Positions always start at 0.0 and always end at 1.0. It is not well documented but other + start and end values generally do not work. +*/ +U_PSEUDO_OBJ *U_PMF_BLENDCOLORS_linear_set(uint32_t Elements, U_PMF_ARGB StartColor, U_PMF_ARGB EndColor){ + double dP,dR,dG,dB,dA,P,R,G,B,A; + U_FLOAT StartPos = 0.0; + U_FLOAT EndPos = 1.0; + U_FLOAT *Positions; + U_FLOAT *pP; + U_PMF_ARGB *Colors; + U_PMF_ARGB *pC; + unsigned int i; + if(Elements <= 2 ){ return(NULL); } + pP = Positions = (U_FLOAT *)malloc(Elements *sizeof(U_FLOAT)); + if(!Positions){ return(NULL); } + pC = Colors = (U_PMF_ARGB *)malloc(Elements *sizeof(U_PMF_ARGB)); + if(!Colors){ + free(Positions); + return(NULL); + } + dP = (EndPos - StartPos )/(float)(Elements - 1); + dB = ((double)EndColor.Blue - (double)StartColor.Blue )/(double)(Elements - 1); + dG = ((double)EndColor.Green - (double)StartColor.Green)/(double)(Elements - 1); + dR = ((double)EndColor.Red - (double)StartColor.Red )/(double)(Elements - 1); + dA = ((double)EndColor.Alpha - (double)StartColor.Alpha)/(double)(Elements - 1); + P = StartPos; + B = StartColor.Blue; + G = StartColor.Green; + R = StartColor.Red; + A = StartColor.Alpha; + for(i=0;i1.0 values, inclusiv + + EMF+ manual 2.2.2.5, Microsoft name: EmfPlusBlendFactors Object +*/ +U_PSEUDO_OBJ *U_PMF_BLENDFACTORS_set(uint32_t Elements, const U_FLOAT *Positions, const U_FLOAT *Factors){ + if(!Positions || !Factors)return(NULL); + const U_SERIAL_DESC List[] = { + {&Elements, 4, 1, U_LE}, + {Positions, 4, Elements, U_LE}, + {Factors, 4, Elements, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_BLENDFACTORS_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_BLENDFACTORS PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Elements members in osition, inluding Start and End (0.0 - 1.0) + \param StartFactor Start Factor (0.0 - 1.0) + \param EndFactor End Factor (0.0 - 1.0) + + EMF+ manual 2.2.2.5, Microsoft name: EmfPlusBlendFactors Object + + + Positions always start at 0.0 and always end at 1.0. It is not well documented but other + start and end values generally do not work. +*/ +U_PSEUDO_OBJ *U_PMF_BLENDFACTORS_linear_set(uint32_t Elements, U_FLOAT StartFactor, U_FLOAT EndFactor){ + double dP,dF,P,F; + U_FLOAT StartPos = 0.0; + U_FLOAT EndPos = 1.0; + U_FLOAT *Positions; + U_FLOAT *Factors; + U_FLOAT *pP; + U_FLOAT *pF; + unsigned int i; + if(Elements <= 2 ){ return(NULL); } + pP = Positions = (U_FLOAT *)malloc(Elements *sizeof(U_FLOAT)); + if(!Positions){ return(NULL); } + pF = Factors = (U_FLOAT *)malloc(Elements *sizeof(U_FLOAT)); + if(!Factors){ + free(Positions); + return(NULL); + } + dP = (EndPos - StartPos )/(float)(Elements - 1); + dF = (EndFactor - StartFactor)/(float)(Elements - 1); + P = StartPos; + F = StartFactor; + for(i=0;iType != U_PMF_PATH_OID)return(NULL); + /* PO Used is size_t, might be 8 bytes, value in record must be 4 bytes */ + uint32_t Used = Path->Used; + const U_SERIAL_DESC List[] = { + {&Used, 4, 1, U_LE}, + {Path->Data, Path->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_BOUNDARYPATHDATA_OID, List); + return(po); +} + + +/** + \brief Create and set a U_PMF_BOUNDARYPOINTDATA PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Elements members in each array + \param Points array of U_PMF_POINTF + + EMF+ manual 2.2.2.7, Microsoft name: EmfPlusBoundaryPointData Object +*/ +U_PSEUDO_OBJ *U_PMF_BOUNDARYPOINTDATA_set(uint32_t Elements, const U_PMF_POINTF *Points){ + if(!Points)return(NULL); + const U_SERIAL_DESC List[] = { + {&Elements, 4, 1, U_LE}, + {Points, 4, 2*Elements,U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_BOUNDARYPOINTDATA_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_CHARACTERRANGE PseudoObject + \return Pointer to PseudoObject, NULL on error + \param First First position in range + \param Length Range length + + EMF+ manual 2.2.2.8, Microsoft name: EmfPlusCharacterRange Object +*/ +U_PSEUDO_OBJ *U_PMF_CHARACTERRANGE_set(int32_t First, int32_t Length){ + const U_SERIAL_DESC List[] = { + {&First, 4, 1, U_LE}, + {&Length, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_CHARACTERRANGE_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_COMPOUNDLINEDATA PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Elements Members in Widths + \param Widths Array of U_FLOAT Line or gap widths (0.0 <-> 1.0, fraction of total line width ) + + EMF+ manual 2.2.2.9, Microsoft name: EmfPlusCompoundLineData Object +*/ +U_PSEUDO_OBJ *U_PMF_COMPOUNDLINEDATA_set(int32_t Elements, const char *Widths){ + if(!Widths)return(NULL); + const U_SERIAL_DESC List[] = { + {&Elements ,4, 1, U_LE}, + {Widths, 4, Elements,U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_COMPOUNDLINEDATA_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_COMPRESSEDIMAGE PseudoObject + \return Pointer to PseudoObject, NULL on error + \param cbImage Bytes in Image + \param Image Stored image in one of the supported formats (GIF, PNG, etc.). + + EMF+ manual 2.2.2.10, Microsoft name: EmfPlusCompressedImage Object +*/ +U_PSEUDO_OBJ *U_PMF_COMPRESSEDIMAGE_set(int32_t cbImage, const char *Image){ + if(!cbImage || !Image)return(NULL); + const U_SERIAL_DESC List[] = { + {Image, cbImage, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_COMPRESSEDIMAGE_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_CUSTOMENDCAPDATA PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Clc U_PSEUDO_OBJ containing a U_PMF_CUSTOMLINECAP object + + EMF+ manual 2.2.2.11, Microsoft name: EmfPlusCustomEndCapData Object +*/ +U_PSEUDO_OBJ *U_PMF_CUSTOMENDCAPDATA_set(const U_PSEUDO_OBJ *Clc){ + if(Clc->Type != U_PMF_CUSTOMLINECAP_OID)return(NULL); + /* PO Used is size_t, might be 8 bytes, value in record must be 4 bytes */ + uint32_t Used = Clc->Used; + const U_SERIAL_DESC List[] = { + {&Used, 4, 1, U_LE}, + {Clc->Data, Clc->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_CUSTOMENDCAPDATA_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_CUSTOMLINECAPARROWDATA PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Width Arrow cap width (is multiplied by line width before draw) + \param Height Arrow cap length (is multiplied by line width before draw) + \param MiddleInset Pixels between outer edge and filled region + \param FillState If set, fill, otherwise, only border + \param StartCap LineCap enumeration (type of cap) + \param EndCap LineCap enumeration + \param Join LineJoin enumeration + \param MiterLimit Maximum (miter length / line width) + \param WidthScale Scale for U_PMF_CUSTOMLINECAP object + + EMF+ manual 2.2.2.12, Microsoft name: EmfPlusCustomLineCapArrowData Object +*/ +U_PSEUDO_OBJ *U_PMF_CUSTOMLINECAPARROWDATA_set(U_FLOAT Width, U_FLOAT Height, + U_FLOAT MiddleInset, uint32_t FillState, uint32_t StartCap, uint32_t EndCap, uint32_t Join, + U_FLOAT MiterLimit, U_FLOAT WidthScale + ){ + const U_SERIAL_DESC List[] = { + {&Width, 4, 1, U_LE}, + {&Height ,4, 1, U_LE}, + {&MiddleInset, 4, 1, U_LE}, + {&FillState, 4, 1, U_LE}, + {&StartCap, 4, 1, U_LE}, + {&EndCap, 4, 1, U_LE}, + {&Join, 4, 1, U_LE}, + {&MiterLimit, 4, 1, U_LE}, + {&WidthScale, 4, 1, U_LE}, + {NULL, 8, 2, U_LE}, /* FillHotSpots and LineHotSpots */ + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_CUSTOMLINECAPARROWDATA_OID, List); + return(po); +} + + +/** + \brief Create and set a U_PMF_CUSTOMLINECAPDATA PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Flags CustomLineCapData flags + \param Cap LineCap enumeration (type of cap) + \param Inset Distance line cap start -> line end + \param StartCap LineCap enumeration + \param EndCap LineCap enumeration + \param Join LineJoin enumeration + \param MiterLimit Maximum (miter length / line width) + \param WidthScale Scale for U_PMF_CUSTOMLINECAP object + \param Clcod U_PSEUDO_OBJ containing a U_PMF_CUSTOMLINECAPOPTIONALDATA object + + EMF+ manual 2.2.2.13, Microsoft name: EmfPlusCustomLineCapData Object +*/ +U_PSEUDO_OBJ *U_PMF_CUSTOMLINECAPDATA_set(uint32_t Flags, uint32_t Cap, + U_FLOAT Inset, uint32_t StartCap, uint32_t EndCap, + uint32_t Join, U_FLOAT MiterLimit, U_FLOAT WidthScale, + const U_PSEUDO_OBJ *Clcod + ){ + if(Clcod->Type != U_PMF_CUSTOMLINECAPOPTIONALDATA_OID)return(NULL); + const U_SERIAL_DESC List[] = { + {&Flags, 4, 1, U_LE}, + {&Cap, 4, 1, U_LE}, + {&Inset, 4, 1, U_LE}, + {&StartCap, 4, 1, U_LE}, + {&EndCap, 4, 1, U_LE}, + {&Join, 4, 1, U_LE}, + {&MiterLimit, 4, 1, U_LE}, + {&WidthScale, 4, 1, U_LE}, + {NULL, 8, 2, U_LE}, /* FillHotSpots and LineHotSpots */ + {Clcod->Data, Clcod->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_CUSTOMLINECAPDATA_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_CUSTOMLINECAPOPTIONALDATA PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Fill U_PSEUDO_OBJ containing a U_PMF_FILLPATHOBJ object (optional) + \param Line U_PSEUDO_OBJ containing a U_PMF_LINEPATH object (optional) + + EMF+ manual 2.2.2.14, Microsoft name: EmfPlusCustomLineCapOptionalData Object +*/ +U_PSEUDO_OBJ *U_PMF_CUSTOMLINECAPOPTIONALDATA_set(const U_PSEUDO_OBJ *Fill, const U_PSEUDO_OBJ *Line){ + if(Fill && (Fill->Type != U_PMF_FILLPATHOBJ_OID))return(NULL); + if(Line && (Line->Type != U_PMF_LINEPATH_OID))return(NULL); + const U_SERIAL_DESC List[] = { + {Fill->Data, Fill->Used, 1, U_XE}, + {Line->Data, Line->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_CUSTOMLINECAPOPTIONALDATA_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_CUSTOMSTARTCAPDATA PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Clc U_PSEUDO_OBJ containing a U_PMF_CUSTOMLINECAPDATA object + + EMF+ manual 2.2.2.15, Microsoft name: EmfPlusCustomStartCapData Object +*/ +U_PSEUDO_OBJ *U_PMF_CUSTOMSTARTCAPDATA_set(const U_PSEUDO_OBJ *Clc){ + if(Clc && (Clc->Type != U_PMF_CUSTOMLINECAP_OID))return(NULL); + const U_SERIAL_DESC List[] = { + {Clc->Data, Clc->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_CUSTOMSTARTCAPDATA_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_DASHEDLINEDATA PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Elements Members in Lengths + \param Lengths Array of U_FLOAT holding lengths of dashes and spaces. + + EMF+ manual 2.2.2.16, Microsoft name: EmfPlusDashedLineData Object +*/ +U_PSEUDO_OBJ *U_PMF_DASHEDLINEDATA_set(int32_t Elements, const U_FLOAT *Lengths){ + if(!Lengths)return(NULL); + const U_SERIAL_DESC List[] = { + {&Elements, 4, 1, U_LE}, + {Lengths, 4, Elements, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_DASHEDLINEDATA_OID, List); + return(po); +} + +/** + \brief Utility function to create and set a U_PMF_DASHEDLINEDATA PseudoObject from one of a predefined set of patterns + \return Pointer to PseudoObject, NULL on error + \param Unit Length of the repeat unit + \param StdPat Members in Lengths + + EMF+ manual 2.2.2.16, Microsoft name: EmfPlusDashedLineData Object +*/ +U_PSEUDO_OBJ *U_PMF_DASHEDLINEDATA_set2(U_FLOAT Unit, int StdPat){ + uint32_t Elements; + uint8_t *p; + U_FLOAT SubUnit; + U_FLOAT Lengths[8]; /* This is the most dash/spaces that will be needed*/ + int i; + /* Dot = 1, Dash = 2; Long = 3, 0 = terminate pattern */ + uint8_t SB[U_DD_Types][5] = + { + {0,0,0,0,0}, // Solid + {2,0,0,0,0}, // Dash + {2,2,0,0,0}, // DashDash + {2,2,2,0,0}, // DashDashDash + {2,2,2,2,0}, // DashDashDashDash + {1,0,0,0,0}, // Dot + {1,1,0,0,0}, // DotDot + {1,1,1,0,0}, // DotDotDot + {1,1,1,1,0}, // DotDotDotDot + {2,1,0,0,0}, // DashDot + {2,2,1,0,0}, // DashDashDot + {2,2,1,1,0}, // DashDashDotDot + {2,2,2,1,0}, // DashDashDashDot + {2,1,1,0,0}, // DashDotDot + {2,1,1,1,0}, // DashDotDotDot + {2,1,2,1,0}, // DashDotDashDot + {3,0,0,0,0}, // Long + {3,3,0,0,0}, // LongLong + {3,3,3,0,0}, // LongLongLong + {3,3,3,3,0}, // LongLongLongLong + {3,1,0,0,0}, // LongDot + {3,3,1,0,0}, // LongLongDot + {3,3,1,1,0}, // LongLongDotDot + {3,3,3,1,0}, // LongLongLongDot + {3,1,1,0,0}, // LongDotDot + {3,1,1,1,0}, // LongDotDotDot + {3,1,3,1,0} // LongDotLongDot + }; + if(Unit <= 0 ){ return(NULL); } + if((StdPat <= 0) || (StdPat > U_DD_LongDotLongDot)){ return(NULL); } + p = &(SB[StdPat][0]); + for(Elements = 0; *p; p++, Elements++){} + SubUnit = Unit/((U_FLOAT) Elements); + Elements *= 2; + p = &(SB[StdPat][0]); + for(i=0; *p; p++){ + switch(*p){ + case 0: break; + case 1: /* dot */ + Lengths[i++] = SubUnit * 0.125; + Lengths[i++] = SubUnit * 0.875; + break; + case 2: /* dash */ + Lengths[i++] = SubUnit * 0.5; + Lengths[i++] = SubUnit * 0.5; + break; + case 3: /* long */ + Lengths[i++] = SubUnit * 0.75; + Lengths[i++] = SubUnit * 0.25; + break; + } + } + + U_PSEUDO_OBJ *po = U_PMF_DASHEDLINEDATA_set(Elements, Lengths); + return(po); +} + +/** + \brief Utility function to create and set a U_PMF_DASHEDLINEDATA PseudoObject from the bits that are set in a uint32_t + \return Pointer to PseudoObject, NULL on error + \param Unit Length of the repeat unit + \param BitPat uint32_t holding the bit pattern, the lowest order bit MUST be set and the highest order MUST be clear. + + Make a line with a dot/dash pattern defined by the bits in the BitPat value. If a bit is set it is drawn, + if clear it is not. Every bit drawn has length Unit/32, and consecutive drawn bits are merged together. + The lowest order bit is the first bit that may be drawn, the highest the last. + + Example: if the integer has value 0x13 the pattern produced will be: + 0 -> 2*unit/32 drawn + 2*unit/32 -> 5*unit/32 not drawn + 5*unit/32 -> 6*unit/32 drawn + 6*unit/32 -> unit not drawn + + EMF+ manual 2.2.2.16, Microsoft name: EmfPlusDashedLineData Object +*/ +U_PSEUDO_OBJ *U_PMF_DASHEDLINEDATA_set3(U_FLOAT Unit, uint32_t BitPat){ + uint32_t Elements=0; + U_FLOAT SubUnit = Unit/32.0; + U_FLOAT Lengths[32]; /* This is the most dash/spaces that will be needed*/ + if(!(0x00000001 & BitPat))return(NULL); /* Pattern must start with a drawn segment, this bit must be set */ + if( 0x80000000 & BitPat )return(NULL); /* Pattern must end with an undrawn segment, this bit must be clear */ + int i=0; + int k; + int lastType=1; + int newType=0; + uint32_t j=1; + Lengths[0]=0; + for(k=0; k<32; k++, j=j<<1){ + if(j & BitPat){ + if(!lastType){ + newType=1; + } + } + else { + if(lastType){ + newType=1; + } + } + if(newType){ + i++; + Lengths[i]=0; + Elements++; + lastType = !lastType; + newType = 0; + } + Lengths[i] += SubUnit; + } + Elements = i+1; + + U_PSEUDO_OBJ *po = U_PMF_DASHEDLINEDATA_set(Elements, Lengths); + return(po); +} + +/** + \brief Create and set a U_PMF_FILLPATHOBJ PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Path U_PSEUDO_OBJ containing a U_PMF_PATH object + + EMF+ manual 2.2.2.17, Microsoft name: EmfPlusFillPath Object +*/ +U_PSEUDO_OBJ *U_PMF_FILLPATHOBJ_set(const U_PSEUDO_OBJ *Path){ + if(Path && (Path->Type != U_PMF_PATH_OID))return(NULL); + const U_SERIAL_DESC List[] = { + {Path->Data, Path->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_FILLPATHOBJ_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_FOCUSSCALEDATA PseudoObject + \return Pointer to PseudoObject, NULL on error + \param ScaleX value 0.0 <-> 1.0 + \param ScaleY value 0.0 <-> 1.0 + + EMF+ manual 2.2.2.18, Microsoft name: EmfPlusFocusScaleData Object +*/ +U_PSEUDO_OBJ *U_PMF_FOCUSSCALEDATA_set(U_FLOAT ScaleX, U_FLOAT ScaleY){ + uint32_t tmp = 2; + const U_SERIAL_DESC List[] = { + {&tmp, 4, 1, U_LE}, + {&ScaleX, 4, 1, U_LE}, + {&ScaleY, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_FOCUSSCALEDATA_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_GRAPHICSVERSION object (Signature always set to 0xDBC01) + \return Pointer to PseudoObject, NULL on error + \param GrfVersion GraphicsVersion enumeration + + EMF+ manual 2.2.2.19, Microsoft name: EmfPlusGraphicsVersion Object +*/ +U_PSEUDO_OBJ *U_PMF_GRAPHICSVERSION_set(int GrfVersion){ + uint32_t tmp; + tmp = U_GFVR_PMF << 12; /* signature, can only have this value */ + tmp |= (GrfVersion & U_GFVR_MASKLO); + const U_SERIAL_DESC List[] = { + {&tmp, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_GRAPHICSVERSION_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_GRAPHICSVERSION object Structure (Signature always set to 0xDBC01) + \return U_PMF_GRAPHICSVERSION + \param GrfVersion GraphicsVersion enumeration + + EMF+ manual 2.2.2.19, Microsoft name: EmfPlusGraphicsVersion Object +*/ +U_PMF_GRAPHICSVERSION U_PMF_GRAPHICSVERSIONOBJ_set(int GrfVersion){ + uint32_t tmp; + tmp = U_GFVR_PMF << 12; /* signature, can only have this value */ + tmp |= (GrfVersion & U_GFVR_MASKLO); + return(tmp); +} + + +/** + \brief Create and set a U_PMF_HATCHBRUSHDATA PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Style HatchStyle enumeration + \param Fg U_PSEUDO_OBJ containing a U_ARGB object, Foreground hatch pattern line color + \param Bg U_PSEUDO_OBJ containing a U_ARGB object, Background hatch pattern line color + + EMF+ manual 2.2.2.20, Microsoft name: EmfPlusHatchBrushData Object +*/ +U_PSEUDO_OBJ *U_PMF_HATCHBRUSHDATA_set(uint32_t Style, const U_PSEUDO_OBJ *Fg, const U_PSEUDO_OBJ *Bg){ + if(!Fg ||(Fg->Type != U_PMF_ARGB_OID))return(NULL); + if(!Bg ||(Bg->Type != U_PMF_ARGB_OID))return(NULL); + const U_SERIAL_DESC List[] = { + {&Style, 4, 1, U_LE}, + {Fg->Data, Fg->Used, 1, U_XE}, + {Bg->Data, Bg->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_HATCHBRUSHDATA_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_INTEGER7 PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Value 7 bit signed integer (stored in an integer, range 63 <-> -64, inclusive) + + EMF+ manual 2.2.2.21, Microsoft name: EmfPlusInteger7 Object +*/ +U_PSEUDO_OBJ *U_PMF_INTEGER7_set(int Value){ + uint8_t utmp; + if(Value < -64 || Value > 63)return(NULL); + utmp = U_MASK_INT7 & *(unsigned int *)&Value; + U_PSEUDO_OBJ *po = U_PO_create((char *)&utmp, 1, 1, U_PMF_INTEGER7_OID); /* simple method is OK, no possibility of Endian issues */ + return(po); +} + +/** + \brief Create and set a U_PMF_INTEGER15 PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Value 15 bit signed integer (stored in an integer, range 32677 <-> -32678, inclusive) + + EMF+ manual 2.2.2.22, Microsoft name: EmfPlusInteger15 Object +*/ +U_PSEUDO_OBJ *U_PMF_INTEGER15_set(int Value){ + uint16_t utmp; + if(Value < -32678 || Value > 32677)return(NULL); + utmp = U_TEST_INT15 | (U_MASK_INT15 & *(unsigned int *)&Value); + const U_SERIAL_DESC List[] = { + {&utmp, 2, 1, U_BE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_INTEGER15_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_LANGUAGEIDENTIFIER value in 4 byte unsigned int, in NATIVE byte order + \return LID value in least significant two bytes and 0 in most significant two bytes. + \param SubLId Example: code for USA + \param PriLId Example: code for English + + EMF+ manual 2.2.2.23, Microsoft name: EmfPlusLanguageIdentifier Object +*/ +U_PMF_LANGUAGEIDENTIFIER U_PMF_LANGUAGEIDENTIFIEROBJ_set(int SubLId, int PriLId){ + U_PMF_LANGUAGEIDENTIFIER utmp32; + utmp32 = ((SubLId & U_FF_MASK_SUBLID) << U_FF_SHFT_SUBLID) | ((PriLId & U_FF_MASK_PRILID) << U_FF_SHFT_PRILID); + return(utmp32); +} + +/** + \brief Create and set a U_PMF_LANGUAGEIDENTIFIER PseudoObject + \return Pointer to PseudoObject, NULL on error + \param LId Language Identifier as produced by U_PMF_LANGUAGEIDENTIFIEROBJ_set(). + + EMF+ manual 2.2.2.23, Microsoft name: EmfPlusLanguageIdentifier Object +*/ +U_PSEUDO_OBJ *U_PMF_LANGUAGEIDENTIFIER_set(U_PMF_LANGUAGEIDENTIFIER LId){ + uint16_t utmp16; + utmp16 = (LId & U_FF_MASK_LID) << U_FF_SHFT_LID; + const U_SERIAL_DESC List[] = { + {&utmp16, 2, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_LANGUAGEIDENTIFIER_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_LINEARGRADIENTBRUSHDATA PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Lgbd U_PMF_LINEARGRADIENTBRUSHDATA object (constant part) + \param Lgbod U_PSEUDO_OBJ containing a U_PMF_LINEARGRADIENTBRUSHOPTIONALDATA object (variable part of a U_PMF_LINEARGRADIENTBRUSHDATA object) + + + EMF+ manual 2.2.2.24, Microsoft name: EmfPlusLinearGradientBrushData Object +*/ +U_PSEUDO_OBJ *U_PMF_LINEARGRADIENTBRUSHDATA_set(const U_PMF_LINEARGRADIENTBRUSHDATA *Lgbd, const U_PSEUDO_OBJ *Lgbod){ + if(!Lgbd || !Lgbod || (Lgbod->Type != U_PMF_LINEARGRADIENTBRUSHOPTIONALDATA_OID))return(NULL); + const U_SERIAL_DESC List[] = { + {Lgbd, 4, 6, U_LE}, + {&(Lgbd->StartColor), 4, 2, U_XE}, + {&(Lgbd->StartColor), 4, 2, U_XE}, /* repeat the start/end colors. Supposedly reserved. */ +// {NULL, 4, 2, U_LE}, /* zero fill the two Reserved fields, no matter what is passed in */ + {(Lgbod->Used ? Lgbod->Data : NULL), Lgbod->Used, 1, U_XE}, /* optional Data can exist and Used can be zero, SERIAL_set would throw an error on that */ + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_LINEARGRADIENTBRUSHDATA_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_LINEARGRADIENTBRUSHOPTIONALDATA PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Flags Bits are set that indicate which of the following were included. The caller must clear before passing it in. + \param Tm U_PSEUDO_OBJ containing a U_PMF_TRANSFORMMATRIX object + \param Bc U_PSEUDO_OBJ containing a U_PMF_BLENDCOLORS object or NULL + \param BfH U_PSEUDO_OBJ containing a U_PMF_BLENDFACTORS (H) object or NULL + \param BfV U_PSEUDO_OBJ containing a U_PMF_BLENDFACTORS (V) object or NULL (WARNING, GDI+ defines this field but does not render it. DO NOT USE.) + + + EMF+ manual 2.2.2.25, Microsoft name: EmfPlusLinearGradientBrushOptionalData Object + + + The rectangular gradients repeat in a tiled pattern. Tm can rotate and offset the gradient within each tile. + The gradient wraps when it is offset. + +*/ +U_PSEUDO_OBJ *U_PMF_LINEARGRADIENTBRUSHOPTIONALDATA_set(uint32_t *Flags, const U_PSEUDO_OBJ *Tm, + const U_PSEUDO_OBJ *Bc, const U_PSEUDO_OBJ *BfH, const U_PSEUDO_OBJ *BfV){ + if(!Flags )return(NULL); + if(Tm && (Tm->Type != U_PMF_TRANSFORMMATRIX_OID))return(NULL); + if(Bc && (Bc->Type != U_PMF_BLENDCOLORS_OID) )return(NULL); + if(BfH && (BfH->Type != U_PMF_BLENDFACTORS_OID) )return(NULL); + if(BfV && (BfV->Type != U_PMF_BLENDFACTORS_OID) )return(NULL); + if(Bc && (BfH || BfV) )return(NULL); + const U_SERIAL_DESC List[] = { + {(Tm ? Tm->Data : NULL), (Tm ? Tm->Used : 0), 1, U_XE}, + {(Bc ? Bc->Data : NULL), (Bc ? Bc->Used : 0), 1, U_XE}, + {(BfH ? BfH->Data : NULL), (BfH ? BfH->Used : 0), 1, U_XE}, + {(BfV ? BfV->Data : NULL), (BfV ? BfV->Used : 0), 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_LINEARGRADIENTBRUSHOPTIONALDATA_OID, List); + if(Tm ){ *Flags |= U_BD_Transform; } + if(Bc ){ *Flags |= U_BD_PresetColors; } + if(BfH){ *Flags |= U_BD_BlendFactorsH; } + if(BfV){ *Flags |= U_BD_BlendFactorsV; } + return(po); +} + +/** + \brief Create and set a U_PMF_LINEPATH PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Path U_PSEUDO_OBJ containing a U_PMF_PATH object + + + EMF+ manual 2.2.2.26, Microsoft name: EmfPlusLinePath Object +*/ +U_PSEUDO_OBJ *U_PMF_LINEPATH_set(const U_PSEUDO_OBJ *Path){ + if(!Path || (Path->Type != U_PMF_PATH_OID))return(NULL); + const U_SERIAL_DESC List[] = { + {&Path->Data, Path->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_LINEPATH_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_METAFILE object (NOT SUPPORTED!) + \return Null + + + EMF+ manual 2.2.2.27, Microsoft name: EmfPlusMetafile Object +*/ +U_PSEUDO_OBJ *U_PMF_METAFILE_set(void){ + return(NULL); +} + +/** + \brief Create and set a U_PMF_PALETTE PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Flags PaletteStyle flags + \param Elements Members in Lengths + \param Pd Array of U_PMF_ARGB holding colors of palettes. (Palette Data) + + EMF+ manual 2.2.2.28, Microsoft name: EmfPlusPalette Object +*/ +U_PSEUDO_OBJ *U_PMF_PALETTE_set(uint32_t Flags, uint32_t Elements, const U_PMF_ARGB *Pd){ + if(!Pd)return(NULL); + const U_SERIAL_DESC List[] = { + {&Flags, 4, 1, U_LE}, + {&Elements, 4, 1, U_LE}, + {Pd, 4, Elements, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_PALETTE_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_PATHGRADIENTBRUSHDATA PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Flags PaletteStyle flags + \param WrapMode WrapMode enumeration + \param CenterColor U_PMF_ARGB Center color + \param Center Center coordinates + \param Gradient U_PSEUDO_OBJ containing an Array of U_PMF_ARGB holding colors of Gradient + \param Boundary U_PSEUDO_OBJ containing a U_PMF_BOUNDARYPATHDATA or U_PMF_BOUNDARYPOINTDATA object. (Boundary Data) + \param Data variable part of U_PMF_LINEARGRADIENTBRUSHDATA, exact composition depends on Flags + + EMF+ manual 2.2.2.29, Microsoft name: EmfPlusPathGradientBrushData Object +*/ +U_PSEUDO_OBJ *U_PMF_PATHGRADIENTBRUSHDATA_set(uint32_t Flags, int32_t WrapMode, U_PMF_ARGB CenterColor, + U_PMF_POINTF Center, + const U_PSEUDO_OBJ *Gradient, const U_PSEUDO_OBJ *Boundary, const U_PSEUDO_OBJ *Data){ + if( (Flags & U_BD_Path) && (!Boundary || (Boundary->Type != U_PMF_BOUNDARYPATHDATA_OID)))return(NULL); + if(!(Flags & U_BD_Path) && (!Boundary || (Boundary->Type != U_PMF_BOUNDARYPOINTDATA_OID)))return(NULL); + if(!(Gradient) || (Gradient->Type != (U_PMF_ARGB_OID | U_PMF_ARRAY_OID)))return(NULL); + if(!(Flags & U_BD_Transform) && + !(Flags & U_BD_PresetColors) && + !(Flags & U_BD_BlendFactorsH) && + !(Flags & U_BD_FocusScales) && + (!Data || (Data->Type != U_PMF_PATHGRADIENTBRUSHOPTIONALDATA_OID)))return(NULL); + + const U_SERIAL_DESC List[] = { + {&Flags, 4, 1, U_LE}, + {&WrapMode, 4, 1, U_LE}, + {&CenterColor, 4, 1, U_XE}, + {&Center.X, 4, 2, U_LE}, + {Gradient->Data, Gradient->Used, 1, U_XE}, /* includes Elements */ + {Boundary->Data, Boundary->Used, 1, U_XE}, + {(Data ? Data->Data : NULL), (Data ? Data->Used : 0), 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_PATHGRADIENTBRUSHDATA_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_PATHGRADIENTBRUSHOPTIONALDATA PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Flags PaletteStyle flags + \param Tm U_PSEUDO_OBJ containing a U_PMF_TRANSFORMMATRIX. (Transformation matrix) + \param Pd U_PSEUDO_OBJ containing a U_PMF_BLENDCOLORS or U_PMF_BLENDFACTORS object. (Pattern Data) + \param Fsd U_PSEUDO_OBJ containing a U_PMF_FOCUSSSCALEDATA object. (Focus Scale Data) + + EMF+ manual 2.2.2.30, Microsoft name: EmfPlusPathGradientBrushOptionalData Object +*/ +U_PSEUDO_OBJ *U_PMF_PATHGRADIENTBRUSHOPTIONALDATA_set(uint32_t Flags, + const U_PSEUDO_OBJ *Tm, const U_PSEUDO_OBJ *Pd, const U_PSEUDO_OBJ *Fsd){ + if(Tm && (Tm->Type != U_PMF_TRANSFORMMATRIX_OID))return(NULL); + if(Pd && !(Flags & (U_BD_PresetColors | U_BD_BlendFactorsH)))return(NULL); + if( (Flags & U_BD_PresetColors) && ((Flags & U_BD_BlendFactorsH) || !Pd || (Pd->Type != U_PMF_BLENDCOLORS_OID) ))return(NULL); + if( (Flags & U_BD_BlendFactorsH) && ((Flags & U_BD_PresetColors) || !Pd || (Pd->Type != U_PMF_BLENDFACTORS_OID)))return(NULL); + if(Fsd && !(Flags & U_BD_FocusScales))return(NULL); + if( (Flags & U_BD_FocusScales) && (!Fsd || (Fsd->Type != U_PMF_BLENDCOLORS_OID) ))return(NULL); + const U_SERIAL_DESC List[] = { + {(Tm ? Tm->Data : NULL), (Tm ? Tm->Used : 0), 1, U_XE}, + {(Pd ? Pd->Data : NULL), (Pd ? Pd->Used : 0), 1, U_XE}, + {(Fsd ? Fsd->Data : NULL), (Fsd ? Fsd->Used : 0), 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_PATHGRADIENTBRUSHOPTIONALDATA_OID, List); + return(po); +} + +/** + \brief Create and set an ARRAY of U_PMF_PATHPOINTTYPE objects + \return Pointer to PseudoObject, NULL on error + \param Elements Number of entries in Flags and Enumerations + \param Ppt Array of unsigned bytes, lower 4 bits hold the PathPointType flag upper 4 bits hold the PathPointType enumeration. + + EMF+ manual 2.2.2.31, Microsoft name: EmfPlusPathPointType Object +*/ +U_PSEUDO_OBJ *U_PMF_PATHPOINTTYPE_set(uint32_t Elements, const uint8_t *Ppt){ + if(!Elements || !Ppt)return(NULL); + const U_SERIAL_DESC List[] = { + {&Elements, 4, 1, U_LE}, + {Ppt, 1, Elements, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_PATHPOINTTYPE_OID | U_PMF_ARRAY_OID, List); + return(po); +} + +/** + \brief Create and set an ARRAY of U_PMF_PATHPOINTTYPE objects, with a preceding Elements count + \return Pointer to PseudoObject, NULL on error + \param Elements Number of elements to add. First is added once and Others Elements-1 times. + \param First Apply to first point, unsigned byte, lower 4 bits hold the PathPointType flag upper 4 bits hold the PathPointType enumeration. + \param Others Apply to all other points, unsigned byte, lower 4 bits hold the PathPointType flag upper 4 bits hold the PathPointType enumeration. + + EMF+ manual 2.2.2.31, Microsoft name: EmfPlusPathPointType Object +*/ +U_PSEUDO_OBJ *U_PMF_PATHPOINTTYPE_set2(uint32_t Elements, uint8_t First, uint8_t Others){ + if(!Elements)return(NULL); + const U_SERIAL_DESC List[] = { + {&Elements, 4, 1, U_XE}, + {&First, 1, 1, U_XE}, + {&Others, 1, Elements-1, U_RP}, /* replicate the one value N-1 times */ + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_PATHPOINTTYPE_OID | U_PMF_ARRAY_OID, List); + return(po); +} + +/** + \brief Create and set an ARRAY of U_PMF_PATHPOINTTYPERLE objects + \return Pointer to PseudoObject containing first the number of elements, then an array of U_PMF_PATHPOINTTYPERLE, NULL on error + \param Elements Number of entries in the arrays + \param Bz Array of unsigned bytes, if not zero, element has Bezier bit set + \param RL Array of unsigned bytes, Run lengths. + \param Ppte Array of unsigned bytes, PathPointType enumerations. + + EMF+ manual 2.2.2.32, Microsoft name: EmfPlusPathPointTypeRLE Object +*/ +U_PSEUDO_OBJ *U_PMF_PATHPOINTTYPERLE_set(uint32_t Elements, const uint8_t *Bz, const uint8_t *RL, const uint8_t *Ppte){ + uint8_t utmp; + if(!Bz || !RL || !Ppte)return(NULL); + /* allocate space in the structure but put no data in */ + U_PSEUDO_OBJ *po = U_PO_create(NULL, 4 + 2*Elements, 0, U_PMF_PATHPOINTTYPERLE_OID | U_PMF_ARRAY_OID); + + U_PSEUDO_OBJ *poi = U_PMF_4NUM_set(Elements); + po = U_PO_append(po, poi->Data, poi->Used); + U_PO_free(&poi); + + if(po){ + for( ;Elements; Elements--, Bz++, RL++, Ppte++){ + po = U_PO_append(po, (char *)Ppte, 1); + if(*RL > 0x3F){ /* run length too big for field */ + U_PO_free(&po); + return(NULL); + } + utmp = (*Bz ? 1 : 0) | ((*RL & 0x3F)<<2); /* bit 1 is not used and is set to 0 */ + po = U_PO_append(po, (char *)&utmp, 1); + } + } + return(po); +} + +/** + \brief Create and set a U_PMF_PENDATA PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Unit UnitType enumeration + \param Width Width in units set by Unit + \param Pod U_PSEUDO_OBJ containing first the PenData flags then a U_PMF_PENOPTIONALDATA object (the second part + may be an empty if Flags is 0) + + + EMF+ manual 2.2.2.33, Microsoft name: EmfPlusPenData Object +*/ +U_PSEUDO_OBJ *U_PMF_PENDATA_set(uint32_t Unit, U_FLOAT Width, const U_PSEUDO_OBJ *Pod){ + if(Pod && ((Pod->Type != U_PMF_PENOPTIONALDATA_OID) || Pod->Used < 4))return(NULL); + const U_SERIAL_DESC List[] = { + {(Pod ? Pod->Data : NULL), 4, 1, U_XE}, /* the Flags field, clear if no optional data */ + {&Unit, 4, 1, U_LE}, + {&Width, 4, 1, U_LE}, + /* next is the (optional) U_PMF_PENOPTIONALDATA part or a terminator */ + {(Pod ? Pod->Data + 4 : NULL), (Pod ? Pod->Used - 4 : 0), (Pod ? 1 : 0), (Pod ? U_XE : U_XX)}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_PENDATA_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_PENOPTIONALDATA PseudoObject + \return Pointer to PseudoObject, NULL on error. Returned PO contains first the Flags, then the PO proper. + \param Flags Determines which of the values are stored. + \param Tm U_PSEUDO_OBJ containing a U_PMF_TRANSFORMMATRIX object (Transformation matrix) + \param StartCap LineCapType enumeration + \param EndCap LineCapType enumeration + \param Join LineJoinType enumeration + \param MiterLimit Maximum (miter length / line width) + \param Style LineStyle enumeration + \param DLCap DashedLineCapType enumeration + \param DLOffset Distance line start to first dash start + \param DLData U_PSEUDO_OBJ containing a U_PMF_DASHEDLINEDATA object Dash and space widths + \param PenAlignment PenAlignment enumeration + \param CmpndLineData U_PSEUDO_OBJ containing a U_PMF_COMPOUNDLINEDATA object Compount Line (parallel lines drawn instead of one) + \param CSCapData U_PSEUDO_OBJ containing a U_PMF_CUSTOMSTARTCAPDATA object Custom start cap + \param CECapData U_PSEUDO_OBJ containing a U_PMF_CUSTOMENDCAPDATA object Custom end cap + + + EMF+ manual 2.2.2.34, Microsoft name: EmfPlusPenOptionalData Object +*/ +U_PSEUDO_OBJ *U_PMF_PENOPTIONALDATA_set(uint32_t Flags, U_PSEUDO_OBJ *Tm, int32_t StartCap, int32_t EndCap, uint32_t Join, + U_FLOAT MiterLimit, int32_t Style, int32_t DLCap, U_FLOAT DLOffset, + U_PSEUDO_OBJ *DLData, int32_t PenAlignment, U_PSEUDO_OBJ *CmpndLineData, U_PSEUDO_OBJ *CSCapData, + U_PSEUDO_OBJ *CECapData + ){ + + if((Flags & U_PD_Transform) && (!Tm || (Tm->Type != U_PMF_TRANSFORMMATRIX_OID)) )return(NULL); + if((Flags & U_PD_DLData) && (!DLData || (DLData->Type != U_PMF_DASHEDLINEDATA_OID)) )return(NULL); + if((Flags & U_PD_CLData) && (!CmpndLineData || (CmpndLineData->Type != U_PMF_COMPOUNDLINEDATA_OID)) )return(NULL); + if((Flags & U_PD_CustomStartCap) && (!CSCapData || (CSCapData->Type != U_PMF_CUSTOMSTARTCAPDATA_OID)))return(NULL); + if((Flags & U_PD_CustomEndCap) &&(!CECapData || (CECapData->Type != U_PMF_CUSTOMENDCAPDATA_OID)) )return(NULL); + + /* prepend the Flags field to the PseudoObject proper */ + const U_SERIAL_DESC List[] = { + {&Flags, 4, 1, U_LE}, + {((Flags & U_PD_Transform) ? Tm->Data : NULL), ((Flags & U_PD_Transform) ? Tm->Used : 0), 1, U_XE}, + {((Flags & U_PD_StartCap ) ? (char *)&StartCap : NULL), ((Flags & U_PD_StartCap ) ? 4 : 0), 1, U_LE}, + {((Flags & U_PD_EndCap ) ? (char *)&EndCap : NULL), ((Flags & U_PD_EndCap ) ? 4 : 0), 1, U_LE}, + {((Flags & U_PD_Join ) ? (char *)&Join : NULL), ((Flags & U_PD_Join ) ? 4 : 0), 1, U_LE}, + {((Flags & U_PD_MiterLimit ) ? (char *)&MiterLimit : NULL), ((Flags & U_PD_MiterLimit ) ? 4 : 0), 1, U_LE}, + {((Flags & U_PD_LineStyle ) ? (char *)&Style : NULL), ((Flags & U_PD_LineStyle ) ? 4 : 0), 1, U_LE}, + {((Flags & U_PD_DLCap ) ? (char *)&DLCap : NULL), ((Flags & U_PD_DLCap ) ? 4 : 0), 1, U_LE}, + {((Flags & U_PD_DLOffset ) ? (char *)&DLOffset : NULL), ((Flags & U_PD_DLOffset ) ? 4 : 0), 1, U_LE}, + {((Flags & U_PD_DLData ) ? DLData->Data : NULL), ((Flags & U_PD_DLData ) ? DLData->Used : 0), 1, U_XE}, + {((Flags & U_PD_NonCenter ) ? (char *)&PenAlignment : NULL), ((Flags & U_PD_NonCenter ) ? 4 : 0), 1, U_LE}, + {((Flags & U_PD_CLData ) ? CmpndLineData->Data : NULL), ((Flags & U_PD_CLData ) ? CmpndLineData->Used : 0), 1, U_XE}, + {((Flags & U_PD_CustomStartCap) ? CSCapData->Data : NULL), ((Flags & U_PD_CustomStartCap) ? CSCapData->Used : 0), 1, U_XE}, + {((Flags & U_PD_CustomEndCap ) ? CECapData->Data : NULL), ((Flags & U_PD_CustomEndCap ) ? CECapData->Used : 0), 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_PENOPTIONALDATA_OID, List); + return(po); +} + +/** + \brief Create and set an ARRAY of U_PMF_POINT objects + \return Pointer to PseudoObject, NULL on error + \param Elements Number of pairs of points in Coords + \param Coords Array of X,Y pairs. + + EMF+ manual 2.2.2.35, Microsoft name: EmfPlusPoint Object +*/ +U_PSEUDO_OBJ *U_PMF_POINT_set(uint32_t Elements, const U_PMF_POINT *Coords){ + if(!Elements || !Coords)return(NULL); + const U_SERIAL_DESC List[] = { + {&Elements, 4, 1, U_LE}, + { Coords, 2, 2*Elements, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_POINT_OID | U_PMF_ARRAY_OID, List); + return(po); +} + +/** + \brief Create and set an ARRAY of U_PMF_POINTF objects, with a leading Elements value + \return Pointer to PseudoObject, NULL on error + \param Elements Number of pairs of points in Coords + \param Coords Array of X,Y pairs. + + EMF+ manual 2.2.2.36, Microsoft name: EmfPlusPointF Object +*/ +U_PSEUDO_OBJ *U_PMF_POINTF_set(uint32_t Elements, const U_PMF_POINTF *Coords){ + if(!Elements || !Coords)return(NULL); + const U_SERIAL_DESC List[] = { + {&Elements, 4, 1, U_LE}, + {Coords, 4, 2*Elements, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_POINTF_OID | U_PMF_ARRAY_OID, List); + return(po); +} + +/** + \brief Create and set an ARRAY of U_PMF_POINTR objects + \return Pointer to PseudoObject, NULL on error + \param Elements Number of pairs of points in Coords + \param Coords Array of X,Y pairs. These are absolute coordinates, they are converted to Relative here. + + EMF+ manual 2.2.2.37, Microsoft name: EmfPlusPointR Object +*/ +U_PSEUDO_OBJ *U_PMF_POINTR_set(uint32_t Elements, const U_PMF_POINTF *Coords){ + int X,Y; + U_FLOAT Xf,Yf; + U_PSEUDO_OBJ *poi; + /* Worst case scenario it is 4 bytes per coord, plus the count */ + U_PSEUDO_OBJ *po = U_PO_create(NULL, 4 + 4*Elements, 0, U_PMF_POINTR_OID); /* not exactly an array, so no U_PMF_ARRAY_OID */ + + poi = U_PMF_4NUM_set(Elements); + po = U_PO_append(po, poi->Data, poi->Used); + U_PO_free(&poi); + + for(Xf = Yf = 0.0 ;Elements; Elements--, Coords++){ + Xf = U_ROUND(Coords->X) - Xf; + Yf = U_ROUND(Coords->Y) - Yf; + X = ( Xf >= UINT16_MAX ? UINT16_MAX : ( Xf <= INT16_MIN ? INT16_MIN : Xf)); + Y = ( Yf >= UINT16_MAX ? UINT16_MAX : ( Yf <= INT16_MIN ? INT16_MIN : Yf)); + Xf = U_ROUND(Coords->X); + Yf = U_ROUND(Coords->Y); + + /* this is not a very efficient method, too much mucking around with memory */ + + poi = U_PMF_INTEGER7_set(X); + if(!poi)poi = U_PMF_INTEGER15_set(X); /* This one must work because of the range checking, above */ + po = U_PO_append(po, poi->Data, poi->Used); + U_PO_free(&poi); + + poi = U_PMF_INTEGER7_set(Y); + if(!poi)poi = U_PMF_INTEGER15_set(Y); /* This one must work because of the range checking, above */ + po = U_PO_append(po, poi->Data, poi->Used); + U_PO_free(&poi); + } + /* Because the values stored were some unpredictable combination of 1 and 2 bytes, the last byte may not end + on a 4 byte boundary. Make it do so by padding with up to 3 zero bytes. */ +#if 1 + int residual; + unsigned long int us, uu; + us = po->Size; /* printing size_t portably is a pain, this avoids the issue */ + uu = po->Used; + residual = 3 & po->Used; +printf("DEBUG Used:%lu residual:%d\n",uu, residual);fflush(stdout); + if(residual){ + po = U_PO_append(po, NULL, (4 - residual)); + } +printf("DEBUG Size:%lu Used:%lu \n",us,uu);fflush(stdout); +#endif + return(po); +} + +/** + \brief Create and set a U_PMF_RECT object + \return Pointer to PseudoObject, NULL on error + \param X UL X value + \param Y UL Y value + \param Width Width + \param Height Height + + EMF+ manual 2.2.2.38, Microsoft name: EmfPlusRect Object +*/ +U_PSEUDO_OBJ *U_PMF_RECT4_set(int16_t X, int16_t Y, int16_t Width, int16_t Height){ + const U_SERIAL_DESC List[] = { + {&X, 2, 1, U_LE}, + {&Y, 2, 1, U_LE}, + {&Width, 2, 1, U_LE}, + {&Height, 2, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_RECT_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_RECT object + \return Pointer to PseudoObject, NULL on error + \param Rect U_PMF_RECT structures + + EMF+ manual 2.2.2.38, Microsoft name: EmfPlusRect Object +*/ +U_PSEUDO_OBJ *U_PMF_RECT_set(U_PMF_RECT *Rect){ + const U_SERIAL_DESC List[] = { + {Rect, 2, 4, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_RECT_OID, List); + return(po); +} + +/** + \brief Create and set an array of U_PMF_RECT objects in a PseudoObject + \return Pointer to PseudoObject, NULL on error. PseudoObject contains Elements followed by the array of U_PMF_RECT objects. + \param Elements Number of elements in Rects + \param Rects Array of U_PMF_RECT structures + + EMF+ manual 2.2.2.38, Microsoft name: EmfPlusRect Object +*/ +U_PSEUDO_OBJ *U_PMF_RECTN_set(uint32_t Elements, U_PMF_RECT *Rects){ + if(!Rects){ return(NULL); } + uint32_t count = Elements; + U_SERIAL_DESC *Lptr = (U_SERIAL_DESC *) malloc(4 + (Elements * 2 * 4) + 4); + U_SERIAL_DESC *List = List; + if(!List){ return(NULL); } + *Lptr++ = (U_SERIAL_DESC){&Elements, 4, 1, U_LE}; + for(; count; count--, Lptr++, Rects++){ *Lptr = (U_SERIAL_DESC){Rects, 2, 4, U_LE}; } + *Lptr = (U_SERIAL_DESC){NULL,0,0,U_XX}; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_RECTF_OID | U_PMF_ARRAY_OID, List); + free(List); + return(po); +} + +/** + \brief Create and set a U_PMF_RECTF object in a PseudoObject + \return Pointer to PseudoObject, NULL on error + \param X UL X value + \param Y UL Y value + \param Width Width + \param Height Height + + EMF+ manual 2.2.2.39, Microsoft name: EmfPlusRectF Object +*/ +U_PSEUDO_OBJ *U_PMF_RECTF4_set(U_FLOAT X, U_FLOAT Y, U_FLOAT Width, U_FLOAT Height){ + const U_SERIAL_DESC List[] = { + {&X, 4, 1, U_LE}, + {&Y, 4, 1, U_LE}, + {&Width, 4, 1, U_LE}, + {&Height, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_RECTF_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_RECTF object in a PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Rect U_PMF_RECTF structure + + EMF+ manual 2.2.2.39, Microsoft name: EmfPlusRectF Object +*/ +U_PSEUDO_OBJ *U_PMF_RECTF_set(U_PMF_RECTF *Rect){ + const U_SERIAL_DESC List[] = { + {Rect, 4, 4, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_RECTF_OID, List); + return(po); +} + +/** + \brief Create and set an array of U_PMF_RECTF objects in a PseudoObject + \return Pointer to PseudoObject, NULL on error. PseudoObject contains Elements followed by the array of U_PMF_RECTF objects. + \param Elements Number of elements in Rects + \param Rects Array of U_PMF_RECTF structures + + EMF+ manual 2.2.2.39, Microsoft name: EmfPlusRectF Object +*/ +U_PSEUDO_OBJ *U_PMF_RECTFN_set(uint32_t Elements, U_PMF_RECTF *Rects){ + if(!Rects){ return(NULL); } + uint32_t count = Elements; + U_SERIAL_DESC *List = (U_SERIAL_DESC *) malloc((Elements + 2) * sizeof(U_SERIAL_DESC)); + U_SERIAL_DESC *Lptr = List; + if(!List){ return(NULL); } + *Lptr++ = (U_SERIAL_DESC){&Elements, 4, 1, U_LE}; + for(; count; count--, Lptr++, Rects++){ + *Lptr = (U_SERIAL_DESC){Rects, 4, 4, U_LE}; + } + *Lptr = (U_SERIAL_DESC){NULL,0,0,U_XX}; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_RECTF_OID | U_PMF_ARRAY_OID, List); + free(List); + return(po); +} + +/** + \brief Create and set a U_PMF_REGIONNODE PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Type RegionNodeDataType Enumeration + \param Rnd (optional) U_PSEUDO_OBJ containing a U_PMF_REGIONNODEPATH, U_PMF_RECTF, or U_PMF_REGIONNODECHILDNODES object (Region Node Data) + + + EMF+ manual 2.2.2.40, Microsoft name: EmfPlusRegionNode Object +*/ +U_PSEUDO_OBJ *U_PMF_REGIONNODE_set(int32_t Type, const U_PSEUDO_OBJ *Rnd){ + int32_t pType; + /* make sure that the type of Rnd agrees with Type */ + if(Rnd){ + pType = U_OID_To_RNDT(Rnd->Type); + if( pType < 0){ return(NULL); } + if((pType > 0) && (pType != Type)){ return(NULL); } + if((pType == 0) && + ( + (Type < U_RNDT_And) || + (Type > U_RNDT_Complement) + ) + ){ return(NULL); } + if((Type == U_RNDT_Rect) && (Rnd->Type != U_PMF_RECTF_OID)){ return(NULL); } + if((Type == U_RNDT_Path) && (Rnd->Type != U_PMF_REGIONNODEPATH_OID)){ return(NULL); } + + } + else { /* only U_RNDT_Empty and U_RNDT_Infinite do not have data */ + if((Type != U_RNDT_Empty) || + (Type != U_RNDT_Infinite) ){ return(NULL); } + } + + + const U_SERIAL_DESC List[] = { + {&Type, 4, 1, U_LE}, + {(Rnd ? Rnd->Data : NULL), (Rnd ? Rnd->Used : 0), 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_REGIONNODE_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_REGIONNODECHILDNODES PseudoObject + \return Pointer to PseudoObject containing a U_PMF_REGIONNODECHILDNODES_OID object, NULL on error + \param Left U_PSEUDO_OBJ containing a U_PMF_REGIONNODE object + \param Right U_PSEUDO_OBJ containing a U_PMF_REGIONNODE object + + + EMF+ manual 2.2.2.41, Microsoft name: EmfPlusRegionNodeChildNodes Object +*/ +U_PSEUDO_OBJ *U_PMF_REGIONNODECHILDNODES_set(const U_PSEUDO_OBJ *Left, const U_PSEUDO_OBJ *Right){ + if(!Left || (Left->Type != U_PMF_REGIONNODE_OID)){ return(NULL); } + if(!Right || (Right->Type != U_PMF_REGIONNODE_OID)){ return(NULL); } + + const U_SERIAL_DESC List[] = { + {Left->Data, Left->Used, 1, U_XE}, + {Right->Data, Right->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_REGIONNODECHILDNODES_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_REGIONNODEPATH PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Path U_PSEUDO_OBJ containing a U_PMF_PATH object + + + EMF+ manual 2.2.2.42, Microsoft name: EmfPlusRegionNodePath Object +*/ +U_PSEUDO_OBJ *U_PMF_REGIONNODEPATH_set(const U_PSEUDO_OBJ *Path){ + if(!Path || (Path->Type != U_PMF_PATH_OID)){ return(NULL); } + /* PO Used is size_t, might be 8 bytes, value in record must be 4 bytes */ + uint32_t Used = Path->Used; + + const U_SERIAL_DESC List[] = { + {&Used, 4, 1, U_LE}, + {Path->Data, Path->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_REGIONNODEPATH_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_SOLIDBRUSHDATA PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Color U_PSEUDO_OBJ containing a U_PMF_ARGB object + + + EMF+ manual 2.2.2.43, Microsoft name: EmfPlusSolidBrushData Object +*/ +U_PSEUDO_OBJ *U_PMF_SOLIDBRUSHDATA_set(const U_PSEUDO_OBJ *Color){ + if(!Color || (Color->Type != U_PMF_ARGB_OID)){ return(NULL); } + + const U_SERIAL_DESC List[] = { + {Color->Data, Color->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_SOLIDBRUSHDATA_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_STRINGFORMATDATA PseudoObject + \return Pointer to PseudoObject, NULL on error + \param TabStopCount Entries in TabStop array + \param TabStops (optional) Array of tabstop locations + \param Ranges (optional) U_PSEUDO_OBJ containing an array of U_PMF_CHARACTERRANGE objects + + + EMF+ manual 2.2.2.44, Microsoft name: EmfPlusStringFormatData Object +*/ +U_PSEUDO_OBJ *U_PMF_STRINGFORMATDATA_set(uint32_t TabStopCount, U_FLOAT *TabStops, const U_PSEUDO_OBJ *Ranges){ + if(Ranges && (Ranges->Type != (U_PMF_CHARACTERRANGE_OID | U_PMF_ARRAY_OID))){ return(NULL); } + + const U_SERIAL_DESC List[] = { + {TabStops, TabStopCount*4, 1, U_LE}, + {(Ranges ? Ranges->Data : NULL), (Ranges ? Ranges->Used : 0), 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_STRINGFORMATDATA_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_TEXTUREBRUSHDATA PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Flags BrushData flags + \param WrapMode WrapMode enumeration + \param Tbod U_PSEUDO_OBJ containing an U_PMF_TEXTUREBRUSHOPTIONALDATA object + + + EMF+ manual 2.2.2.45, Microsoft name: EmfPlusTextureBrushData Object +*/ +U_PSEUDO_OBJ *U_PMF_TEXTUREBRUSHDATA_set(uint32_t Flags, uint32_t WrapMode, const U_PSEUDO_OBJ *Tbod){ + if(Flags & ~U_BD_MASKB){ return(NULL); } /* a bit was set that is not supported for this record */ + if(WrapMode > U_WM_Clamp){ return(NULL); } + if(!Tbod || (Tbod->Type != (U_PMF_TEXTUREBRUSHOPTIONALDATA_OID))){ return(NULL); } + + const U_SERIAL_DESC List[] = { + {&Flags, 4, 1, U_LE}, + {&WrapMode, 4, 1, U_LE}, + {Tbod->Data, Tbod->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_TEXTUREBRUSHDATA_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_TEXTUREBRUSHOPTIONALDATA PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Tm (optional) U_PSEUDO_OBJ containing an U_PMF_TRANSFORMMATRIX object + \param Image (optional) U_PSEUDO_OBJ containing an U_PMF_IMAGE object + + + EMF+ manual 2.2.2.46, Microsoft name: EmfPlusTextureBrushOptionalData Object +*/ +U_PSEUDO_OBJ *U_PMF_TEXTUREBRUSHOPTIONALDATA_set(const U_PSEUDO_OBJ *Tm, const U_PSEUDO_OBJ *Image){ + if(Tm && (Tm->Type != (U_PMF_TRANSFORMMATRIX_OID))){ return(NULL); } + if(Image && (Image->Type != (U_PMF_IMAGE_OID))){ return(NULL); } + + const U_SERIAL_DESC List[] = { + {(Tm ? Tm->Data : NULL), (Tm ? Tm->Used : 0), 1, U_XE}, + {(Image ? Image->Data : NULL), (Image ? Image->Used : 0), 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_TEXTUREBRUSHOPTIONALDATA_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_TRANSFORMMATRIX PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Tm U_PMF_TRANSFORMMATRIX_ object + + + EMF+ manual 2.2.2.47, Microsoft name: EmfPlusTransformMatrix Object +*/ +U_PSEUDO_OBJ *U_PMF_TRANSFORMMATRIX_set(U_PMF_TRANSFORMMATRIX *Tm){ + if(!Tm){ return(NULL); } + + const U_SERIAL_DESC List[] = { + {Tm, 4, 6, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_TRANSFORMMATRIX_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_IE_BLUR PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Radius Blur radius in pixels + \param ExpandEdge 1: expand bitmap by Radius; 0: bitmap size unchanged + + + EMF+ manual 2.2.3.1, Microsoft name: BlurEffect Object +*/ +U_PSEUDO_OBJ *U_PMF_IE_BLUR_set(U_FLOAT Radius, uint32_t ExpandEdge){ + + const U_SERIAL_DESC List[] = { + {&Radius, 4, 1, U_LE}, + {&ExpandEdge, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_IE_BLUR_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_IE_BRIGHTNESSCONTRAST PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Brightness -255 to 255, 0 is unchanged, positive increases, negative decreases + \param Contrast -100 to 100, 0 is unchanged, positive increases, negative decreases + + + EMF+ manual 2.2.3.2, Microsoft name: BrightnessContrastEffect Object +*/ +U_PSEUDO_OBJ *U_PMF_IE_BRIGHTNESSCONTRAST_set(int32_t Brightness, int32_t Contrast){ + + const U_SERIAL_DESC List[] = { + {&Brightness, 4, 1, U_LE}, + {&Contrast, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_IE_BRIGHTNESSCONTRAST_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_IE_COLORBALANCE PseudoObject + \return Pointer to PseudoObject, NULL on error + \param CyanRed -100 to 100, 0 is unchanged, positive increases Red & decreases Cyan, negative is opposite + \param MagentaGreen -100 to 100, 0 is unchanged, positive increases Green & decreases Magenta, negative is opposite + \param YellowBlue -100 to 100, 0 is unchanged, positive increases Blue & decreases Yellow, negative is opposite + + + EMF+ manual 2.2.3.3, Microsoft name: ColorBalanceEffect Object +*/ +U_PSEUDO_OBJ *U_PMF_IE_COLORBALANCE_set(int32_t CyanRed, int32_t MagentaGreen, int32_t YellowBlue){ + + const U_SERIAL_DESC List[] = { + {&CyanRed, 4, 1, U_LE}, + {&MagentaGreen, 4, 1, U_LE}, + {&YellowBlue, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_IE_COLORBALANCE_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_IE_COLORCURVE PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Adjust CurveAdjustment enumeration + \param Channel CurveChannel enumeration + \param Intensity adjustment to apply. "Adjust" determines what field this is and range values. + + + EMF+ manual 2.2.3.4, Microsoft name: ColorCurveEffect Object +*/ +U_PSEUDO_OBJ *U_PMF_IE_COLORCURVE_set(uint32_t Adjust, uint32_t Channel, int32_t Intensity){ + + const U_SERIAL_DESC List[] = { + {&Adjust, 4, 1, U_LE}, + {&Channel, 4, 1, U_LE}, + {&Intensity, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_IE_COLORCURVE_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_IE_COLORLOOKUPTABLE PseudoObject + \return Pointer to PseudoObject, NULL on error + \param BLUT Blue color lookup table + \param GLUT Green color lookup table + \param RLUT Red color lookup table + \param ALUT Alpha color lookup table + + + + EMF+ manual 2.2.3.5, Microsoft name: ColorLookupTableEffect Object. + All tables have 256 entries. +*/ +U_PSEUDO_OBJ *U_PMF_IE_COLORLOOKUPTABLE_set(const uint8_t *BLUT, const uint8_t *GLUT, const uint8_t *RLUT, const uint8_t *ALUT){ + if(!BLUT || !GLUT || !RLUT || !ALUT)return(NULL); + + const U_SERIAL_DESC List[] = { + {BLUT, 1, 256, U_XE}, + {GLUT, 1, 256, U_XE}, + {RLUT, 1, 256, U_XE}, + {ALUT, 1, 256, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_IE_COLORLOOKUPTABLE_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_IE_COLORMATRIX PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Matrix 5 x 5 color transformation matrix, First 4 rows are [{4 multiplier values},0.0] for R,G,B,A, last Row is [{4 color translation valuess}, 1.0] + + + EMF+ manual 2.2.3.6, Microsoft name: ColorMatrixEffect Object +*/ +U_PSEUDO_OBJ *U_PMF_IE_COLORMATRIX_set(const U_FLOAT *Matrix){ + if(!Matrix)return(NULL); + + const U_SERIAL_DESC List[] = { + {Matrix, 4, 25, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_IE_COLORMATRIX_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_IE_HUESATURATIONLIGHTNESS PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Hue -180 to 180, 0 is unchanged + \param Saturation -100 to 100, 0 is unchanged + \param Lightness -100 to 100, 0 is unchanged + + + EMF+ manual 2.2.3.7, Microsoft name: HueSaturationLightnessEffect Object +*/ +U_PSEUDO_OBJ *U_PMF_IE_HUESATURATIONLIGHTNESS_set(int32_t Hue, int32_t Saturation, int32_t Lightness){ + + const U_SERIAL_DESC List[] = { + {&Hue, 4, 1, U_LE}, + {&Saturation, 4, 1, U_LE}, + {&Lightness, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_IE_HUESATURATIONLIGHTNESS_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_IE_LEVELS PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Highlight 0 to 100, 100 is unchanged + \param Midtone -100 to 0, 0 is unchanged + \param Shadow 0 to 100, 0 is unchanged + + + EMF+ manual 2.2.3.8, Microsoft name: LevelsEffect Object +*/ +U_PSEUDO_OBJ *U_PMF_IE_LEVELS_set(int32_t Highlight, int32_t Midtone, int32_t Shadow){ + + const U_SERIAL_DESC List[] = { + {&Highlight, 4, 1, U_LE}, + {&Midtone, 4, 1, U_LE}, + {&Shadow, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_IE_LEVELS_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_IE_REDEYECORRECTION PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Elements Number of members in Rects + \param Rects Array of U_RECTL rectangular area(s) to apply red eye correction + + + EMF+ manual 2.2.3.9, Microsoft name: RedEyeCorrectionEffect Object +*/ +U_PSEUDO_OBJ *U_PMF_IE_REDEYECORRECTION_set(uint32_t Elements, const U_RECTL *Rects){ + if(!Elements || !Rects){return(NULL);} + + const U_SERIAL_DESC List[] = { + {&Elements, 4, 1, U_LE}, + {Rects, 4*4, Elements,U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_IE_REDEYECORRECTION_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_IE_SHARPEN PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Radius Sharpening radius in pixels + \param Sharpen 0 to 100, 0 is unchanged + + + EMF+ manual 2.2.3.10, Microsoft name: SharpenEffect Object +*/ +U_PSEUDO_OBJ *U_PMF_IE_SHARPEN_set(U_FLOAT Radius, int32_t Sharpen){ + + const U_SERIAL_DESC List[] = { + {&Radius, 4, 1, U_LE}, + {&Sharpen, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_IE_SHARPEN_OID, List); + return(po); +} + +/** + \brief Create and set a U_PMF_IE_TINT PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Hue -180 to 180, [positive==clockwise] rotation in degrees starting from blue + \param Amount -100 [add black] to 100[add white], 0 is unchanged. Change in hue on specified axis + + + EMF+ manual 2.2.3.11, Microsoft name: TintEffect Object +*/ +U_PSEUDO_OBJ *U_PMF_IE_TINT_set(const int32_t Hue, const int32_t Amount){ + + const U_SERIAL_DESC List[] = { + {&Hue, 4, 1, U_LE}, + {&Amount, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMF_IE_TINT_OID, List); + return(po); +} + +//! \cond +/* internal routine, not part of the API. + Returns a PseudoObject containing a U_PMR_CMN_HDR_OID object. + The type is something like U_PMR_OFFSETCLIP (the record type, NOT the U_PMR_OFFSETCLIP_OID PseudoObject Type!). + The U_PMR_RECFLAG bit is added both in the data and in the Type of the PseudoObject. + If that bit is already set no harm, no foul. +*/ + +U_PSEUDO_OBJ *U_PMR_CMN_HDR_set(uint32_t Type, uint16_t Flags, uint32_t DataSize){ + + uint32_t Size = 12 + UP4(DataSize); /* The header itself is always 12, PMR records must be a multiple of 4 */ + Type |= U_PMR_RECFLAG; + uint16_t utmp16 = Type; + const U_SERIAL_DESC List[] = { + {&utmp16, 2, 1, U_LE}, + {&Flags, 2, 1, U_LE}, /* Microsoft EMF+ manual is BE, but this field in this implementation is LE */ + {&Size, 4, 1, U_LE}, + {&DataSize, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_CMN_HDR_OID, List); + return(po); +} +//! \endcond + + +/** + \brief Create and set a U_PMR_STROKEFILLPATH PseudoObject + \return Pointer to PseudoObject, NULL on error + + + EMF+ manual mentioned in 2.1.1.1, not otherwise documented, Microsoft name: EmfPlusStrokeFillPath Record, Index 0x37 + + "This record closes any open figures in a path, strokes the outline of + the path by using the current pen, and fills its interior by using the current brush." + +*/ +U_PSEUDO_OBJ *U_PMR_STROKEFILLPATH_set(void){ + int Size = 0; + uint16_t utmp16 = 0; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_STROKEFILLPATH,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_STROKEFILLPATH_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_OFFSETCLIP PseudoObject + \return Pointer to PseudoObject, NULL on error + \param dX horizontal translation offset to apply to clipping region + \param dY vertical translation offset to apply to clipping region + + + EMF+ manual 2.3.1.1, Microsoft name: EmfPlusOffsetClip Record, Index 0x35 +*/ +U_PSEUDO_OBJ *U_PMR_OFFSETCLIP_set(U_FLOAT dX, U_FLOAT dY){ + int Size = 2*4; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_OFFSETCLIP,0,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {&dX, 4, 1, U_LE}, + {&dY, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_OFFSETCLIP_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_RESETCLIP PseudoObject + \return Pointer to PseudoObject, NULL on error + + + EMF+ manual 2.3.1.2, Microsoft name: EmfPlusResetClip Record, Index 0x31 +*/ +U_PSEUDO_OBJ *U_PMR_RESETCLIP_set(void){ + int Size = 0; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_RESETCLIP,0,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_RESETCLIP_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_SETCLIPPATH PseudoObject + \return Pointer to PseudoObject, NULL on error + \param CMenum CombineMode enumeration.. + \param PathID U_PMF_PATH object in the EMF+ object table (0-63, inclusive) + + + EMF+ manual 2.3.1.3, Microsoft name: EmfPlusSetClipPath Record, Index 0x33 +*/ +U_PSEUDO_OBJ *U_PMR_SETCLIPPATH_set(uint32_t PathID, uint32_t CMenum){ + if(PathID>63)return(NULL); + int Size=0; + uint16_t utmp16 = ((PathID & U_FF_MASK_OID8) << U_FF_SHFT_OID8) | ((CMenum & U_FF_MASK_CM4) << U_FF_SHFT_CM4); + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_SETCLIPPATH,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_SETCLIPPATH_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_SETCLIPRECT PseudoObject + \return Pointer to PseudoObject, NULL on error + \param CMenum CombineMode enumeration.. + \param Rect U_PSEUDO_OBJ containing an U_PMF_RECTF object or an array of U_PMF_RECTF objects (the first is used) + + + EMF+ manual 2.3.1.4, Microsoft name: EmfPlusSetClipRect Record, Index 0x32 +*/ +U_PSEUDO_OBJ *U_PMR_SETCLIPRECT_set(uint32_t CMenum, const U_PSEUDO_OBJ *Rect){ + int Size=4*4; + const char *start; + uint16_t utmp16 = ((CMenum & U_FF_MASK_CM4) << U_FF_SHFT_CM4); + if(Rect){ + if( Rect->Type == U_PMF_RECTF_OID){ + start = Rect->Data; + } + else if(Rect->Type == (U_PMF_RECTF_OID | U_PMF_ARRAY_OID)){ + start = Rect->Data + 4; + } + else { return(0); } + } + else { return(0); } + + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_SETCLIPRECT,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {start, 4, 4, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_SETCLIPRECT_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_SETCLIPREGION PseudoObject + \return Pointer to PseudoObject, NULL on error + \param PathID U_PMF_PATH object in the EMF+ object table (0-63, inclusive) + \param CMenum CombineMode enumeration.. + + + EMF+ manual 2.3.1.5, Microsoft name: EmfPlusSetClipRegion Record, Index 0x34 +*/ +U_PSEUDO_OBJ *U_PMR_SETCLIPREGION_set(uint32_t PathID, uint32_t CMenum){ + if(PathID>63)return(NULL); + int Size=0; + uint16_t utmp16 = ((PathID & U_FF_MASK_OID8) << U_FF_SHFT_OID8) | ((CMenum & U_FF_MASK_CM4) << U_FF_SHFT_CM4); + + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_SETCLIPREGION,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_SETCLIPREGION_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_COMMENT PseudoObject + \return Pointer to PseudoObject, NULL on error + \param cbData Number of bytes in Data, must be a multiple of 4 + \param Data Private data, may be anything. Stored in PseudoObject without adjusting byte order. + + + EMF+ manual 2.3.2.1, Microsoft name: EmfPlusComment Record, Index 0x03 +*/ +U_PSEUDO_OBJ *U_PMR_COMMENT_set(size_t cbData, const void *Data){ + if(UP4(cbData) != cbData){ return(NULL); } + int Size=cbData; + + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_COMMENT,0,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {Data, cbData, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_COMMENT_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_ENDOFFILE PseudoObject + \return Pointer to PseudoObject, NULL on error + + + EMF+ manual 2.3.3.1, Microsoft name: EmfPlusEndOfFile Record, Index 0x02 +*/ +U_PSEUDO_OBJ *U_PMR_ENDOFFILE_set(void){ + int Size=0; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_ENDOFFILE,0,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_ENDOFFILE_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_GETDC PseudoObject + \return Pointer to PseudoObject, NULL on error + + + EMF+ manual 2.3.3.2, Microsoft name: EmfPlusGetDC Record, Index 0x04 +*/ +U_PSEUDO_OBJ *U_PMR_GETDC_set(void){ + int Size=0; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_GETDC,0,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_GETDC_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_HEADER PseudoObject + \return Pointer to PseudoObject, NULL on error + \param IsDual set = Dual-mode file, clear= EMF+ only file. + \param IsVideo set = video device, clear= printer. Ignore all other bits. + \param Version U_PSEUDO_OBJ containing a U_PMF_GRAPHICSVERSION object + \param LogicalDpiX Horizontal resolution reference device in DPI + \param LogicalDpiY Vertical resolution reference device in DPI + + + EMF+ manual 2.3.3.3, Microsoft name: EmfPlusHeader Record, Index 0x01 +*/ +U_PSEUDO_OBJ *U_PMR_HEADER_set(int IsDual, int IsVideo, const U_PSEUDO_OBJ *Version, + uint32_t LogicalDpiX, uint32_t LogicalDpiY){ + if(!Version || (Version->Type != U_PMF_GRAPHICSVERSION_OID)){ return(NULL); } + int Size=Version->Used + 3*4; + uint16_t utmp16 = (IsDual ? U_PPF_DM : 0); + uint32_t Flags = (IsVideo ? U_PPF_VIDEO : 0); + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_HEADER,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {Version->Data, Version->Used, 1, U_XE}, + {&Flags, 4, 1, U_LE}, + {&LogicalDpiX, 4, 1, U_LE}, + {&LogicalDpiY, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_HEADER_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_CLEAR PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Color U_PSEUDO_OBJ containing a U_PMF_ARGB object. + + + + EMF+ manual 2.3.4.1, Microsoft name: EmfPlusClear Record, Index 0x09 + + Erase everything preceding, set background ARGB to Color. +*/ +U_PSEUDO_OBJ *U_PMR_CLEAR_set(const U_PSEUDO_OBJ *Color){ + if(!Color || (Color->Type != U_PMF_ARGB_OID)){ return(NULL); } + int Size=Color->Used; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_CLEAR,0,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {Color->Data, Color->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_CLEAR_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_DRAWARC PseudoObject + \return Pointer to PseudoObject, NULL on error + \param PenID U_PMF_PEN object in the EMF+ object table (0-63, inclusive) + \param Start Start angle, >=0.0, degrees clockwise from 3:00 + \param Sweep Sweep angle, -360<= angle <=360, degrees clockwise from Start + \param Rect U_PSEUDO_OBJ containing a U_PMF_RECT or U_PMF_RECTF object + + + EMF+ manual 2.3.4.2, Microsoft name: EmfPlusDrawArc Record, Index 0x12 +*/ +U_PSEUDO_OBJ *U_PMR_DRAWARC_set(uint32_t PenID, U_FLOAT Start, U_FLOAT Sweep, const U_PSEUDO_OBJ *Rect){ + int ctype; + if(PenID>63)return(NULL); + if(!Rect){ return(NULL); } + else { + if( Rect->Type == U_PMF_RECT_OID ){ ctype = 1; } + else if(Rect->Type == U_PMF_RECTF_OID){ ctype = 0; } + else { return(NULL); } + } + int Size = 2*4 + Rect->Used; + uint16_t utmp16 = (ctype ? U_PPF_C : 0) | (PenID & U_FF_MASK_OID8) << U_FF_SHFT_OID8; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_DRAWARC,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {&Start, 4, 1, U_LE}, + {&Sweep, 4, 1, U_LE}, + {Rect->Data, Rect->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_DRAWARC_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_DRAWBEZIERS PseudoObject + \return Pointer to PseudoObject, NULL on error + \param PenID U_PMF_PEN object in the EMF+ object table (0-63, inclusive) + \param Points U_PSEUDO_OBJ containing first Elements, then a U_PMF_POINT, U_PMF_POINTR or U_PMF_POINTF object + + + EMF+ manual 2.3.4.3, Microsoft name: EmfPlusDrawBeziers Record, Index 0x19 +*/ +U_PSEUDO_OBJ *U_PMR_DRAWBEZIERS_set(uint32_t PenID, const U_PSEUDO_OBJ *Points){ + int ctype, RelAbs; + if(PenID>63)return(NULL); + if(Points){ + if( Points->Type == U_PMF_POINTR_OID){ RelAbs = 1; ctype = 0; } + else if(Points->Type == (U_PMF_POINT_OID | U_PMF_ARRAY_OID)){ RelAbs = 0; ctype = 1; } + else if(Points->Type == (U_PMF_POINTF_OID | U_PMF_ARRAY_OID)){ RelAbs = 0; ctype = 0; } + else { return(NULL); } + } + else { return(NULL); } + int Size = Points->Used; + uint16_t utmp16 = (ctype ? U_PPF_C : 0) | (RelAbs ? U_PPF_P : 0) |(PenID & U_FF_MASK_OID8) << U_FF_SHFT_OID8; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_DRAWBEZIERS,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {Points->Data, Points->Used, 1, U_XE}, /* Includes Elements */ + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_DRAWBEZIERS_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_DRAWCLOSEDCURVE PseudoObject + \return Pointer to PseudoObject, NULL on error + \param PenID U_PMF_PEN object in the EMF+ object table (0-63, inclusive) + \param Tension Controls splines, 0 is straight line, >0 is curved + \param Points U_PSEUDO_OBJ containing a U_PMF_POINT, U_PMF_POINTR or U_PMF_POINTF object + + + EMF+ manual 2.3.4.4, Microsoft name: EmfPlusDrawClosedCurve Record, Index 0x17 + + Curve is a cardinal spline. + + References sent by MS support: + + http://alvyray.com/Memos/CG/Pixar/spline77.pdf + + http://msdn.microsoft.com/en-us/library/4cf6we5y(v=vs.110).aspx + + +*/ +U_PSEUDO_OBJ *U_PMR_DRAWCLOSEDCURVE_set(uint32_t PenID, U_FLOAT Tension, const U_PSEUDO_OBJ *Points){ + int ctype, RelAbs; + if(PenID>63)return(NULL); + if(Points){ + if( Points->Type == U_PMF_POINTR_OID){ RelAbs = 1; ctype = 0; } + else if(Points->Type == (U_PMF_POINT_OID | U_PMF_ARRAY_OID)){ RelAbs = 0; ctype = 1; } + else if(Points->Type == (U_PMF_POINTF_OID | U_PMF_ARRAY_OID)){ RelAbs = 0; ctype = 0; } + else { return(NULL); } + } + else { return(NULL); } + int Size = 4 + Points->Used; + uint16_t utmp16 = (ctype ? U_PPF_C : 0) | (RelAbs ? U_PPF_P : 0) |(PenID & U_FF_MASK_OID8) << U_FF_SHFT_OID8; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_DRAWCLOSEDCURVE,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {&Tension, 4, 1, U_LE}, + {Points->Data, Points->Used, 1, U_XE}, /* includes Elements*/ + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_DRAWCLOSEDCURVE_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_DRAWCURVE PseudoObject + \return Pointer to PseudoObject, NULL on error + \param PenID U_PMF_PEN object in the EMF+ object table (0-63, inclusive) + \param Tension Controls splines, 0 is straight line, >0 is curved + \param Offset The starting point in the list of points, 0 is first. + \param NSegs Number of segments to draw. Starting at Offset go NSegs straight lines, must not run out of points.. + \param Points U_PSEUDO_OBJ containing an element count then a series of U_PMF_POINT or U_PMF_POINTF object + + + EMF+ manual 2.3.4.5, Microsoft name: EmfPlusDrawCurve Record, Index 0x18 + + Curve is a cardinal spline, using doubled terminator points to generate curves for the terminal segments. + + References sent by MS support: + + http://alvyray.com/Memos/CG/Pixar/spline77.pdf + + http://msdn.microsoft.com/en-us/library/4cf6we5y(v=vs.110).aspx + +*/ +U_PSEUDO_OBJ *U_PMR_DRAWCURVE_set(uint32_t PenID, U_FLOAT Tension, uint32_t Offset, uint32_t NSegs, const U_PSEUDO_OBJ *Points){ + int ctype; + if(PenID>63)return(NULL); + if(!Points){ return(NULL); } + if(!NSegs){ return(NULL); } + else { + if( Points->Type == (U_PMF_POINT_OID | U_PMF_ARRAY_OID)){ ctype = 1; } + else if(Points->Type == (U_PMF_POINTF_OID | U_PMF_ARRAY_OID)){ ctype = 0; } + else { return(NULL); } + } + uint32_t Elements = (Points->Used - 4)/(ctype ? 4 : 8); /* This way do not need to worry about byte order */ + if(Offset + NSegs + 1 > Elements){ return(NULL); } + int Size = 3*4 + Points->Used; + uint16_t utmp16 = (ctype ? U_PPF_C : 0) |(PenID & U_FF_MASK_OID8) << U_FF_SHFT_OID8; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_DRAWCURVE,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {&Tension, 4, 1, U_LE}, + {&Offset, 4, 1, U_LE}, + {&NSegs, 4, 1, U_LE}, + {Points->Data, Points->Used, 1, U_XE}, /* Elements, points */ + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_DRAWCURVE_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_DRAWDRIVERSTRING PseudoObject + \return Pointer to PseudoObject, NULL on error + \param FontID U_PMF_FONT object in the EMF+ object table (0-63, inclusive) + \param Tension Controls splines, 0 is straight line, >0 is curved + \param BrushID U_PSEUDO_OBJ containing a U_PMF_ARGB or a U_PMF_4NUM. Color or U_PMF_BRUSH object in the EMF+ object table (0-63, inclusive) + \param DSOFlags DriverStringOptions flags + \param HasMatrix If 1 record contains a TransformMatrix field, if 0 it does not. + \param GlyphCount The number of Elements in Glyphs, must agree with the number of elements in Points. + \param Glyphs If U_DSO_CmapLookup is set in DSOFlags this is an array of UTF16LE characters, otherwise, it is an array of indices into the U_PMF_FONT object indexed by Object_ID in flags. + \param Points U_PSEUDO_OBJ containing a U_PMF_POINTF object + \param Tm U_PSEUDO_OBJ containing a U_PMF_TRANSFORMMATRIX object. Apply to Glyphs & Positions. Present if HasMatrix is 1 + + + EMF+ manual 2.3.4.6, Microsoft name: EmfPlusDrawDriverString Record, Index 0x36 +*/ +U_PSEUDO_OBJ *U_PMR_DRAWDRIVERSTRING_set(uint32_t FontID, U_FLOAT Tension, const U_PSEUDO_OBJ *BrushID, + uint32_t DSOFlags, uint32_t HasMatrix, uint32_t GlyphCount, + const uint16_t *Glyphs, const U_PSEUDO_OBJ *Points, const U_PSEUDO_OBJ *Tm){ + int btype; + if(FontID>63){ return(NULL); } + if(!Glyphs){ return(NULL); } + if(!Points || (Points->Type != (U_PMF_POINTF_OID | U_PMF_ARRAY_OID))){ return(NULL); } + uint32_t Elements = (Points->Used -4)/4; + if(GlyphCount != Elements){ return(NULL); } + if(BrushID){ + if( BrushID->Used != 4){ return(NULL); } + else if( BrushID->Type == U_PMF_ARGB_OID){ btype = 1; } + else if( BrushID->Type == U_PMF_4NUM_OID){ btype = 0; } + else { return(NULL); } + } + else { return(NULL); } + int Size = 4 + BrushID->Used + 3*4 + Elements*2 + (Points->Used - 4); + if(HasMatrix){ + if(!Tm){ return(NULL); } + else if(Tm->Type != (U_PMF_TRANSFORMMATRIX_OID)){ return(NULL); } + Size += Tm->Used; + } + uint16_t utmp16 = (btype ? U_PPF_B : 0) |(FontID & U_FF_MASK_OID8) << U_FF_SHFT_OID8; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_DRAWDRIVERSTRING,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data,ph->Used, 1, U_XE}, + {&Tension, 4, 1, U_LE}, + {BrushID->Data, BrushID->Used, 1, U_XE}, + {&DSOFlags, 4, 1, U_LE}, + {&HasMatrix, 4, 1, U_LE}, + {&Elements, 4, 1, U_LE}, + {Glyphs, 2, Elements, U_LE}, + {Points->Data + 4, Points->Used - 4, 1, U_XE}, /* omit Elements */ + {(HasMatrix ? Tm->Data : NULL), (HasMatrix ? Tm->Used : 0), 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_DRAWDRIVERSTRING_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_DRAWELLIPSE PseudoObject + \return Pointer to PseudoObject, NULL on error + \param PenID U_PMF_PEN object in the EMF+ object table (0-63, inclusive) + \param Rect U_PSEUDO_OBJ containing a U_PMF_RECT or U_PMF_RECTF object + + + EMF+ manual 2.3.4.7, Microsoft name: EmfPlusDrawEllipse Record, Index 0x0F +*/ +U_PSEUDO_OBJ *U_PMR_DRAWELLIPSE_set(uint32_t PenID, const U_PSEUDO_OBJ *Rect){ + if(PenID>63)return(NULL); + int ctype; + if(!Rect){ return(NULL); } + else { + if( Rect->Type == U_PMF_RECT_OID ){ ctype = 1; } + else if(Rect->Type == U_PMF_RECTF_OID){ ctype = 0; } + else { return(NULL); } + } + int Size = Rect->Used; + uint16_t utmp16 = (ctype ? U_PPF_C : 0) | (PenID & U_FF_MASK_OID8) << U_FF_SHFT_OID8; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_DRAWELLIPSE,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {Rect->Data, Rect->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_DRAWELLIPSE_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_DRAWIMAGE PseudoObject + \return Pointer to PseudoObject, NULL on error + \param ImgID U_PMF_IMAGE object in the EMF+ object table (0-63, inclusive) + \param ImgAttrID index of a U_PMF_IMAGEATTRIBUTES object in the object table + \param SrcUnit UnitType enumeration + \param SrcRect U_PSEUDO_OBJ containing a U_PMF_RECTF object, Source region of image + \param DstRect U_PSEUDO_OBJ containing a U_PMF_RECT or U_PMF_RECTF object + + + EMF+ manual 2.3.4.8, Microsoft name: EmfPlusDrawImage Record, Index 0x1A +*/ +U_PSEUDO_OBJ *U_PMR_DRAWIMAGE_set(uint32_t ImgID, + int32_t ImgAttrID, int32_t SrcUnit, const U_PSEUDO_OBJ *SrcRect, const U_PSEUDO_OBJ *DstRect){ + int ctype; + if(ImgID>63)return(NULL); + if(!SrcRect || (SrcRect->Type != U_PMF_RECTF_OID)){ return(NULL); } + if(!DstRect){ return(NULL); } + else { + if( DstRect->Type == U_PMF_RECT_OID ){ ctype = 1; } + else if(DstRect->Type == U_PMF_RECTF_OID){ ctype = 0; } + else { return(NULL); } + } + int Size = 2*4 + SrcRect->Used + DstRect->Used; + uint16_t utmp16 = (ctype ? U_PPF_C : 0) | (ImgID & U_FF_MASK_OID8) << U_FF_SHFT_OID8; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_DRAWIMAGE,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {&ImgAttrID, 4, 1, U_LE}, + {&SrcUnit, 4, 1, U_LE}, + {SrcRect->Data, SrcRect->Used, 1, U_XE}, + {DstRect->Data, DstRect->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_DRAWIMAGE_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_DRAWIMAGEPOINTS PseudoObject + \return Pointer to PseudoObject, NULL on error + \param ImgID U_PMF_IMAGE object in the EMF+ object table (0-63, inclusive) + \param etype Set: effect from previous U_PMR_SERIALIZABLEOBJECT record will be applied; Clear: no effect applied + \param ImgAttrID index of a U_PMF_IMAGEATTRIBUTES object in the object table + \param SrcUnit UnitType enumeration + \param SrcRect U_PSEUDO_OBJ containing a U_PMF_RECTF object, Source region of image + \param Points U_PSEUDO_OBJ containing an array of 3 (U_PMF_POINT, U_PMF_POINTF, or U_PMF_POINTF) objects. These points are the UL, UR, and LL vertices of a parallelogram. + + + EMF+ manual 2.3.4.9, Microsoft name: EmfPlusDrawImagePoints Record, Index 0x1B + + + WARNING! Windows XP Preview does not show filter effects, whether or not U_PPF_E is set. They are visible if the EMF+ + file is inserted as an image into PowerPoint. +*/ +U_PSEUDO_OBJ *U_PMR_DRAWIMAGEPOINTS_set(uint32_t ImgID, int etype, + int32_t ImgAttrID, int32_t SrcUnit, const U_PSEUDO_OBJ *SrcRect, + const U_PSEUDO_OBJ *Points){ + int ctype, RelAbs; + if(ImgID>63){ return(NULL); } + if(!SrcRect || (SrcRect->Type != U_PMF_RECTF_OID)){ return(NULL); } + if(Points){ + if( Points->Type == U_PMF_POINTR_OID){ RelAbs = 1; ctype = 0; } + else if(Points->Type == (U_PMF_POINT_OID | U_PMF_ARRAY_OID)){ RelAbs = 0; ctype = 1; } + else if(Points->Type == (U_PMF_POINTF_OID | U_PMF_ARRAY_OID)){ RelAbs = 0; ctype = 0; } + else { return(NULL); } + } + else { return(NULL); } + int Size = 2*4 + SrcRect->Used + Points->Used; + uint16_t utmp16 = (ctype ? U_PPF_C : 0) | (etype ? U_PPF_E : 0) | (RelAbs ? U_PPF_P : 0) | (ImgID & U_FF_MASK_OID8) << U_FF_SHFT_OID8; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_DRAWIMAGEPOINTS,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {&ImgAttrID, 4, 1, U_LE}, + {&SrcUnit, 4, 1, U_LE}, + {SrcRect->Data, SrcRect->Used, 1, U_XE}, + {Points->Data, Points->Used, 1, U_XE}, /* includes Elements*/ + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_DRAWIMAGEPOINTS_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_DRAWLINES PseudoObject + \return Pointer to PseudoObject, NULL on error + \param PenID U_PMF_PEN object in the EMF+ object table (0-63, inclusive) + \param dtype Set: path must be closed, Clear: path is open + \param Points U_PSEUDO_OBJ containing an array of 3 U_PMF_POINT, U_PMF_POINTR, or U_PMF_POINTF objects + + + EMF+ manual 2.3.4.10, Microsoft name: EmfPlusDrawLines Record, Index 0x0D +*/ +U_PSEUDO_OBJ *U_PMR_DRAWLINES_set(uint32_t PenID, int dtype, const U_PSEUDO_OBJ *Points){ + int ctype, RelAbs; + if(PenID>63){ return(NULL); } + if(Points){ + if( Points->Type == U_PMF_POINTR_OID){ RelAbs = 1; ctype = 0; } + else if(Points->Type == (U_PMF_POINT_OID | U_PMF_ARRAY_OID)){ RelAbs = 0; ctype = 1; } + else if(Points->Type == (U_PMF_POINTF_OID | U_PMF_ARRAY_OID)){ RelAbs = 0; ctype = 0; } + else { return(NULL); } + } + else { return(NULL); } + int Size = Points->Used; + uint16_t utmp16 = (ctype ? U_PPF_C : 0) | (dtype ? U_PPF_D : 0) | (RelAbs ? U_PPF_P : 0) | (PenID & U_FF_MASK_OID8) << U_FF_SHFT_OID8; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_DRAWLINES,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {Points->Data, Points->Used, 1, U_XE}, /* includes Elements */ + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_DRAWLINES_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_DRAWPATH PseudoObject + \return Pointer to PseudoObject, NULL on error + \param PathID U_PMF_PATH object in the EMF+ object table (0-63, inclusive) + \param PenID U_PMF_PEN object in the EMF+ object table (0-63, inclusive) + + + EMF+ manual 2.3.4.11, Microsoft name: EmfPlusDrawPath Record, Index 0x15 +*/ +U_PSEUDO_OBJ *U_PMR_DRAWPATH_set(uint32_t PathID, uint32_t PenID){ + if(PathID>63)return(NULL); + if(PenID>63)return(NULL); + int Size = 4; + uint16_t utmp16 = (PathID & U_FF_MASK_OID8) << U_FF_SHFT_OID8; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_DRAWPATH,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {&PenID, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_DRAWPATH_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_DRAWPIE PseudoObject + \return Pointer to PseudoObject, NULL on error + \param PenID U_PMF_PEN object in the EMF+ object table (0-63, inclusive) + \param Start Start angle, >=0.0, degrees clockwise from 3:00 + \param Sweep Sweep angle, -360<= angle <=360, degrees clockwise from Start + \param Rect U_PSEUDO_OBJ containing a U_PMF_RECT or U_PMF_RECTF object + + + EMF+ manual 2.3.4.12, Microsoft name: EmfPlusDrawPie Record, Index 0x0D +*/ +U_PSEUDO_OBJ *U_PMR_DRAWPIE_set(uint32_t PenID, + U_FLOAT Start, U_FLOAT Sweep, const U_PSEUDO_OBJ *Rect){ + int ctype; + if(PenID>63)return(NULL); + if(!Rect){ return(NULL); } + else { + if( Rect->Type == U_PMF_RECT_OID ){ ctype = 1; } + else if(Rect->Type == U_PMF_RECTF_OID){ ctype = 0; } + else { return(NULL); } + } + int Size = 2*4 + Rect->Used; + uint16_t utmp16 = (ctype ? U_PPF_C : 0) | (PenID & U_FF_MASK_OID8) << U_FF_SHFT_OID8; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_DRAWPIE,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {&Start, 4, 1, U_LE}, + {&Sweep, 4, 1, U_LE}, + {Rect->Data, Rect->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_DRAWPIE_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_DRAWRECTS PseudoObject + \return Pointer to PseudoObject, NULL on error + \param PenID U_PMF_PEN object in the EMF+ object table (0-63, inclusive) + \param Rects U_PSEUDO_OBJ containing 1 rect OR a count N follwed by N rects. Rects may be either U_PMF_RECT or U_PMF_RECTF + + + EMF+ manual 2.3.4.13, Microsoft name: EmfPlusDrawRects Record, Index 0x0B +*/ +U_PSEUDO_OBJ *U_PMR_DRAWRECTS_set(uint32_t PenID, const U_PSEUDO_OBJ *Rects){ + int ctype; + int just1; + uint32_t Elements=1; /* only used when a single rect is passed in, not an array, not even an array with one member*/ + if(PenID>63){ return(NULL); } + if(Rects){ + if( (Rects->Type & U_PMF_MASK_OID) == U_PMF_RECT_OID ){ ctype = 1; } + else if( (Rects->Type & U_PMF_MASK_OID) == U_PMF_RECTF_OID){ ctype = 0; } + else { return(NULL); } + } + else { return(NULL); } + just1 = (Rects->Type & U_PMF_ARRAY_OID ? 0 : 1); + int Size = Rects->Used + (just1 ? 4 : 0); /* Elements in Rects for array, not for single */ + uint16_t utmp16 = (ctype ? U_PPF_C : 0)| (PenID & U_FF_MASK_OID8) << U_FF_SHFT_OID8; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_DRAWRECTS,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {(just1 ? (char *)&Elements : NULL), (just1 ? 4: 0), 1, U_LE}, /* element count if a single Rect was passed in, empty otherwise */ + {Rects->Data, Rects->Used, 1, U_XE}, /* Elements + Array, already stored in Rects, if an array was passed in, just rect if a single */ + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_DRAWRECTS_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_DRAWSTRING PseudoObject + \return Pointer to PseudoObject, NULL on error + \param FontID U_PMF_FONT object in the EMF+ object table (0-63, inclusive) + \param BrushID U_PSEUDO_OBJ containing a U_PMF_ARGB or a U_PMF_4NUM. Color or U_PMF_BRUSH object in the EMF+ object table (0-63, inclusive) + \param FormatID U_PMF_STRINGFORMAT object in EMF+ Object Table. + \param Length Number of characters in the string. + \param Rect U_PSEUDO_OBJ containing a U_PMF_RECTF object, string's bounding box + \param Text Array of UFT-16LE unicode characters. + + + EMF+ manual 2.3.4.14, Microsoft name: EmfPlusDrawString Record, Index 0x1C +*/ +U_PSEUDO_OBJ *U_PMR_DRAWSTRING_set(uint32_t FontID, const U_PSEUDO_OBJ *BrushID, + uint32_t FormatID, uint32_t Length, const U_PSEUDO_OBJ *Rect, const uint16_t *Text){ + int btype; + if(FontID>63){ return(NULL); } + if(!Length){ return(NULL); } + if(!Rect || Rect->Type != U_PMF_RECTF_OID){ return(NULL); } + if(BrushID){ + if( BrushID->Used != 4){ return(NULL); } + else if( BrushID->Type == U_PMF_ARGB_OID){ btype = 1; } + else if( BrushID->Type == U_PMF_4NUM_OID){ btype = 0; } + else { return(NULL); } + } + else { return(NULL); } + int Size = BrushID->Used + 2*4 + Rect->Used +2*Length; + uint16_t utmp16 = (btype ? U_PPF_B : 0)| (FontID & U_FF_MASK_OID8) << U_FF_SHFT_OID8; + uint32_t pad = (0x1 & Length ? 2 : 0); + Size+=pad; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_DRAWSTRING,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {BrushID->Data, BrushID->Used, 1, U_XE}, + {&FormatID, 4, 1, U_LE}, + {&Length, 4, 1, U_LE}, + {Rect->Data, Rect->Used, 1, U_XE}, + {Text, 2*Length, 1, U_XE}, + {NULL, pad, (pad ? 1 : 0), (pad ? U_XE : U_XX)}, /* Entire record must be a multiple of 4 */ + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_DRAWSTRING_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_FILLCLOSEDCURVE PseudoObject + \return Pointer to PseudoObject, NULL on error + \param ftype If U_WINDING use winding fill, else use fill + \param BrushID U_PSEUDO_OBJ containing a U_PMF_ARGB or a U_PMF_4NUM. Color or U_PMF_BRUSH object in the EMF+ object table (0-63, inclusive) + \param Tension Controls splines, 0 is straight line, >0 is curved + \param Points U_PSEUDO_OBJ containing a U_PMF_POINT, U_PMF_POINTR or U_PMF_POINTF object + + + EMF+ manual 2.3.4.15, Microsoft name: EmfPlusFillClosedCurve Record, Index 0x16 +*/ +U_PSEUDO_OBJ *U_PMR_FILLCLOSEDCURVE_set(int ftype, U_FLOAT Tension, const U_PSEUDO_OBJ *BrushID, const U_PSEUDO_OBJ *Points){ + int btype, ctype, RelAbs; + int Size=0; + if(BrushID){ + if( BrushID->Used != 4){ return(NULL); } + else if( BrushID->Type == U_PMF_ARGB_OID){ btype = 1; } + else if( BrushID->Type == U_PMF_4NUM_OID){ btype = 0; } + else { return(NULL); } + } + else { return(NULL); } + if(Points){ + if( Points->Type == U_PMF_POINTR_OID){ RelAbs = 1; ctype = 0; } + else if(Points->Type == (U_PMF_POINT_OID | U_PMF_ARRAY_OID)){ RelAbs = 0; ctype = 1; } + else if(Points->Type == (U_PMF_POINTF_OID | U_PMF_ARRAY_OID)){ RelAbs = 0; ctype = 0; } + else { return(NULL); } + } + else { return(NULL); } + Size = BrushID->Used + 4 + Points->Used; + uint16_t utmp16 = (btype ? U_PPF_B : 0) | (ctype ? U_PPF_C : 0) |((ftype == U_WINDING) ? U_PPF_F : 0) |(RelAbs ? U_PPF_P : 0); + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_FILLCLOSEDCURVE,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {BrushID->Data, BrushID->Used, 1, U_XE}, + {&Tension, 4, 1, U_LE}, + {Points->Data, Points->Used, 1, U_XE}, /* includes Elements */ + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_FILLCLOSEDCURVE_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_FILLELLIPSE PseudoObject + \return Pointer to PseudoObject, NULL on error + \param BrushID U_PSEUDO_OBJ containing a U_PMF_ARGB or a U_PMF_4NUM. Color or U_PMF_BRUSH object in the EMF+ object table (0-63, inclusive) + \param Rect U_PSEUDO_OBJ containing a U_PMF_RECT or U_PMF_RECTF object + + + EMF+ manual 2.3.4.16, Microsoft name: EmfPlusFillEllipse Record, Index 0x0E +*/ +U_PSEUDO_OBJ *U_PMR_FILLELLIPSE_set(const U_PSEUDO_OBJ *BrushID, const U_PSEUDO_OBJ *Rect){ + int btype, ctype; + if(BrushID){ + if( BrushID->Used != 4){ return(NULL); } + else if( BrushID->Type == U_PMF_ARGB_OID){ btype = 1; } + else if( BrushID->Type == U_PMF_4NUM_OID){ btype = 0; } + else { return(NULL); } + } + else { return(NULL); } + if(Rect){ + if( Rect->Type == U_PMF_RECT_OID ){ ctype = 1; } + else if(Rect->Type == U_PMF_RECTF_OID){ ctype = 0; } + else { return(NULL); } + } + else { return(NULL); } + int Size = BrushID->Used + Rect->Used; + uint16_t utmp16 = (btype ? U_PPF_B : 0) | (ctype ? U_PPF_C : 0); + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_FILLELLIPSE,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {BrushID->Data, BrushID->Used, 1, U_XE}, + {Rect->Data, Rect->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_FILLELLIPSE_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_FILLPATH PseudoObject + \return Pointer to PseudoObject, NULL on error + \param PathID U_PMF_PATH object in the EMF+ object table (0-63, inclusive) + \param BrushID U_PSEUDO_OBJ containing a U_PMF_ARGB or a U_PMF_4NUM. Color or U_PMF_BRUSH object in the EMF+ object table (0-63, inclusive) + + + EMF+ manual 2.3.4.17, Microsoft name: EmfPlusFillPath Record, Index 0x14 +*/ +U_PSEUDO_OBJ *U_PMR_FILLPATH_set(uint32_t PathID, const U_PSEUDO_OBJ *BrushID){ + int btype; + int Size=0; + if(PathID>63)return(NULL); + if(BrushID){ + if( BrushID->Used != 4){ return(NULL); } + else if( BrushID->Type == U_PMF_ARGB_OID){ btype = 1; } + else if( BrushID->Type == U_PMF_4NUM_OID){ btype = 0; } + else { return(NULL); } + } + else { return(NULL); } + Size = BrushID->Used; + uint16_t utmp16 = (btype ? U_PPF_B : 0) | (PathID & U_FF_MASK_OID8) << U_FF_SHFT_OID8 ; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_FILLPATH,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {BrushID->Data, BrushID->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_FILLPATH_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_FILLPIE PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Start Start angle, >=0.0, degrees clockwise from 3:00 + \param Sweep Sweep angle, -360<= angle <=360, degrees clockwise from Start + \param BrushID U_PSEUDO_OBJ containing a U_PMF_ARGB or a U_PMF_4NUM. Color or U_PMF_BRUSH object in the EMF+ object table (0-63, inclusive) + \param Rect U_PSEUDO_OBJ containing a U_PMF_RECT or U_PMF_RECTF object + + + EMF+ manual 2.3.4.18, Microsoft name: EmfPlusFillPie Record, Index 0x10 +*/ +U_PSEUDO_OBJ *U_PMR_FILLPIE_set(U_FLOAT Start, U_FLOAT Sweep, const U_PSEUDO_OBJ *BrushID, const U_PSEUDO_OBJ *Rect){ + int btype, ctype; + if(BrushID){ + if( BrushID->Used != 4){ return(NULL); } + else if( BrushID->Type == U_PMF_ARGB_OID){ btype = 1; } + else if( BrushID->Type == U_PMF_4NUM_OID){ btype = 0; } + else { return(NULL); } + } + else { return(NULL); } + if(!Rect){ return(NULL); } + else { + if( Rect->Type == U_PMF_RECT_OID ){ ctype = 1; } + else if(Rect->Type == U_PMF_RECTF_OID){ ctype = 0; } + else { return(NULL); } + } + int Size = BrushID->Used + 2*4 + Rect->Used; + uint16_t utmp16 = (btype ? U_PPF_B : 0) | (ctype ? U_PPF_C : 0); + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_FILLPIE,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {BrushID->Data, BrushID->Used, 1, U_XE}, + {&Start, 4, 1, U_LE}, + {&Sweep, 4, 1, U_LE}, + {Rect->Data, Rect->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_FILLPIE_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_FILLPOLYGON PseudoObject + \return Pointer to PseudoObject, NULL on error + \param BrushID U_PSEUDO_OBJ containing a U_PMF_ARGB or a U_PMF_4NUM. Color or U_PMF_BRUSH object in the EMF+ object table (0-63, inclusive) + \param Points U_PSEUDO_OBJ containing an array of 3 U_PMF_POINT, U_PMF_POINTR, or U_PMF_POINTF objects + + + EMF+ manual 2.3.4.19, Microsoft name: EmfPlusFillPolygon Record, Index 0x0C +*/ +U_PSEUDO_OBJ *U_PMR_FILLPOLYGON_set(const U_PSEUDO_OBJ *BrushID, const U_PSEUDO_OBJ *Points){ + int btype, ctype, RelAbs; + if(BrushID){ + if( BrushID->Used != 4){ return(NULL); } + else if( BrushID->Type == U_PMF_ARGB_OID){ btype = 1; } + else if( BrushID->Type == U_PMF_4NUM_OID){ btype = 0; } + else { return(NULL); } + } + else { return(NULL); } + if(Points){ + if( Points->Type == U_PMF_POINTR_OID){ RelAbs = 1; ctype = 0; } + else if(Points->Type == (U_PMF_POINT_OID | U_PMF_ARRAY_OID)){ RelAbs = 0; ctype = 1; } + else if(Points->Type == (U_PMF_POINTF_OID | U_PMF_ARRAY_OID)){ RelAbs = 0; ctype = 0; } + else { return(NULL); } + } + else { return(NULL); } + int Size = BrushID->Used + Points->Used; + uint16_t utmp16 = (btype ? U_PPF_B : 0) | (ctype ? U_PPF_C : 0) |(RelAbs ? U_PPF_P : 0); + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_FILLPOLYGON,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {BrushID->Data, BrushID->Used, 1, U_XE}, + {Points->Data, Points->Used, 1, U_XE}, /* includes Elements */ + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_FILLPOLYGON_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_FILLRECTS PseudoObject + \return Pointer to PseudoObject, NULL on error + \param BrushID U_PSEUDO_OBJ containing a U_PMF_ARGB or a U_PMF_4NUM. Color or U_PMF_BRUSH object in the EMF+ object table (0-63, inclusive) + \param Rects U_PSEUDO_OBJ containing 1 rect OR a count N followed by N rects. Rects may be either U_PMF_RECT or U_PMF_RECTF + + + EMF+ manual 2.3.4.20, Microsoft name: EmfPlusFillRects Record, Index 0x0A +*/ +U_PSEUDO_OBJ *U_PMR_FILLRECTS_set(const U_PSEUDO_OBJ *BrushID, const U_PSEUDO_OBJ *Rects){ + int btype, ctype; + int just1; + uint32_t Elements=1; /* only used when a single rect is passed in, not an array, not even an array with one member*/ + if(BrushID){ + if( BrushID->Used != 4){ return(NULL); } + else if( BrushID->Type == U_PMF_ARGB_OID){ btype = 1; } + else if( BrushID->Type == U_PMF_4NUM_OID){ btype = 0; } + else { return(NULL); } + } + else { return(NULL); } + if(Rects){ + if( (Rects->Type & U_PMF_MASK_OID) == U_PMF_RECT_OID ){ ctype = 1; } + else if( (Rects->Type & U_PMF_MASK_OID) == U_PMF_RECTF_OID){ ctype = 0; } + else { return(NULL); } + } + else { return(NULL); } + just1 = (Rects->Type & U_PMF_ARRAY_OID ? 0 : 1); + int Size = BrushID->Used + Rects->Used + (just1 ? 4 : 0); /* Elements in Rects for array, not for single */ + uint16_t utmp16 = (btype ? U_PPF_B : 0)|(ctype ? U_PPF_C : 0); + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_FILLRECTS,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {BrushID->Data, BrushID->Used, 1, U_XE}, + {(just1 ? (char *)&Elements : NULL), (just1 ? 4: 0), 1, U_LE}, /* element count if a single Rect was passed in, empty otherwise */ + {Rects->Data, Rects->Used, 1, U_XE}, /* Elements + Array, already stored in Rects, if an array was passed in, just rect if a single */ + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_FILLRECTS_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_FILLREGION PseudoObject + \return Pointer to PseudoObject, NULL on error + \param RgnID U_PMF_REGION object in the EMF+ object table (0-63, inclusive) + \param BrushID U_PSEUDO_OBJ containing a U_PMF_ARGB or a U_PMF_4NUM. Color or U_PMF_BRUSH object in the EMF+ object table (0-63, inclusive) + + + EMF+ manual 2.3.4.21, Microsoft name: EmfPlusFillRegion Record, Index 0x13 +*/ +U_PSEUDO_OBJ *U_PMR_FILLREGION_set(uint32_t RgnID, const U_PSEUDO_OBJ *BrushID){ + int btype; + if(BrushID){ + if( BrushID->Used != 4){ return(NULL); } + else if( BrushID->Type == U_PMF_ARGB_OID){ btype = 1; } + else if( BrushID->Type == U_PMF_4NUM_OID){ btype = 0; } + else { return(NULL); } + } + else { return(NULL); } + int Size = BrushID->Used; + uint16_t utmp16 = (btype ? U_PPF_B : 0) | (RgnID & U_FF_MASK_OID8) << U_FF_SHFT_OID8; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_FILLREGION,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {BrushID->Data, BrushID->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_FILLREGION_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_OBJECT PseudoObject from another PseudoObject + \return Pointer to PseudoObject, NULL on error + \param ObjID Index for this object in the EMF+ object table (0-63, inclusive) + \param Po U_PSEUDO_OBJ containing an object type that may be stored in the EMF+ object table +*/ +U_PSEUDO_OBJ *U_PMR_OBJECT_PO_set(uint32_t ObjID, U_PSEUDO_OBJ *Po){ + int otype = U_OID_To_OT(Po->Type); /* This will return 0 if the type is not valid for an object */ + if(!otype){ return(NULL); } + U_PSEUDO_OBJ *po = U_PMR_OBJECT_set(ObjID, otype, 0, 0, Po->Used, Po->Data); /* 0,0 = rec. not continued, TSize value (ignored) */ + return(po); +} + +/** + \brief Create and set a U_PMR_OBJECT PseudoObject + \return Pointer to PseudoObject, NULL on error + \param ObjID Index for this object in the EMF+ object table (0-63, inclusive) + \param otype ObjectType enumeration for this Object + \param ntype Set: object definition continues in next record; Clear: this is the sole object definition record + \param TSize If ntype is set the total number of data bytes split across multiple records. If ntype is clear, it is ignored. + \param cbData Object's data size, in bytes. + \param Data Object's data. Type from otype. + + + EMF+ manual 2.3.5.1, Microsoft name: EmfPlusObject Record, Index 0x13 + + Normally this is only called by U_PMR_OBJECT_PO_set(). + + U_PMR_OBJECT records can only hold a maximum of 65020 bytes of data. If the object is larger than that + then multiple U_PMR_OBJECT records are created, one after the other. If this + happens each record has cbData following ph, and the ntype flag is set. If all of the data is less than 65020 + then cbData is NOT entered following ph, and the ntype flag is clear. + + Call initially in all cases with ntype clear and TSize = 0. If the record needs to be fragmented + the function will call itself recursively to do so. + +*/ +U_PSEUDO_OBJ *U_PMR_OBJECT_set(uint32_t ObjID, int otype, int ntype, uint32_t TSize, size_t cbData, const char *Data){ + uint32_t CSize; + int Pad = UP4(TSize) - TSize; + if((otype < U_OT_Brush) || (otype > U_OT_CustomLineCap)){ return(NULL); } + if(ntype && (cbData > U_OBJRECLIM)){ return(NULL); } + U_PSEUDO_OBJ *po; + + if(!ntype && !TSize && (cbData > U_OBJRECLIM)){ + ntype = 1; + TSize = cbData; + po = U_PO_create(NULL, TSize + 16 * (1 + (TSize/cbData)), 0, U_PMR_OBJECT_OID); + if(!po)return(po); + while(cbData){ + CSize = (cbData > U_OBJRECLIM ? U_OBJRECLIM : cbData); + U_PSEUDO_OBJ *pot = U_PMR_OBJECT_set(ObjID, otype, ntype, TSize, CSize, Data); + po = U_PO_po_append(po, pot, U_PMF_KEEP_ELEMENTS); + U_PO_free(&pot); + Data += U_OBJRECLIM; + cbData -= CSize; + } + } + else { + /* Send in DataSize, U_PMR_CMN_HDR_set will adjust Header Size with 1-3 pad bytes if needed */ + uint16_t utmp16 = otype << 8 | (ntype ? U_PPF_N : 0) | (ObjID & U_FF_MASK_OID8) << U_FF_SHFT_OID8; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_OBJECT,utmp16,cbData + (ntype ? 4 : 0)); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE }, + {(ntype ? &TSize : NULL), (ntype ? 4 : 0), (ntype ? 1 : 0), U_LE }, + {Data, cbData, 1, U_XE }, + {NULL, (Pad ? Pad : 0), (Pad ? 1 : 0), (Pad ? U_XE : U_XX)}, /* Either 1-3 pad bytes or a terminator */ + {NULL,0,0,U_XX} /* terminator, possibly a second in the list, which is harmless */ + }; + po = U_PMF_SERIAL_set(U_PMR_OBJECT_OID, List); + U_PO_free(&ph); + } + return(po); +} + +/** + \brief Create and set a U_PMR_SERIALIZABLEOBJECT PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Siepb U_PSEUDO_OBJ containing a "Serialized image effects parameter block". One of the ImageEffects objects. + + EMF+ manual 2.3.5.2, Microsoft name: EmfPlusSerializableObject Record, Index 0x38 + + + This sets an ImageEffect in the renderer, which will be applied to the next EmfPlusDrawImagePoints + record that is encountered. The image effect is "consumed" by that EmfPlusDrawImagePoints record, resetting + the renderer to its original state.\n + + WARNING! Windows XP Preview does not show filter effects, whether or not U_PPF_E is set. They are visible if the EMF+ + file is inserted as an image into PowerPoint. + +*/ +U_PSEUDO_OBJ *U_PMR_SERIALIZABLEOBJECT_set(const U_PSEUDO_OBJ *Siepb){ + if(!Siepb){ return(NULL); } + uint8_t *GUID = U_OID_To_GUID(Siepb->Type); + if(!GUID){ return(NULL); } + /* PO Used is size_t, might be 8 bytes, value in record must be 4 bytes */ + uint32_t Used = Siepb->Used; + int Size = 16 + 4 + Siepb->Used; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_SERIALIZABLEOBJECT,0,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {GUID, 16, 1, U_XE}, + {&Used, 4, 1, U_LE}, + {Siepb->Data, Siepb->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_SERIALIZABLEOBJECT_OID, List); + U_PO_free(&ph); + free(GUID); + return(po); +} + +/** + \brief Create and set a U_PMR_SETANTIALIASMODE PseudoObject + \return Pointer to PseudoObject, NULL on error + \param SMenum SmoothingMode enumeration + \param aatype Set: anti-aliasing on; Clear: anti-aliasing off + + + EMF+ manual 2.3.6.1, Microsoft name: EmfPlusSetAntiAliasMode Record, Index 0x1E +*/ +U_PSEUDO_OBJ *U_PMR_SETANTIALIASMODE_set(int SMenum, int aatype){ + int Size = 0; + uint16_t utmp16 = (aatype ? U_PPF_AA : 0) | (SMenum & U_FF_MASK_AA)<Data, ph->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_SETANTIALIASMODE_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_SETCOMPOSITINGMODE PseudoObject + \return Pointer to PseudoObject, NULL on error + \param CMenum CompositingMode enumeration + + + EMF+ manual 2.3.6.2, Microsoft name: EmfPlusSetCompositingMode Record, Index 0x23 +*/ +U_PSEUDO_OBJ *U_PMR_SETCOMPOSITINGMODE_set(int CMenum){ + int Size = 0; + uint16_t utmp16 = (CMenum & U_FF_MASK_CM)<Data, ph->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_SETCOMPOSITINGMODE_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_SETCOMPOSITINGQUALITY PseudoObject + \return Pointer to PseudoObject, NULL on error + \param CQenum CompositingQuality enumeration + + + EMF+ manual 2.3.6.3, Microsoft name: EmfPlusSetCompositingQuality Record, Index 0x24 +*/ +U_PSEUDO_OBJ *U_PMR_SETCOMPOSITINGQUALITY_set(int CQenum){ + int Size = 0; + uint16_t utmp16 = (CQenum & U_FF_MASK_CQ)<Data, ph->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_SETCOMPOSITINGQUALITY_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_SETINTERPOLATIONMODE PseudoObject + \return Pointer to PseudoObject, NULL on error + \param IMenum InterpolationMode enumeration + + + EMF+ manual 2.3.6.4, Microsoft name: EmfPlusSetInterpolationMode Record, Index 0x21 +*/ +U_PSEUDO_OBJ *U_PMR_SETINTERPOLATIONMODE_set(int IMenum){ + int Size = 0; + uint16_t utmp16 = (IMenum & U_FF_MASK_IM)<Data, ph->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_SETINTERPOLATIONMODE_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_SETPIXELOFFSETMODE PseudoObject + \return Pointer to PseudoObject, NULL on error + \param POMenum PixelOffsetMode enumeration + + + EMF+ manual 2.3.6.5, Microsoft name: EmfPlusSetPixelOffsetMode Record, Index 0x22 +*/ +U_PSEUDO_OBJ *U_PMR_SETPIXELOFFSETMODE_set(int POMenum){ + int Size = 0; + uint16_t utmp16 = (POMenum & U_FF_MASK_PxOffM) << U_FF_SHFT_PxOffM; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_SETPIXELOFFSETMODE,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_SETPIXELOFFSETMODE_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_SETRENDERINGORIGIN PseudoObject + \return Pointer to PseudoObject, NULL on error + \param X X coordinate of rendering origin. + \param Y Y coordinate of rendering origin. + + + EMF+ manual 2.3.6.6, Microsoft name: EmfPlusSetRenderingOrigin Record, Index 0x1D +*/ +U_PSEUDO_OBJ *U_PMR_SETRENDERINGORIGIN_set(int32_t X, int32_t Y){ + int Size = 2*4; + uint16_t utmp16 = 0; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_SETRENDERINGORIGIN,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {&X, 4, 1, U_LE}, + {&Y, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_SETRENDERINGORIGIN_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_SETTEXTCONTRAST PseudoObject + \return Pointer to PseudoObject, NULL on error + \param TGC Text Gamma correction value (x 1000). + + + EMF+ manual 2.3.6.7, Microsoft name: EmfPlusSetTextContrast Record, Index 0x20 +*/ +U_PSEUDO_OBJ *U_PMR_SETTEXTCONTRAST_set(int TGC){ + int Size = 0; + uint16_t utmp16 = (TGC & U_FF_MASK_TGC) << U_FF_SHFT_TGC; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_SETTEXTCONTRAST,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_SETTEXTCONTRAST_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_SETTEXTRENDERINGHINT PseudoObject + \return Pointer to PseudoObject, NULL on error + \param TRHenum TextRenderingHint enumeration + + + EMF+ manual 2.3.6.8, Microsoft name: EmfPlusSetTextRenderingHint Record, Index 0x1F +*/ +U_PSEUDO_OBJ *U_PMR_SETTEXTRENDERINGHINT_set(int TRHenum){ + int Size = 0; + uint16_t utmp16 = (TRHenum & U_FF_MASK_TRH) << U_FF_SHFT_TRH; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_SETTEXTRENDERINGHINT,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_SETTEXTRENDERINGHINT_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_BEGINCONTAINER PseudoObject + \return Pointer to PseudoObject, NULL on error + \param UTenum UnitType enumeration + \param DstRect a U_PSEUDO_OBJ containing a U_PMF_RECTF object. with SrcRect specifies a transformation + \param SrcRect a U_PSEUDO_OBJ containing a U_PMF_RECTF object. with DstRect specifies a transformation + \param StackID EMF+ Object Stack Index to use for this graphics container + + + EMF+ manual 2.3.7.1, Microsoft name: EmfPlusBeginContainer Record, Index 0x27 +*/ +U_PSEUDO_OBJ *U_PMR_BEGINCONTAINER_set(int UTenum, U_PSEUDO_OBJ *DstRect, U_PSEUDO_OBJ *SrcRect, uint32_t StackID){ + if(UTenum < U_UT_World || UTenum > U_UT_Millimeter){ return(NULL); } + if(!DstRect || (DstRect->Type != U_PMF_RECTF_OID)){ return(NULL); } + if(!SrcRect || (SrcRect->Type != U_PMF_RECTF_OID)){ return(NULL); } + int Size = DstRect->Used + SrcRect->Used + 4; + uint16_t utmp16 = (UTenum & U_FF_MASK_UT) << U_FF_SHFT_UT; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_BEGINCONTAINER,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {DstRect->Data, DstRect->Used, 1, U_XE}, + {SrcRect->Data, SrcRect->Used, 1, U_XE}, + {&StackID, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_BEGINCONTAINER_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_BEGINCONTAINERNOPARAMS PseudoObject + \return Pointer to PseudoObject, NULL on error + \param StackID EMF+ Object Stack Index to use for this graphics container + + + EMF+ manual 2.3.7.2, Microsoft name: EmfPlusBeginContainerNoParams Record, Index 0x28 +*/ +U_PSEUDO_OBJ *U_PMR_BEGINCONTAINERNOPARAMS_set(int StackID){ + int Size = 4; + uint16_t utmp16 = 0; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_BEGINCONTAINERNOPARAMS,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {&StackID, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_BEGINCONTAINERNOPARAMS_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_ENDCONTAINER PseudoObject + \return Pointer to PseudoObject, NULL on error + \param StackID EMF+ Object Stack Index to use for this graphics container + + + EMF+ manual 2.3.7.3, Microsoft name: EmfPlusEndContainer Record, Index 0x29 +*/ +U_PSEUDO_OBJ *U_PMR_ENDCONTAINER_set(int StackID){ + int Size = 4; + uint16_t utmp16 = 0; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_ENDCONTAINER,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {&StackID, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_ENDCONTAINER_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_RESTORE PseudoObject + \return Pointer to PseudoObject, NULL on error + \param StackID EMF+ Graphics State Stack to restore from. Must have been put on the GSS with a U_PMR_SAVE. + + + EMF+ manual 2.3.7.4, Microsoft name: EmfPlusRestore Record, Index 0x26 +*/ +U_PSEUDO_OBJ *U_PMR_RESTORE_set(int StackID){ + int Size = 4; + uint16_t utmp16 = 0; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_RESTORE,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {&StackID, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_RESTORE_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_SAVE PseudoObject + \return Pointer to PseudoObject, NULL on error + \param StackID EMF+ Graphics State Stack to restore from. Must have been put on the GSS with a U_PMR_SAVE. + + + EMF+ manual 2.3.7.5, Microsoft name: EmfPlusSave Record, Index 0x25 +*/ +U_PSEUDO_OBJ *U_PMR_SAVE_set(int StackID){ + int Size = 4; + uint16_t utmp16 = 0; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_SAVE,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {&StackID, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_SAVE_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_SETTSCLIP PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Rects a U_PSEUDO_OBJ containing an array of U_PMF_RECT or U_PMF_RECTF objects. + + + EMF+ manual 2.3.8.1, Microsoft name: EmfPlusSetTSClip Record, Index 0x3A +*/ +U_PSEUDO_OBJ *U_PMR_SETTSCLIP_set(U_PSEUDO_OBJ *Rects){ + int ctype; + uint32_t Elements; + if(Rects){ + if( Rects->Type == (U_PMF_RECT_OID | U_PMF_ARRAY_OID)){ ctype = 1; Elements = (Rects->Used - 4)/8; } + else if(Rects->Type == (U_PMF_RECTF_OID | U_PMF_ARRAY_OID)){ ctype = 0; Elements = (Rects->Used - 4)/16; } + else { return(NULL); } + } + else { return(NULL); } + int Size = Rects->Used; /* Rects includes Elements */ + uint16_t utmp16 = (ctype ? U_PPF_K : 0) | (Elements & U_FF_MASK_TSC) << U_FF_SHFT_TSC; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_SETTSCLIP,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {Rects->Data, Rects->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_SETTSCLIP_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_SETTSGRAPHICS PseudoObject + \return Pointer to PseudoObject, NULL on error + \param vgatype Set: Palette is VGA basic colors; Clear: Palette is ??? + \param Tsg A U_PMF_SETTSGRAPHICS object + \param Palette (optional) a U_PSEUDO_OBJ containing a U_PMF_PALETTE object. + + + EMF+ manual 2.3.8.2, Microsoft name: EmfPlusSetTSGraphics Record, Index 0x39 +*/ +U_PSEUDO_OBJ *U_PMR_SETTSGRAPHICS_set(int vgatype, U_PMF_SETTSGRAPHICS *Tsg, U_PSEUDO_OBJ *Palette){ + if(!Tsg){ return(NULL); } + int Size = sizeof(U_PMF_SETTSGRAPHICS) + (Palette ? Palette->Used : 0); + uint16_t utmp16 = (vgatype ? U_PPF_VGA : 0) | (Palette ? U_PPF_PP : 0) ; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_SETTSGRAPHICS,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {&(Tsg->AntiAliasMode), 1, 1, U_XE}, + {&(Tsg->TextRenderHint), 1, 1, U_XE}, + {&(Tsg->CompositingMode), 1, 1, U_XE}, + {&(Tsg->CompositingQuality), 1, 1, U_XE}, + {&(Tsg->RenderOriginX), 2, 1, U_LE}, + {&(Tsg->RenderOriginY), 2, 1, U_LE}, + {&(Tsg->TextContrast), 2, 1, U_LE}, + {&(Tsg->FilterType), 1, 1, U_XE}, + {&(Tsg->PixelOffset), 1, 1, U_XE}, + {&(Tsg->WorldToDevice), 4, 6, U_LE}, + {(Palette ? Palette->Data : NULL), (Palette ? Palette->Used: 0), 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_SETTSGRAPHICS_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_MULTIPLYWORLDTRANSFORM PseudoObject + \return Pointer to PseudoObject, NULL on error + \param xmtype Set: Post multiply; Clear: Pre multiply + \param Tm a U_PSEUDO_OBJ containing a U_PMF_TRANSFORMMATRIX. (Transformation matrix) + + + EMF+ manual 2.3.9.1, Microsoft name: EmfPlusMultiplyWorldTransform Record, Index 0x2C +*/ +U_PSEUDO_OBJ *U_PMR_MULTIPLYWORLDTRANSFORM_set(int xmtype, U_PSEUDO_OBJ *Tm){ + if(!Tm || (Tm->Type != U_PMF_TRANSFORMMATRIX_OID)){ return(NULL); } + int Size = Tm->Used; + uint16_t utmp16 = (xmtype ? U_PPF_XM : 0); + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_MULTIPLYWORLDTRANSFORM,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {Tm->Data, Tm->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_MULTIPLYWORLDTRANSFORM_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_RESETWORLDTRANSFORM PseudoObject + \return Pointer to PseudoObject, NULL on error + + + EMF+ manual 2.3.9.2, Microsoft name: EmfPlusResetWorldTransform Record, Index 0x2B +*/ +U_PSEUDO_OBJ *U_PMR_RESETWORLDTRANSFORM_set(void){ + int Size = 0; + uint16_t utmp16 = 0; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_RESETWORLDTRANSFORM,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_RESETWORLDTRANSFORM_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_ROTATEWORLDTRANSFORM PseudoObject + \return Pointer to PseudoObject, NULL on error + \param xmtype Set: Post multiply; Clear: Pre multiply + \param Angle Rotation angle, in degrees + + + EMF+ manual 2.3.9.3, Microsoft name: EmfPlusRotateWorldTransform Record, Index 0x2F +*/ +U_PSEUDO_OBJ *U_PMR_ROTATEWORLDTRANSFORM_set(int xmtype, U_FLOAT Angle){ + int Size = 4; + uint16_t utmp16 = (xmtype ? U_PPF_XM : 0); + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_ROTATEWORLDTRANSFORM,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {&Angle, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_ROTATEWORLDTRANSFORM_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_SCALEWORLDTRANSFORM PseudoObject + \return Pointer to PseudoObject, NULL on error + \param xmtype Set: Post multiply; Clear: Pre multiply + \param X Scale in X + \param Y Scale in Y + + EMF+ manual 2.3.9.4, Microsoft name: EmfPlusScaleWorldTransform Record, Index 0x2E +*/ +U_PSEUDO_OBJ *U_PMR_SCALEWORLDTRANSFORM_set(int xmtype, U_FLOAT X, U_FLOAT Y){ + int Size = 2*4; + uint16_t utmp16 = (xmtype ? U_PPF_XM : 0); + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_SCALEWORLDTRANSFORM,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {&X, 4, 1, U_LE}, + {&Y, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_SCALEWORLDTRANSFORM_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_SETPAGETRANSFORM PseudoObject + \return Pointer to PseudoObject, NULL on error + \param PUenum Page Unit, in UnitType enumeration + \param Scale Scale factor to convert page space to device space + + + + EMF+ manual 2.3.9.5, Microsoft name: EmfPlusSetPageTransform Record, Index 0x30 + + Defines Page Space -> Device Space transformation +*/ +U_PSEUDO_OBJ *U_PMR_SETPAGETRANSFORM_set(int PUenum, U_FLOAT Scale){ + int Size = 4; + uint16_t utmp16 = (PUenum & U_FF_MASK_PU) << U_FF_SHFT_PU; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_SETPAGETRANSFORM,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {&Scale, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_SETPAGETRANSFORM_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_SETWORLDTRANSFORM PseudoObject + \return Pointer to PseudoObject, NULL on error + \param Tm a U_PSEUDO_OBJ containing a U_PMF_TRANSFORMMATRIX. (Transformation matrix) + + + + EMF+ manual 2.3.9.6, Microsoft name: EmfPlusSetWorldTransform Record, Index 0x2A + + Defines World Space -> Page Space transformation +*/ +U_PSEUDO_OBJ *U_PMR_SETWORLDTRANSFORM_set(U_PSEUDO_OBJ *Tm){ + if(!Tm || (Tm->Type != U_PMF_TRANSFORMMATRIX_OID)){ return(NULL); } + int Size = Tm->Used; + uint16_t utmp16 = 0; + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_SETWORLDTRANSFORM,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {Tm->Data, Tm->Used, 1, U_XE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_SETWORLDTRANSFORM_OID, List); + U_PO_free(&ph); + return(po); +} + +/** + \brief Create and set a U_PMR_TRANSLATEWORLDTRANSFORM PseudoObject + \return Pointer to PseudoObject, NULL on error + \param xmtype Set: Post multiply; Clear: Pre multiply + \param Dx X offset + \param Dy Y offset + + + EMF+ manual 2.3.9.7, Microsoft name: EmfPlusTranslateWorldTransform Record, Index 0x2D +*/ +U_PSEUDO_OBJ *U_PMR_TRANSLATEWORLDTRANSFORM_set(int xmtype, U_FLOAT Dx, U_FLOAT Dy){ + int Size = 2*4; + uint16_t utmp16 = (xmtype ? U_PPF_XM : 0); + U_PSEUDO_OBJ *ph = U_PMR_CMN_HDR_set(U_PMR_TRANSLATEWORLDTRANSFORM,utmp16,Size); + const U_SERIAL_DESC List[] = { + {ph->Data, ph->Used, 1, U_XE}, + {&Dx, 4, 1, U_LE}, + {&Dy, 4, 1, U_LE}, + {NULL,0,0,U_XX} + }; + U_PSEUDO_OBJ *po = U_PMF_SERIAL_set(U_PMR_TRANSLATEWORLDTRANSFORM_OID, List); + U_PO_free(&ph); + return(po); +} + + +//! \cond +/* core _get functions, not accessed outside of this routine */ + +/* get copies of up to 0-6 consecutive 4 byte values and a pointer to the rest */ +int U_PMF_CORE1_get(const char *contents, void *v1, void *v2, void *v3, void *v4, void *v5, void *v6, const char **vR){ + if(v1){ U_PMF_MEMCPY_SRCSHIFT(v1, &contents, 4); + if(v2){ U_PMF_MEMCPY_SRCSHIFT(v2, &contents, 4); + if(v3){ U_PMF_MEMCPY_SRCSHIFT(v3, &contents, 4); + if(v4){ U_PMF_MEMCPY_SRCSHIFT(v4, &contents, 4); + if(v5){ U_PMF_MEMCPY_SRCSHIFT(v5, &contents, 4); + if(v6){ U_PMF_MEMCPY_SRCSHIFT(v6, &contents, 4); }}}}}} + if(vR){ *vR = contents; } + return(1); +} +//! \endcond + + +/** + \brief Get data from a U_PMF_BRUSH object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Version EmfPlusGraphicsVersion object + \param Type BrushType Enumeration + \param Data one of the 5 types of Brush data + + EMF+ manual 2.2.1.1, Microsoft name: EmfPlusBrush Object +*/ +int U_PMF_BRUSH_get(const char *contents, uint32_t *Version, uint32_t *Type, const char **Data){ + if(!contents || !Version || !Type || !Data){ return(0); } + U_PMF_SERIAL_get(&contents, Version, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Type, 4, 1, U_LE); + U_PMF_PTRSAV_SHIFT(Data, &contents, 0); + return(1); +} + +/** + \brief Get data from a U_PMF_CUSTOMLINECAP object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Version EmfPlusGraphicsVersion object + \param Type CustomLineCapData Enumeration + \param Data one of the 2 types of Linecap data + + EMF+ manual 2.2.1.2, Microsoft name: EmfPlusCustomLineCap Object +*/ +int U_PMF_CUSTOMLINECAP_get(const char *contents, uint32_t *Version, uint32_t *Type, const char **Data){ + if(!contents || !Version || !Type || !Data){ return(0); } + U_PMF_SERIAL_get(&contents, Version, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Type, 4, 1, U_LE); + U_PMF_PTRSAV_SHIFT(Data, &contents, 0); + return(1); +} + +/** + \brief Get data from a U_PMF_FONT object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Version EmfPlusGraphicsVersion object + \param EmSize em size in units of SizeUnit + \param SizeUnit UnitType enumeration + \param FSFlags FontStyle flags + \param Length Number of Unicode Characters in FamilyName + \param Data Unicode (UTF-16LE) name of font family + + EMF+ manual 2.2.1.3, Microsoft name: EmfPlusFont Object +*/ +int U_PMF_FONT_get(const char *contents, uint32_t *Version, U_FLOAT *EmSize, uint32_t *SizeUnit, + int32_t *FSFlags, uint32_t *Length, const char **Data){ + if(!contents || !Version || !EmSize || !SizeUnit || !FSFlags || !Length || !Data){ return(0); } + U_PMF_SERIAL_get(&contents, Version, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, EmSize, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, SizeUnit, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, FSFlags, 4, 1, U_LE); + contents += 4; /* Reserved field, which is ignored */ + U_PMF_SERIAL_get(&contents, Length, 4, 1, U_LE); + U_PMF_PTRSAV_SHIFT(Data, &contents, 0); + return(1); +} + + +/** + \brief Get data from a U_PMF_IMAGE object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Version EmfPlusGraphicsVersion object + \param Type ImageDataType Enumeration + \param Data one of the 2 types of image data + + EMF+ manual 2.2.1.4, Microsoft name: EmfPlusImage Object +*/ +int U_PMF_IMAGE_get(const char *contents, uint32_t *Version, uint32_t *Type, const char **Data){ + if(!contents || !Version || !Type){ return(0); } + U_PMF_SERIAL_get(&contents, Version, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Type, 4, 1, U_LE); + U_PMF_PTRSAV_SHIFT(Data, &contents, 0); + return(1); +} + +/** + \brief Get data from a U_PMF_IMAGEATTRIBUTES object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Version EmfPlusGraphicsVersion object + \param WrapMode WrapMode object + \param ClampColor EmfPlusARGB object + \param ObjectClamp ObjectClamp Identifiers + + EMF+ manual 2.2.1.5, Microsoft name: EmfPlusImageAttributes Object +*/ +int U_PMF_IMAGEATTRIBUTES_get(const char *contents, uint32_t *Version, uint32_t *WrapMode, uint32_t *ClampColor, uint32_t *ObjectClamp){ + if(!contents || !Version || !WrapMode || !ClampColor || !ObjectClamp){ return(0); } + U_PMF_SERIAL_get(&contents, Version, 4, 1, U_LE); + contents += 4; /* Skip Reserved 1*/ + U_PMF_SERIAL_get(&contents, WrapMode, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, ClampColor, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, ObjectClamp,4, 1, U_LE); + /* Skip Reserved 2*/ + return(1); +} + +/** + \brief Get data from a U_PMF_PATH object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Version EmfPlusGraphicsVersion object + \param Count Number of points and point types in this object + \param Flags PathPoint Flags + \param Points array of points type PMFPointR, PMFPoint, or PMFPointF + \param Types array of U_PMF_PATHPOINTTYPERLE and/or U_PMF_PATHPOINTTYPE + + EMF+ manual 2.2.1.6, Microsoft name: EmfPlusPath Object +*/ +int U_PMF_PATH_get(const char *contents, uint32_t *Version, uint32_t *Count, uint16_t *Flags, const char **Points, const char **Types){ + if(!contents || !Version || !Count || !Flags || !Points || !Types){ return(0); } + U_PMF_SERIAL_get(&contents, Version, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Count, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Flags, 2, 1, U_LE); + contents+=2; /* reserved */ + U_PMF_PTRSAV_SHIFT(Points, &contents, 0); + if(*Flags & U_PPF_P){ + int killme = U_PMF_LEN_REL715(contents,*Count); //DEBUG + printf("DEBUG U_PMF_PATH_get count:%d LENREL715:%d\n",*Count,killme);fflush(stdout); + contents += killme; + } + else if(*Flags & U_PPF_C){ contents += *Count * sizeof(U_PMF_POINT); } + else { contents += *Count * sizeof(U_PMF_POINTF); } + U_PMF_PTRSAV_SHIFT(Types, &contents, 0); + return(1); +} + +/** + \brief Get data from a U_PMF_PEN object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Version EmfPlusGraphicsVersion object + \param Type must be zero + \param PenData Pen description + \param Brush Brush Description + + EMF+ manual 2.2.1.7, Microsoft name: EmfPlusPen Object +*/ +int U_PMF_PEN_get(const char *contents, uint32_t *Version, uint32_t *Type, const char **PenData, const char **Brush){ + if(!contents || !Type || !PenData || !Brush){ return(0); } + U_PMF_SERIAL_get(&contents, Version, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Type, 4, 1, U_LE); + U_PMF_PTRSAV_SHIFT(PenData, &contents, 0); + *Brush = *PenData + U_PMF_LEN_PENDATA(*PenData); + return(1); +} + +/** + \brief Get data from a U_PMF_REGION object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Version EmfPlusGraphicsVersion object + \param Count Number of CHILD nodes. This is one less than the total number of U_PMF_REGIONNODE objects in Nodes. + \param Nodes Nodes defining region + + EMF+ manual 2.2.1.8, Microsoft name: EmfPlusRegion Object +*/ +int U_PMF_REGION_get(const char *contents, uint32_t *Version, uint32_t *Count, const char **Nodes){ + if(!contents || !Version || !Count || !Nodes){ return(0); } + U_PMF_SERIAL_get(&contents, Version, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Count, 4, 1, U_LE); + U_PMF_PTRSAV_SHIFT(Nodes, &contents, 0); + return(1); +} + +/** + \brief Get data from a U_PMF_STRINGFORMAT object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Sfs pointer to U_PMF_STRINGFORMAT structure, with no variable part + \param Data pointer to variable part + + EMF+ manual 2.2.1.9, Microsoft name: EmfPlusStringFormat Object +*/ +int U_PMF_STRINGFORMAT_get(const char *contents, U_PMF_STRINGFORMAT *Sfs, const char **Data){ + if(!contents || !Sfs || !Data){ return(0); } + U_PMF_SERIAL_get(&contents, Sfs, 4, 15, U_LE); + *Data = contents; + return(1); +} + +/** + \brief Get data from a U_PMF_ARGB object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Blue Blue color (0-255) + \param Green Green color (0-255) + \param Red Red color (0-255) + \param Alpha Alpha (0-255) + + EMF+ manual 2.2.2.1, Microsoft name: EmfPlusARGB Object +*/ +int U_PMF_ARGB_get(const char *contents, uint8_t *Blue, uint8_t *Green, uint8_t *Red, uint8_t *Alpha){ + if(!contents || !Blue || !Green || !Red || !Alpha){ return(0); } + U_PMF_SERIAL_get(&contents, Blue, 1, 1, U_XE); + U_PMF_SERIAL_get(&contents, Green, 1, 1, U_XE); + U_PMF_SERIAL_get(&contents, Red, 1, 1, U_XE); + U_PMF_SERIAL_get(&contents, Alpha, 1, 1, U_XE); + return(1); +} + +/** + \brief Get data from a U_PMF_BITMAP object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Bs pointer to U_PMF_BITMAP structure, with no variable part + \param Data pointer to variable part + + EMF+ manual 2.2.2.2, Microsoft name: EmfPlusBitmap Object +*/ +int U_PMF_BITMAP_get(const char *contents, U_PMF_BITMAP *Bs, const char **Data){ + if(!contents || !Bs || !Data){ return(0); } + U_PMF_SERIAL_get(&contents, Bs, 4, 5, U_LE); + U_PMF_PTRSAV_SHIFT(Data, &contents, 0); + return(1); +} + +/** + \brief Get data from a U_PMF_BITMAPDATA object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Ps pointer to U_PMF_PALETTE structure, with no variable part + \param Colors Color part of U_PMF_PALETTE object + \param Data An array of bytes, meaning depends on fields in U_PMF_BITMAP object and the PixelFormat enumeration. + + EMF+ manual 2.2.2.3, Microsoft name: EmfPlusBitmapData Object +*/ +int U_PMF_BITMAPDATA_get(const char *contents, U_PMF_PALETTE *Ps, const char **Colors, const char **Data){ + if(!contents || !Ps || !Colors || !Data ){ return(0); } + U_PMF_SERIAL_get(&contents, Ps, 4, 2, U_LE); + U_PMF_PTRSAV_SHIFT(Colors, &contents, Ps->Elements * sizeof(U_PMF_ARGB)); + U_PMF_PTRSAV_SHIFT(Data, &contents, 0); + return(1); +} + +/** + \brief Get data from a U_PMF_BLENDCOLORS object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Elements Number of members in Positions and Colors + \param Positions Caller must free. Pointer to memory holding positions along gradient line. + \param Colors Caller must NOT free memory ,Pointer to memory holding colors at positions on gradient line. + + EMF+ manual 2.2.2.4, Microsoft name: EmfPlusBlendColors Object +*/ +int U_PMF_BLENDCOLORS_get(const char *contents, uint32_t *Elements, U_FLOAT **Positions, const char **Colors){ + if(!contents || !Positions || !Colors){ return(0); } + U_PMF_SERIAL_get(&contents, Elements, 4, 1, U_LE); + if(!U_PMF_SERIAL_array_copy_get(&contents, (void **)Positions, 4, *Elements, U_LE,1)){ return(0); } + U_PMF_PTRSAV_SHIFT(Colors, &contents, 0); + return(1); +} + +/** + \brief Get data from a U_PMF_BLENDFACTORS object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Elements members in each array + \param Positions Caller must free. Pointer to memory holding positions along gradient line. + \param Factors Caller must free. Pointer to memory holding blending factors, 0.0->1.0 values, inclusive along gradient line. + + EMF+ manual 2.2.2.5, Microsoft name: EmfPlusBlendFactors Object +*/ +int U_PMF_BLENDFACTORS_get(const char *contents, uint32_t *Elements, U_FLOAT **Positions, U_FLOAT **Factors){ + if(!contents || !Elements || !Positions || !Factors){ return(0); } + U_PMF_SERIAL_get(&contents, Elements, 4, 1, U_LE); + if(!U_PMF_SERIAL_array_copy_get(&contents, (void **)Positions, 4, *Elements, U_LE, 1)){ return(0); } + if(!U_PMF_SERIAL_array_copy_get(&contents, (void **)Factors, 4, *Elements, U_LE, 1)){ + free(*Positions); + return(0); + } + return(1); +} + +/** + \brief Get data from a U_PMF_BOUNDARYPATHDATA object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Size bytes in Data + \param Data boundary of the brush + + EMF+ manual 2.2.2.6, Microsoft name: EmfPlusBoundaryPathData Object +*/ +int U_PMF_BOUNDARYPATHDATA_get(const char *contents, int32_t *Size, const char **Data){ + if(!contents || !Size || !Data){ return(0); } + U_PMF_SERIAL_get(&contents, Size, 4, 1, U_LE); + U_PMF_PTRSAV_SHIFT(Data, &contents, 0); + return(1); +} + +/** + \brief Get data from a U_PMF_BOUNDARYPOINTDATA object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Elements Members in POints + \param Points Caller must free. Pointer to memory holding points along gradient line. Boundary of the brush. + + EMF+ manual 2.2.2.7, Microsoft name: EmfPlusBoundaryPointData Object +*/ +int U_PMF_BOUNDARYPOINTDATA_get(const char *contents, int32_t *Elements, U_PMF_POINTF **Points){ + if(!contents || !Elements || !Points){ return(0); } + U_PMF_SERIAL_get(&contents, Elements, 4, 1, U_LE); + if(!U_PMF_SERIAL_array_copy_get(&contents, (void **)Points, 4, *Elements * 2, U_LE, 1)){ return(0); } + return(1); +} + +/** + \brief Get data from a U_PMF_CHARACTERRANGE object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param First First position in range + \param Length Range length + + EMF+ manual 2.2.2.8, Microsoft name: EmfPlusCharacterRange Object +*/ +int U_PMF_CHARACTERRANGE_get(const char *contents, int32_t *First, int32_t *Length){ + if(!contents || !First || !Length){ return(0); } + U_PMF_SERIAL_get(&contents, First, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Length, 4, 1, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMF_COMPOUNDLINEDATA object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Elements Members in the array + \param Widths Caller must free. Pointer to memory holding Line or gap widths (0.0 <-> 1.0, fraction of total line width ). + + EMF+ manual 2.2.2.9, Microsoft name: EmfPlusCompoundLineData Object +*/ +int U_PMF_COMPOUNDLINEDATA_get(const char *contents, int32_t *Elements, U_FLOAT **Widths){ + if(!contents || !Elements || !Widths){ return(0); } + U_PMF_SERIAL_get(&contents, Elements, 4, 1, U_LE); + *Widths = (U_FLOAT *)malloc(*Elements * sizeof(U_FLOAT)); + if(!*Widths){ return(0); } + U_PMF_SERIAL_get(&contents, *Widths, 4, *Elements, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMF_COMPRESSEDIMAGE object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Data Stored image in one of the supported formats. + + EMF+ manual 2.2.2.10, Microsoft name: EmfPlusCompressedImage Object + + + This function does not do anything useful, but it is included so that all objects have a corresponding _get(). +*/ +int U_PMF_COMPRESSEDIMAGE_get(const char *contents, const char **Data){ + if(!contents || !Data){ return(0); } + U_PMF_PTRSAV_SHIFT(Data, &contents, 0); + return(1); +} + +/** + \brief Get data from a U_PMF_CUSTOMENDCAPDATA object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Size Bytes in Data + \param Data Description of linecap + + EMF+ manual 2.2.2.11, Microsoft name: EmfPlusCustomEndCapData Object +*/ +int U_PMF_CUSTOMENDCAPDATA_get(const char *contents, int32_t *Size, const char **Data){ + if(!contents || !Size || !Data){ return(0); } + U_PMF_SERIAL_get(&contents, Size, 4, 1, U_LE); + U_PMF_PTRSAV_SHIFT(Data, &contents, 0); + return(1); +} + +/** + \brief Get data from a U_PMF_CUSTOMLINECAPARROWDATA object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Ccad pointer to U_PMF_CUSTOMLINECAPARROWDATA structure + + EMF+ manual 2.2.2.12, Microsoft name: EmfPlusCustomLineCapArrowData Object +*/ +int U_PMF_CUSTOMLINECAPARROWDATA_get(const char *contents, U_PMF_CUSTOMLINECAPARROWDATA *Ccad){ + if(!contents || !Ccad){ return(0); } + U_PMF_SERIAL_get(&contents, Ccad, 4, 13, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMF_CUSTOMLINECAPDATA object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Clcd pointer to U_PMF_CUSTOMLINECAPDATA structure, with no variable part + \param Data variable part of U_PMF_CUSTOMLINECAPDATA + + EMF+ manual 2.2.2.13, Microsoft name: EmfPlusCustomLineCapData Object +*/ +int U_PMF_CUSTOMLINECAPDATA_get(const char *contents, U_PMF_CUSTOMLINECAPDATA *Clcd, const char **Data){ + if(!contents || !Clcd){ return(0); } + U_PMF_SERIAL_get(&contents, Clcd, 4, 12, U_LE); + U_PMF_PTRSAV_SHIFT(Data, &contents, 0); + return(1); +} + +/** + \brief Get data from a U_PMF_CUSTOMLINECAPOPTIONALDATA object + \return on success 3,5, or 7 (for varying combinations of data present) or 1 (no data is present), 0 on error + \param contents Record from which to extract data + \param Flags bits set to indicate the presence of FillData and/or LineData + \param FillData Path to fill (optional) + \param LineData Path to stroke (optional) + + EMF+ manual 2.2.2.14, Microsoft name: EmfPlusCustomLineCapOptionalData Object +*/ +int U_PMF_CUSTOMLINECAPOPTIONALDATA_get(const char *contents, uint32_t Flags, const char **FillData, const char **LineData){ + uint32_t length; + int status = 1; + if(!contents){ return(0); } + if(Flags & U_CLCD_FillPath){ + if(!FillData){ return(0); } + U_PMF_SERIAL_get(&contents, &length, 4, 1, U_LE); + contents -= 4; /* undo the unneeded shift from preceding */ + U_PMF_PTRSAV_SHIFT(FillData, &contents, 4 + length); + status += 2; + } + else { *FillData = NULL; } + + if(Flags & U_CLCD_LinePath){ + if(!LineData){ return(0); } + U_PMF_PTRSAV_SHIFT(LineData, &contents, 0); + status += 4; + } + else { *LineData = NULL; } + return(status); +} + +/** + \brief Get data from a U_PMF_CUSTOMSTARTCAPDATA object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Size Bytes in Data + \param Data Description of linecap + + EMF+ manual 2.2.2.15, Microsoft name: EmfPlusCustomStartCapData Object +*/ +int U_PMF_CUSTOMSTARTCAPDATA_get(const char *contents, int32_t *Size, const char **Data){ + if(!contents || !Size || !Data){ return(0); } + U_PMF_SERIAL_get(&contents, Size, 4, 1, U_LE); + U_PMF_PTRSAV_SHIFT(Data, &contents, 0); + return(1); +} + +/** + \brief Get data from a U_PMF_DASHEDLINEDATA object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Elements Members in the array + \param Lengths Caller must free. Pointer to memory holding lengths of dashes and spaces. + + EMF+ manual 2.2.2.16, Microsoft name: EmfPlusDashedLineData Object +*/ +int U_PMF_DASHEDLINEDATA_get(const char *contents, int32_t *Elements, U_FLOAT **Lengths){ + if(!contents || !Elements || !Lengths){ return(0); } + U_PMF_SERIAL_get(&contents, Elements, 4, 1, U_LE); + *Lengths = (U_FLOAT *)malloc(*Elements * sizeof(U_FLOAT)); + if(!*Lengths){ return(0); } + U_PMF_SERIAL_get(&contents, *Lengths, 4, *Elements, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMF_FILLPATHOBJ object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Size Bytes in Data + \param Data Path specification + + EMF+ manual 2.2.2.17, Microsoft name: EmfPlusFillPath Object +*/ +int U_PMF_FILLPATHOBJ_get(const char *contents, int32_t *Size, const char **Data){ + if(!contents || !Size || !Data){ return(0); } + U_PMF_SERIAL_get(&contents, Size, 4, 1, U_LE); + U_PMF_PTRSAV_SHIFT(Data, &contents, 0); + return(1); +} + +/** + \brief Get data from a U_PMF_FOCUSSCALEDATA object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Count must be 2 + \param ScaleX value 0.0 <-> 1.0 + \param ScaleY value 0.0 <-> 1.0 + + EMF+ manual 2.2.2.18, Microsoft name: EmfPlusFocusScaleData Object +*/ +int U_PMF_FOCUSSCALEDATA_get(const char *contents, uint32_t *Count, U_FLOAT *ScaleX, U_FLOAT *ScaleY){ + if(!contents || !Count || !ScaleX || !ScaleY){ return(0); } + U_PMF_SERIAL_get(&contents, Count, 4, 1, U_LE); + if(*Count != 2){ return(0); } + U_PMF_SERIAL_get(&contents, ScaleX, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, ScaleY, 4, 1, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMF_GRAPHICSVERSION object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Signature Must be U_GFVR_PMF (0xDBC01) + \param GrfVersion GraphicsVersion enumeration + + EMF+ manual 2.2.2.19, Microsoft name: EmfPlusGraphicsVersion Object +*/ +int U_PMF_GRAPHICSVERSION_get(const char *contents, int *Signature, int *GrfVersion){ + if(!contents || !Signature || !GrfVersion){ return(0); } + uint32_t tmp; + memcpy(&tmp, contents, 4); + *Signature = tmp >> 12; + *GrfVersion = tmp & U_GFVR_MASKLO; + return(1); +} + +/** + \brief Get data from a U_PMF_HATCHBRUSHDATA object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Style HatchStyle enumeration + \param Foreground Hatch pattern line color + \param Background Hatch pattern bkground color + + EMF+ manual 2.2.2.20, Microsoft name: EmfPlusHatchBrushData Object +*/ +int U_PMF_HATCHBRUSHDATA_get(const char *contents, uint32_t *Style, U_PMF_ARGB *Foreground, U_PMF_ARGB *Background){ + if(!contents || !Style || !Foreground || !Background){ return(0); } + U_PMF_SERIAL_get(&contents, Style, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Foreground, 4, 1, U_XE); + U_PMF_SERIAL_get(&contents, Background, 4, 1, U_XE); + return(1); +} + +/** + \brief Get data from a U_PMF_INTEGER7 object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Value 7 bit signed integer (stored in an integer) + + EMF+ manual 2.2.2.21, Microsoft name: EmfPlusInteger7 Object +*/ +int U_PMF_INTEGER7_get(const char **contents, U_FLOAT *Value){ + if(!contents || !*contents || !Value){ return(0); } + uint8_t tmp; + if(**contents & U_TEST_INT7)return(0); /* this bit must be 0 in this object type */ + U_PMF_SERIAL_get(contents, &tmp, 1, 1, U_XE); + if(tmp & U_SIGN_INT7){ + tmp |= U_TEST_INT7; /* now it has the bit pattern of a signed int8_t */ + *Value = *(int8_t *)&tmp; + } + else { + *Value = tmp; + } + return(1); +} + +/** + \brief Get data from a U_PMF_INTEGER15 object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Value 15 bit signed integer (stored in an integer) + + EMF+ manual 2.2.2.22, Microsoft name: EmfPlusInteger15 Object +*/ +int U_PMF_INTEGER15_get(const char **contents, U_FLOAT *Value){ + if(!contents || !*contents || !Value){ return(0); } + uint16_t tmp; + if(!(**contents & U_TEST_INT7))return(0); /* this bit must be 1 in this object type */ + U_PMF_SERIAL_get(contents, &tmp, 2, 1, U_BE); + tmp &= U_MASK_INT15; /* drop the 7/15 flag from the most significant bit */ + if(tmp & U_SIGN_INT15){ + tmp |= U_TEST_INT15; /* now it has the bit pattern of a signed int16_t */ + *Value = *(int16_t *)&tmp; + } + else { + *Value = tmp; + } + return(1); +} + +/** + \brief Get data from a U_PMF_LANGUAGEIDENTIFIER object + \return 1 on success, 0 on error + \param LId U_PMF_LANGUAGEIDENTIFIER from which to extract data + \param SubLId Example: code for USA + \param PriLId Example: code for English + + + + EMF+ manual 2.2.2.23, Microsoft name: EmfPlusLanguageIdentifier Object + + This type is defined as 16 bits in the manual section, but it is only ever used as part of a 32 bit field! +*/ +int U_PMF_LANGUAGEIDENTIFIER_get(U_PMF_LANGUAGEIDENTIFIER LId, int *SubLId, int *PriLId){ + if(!SubLId || !PriLId){ return(0); } + *SubLId = (LId >> U_FF_SHFT_SUBLID ) & U_FF_MASK_SUBLID; + *PriLId = (LId >> U_FF_SHFT_PRILID ) & U_FF_MASK_PRILID; + /* 16 bits above that are not used */ + return(1); +} + +/** + \brief Get data from a U_PMF_LINEARGRADIENTBRUSHDATA object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Lgbd U_PMF_LINEARGRADIENTBRUSHDATA structure, with no variable part + \param Data variable part of U_PMF_LINEARGRADIENTBRUSHDATA + + EMF+ manual 2.2.2.24, Microsoft name: EmfPlusLinearGradientBrushData Object +*/ +int U_PMF_LINEARGRADIENTBRUSHDATA_get(const char *contents, U_PMF_LINEARGRADIENTBRUSHDATA *Lgbd, const char **Data){ + if(!contents || !Lgbd || !Data){ return(0); } + U_PMF_SERIAL_get(&contents, Lgbd, 4, 6, U_LE); /* Flags, WrapMode, RectF*/ + U_PMF_SERIAL_get(&contents, &(Lgbd->StartColor), 4, 4, U_XE); /* StartColor, EndColor, Reserved1 & 2 */ + U_PMF_PTRSAV_SHIFT(Data, &contents, 0); + return(1); +} + +/** + \brief Get data from a U_PMF_LINEARGRADIENTBRUSHOPTIONALDATA object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Flags BrushData flags - indicates which of the following date fields are present. + \param Tm Transformation matrix + \param Bc U_PMF_BLENDCOLORS object or NULL + \param BfH U_PMF_BLENDFACTORS (H) object or NULL + \param BfV U_PMF_BLENDFACTORS (V) object or NULL (WARNING, GDI+ defines this field but does not render it. DO NOT USE.) + + EMF+ manual 2.2.2.25, Microsoft name: EmfPlusLinearGradientBrushOptionalData Object +*/ +int U_PMF_LINEARGRADIENTBRUSHOPTIONALDATA_get(const char *contents, uint32_t Flags, U_PMF_TRANSFORMMATRIX *Tm, + const char **Bc, const char **BfH, const char **BfV){ + uint32_t Elements; + if(!contents || !Tm|| !Bc || !BfH || !BfV){ return(0); } + *Bc = *BfH = *BfV = NULL; + if(Flags & U_BD_Transform)U_PMF_SERIAL_get(&contents, Tm, 4, 6, U_LE); + if(Flags & U_BD_PresetColors){ + U_PMF_PTRSAV_SHIFT(Bc, &contents, 0); + } + else if(Flags & U_BD_BlendFactorsH){ + U_PMF_SERIAL_get(&contents, &Elements, 4, 1, U_LE); /* starts with a 4 byte count*/ + contents-=4; /* back up to the front of the count, as it is part of the data field */ + U_PMF_PTRSAV_SHIFT(BfH, &contents, 4 + 8*Elements); /* 4 byte count + 2 * 4bytes * Elements */ + if(Flags & U_BD_BlendFactorsV){ + U_PMF_PTRSAV_SHIFT(BfV, &contents, 0); + } + } + else if(Flags & U_BD_BlendFactorsV){ + U_PMF_PTRSAV_SHIFT(BfV, &contents, 0); + } + return(1); +} + +/** + \brief Get data from a U_PMF_LINEPATH object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Size Bytes in Data + \param Data Outline path + + EMF+ manual 2.2.2.26, Microsoft name: EmfPlusLinePath Object +*/ +int U_PMF_LINEPATH_get(const char *contents, int32_t *Size, const char **Data){ + if(!contents || !Size || !Data){ return(0); } + U_PMF_SERIAL_get(&contents, Size, 4, 1, U_LE); + U_PMF_PTRSAV_SHIFT(Data, &contents, 0); + return(1); +} + +/** + \brief Get data from a U_PMF_METAFILE object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Type + \param Size Bytes in Data + \param Data Various types of data, like an EMF metafile, WMF metafile, another EMF+ metafile + + EMF+ manual 2.2.2.27, Microsoft name: EmfPlusMetafile Object +*/ +int U_PMF_METAFILE_get(const char *contents, uint32_t *Type, uint32_t *Size, const char **Data){ + if(!contents || !Type || !Size || !Data){ return(0); } + U_PMF_SERIAL_get(&contents, &Type, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, &Size, 4, 1, U_LE); + U_PMF_PTRSAV_SHIFT(Data, &contents, 0); + return(1); +} + +/** + \brief Get data from a U_PMF_PALETTE object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Flags PaletteStyle flags + \param Elements Members in the array + \param Colors Palette data (array of colors) + + EMF+ manual 2.2.2.28, Microsoft name: EmfPlusPalette Object +*/ +int U_PMF_PALETTE_get(const char *contents, uint32_t *Flags, uint32_t *Elements, const char **Colors){ + if(!contents || !Flags || !Elements || !Colors){ return(0); } + U_PMF_SERIAL_get(&contents, &Flags, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, &Elements, 4, 1, U_LE); + U_PMF_PTRSAV_SHIFT(Colors, &contents, 0); + return(1); + +} + +/** + \brief Get data from a U_PMF_PATHGRADIENTBRUSHDATA object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Pgbd constant part of U_PMF_PATHGRADIENTBRUSHDATA object + \param Gradient variable part of U_PMF_LINEARGRADIENTBRUSHDATA, Color Gradient with Elements members + \param Boundary variable part of U_PMF_LINEARGRADIENTBRUSHDATA, U_PMF_BOUNDARYPATHDATA object if BrushDataPath bit set in Flag, else U_PMF_BOUNDARYPOINTDATA object + \param Data variable part of U_PMF_LINEARGRADIENTBRUSHDATA, exact composition depends on Flags + + EMF+ manual 2.2.2.29, Microsoft name: EmfPlusPathGradientBrushData Object +*/ +int U_PMF_PATHGRADIENTBRUSHDATA_get(const char *contents, U_PMF_PATHGRADIENTBRUSHDATA *Pgbd, const char **Gradient, const char **Boundary, const char **Data){ + if(!contents || !Pgbd || !Gradient || !Boundary || !Data){ return(0); } + uint32_t Size; + U_PMF_SERIAL_get(&contents, Pgbd, 4, 2, U_LE); /* Flags and WrapMode*/ + U_PMF_SERIAL_get(&contents, &(Pgbd->CenterColor), 4, 1, U_XE); + U_PMF_SERIAL_get(&contents, &(Pgbd->Center), 4, 3, U_LE); /* Center and Elements */ + U_PMF_PTRSAV_SHIFT(Gradient, &contents, Pgbd->Elements * sizeof(U_PMF_ARGB)); + U_PMF_PTRSAV_SHIFT(Boundary, &contents, 0); + U_PMF_SERIAL_get(&contents, &Size, 4, 1, U_LE); /* The first 4 bytes of the Boundary are always a size */ + if(Pgbd->Flags & U_BD_Path){ contents += Size; } // U_PMF_BOUNDARYPATHDATA + else { contents += Size*2*sizeof(U_FLOAT); } // U_PMF_BOUNDARYPOINTDATA + U_PMF_PTRSAV_SHIFT(Data, &contents, 0); + return(1); +} + +/** + \brief Get data from a U_PMF_PATHGRADIENTBRUSHOPTIONALDATA object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Flags bits set to indicate the presence of FillData and/or LineData + \param Matrix Transformation matrix + \param Pattern Blend Pattern + \param Data Focus scales for the brush + + EMF+ manual 2.2.2.30, Microsoft name: EmfPlusPathGradientBrushOptionalData Object +*/ +int U_PMF_PATHGRADIENTBRUSHOPTIONALDATA_get(const char *contents, uint32_t Flags, U_PMF_TRANSFORMMATRIX *Matrix, const char **Pattern, const char **Data){ + if(!contents || !Flags || !Matrix || !Pattern || !Data){ return(0); } + U_PMF_SERIAL_get(&contents, &Flags, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Matrix, 4, 6, U_LE); + U_PMF_PTRSAV_COND(Data, contents, (Flags & (U_BD_PresetColors | U_BD_BlendFactorsH))); + U_PMF_PTRSAV_COND(Data, contents, (Flags & U_BD_FocusScales)); + return(1); +} + +/** + \brief Get data from a U_PMF_PATHPOINTTYPE object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Flags PathPointType flags + \param Type PathPointType enumeration + + EMF+ manual 2.2.2.31, Microsoft name: EmfPlusPathPointType Object + + Note: order of 4bit fields appears to be shown in the LE column, not as + documented in the BE column. +*/ +int U_PMF_PATHPOINTTYPE_get(const char *contents, int *Flags, int *Type){ + if(!contents || !Flags || !Type){ return(0); } + uint8_t tmp; + memcpy(&tmp, contents, 1); + *Flags =(tmp & U_PTP_MASK) >> U_PTP_SHIFT; + *Type = (tmp & U_PPT_MASK); + return(1); +} + +/** + \brief Get data from a U_PMF_PATHPOINTTYPERLE object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Bezier Set: Bezier curve, Clear: straight line + \param RL Run Length + \param Ppt PathPointType enumeration + + EMF+ manual 2.2.2.32, Microsoft name: EmfPlusPathPointTypeRLE Object +*/ +int U_PMF_PATHPOINTTYPERLE_get(const char *contents, int *Bezier, int *RL, int *Ppt){ + if(!contents || !Bezier || !RL || !Ppt){ return(0); } + uint16_t tmp; + U_PMF_SERIAL_get(&contents, &tmp, 2, 1, U_LE); + *Bezier = tmp & U_PPF_BZ; + *RL = (tmp >> U_FF_SHFT_RL) & U_FF_MASK_RL; + *Ppt = (tmp >> U_FF_SHFT_PPT) & U_FF_MASK_PPT; + return(1); +} + +/** + \brief Get data from a U_PMF_PENDATA object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Flags PenData flags + \param Unit UnitType enumeration + \param Width Width in units set by Unit + \param Data Optional pen data, exact composition depends on Flags + + EMF+ manual 2.2.2.33, Microsoft name: EmfPlusPenData Object +*/ +int U_PMF_PENDATA_get(const char *contents, uint32_t *Flags, uint32_t *Unit, U_FLOAT *Width, const char **Data){ + if(!contents || !Flags || !Unit || !Width || !Data){ return(0); } + U_PMF_SERIAL_get(&contents, Flags, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Unit, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Width, 4, 1, U_LE); + U_PMF_PTRSAV_SHIFT(Data, &contents, 0); + return(1); +} + +/** + \brief Get data from a U_PMF_PENOPTIONALDATA object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Flags; PenData Flags - indicated which of the many fields are present. + \param Matrix; Transformation matrix + \param StartCap LineCapType enumeration + \param EndCap LineCapType enumeration + \param Join LineJoinType enumeration + \param MiterLimit Maximum (miter length / line width) + \param Style LineStyle enumeration + \param DLCap DashedLineCapType enumeration + \param DLOffset Distance line start to first dash start + \param DLData Dash and space widths + \param Alignment PenAlignment enumeration + \param CmpndLineData Compount Line (parallel lines drawn instead of one) + \param CSCapData Custom start cap + \param CECapData Custom end cap + + EMF+ manual 2.2.2.34, Microsoft name: EmfPlusPenOptionalData Object + + This object consists of a large number of optional and or variable values, which + are returned, or not, depending on bits in Flags. +*/ +int U_PMF_PENOPTIONALDATA_get( + const char *contents, + uint32_t Flags, // determines which fields are filled + U_PMF_TRANSFORMMATRIX *Matrix, + int32_t *StartCap, + int32_t *EndCap, + uint32_t *Join, + U_FLOAT *MiterLimit, + int32_t *Style, + int32_t *DLCap, + U_FLOAT *DLOffset, + const char **DLData, + int32_t *Alignment, + const char **CmpndLineData, + const char **CSCapData, + const char **CECapData){ + if(!contents || + !Flags || !Matrix || !StartCap || !EndCap || + !Join || !MiterLimit || !Style || !DLCap || + !DLOffset || !DLData || !Alignment || !CmpndLineData || + !CSCapData || !CECapData){ return(0); } + + if(Flags & U_PD_Transform){ U_PMF_SERIAL_get(&contents, Matrix, 4, 6, U_LE); } + if(Flags & U_PD_StartCap){ U_PMF_SERIAL_get(&contents, StartCap, 4, 1, U_LE); } + if(Flags & U_PD_EndCap){ U_PMF_SERIAL_get(&contents, EndCap, 4, 1, U_LE); } + if(Flags & U_PD_Join){ U_PMF_SERIAL_get(&contents, Join, 4, 1, U_LE); } + if(Flags & U_PD_MiterLimit){ U_PMF_SERIAL_get(&contents, MiterLimit, 4, 1, U_LE); } + if(Flags & U_PD_LineStyle){ U_PMF_SERIAL_get(&contents, Style, 4, 1, U_LE); } + if(Flags & U_PD_DLCap){ U_PMF_SERIAL_get(&contents, DLCap, 4, 1, U_LE); } + if(Flags & U_PD_DLOffset){ U_PMF_SERIAL_get(&contents, DLOffset, 4, 1, U_LE); } + if(Flags & U_PD_DLData){ U_PMF_PTRSAV_SHIFT( DLData, &contents, U_PMF_LEN_FLOATDATA(contents)); } + if(Flags & U_PD_NonCenter){ U_PMF_SERIAL_get(&contents, Alignment, 4, 1, U_LE); } + if(Flags & U_PD_CLData){ U_PMF_PTRSAV_SHIFT( CmpndLineData, &contents, U_PMF_LEN_FLOATDATA(contents)); } + if(Flags & U_PD_CustomStartCap){ U_PMF_PTRSAV_SHIFT( CSCapData, &contents, U_PMF_LEN_BYTEDATA(contents)); } + if(Flags & U_PD_CustomEndCap){ U_PMF_PTRSAV_SHIFT( CECapData, &contents, U_PMF_LEN_BYTEDATA(contents)); } + return(1); +} + +/** + \brief Get data from a U_PMF_POINT object + \return 1 on success, 0 on error + \param contents Record from which to extract data. On return position is offset by sizeof(U_PMF_POINT). + \param X X coordinate + \param Y Y coordinate + + EMF+ manual 2.2.2.35, Microsoft name: EmfPlusPoint Object +*/ +int U_PMF_POINT_get(const char **contents, U_FLOAT *X, U_FLOAT *Y){ + if(!contents || !X || !Y){ return(0); } + int16_t tmp; + U_PMF_SERIAL_get(contents, &tmp, 2, 1, U_LE); *X = tmp; + U_PMF_SERIAL_get(contents, &tmp, 2, 1, U_LE); *Y = tmp; + return(1); +} + +/** + \brief Get data from a U_PMF_POINTF object + \return 1 on success, 0 on error + \param contents Record from which to extract data. On return position is offset by sizeof(U_PMF_POINTF). + \param X X coordinate + \param Y Y coordinate + + EMF+ manual 2.2.2.36, Microsoft name: EmfPlusPointF Object +*/ +int U_PMF_POINTF_get(const char **contents, U_FLOAT *X, U_FLOAT *Y){ + if(!contents || !X || !Y){ return(0); } + U_PMF_SERIAL_get(contents, X, 4, 1, U_LE); + U_PMF_SERIAL_get(contents, Y, 4, 1, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMF_POINTR object + \return size in bytes traversed on success, 0 on error + \param contents Record from which to extract data. On return position is offset by returned size. + \param X X coordinate + \param Y Y coordinate + + EMF+ manual 2.2.2.37, Microsoft name: EmfPlusPointR Object +*/ +int U_PMF_POINTR_get(const char **contents, U_FLOAT *X, U_FLOAT *Y){ + if(!contents || !*contents | !X || !Y){ return(0); } + int size=0; + + if( U_PMF_INTEGER7_get( contents, X)){ size +=1; } + else if(U_PMF_INTEGER15_get(contents, X)){ size +=2; } + else { return(0); } + + if( U_PMF_INTEGER7_get( contents, Y)){ size +=1; } + else if(U_PMF_INTEGER15_get(contents, Y)){ size +=2; } + else { return(0); } + + return(size); +} + +/** + \brief Get data from a variable POINTS object, which may be U_PMF_POINTS, U_PMF_POINTF, or U_PMF_POINTR. + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Flags Record flags (bits U_PPF_C and U_PPF_P are referenced) + \param Elements Number of points to retrieve. + \param Points Caller must free. Array of U_PMF_POINTF coordinates. +*/ +int U_PMF_VARPOINTS_get(const char **contents, uint16_t Flags, int Elements, U_PMF_POINTF **Points){ + U_PMF_POINTF *pts = (U_PMF_POINTF *)malloc(Elements * sizeof(U_PMF_POINTF)); + U_FLOAT XF, YF; + U_FLOAT XFS, YFS; + + if(!contents || !*contents || !Points){ return(0); } + *Points = pts; + for(XFS = YFS = 0.0; Elements; Elements--, pts++){ + if(Flags & U_PPF_P){ + U_PMF_POINTR_get(contents, &XF, &YF); + XFS += XF; /* position relative to previous point, first point is always 0,0 */ + YFS += YF; + pts->X = XFS; + pts->Y = YFS; + } + else if(Flags & U_PPF_C){ + (void) U_PMF_POINT_get(contents, &XF, &XF); + pts->X = XF; + pts->Y = YF; + } + else { + (void) U_PMF_POINTF_get(contents, &(pts->X), &(pts->Y)); + } + } + return(1); +} + +/** + \brief Get data from a U_PMF_RECT object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param X UL X value + \param Y UL Y value + \param Width Width + \param Height Height + + EMF+ manual 2.2.2.38, Microsoft name: EmfPlusRect Object +*/ +int U_PMF_RECT_get(const char **contents, int16_t *X, int16_t *Y, int16_t *Width, int16_t *Height){ + if(!contents || !X || !Y|| !Width || !Height){ return(0); } + U_PMF_SERIAL_get(contents, X, 2, 1, U_LE); + U_PMF_SERIAL_get(contents, Y, 2, 1, U_LE); + U_PMF_SERIAL_get(contents, Width, 2, 1, U_LE); + U_PMF_SERIAL_get(contents, Height, 2, 1, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMF_RECTF object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param X UL X value + \param Y UL Y value + \param Width Width + \param Height Height + + EMF+ manual 2.2.2.39, Microsoft name: EmfPlusRectF Object +*/ +int U_PMF_RECTF_get(const char **contents, U_FLOAT *X, U_FLOAT *Y, U_FLOAT *Width, U_FLOAT *Height){ + if(!contents || !X || !Y|| !Width || !Height){ return(0); } + U_PMF_SERIAL_get(contents, X, 4, 1, U_LE); + U_PMF_SERIAL_get(contents, Y, 4, 1, U_LE); + U_PMF_SERIAL_get(contents, Width, 4, 1, U_LE); + U_PMF_SERIAL_get(contents, Height, 4, 1, U_LE); + return(1); +} + +/** + \brief Get data from a variable RECTS object, which may be U_PMF_RECT or U_PMF_RECTF + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Flags Record flags (bit U_PPF_C is referenced) + \param Elements Number of rects to retrieve. + \param Rects Caller must free. Array of U_PMF_RECTF coordinates. + + Rects in record may be either U_PMF_RECT or U_PMF_RECTF, but this function always + returns U_PMF_RECTF +*/ +int U_PMF_VARRECTS_get(const char **contents, uint16_t Flags, int Elements, U_PMF_RECTF **Rects){ + int16_t X16, Y16, Width, Height; + if(!contents || !*contents || !Rects){ return(0); } + U_PMF_RECTF *rts = (U_PMF_RECTF *)malloc(Elements * sizeof(U_PMF_RECTF)); + if(!rts){ + *Rects = NULL; + return(0); + } + + *Rects = rts; + for(; Elements; Elements--, rts++){ + if(Flags & U_PPF_C){ + (void) U_PMF_RECT_get(contents, &X16, &Y16, &Width, &Height); + rts->X = X16; + rts->Y = Y16; + rts->Width = Width; + rts->Height = Height; + } + else { + (void) U_PMF_RECTF_get(contents, &(rts->X), &(rts->Y), &(rts->Width), &(rts->Height)); + } + } + return(1); +} + +/** + \brief Get data from a U_PMF_REGIONNODE object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Type RegionNodeDataType + \param Data Depending on Type: U_PMF_REGIONNODEPATH, U_PMF_RECTF, or U_PMF_REGIONNODECHILDNODES + + + EMF+ manual 2.2.2.40, Microsoft name: EmfPlusRegionNode Object +*/ +int U_PMF_REGIONNODE_get(const char *contents, uint32_t *Type, const char **Data){ + if(!contents || !Type|| !Data){ return(0); } + U_PMF_SERIAL_get(&contents, Type, 4, 1, U_LE); + U_PMF_PTRSAV_COND(Data, contents, !(*Type == U_RNDT_Empty || *Type == U_RNDT_Infinite )); + return(1); +} + +/** + There is no U_PMF_REGIONNODECHILDNODES_get! + + The Region object is recursive allowing U_PMF_REGIONNODECHILDNODES -> + U_PMF_REGIONNODE -> U_PMF_REGIONNODECHILDNODES etc. + So the data stored in each node must be handled as the tree is followed recursively. + + See U_PMF_REGIONNODECHILDNODES_print() and U_PMF_REGIONNODE_print() for an example. + + + EMF+ manual 2.2.2.41, Microsoft name: EmfPlusRegionNodeChildNodes Object +*/ + +/** + \brief Get data from a U_PMF_REGIONNODEPATH object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Size Bytes in Data + \param Data Boundary of region node + + EMF+ manual 2.2.2.42, Microsoft name: EmfPlusRegionNodePath Object +*/ +int U_PMF_REGIONNODEPATH_get(const char *contents, int32_t *Size, const char **Data){ + if(!contents || !Size || !Data){ return(0); } + U_PMF_SERIAL_get(&contents, Size, 4, 1, U_LE); + U_PMF_PTRSAV_SHIFT(Data, &contents, 0); + return(1); +} + +/** + \brief Get data from a U_PMF_SOLIDBRUSHDATA object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Color Color of brush + + EMF+ manual 2.2.2.43, Microsoft name: EmfPlusSolidBrushData Object +*/ +int U_PMF_SOLIDBRUSHDATA_get(const char *contents, U_PMF_ARGB *Color){ + if(!contents || !Color){ return(0); } + U_PMF_SERIAL_get(&contents, Color, 4, 1, U_XE); + return(1); +} + +/** + \brief Get data from a U_PMF_STRINGFORMATDATA object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param TabStopCount Entries in TabStop array + \param RangeCount Entries in CharRange array + \param TabStops Array of tabstop locations + \param CharRange Array of character ranges in the text + + EMF+ manual 2.2.2.44, Microsoft name: EmfPlusStringFormatData Object +*/ +int U_PMF_STRINGFORMATDATA_get(const char *contents, uint32_t TabStopCount, uint32_t RangeCount, + const U_FLOAT **TabStops, const U_PMF_CHARACTERRANGE **CharRange){ + if(!contents || !TabStops|| !CharRange){ return(0); } + *TabStops = NULL; + if(TabStopCount > 0){ U_PMF_SERIAL_get(&contents, TabStops, 4, TabStopCount, U_LE); } + *CharRange = NULL; + if(RangeCount > 0){ U_PMF_SERIAL_get(&contents, CharRange, 4, 2*RangeCount, U_LE); } + return(1); +} + +/** + \brief Get data from a U_PMF_TEXTUREBRUSHDATA object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Flags BrushData flags + \param WrapMode WrapMode enumeration + \param Data Optional texture data + + EMF+ manual 2.2.2.45, Microsoft name: EmfPlusTextureBrushData Object +*/ +int U_PMF_TEXTUREBRUSHDATA_get(const char *contents, uint32_t *Flags, int32_t *WrapMode, const char **Data){ + if(!contents || !Flags || !WrapMode || !Data){ return(0); } + U_PMF_SERIAL_get(&contents, Flags, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, WrapMode, 4, 1, U_LE); + U_PMF_PTRSAV_SHIFT(Data, &contents, 0); + return(1); +} + +/** + \brief Get data from a U_PMF_TEXTUREBRUSHOPTIONALDATA object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param HasImage True if this object has an Image + \param Matrix Transformation matrix, present if Flag BrushDataTransform is set. + \param Image Image that contains the texture. + + + EMF+ manual 2.2.2.46, Microsoft name: EmfPlusTextureBrushOptionalData Object +*/ +int U_PMF_TEXTUREBRUSHOPTIONALDATA_get(const char *contents, int HasImage, U_PMF_TRANSFORMMATRIX *Matrix, const char **Image){ + if(!contents || !Matrix || !Image){ return(0); } + U_PMF_SERIAL_get(&contents, Matrix, 4, 6, U_LE); + U_PMF_PTRSAV_COND(Image, contents, HasImage); + return(1); +} + +/** + \brief Get data from a U_PMF_TRANSFORMMATRIX object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Matrix Transformation matrix, present if Flag BrushDataTransform is set. + + EMF+ manual 2.2.2.47, Microsoft name: EmfPlusTransformMatrix Object +*/ +int U_PMF_TRANSFORMMATRIX_get(const char *contents, U_PMF_TRANSFORMMATRIX *Matrix){ + if(!contents || !Matrix){ return(0); } + U_PMF_SERIAL_get(&contents, Matrix, 4, 6, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMF_IE_BLUR object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Radius Blur radius in pixels + \param ExpandEdge 1: expand bitmap by Radius; 0: bitmap size unchanged + + EMF+ manual 2.2.3.1, Microsoft name: BlurEffect Object +*/ +int U_PMF_IE_BLUR_get(const char *contents, U_FLOAT *Radius, uint32_t *ExpandEdge){ + if(!contents || !Radius || !ExpandEdge){ return(0); } + U_PMF_SERIAL_get(&contents, Radius, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, ExpandEdge, 4, 1, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMF_IE_BRIGHTNESSCONTRAST object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Brightness -255 to 255, 0 is unchanged, positive increases, negative decreases + \param Contrast -100 to 100, 0 is unchanged, positive increases, negative decreases + + EMF+ manual 2.2.3.2, Microsoft name: BrightnessContrastEffect Object +*/ +int U_PMF_IE_BRIGHTNESSCONTRAST_get(const char *contents, int32_t *Brightness, int32_t *Contrast){ + if(!contents || !Brightness || !Contrast){ return(0); } + U_PMF_SERIAL_get(&contents, Brightness, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Contrast, 4, 1, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMF_IE_COLORBALANCE object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param CyanRed -100 to 100, 0 is unchanged, positive increases Red & decreases Cyan, negative is opposite + \param MagentaGreen -100 to 100, 0 is unchanged, positive increases Green & decreases Magenta, negative is opposite + \param YellowBlue -100 to 100, 0 is unchanged, positive increases Blue & decreases Yellow, negative is opposite + + EMF+ manual 2.2.3.3, Microsoft name: ColorBalanceEffect Object +*/ +int U_PMF_IE_COLORBALANCE_get(const char *contents, int32_t *CyanRed, int32_t *MagentaGreen, int32_t *YellowBlue){ + if(!contents || !CyanRed || !MagentaGreen || !YellowBlue){ return(0); } + U_PMF_SERIAL_get(&contents, CyanRed, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, MagentaGreen, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, YellowBlue, 4, 1, U_LE); + return(1); +} + + +/** + \brief Get data from a U_PMF_IE_COLORCURVE object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Adjust CurveAdjustment enumeration + \param Channel CurveChannel enumeration + \param Intensity adjustment to apply. "Adjust" determines what field this is and range values. + + EMF+ manual 2.2.3.4, Microsoft name: ColorCurveEffect Object +*/ +int U_PMF_IE_COLORCURVE_get(const char *contents, uint32_t *Adjust, uint32_t *Channel, int32_t *Intensity){ + if(!contents || !Adjust || !Channel || !Intensity){ return(0); } + U_PMF_SERIAL_get(&contents, Adjust, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Channel, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Intensity, 4, 1, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMF_IE_COLORLOOKUPTABLE object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param BLUT Blue color lookup table + \param GLUT Green color lookup table + \param RLUT Red color lookup table + \param ALUT Alpha color lookup table + + EMF+ manual 2.2.3.5, Microsoft name: ColorLookupTableEffect Object +*/ +int U_PMF_IE_COLORLOOKUPTABLE_get(const char *contents, + const uint8_t **BLUT, const uint8_t **GLUT, const uint8_t **RLUT, const uint8_t **ALUT){ + if(!contents || !BLUT || !GLUT || !RLUT || !ALUT){ return(0); } + U_PMF_PTRSAV_SHIFT((const char **)BLUT, &contents, 256); + U_PMF_PTRSAV_SHIFT((const char **)GLUT, &contents, 256); + U_PMF_PTRSAV_SHIFT((const char **)RLUT, &contents, 256); + U_PMF_PTRSAV_SHIFT((const char **)ALUT, &contents, 256); + return(1); +} + +/** + \brief Get data from a U_PMF_IE_COLORMATRIX object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Matrix 5 x 5 color transformation matrix, First 4 rows are [{4 multiplier values},0.0] for R,G,B,A, last Row is [{4 color translation valuess}, 1.0] + + EMF+ manual 2.2.3.6, Microsoft name: ColorMatrixEffect Object +*/ +int U_PMF_IE_COLORMATRIX_get(const char *contents, U_PMF_IE_COLORMATRIX *Matrix){ + if(!contents || !Matrix){ return(0); } + U_PMF_SERIAL_get(&contents, Matrix, 4, 5*5, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMF_IE_HUESATURATIONLIGHTNESS object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Hue -180 to 180, 0 is unchanged + \param Saturation -100 to 100, 0 is unchanged + \param Lightness -100 to 100, 0 is unchanged + + EMF+ manual 2.2.3.7, Microsoft name: HueSaturationLightnessEffect Object +*/ +int U_PMF_IE_HUESATURATIONLIGHTNESS_get(const char *contents, int32_t *Hue, int32_t *Saturation, int32_t *Lightness){ + if(!contents || !Hue || !Saturation || !Lightness){ return(0); } + U_PMF_SERIAL_get(&contents, Hue, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Saturation, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Lightness, 4, 1, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMF_IE_LEVELS object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Highlight 0 to 100, 100 is unchanged + \param Midtone -100 to 100, 0 is unchanged + \param Shadow 0 to 100, 0 is unchanged + + EMF+ manual 2.2.3.8, Microsoft name: LevelsEffect Object +*/ +int U_PMF_IE_LEVELS_get(const char *contents, int32_t *Highlight, int32_t *Midtone, int32_t *Shadow){ + if(!contents || !Highlight || !Midtone || !Shadow){ return(0); } + U_PMF_SERIAL_get(&contents, Highlight, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Midtone, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Shadow, 4, 1, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMF_IE_REDEYECORRECTION object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Elements Number of members in Rects + \param Rects Caller must free. Pointer to memory holding an array of U_RECTL. + + EMF+ manual 2.2.3.9, Microsoft name: RedEyeCorrectionEffect Object +*/ +int U_PMF_IE_REDEYECORRECTION_get(const char *contents, int32_t *Elements, U_RECTL **Rects){ + if(!contents || !Elements || !Rects){ return(0); } + U_PMF_SERIAL_get(&contents, Elements, 4, 1, U_LE); + *Rects = (U_RECTL *) malloc(*Elements * sizeof(U_RECTL)); + if(!*Rects){ return(0); } + U_PMF_SERIAL_get(&contents, *Rects, 4, *Elements * 4, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMF_IE_SHARPEN object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Radius Sharpening radius in pixels + \param Sharpen 0 to 100, 0 is unchanged + + EMF+ manual 2.2.3.10, Microsoft name: SharpenEffect Object +*/ +int U_PMF_IE_SHARPEN_get(const char *contents, U_FLOAT *Radius, int32_t *Sharpen){ + if(!contents || !Radius || !Sharpen){ return(0); } + U_PMF_SERIAL_get(&contents, Radius, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Sharpen, 4, 1, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMF_IE_TINT object + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Hue -180 to 180, [positive==clockwise] rotation in degrees starting from blue + \param Amount -100 [add black] to 100[add white], 0 is unchanged. Change in hue on specified axis + + EMF+ manual 2.2.3.11, Microsoft name: TintEffect Object +*/ +int U_PMF_IE_TINT_get(const char *contents, int32_t *Hue, int32_t *Amount){ + if(!contents || !Hue || !Amount){ return(0); } + U_PMF_SERIAL_get(&contents, Hue, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Amount, 4, 1, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMR_OFFSETCLIP record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header (ignore flags) + \param dX horizontal translation offset to apply to clipping region + \param dY vertical translation offset to apply to clipping region + + EMF+ manual 2.3.1.1, Microsoft name: EmfPlusOffsetClip Record, Index 0x35 +*/ +int U_PMR_OFFSETCLIP_get(const char *contents, U_PMF_CMN_HDR *Header, + U_FLOAT *dX, U_FLOAT *dY){ + if(!contents){ return(0); } + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, dX, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, dY, 4, 1, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMR_RESETCLIP record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header (ignore flags) + + EMF+ manual 2.3.1.2, Microsoft name: EmfPlusResetClip Record, Index 0x31 +*/ +int U_PMR_RESETCLIP_get(const char *contents, U_PMF_CMN_HDR *Header){ + if(!contents){ return(0); } + U_PMF_CMN_HDR_get(&contents, Header); + return(1); +} + +/** + \brief Get data from a U_PMR_SETCLIPPATH record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param CMenum CombineMode enumeration.. + \param PathID U_PMF_PATH object in the EMF+ object table (0-63, inclusive) + + EMF+ manual 2.3.1.3, Microsoft name: EmfPlusSetClipPath Record, Index 0x33 +*/ +int U_PMR_SETCLIPPATH_get(const char *contents, U_PMF_CMN_HDR *Header, + uint32_t *PathID, int *CMenum){ + if(!contents || !PathID || !CMenum){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *CMenum = (Flags >> U_FF_SHFT_CM4) & U_FF_MASK_CM4; + *PathID = (Flags >> U_FF_SHFT_OID8) & U_FF_MASK_OID8; + U_PMF_CMN_HDR_get(&contents, Header); + return(1); +} + +/** + \brief Get data from a U_PMR_SETCLIPRECT record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header (ignore flags) + \param CMenum Combine mode enumeration. + \param Rect Rectangle used with CombineMode enumeration from Header.Flags + + EMF+ manual 2.3.1.4, Microsoft name: EmfPlusSetClipRect Record, Index 0x32 +*/ +int U_PMR_SETCLIPRECT_get(const char *contents, U_PMF_CMN_HDR *Header, + int *CMenum, + U_PMF_RECTF *Rect){ + if(!contents || !CMenum || !Rect ){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *CMenum = (Flags >> U_FF_SHFT_CM4) & U_FF_MASK_CM4; + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, Rect, 4, 4, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMR_SETCLIPREGION record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param CMenum CombineMode enumeration.. + \param PathID U_PMF_PATH object in the EMF+ object table (0-63, inclusive) + + EMF+ manual 2.3.1.5, Microsoft name: EmfPlusSetClipRegion Record, Index 0x34 +*/ +int U_PMR_SETCLIPREGION_get(const char *contents, U_PMF_CMN_HDR *Header, + uint32_t *PathID, int *CMenum){ + if(!contents || !PathID || !CMenum){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *CMenum = (Flags >> U_FF_SHFT_CM4) & U_FF_MASK_CM4; + *PathID = (Flags >> U_FF_SHFT_OID8) & U_FF_MASK_OID8; + U_PMF_CMN_HDR_get(&contents, Header); + return(1); +} + +/** + \brief Get data from a U_PMR_COMMENT record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header (ignore flags) + \param Data Private data, may be anything + + EMF+ manual 2.3.2.1, Microsoft name: EmfPlusComment Record, Index 0x03 +*/ +int U_PMR_COMMENT_get(const char *contents, U_PMF_CMN_HDR *Header, + const char **Data){ + if(!contents || !Data){ return(0); } + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_PTRSAV_SHIFT(Data, &contents, 0); + return(1); +} + +/** + \brief Get data from a U_PMR_ENDOFFILE record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header (ignore flags) + + EMF+ manual 2.3.3.1, Microsoft name: EmfPlusEndOfFile Record, Index 0x02 +*/ +int U_PMR_ENDOFFILE_get(const char *contents, U_PMF_CMN_HDR *Header){ + if(!contents){ return(0); } + U_PMF_CMN_HDR_get(&contents, Header); + return(1); +} + +/** + \brief Get data from a U_PMR_GETDC record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header (ignore flags) + + EMF+ manual 2.3.3.2, Microsoft name: EmfPlusGetDC Record, Index 0x04 +*/ +int U_PMR_GETDC_get(const char *contents, U_PMF_CMN_HDR *Header){ + if(!contents){ return(0); } + U_PMF_CMN_HDR_get(&contents, Header); + return(1); +} + +/** + \brief Get data from a U_PMR_HEADER record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header (ignore flags) + \param Version EmfPlusGraphicsVersion object + \param IsDual set = Dual-mode file, clear= EMF+ only file. + \param IsVideo set = video device, clear= printer. Ignore all other bits. + \param LogicalDpiX Horizontal resolution reference device in DPI + \param LogicalDpiY Vertical resolution reference device in DPI + + EMF+ manual 2.3.3.3, Microsoft name: EmfPlusHeader Record, Index 0x01 +*/ +int U_PMR_HEADER_get(const char *contents, U_PMF_CMN_HDR *Header, + U_PMF_GRAPHICSVERSION *Version, int *IsDual, int *IsVideo, uint32_t *LogicalDpiX, uint32_t *LogicalDpiY){ + if(!contents || !Version || !IsDual || !IsVideo || !LogicalDpiX || !LogicalDpiY){ return(0); } + uint32_t tmp; + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *IsDual = (Flags & U_PPF_DM ? 1 : 0 ); + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, Version, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, &tmp, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, LogicalDpiX, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, LogicalDpiY, 4, 1, U_LE); + *IsVideo = (tmp & U_PPF_VIDEO ? 1 : 0 ); + return(1); +} + +/** + \brief Get data from a U_PMR_CLEAR record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header (ignore flags) + \param Color Erase everything preceding, set background ARGB color. + + EMF+ manual 2.3.4.1, Microsoft name: EmfPlusClear Record, Index 0x09 +*/ +int U_PMR_CLEAR_get(const char *contents, U_PMF_CMN_HDR *Header, + U_PMF_ARGB *Color){ + if(!contents || !Color){ return(0); } + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, Color, 4, 1, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMR_DRAWARC record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param PenID U_PMF_PEN object in the EMF+ object table (0-63, inclusive) + \param ctype Set: int16_t coordinates; Clear: U_FLOAT coordinates + \param Start Start angle, >=0.0, degrees clockwise from 3:00 + \param Sweep Sweep angle, -360<= angle <=360, degrees clockwise from Start + \param Rect Caller must free. Bounding rectangle. Coordinate type set by ctype. + + EMF+ manual 2.3.4.2, Microsoft name: EmfPlusDrawArc Record, Index 0x12 +*/ +int U_PMR_DRAWARC_get(const char *contents, U_PMF_CMN_HDR *Header, + uint32_t *PenID, int *ctype, + U_FLOAT *Start, U_FLOAT *Sweep, + U_PMF_RECTF *Rect){ + if(!contents || !PenID || !ctype || !Start || !Sweep || !Rect){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *ctype = (Flags & U_PPF_C ? 1 : 0 ); + *PenID = (Flags >> U_FF_SHFT_OID8) & U_FF_MASK_OID8; + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, Start, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Sweep, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Rect, 4, 4, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMR_DRAWBEZIERS record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param PenID U_PMF_PEN object in the EMF+ object table (0-63, inclusive) + \param ctype Set: int16_t coordinates; Clear: U_FLOAT coordinates + \param RelAbs Set: Coordinates are relative; Clear: Coordinates are absolute and their type is set by ctype + \param Elements Number of members in the Data array + \param Points Caller must free. Array of U_POINT_F = Sequence of points to connect. Coordinate type set by ctype and RelAbs. + + EMF+ manual 2.3.4.3, Microsoft name: EmfPlusDrawBeziers Record, Index 0x19 +*/ +int U_PMR_DRAWBEZIERS_get(const char *contents, U_PMF_CMN_HDR *Header, + uint32_t *PenID, int *ctype, int *RelAbs, + uint32_t *Elements, + U_PMF_POINTF **Points){ + if(!contents || !PenID || !ctype || !RelAbs || !Elements || !Points){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *ctype = (Flags & U_PPF_C ? 1 : 0 ); + *RelAbs = (Flags & U_PPF_P ? 1 : 0 ); + *PenID = (Flags >> U_FF_SHFT_OID8) & U_FF_MASK_OID8; + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, Elements, 4, 1, U_LE); + U_PMF_VARPOINTS_get(&contents, Flags, *Elements, Points); + return(1); +} + +/** + \brief Get data from a U_PMR_DRAWCLOSEDCURVE record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param PenID U_PMF_PEN object in the EMF+ object table (0-63, inclusive) + \param ctype Set: int16_t coordinates; Clear: U_FLOAT coordinates + \param RelAbs Set: Coordinates are relative; Clear: Coordinates are absolute and their type is set by ctype + \param Tension Controls splines, 0 is straight line, >0 is curved + \param Elements Number of members in the Data array + \param Points Caller must free. Array of U_POINT_F = Sequence of points to connect. Coordinate type set by ctype and RelAbs. + + EMF+ manual 2.3.4.4, Microsoft name: EmfPlusDrawClosedCurve Record, Index 0x17 +*/ +int U_PMR_DRAWCLOSEDCURVE_get(const char *contents, U_PMF_CMN_HDR *Header, + uint32_t *PenID, int *ctype, int *RelAbs, + U_FLOAT *Tension, uint32_t *Elements, + U_PMF_POINTF **Points){ + if(!contents || !PenID || !ctype || !RelAbs || !Tension || !Elements || !Points){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *ctype = (Flags & U_PPF_C ? 1 : 0 ); + *RelAbs = (Flags & U_PPF_P ? 1 : 0 ); + *PenID = (Flags >> U_FF_SHFT_OID8) & U_FF_MASK_OID8; + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, Tension, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Elements, 4, 1, U_LE); + U_PMF_VARPOINTS_get(&contents, Flags, *Elements, Points); + return(1); +} + +/** + \brief Get data from a U_PMR_DRAWCURVE record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param PenID U_PMF_PEN object in the EMF+ object table (0-63, inclusive) + \param ctype Set: int16_t coordinates; Clear: U_FLOAT coordinates + \param Tension Controls splines, 0 is straight line, >0 is curved + \param Offset Element in Points that is the spline's starting point + \param NSegs Number of segments + \param Elements Number of members in Data array + \param Points Caller must free. Array of U_POINT_F = Sequence of points to connect. Coordinate type set by ctype and RelAbs. + + EMF+ manual 2.3.4.5, Microsoft name: EmfPlusDrawCurve Record, Index 0x18 +*/ +int U_PMR_DRAWCURVE_get(const char *contents, U_PMF_CMN_HDR *Header, + uint32_t *PenID, int *ctype, + U_FLOAT *Tension, uint32_t *Offset, uint32_t *NSegs, uint32_t *Elements, + U_PMF_POINTF **Points){ + if(!contents || !PenID || !ctype || !Tension || !Offset || !NSegs || !Elements || !Points){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *ctype = (Flags & U_PPF_C ? 1 : 0 ); + *PenID = (Flags >> U_FF_SHFT_OID8) & U_FF_MASK_OID8; + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, Tension, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Offset, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, NSegs, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Elements, 4, 1, U_LE); + U_PMF_VARPOINTS_get(&contents, Flags, *Elements, Points); + return(1); +} + +/** + \brief Get data from a U_PMR_DRAWDRIVERSTRING record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param FontID U_PMF_FONT object in the EMF+ object table (0-63, inclusive) + \param btype Set: BrushID is an U_PFM_ARGB; Clear: index of U_PMF_BRUSH object in EMF+ object table. + \param Tension Controls splines, 0 is straight line, >0 is curved + \param BrushID Color or index of U_PMF_BRUSH object in the EMF+ object table, depends on Flags bit0 + \param DSOFlags DriverStringOptions flags + \param HasMatrix If 1 record contains a TransformMatrix field, if 0 it does not. + \param Elements Number of members in Glyphs and Positions array + \param Glyphs Caller must free. If U_DSO_CmapLookup is set in DSOFlags this is an array of UTF16LE characters, otherwise, it is an array of indices into the U_PMF_FONT object indexed by Object_ID in flags. + \param Points Caller must free. Coordinates of each member of Glyphs. U_DSO_RealizedAdvance set in DSOFlags Relative then positions are calculated relative to the first glyph which is stored in Positions, otherwise, all glyph positions are stored in Positions. + \param Matrix Caller must free. Transformation to apply to Glyphs & Positions. Present if HasMatrix is 1 + + EMF+ manual 2.3.4.6, Microsoft name: EmfPlusDrawDriverString Record, Index 0x36 +*/ +int U_PMR_DRAWDRIVERSTRING_get(const char *contents, U_PMF_CMN_HDR *Header, + uint32_t *FontID, int *btype, + U_FLOAT *Tension, uint32_t *BrushID, uint32_t *DSOFlags, uint32_t *HasMatrix, uint32_t *Elements, + uint16_t **Glyphs, U_PMF_POINTF **Points, U_PMF_TRANSFORMMATRIX **Matrix){ + if(!contents || !FontID || !btype || !Tension || !BrushID || + !DSOFlags || !HasMatrix || !Elements || !Glyphs || !Points || !Matrix){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *btype = (Flags & U_PPF_B ? 1 : 0 ); + *FontID = (Flags >> U_FF_SHFT_OID8) & U_FF_MASK_OID8; + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, Tension, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, BrushID, 4, 1, (*btype ? U_XE : U_LE)); /* color is not byte swapped, ID integer is */ + U_PMF_SERIAL_get(&contents, DSOFlags, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, HasMatrix, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Elements, 4, 1, U_LE); + if(!U_PMF_SERIAL_array_copy_get(&contents, (void **)Glyphs, 2, *Elements, U_LE, (*DSOFlags & U_DSO_CmapLookup))){ return(0); } + if(!U_PMF_SERIAL_array_copy_get(&contents, (void **)Points, 4, *Elements *2, U_LE, (*DSOFlags & U_DSO_RealizedAdvance))){ return(0); } + if(!U_PMF_SERIAL_array_copy_get(&contents, (void **)Matrix, 4, 6, U_LE, (*HasMatrix))){ return(0); } + return(1); +} + +/** + \brief Get data from a U_PMR_DRAWELLIPSE record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param PenID U_PMF_PEN object in the EMF+ object table (0-63, inclusive) + \param ctype Set: int16_t coordinates; Clear: U_FLOAT coordinates + \param Rect Caller must free. Bounding rectangle. Coordinate type set by ctype. + + EMF+ manual 2.3.4.7, Microsoft name: EmfPlusDrawEllipse Record, Index 0x0F +*/ +int U_PMR_DRAWELLIPSE_get(const char *contents, U_PMF_CMN_HDR *Header, + uint32_t *PenID, int *ctype, + U_PMF_RECTF *Rect){ + if(!contents || !PenID || !ctype || !Rect){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *ctype = (Flags & U_PPF_C ? 1 : 0 ); + *PenID = (Flags >> U_FF_SHFT_OID8) & U_FF_MASK_OID8; + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, Rect, 4, 4, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMR_DRAWIMAGE record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param ImgID U_PMF_IMAGE object in the EMF+ object table (0-63, inclusive) + \param ctype Set: int16_t coordinates; Clear: U_FLOAT coordinates + \param ImgAttrID index of a U_PMF_IMAGEATTRIBUTES object in the object table + \param SrcUnit UnitType enumeration + \param SrcRect Region of image + \param DstRect Destination rectangle for image. Coordinate type set by ctype. + + EMF+ manual 2.3.4.8, Microsoft name: EmfPlusDrawImage Record, Index 0x1A +*/ +int U_PMR_DRAWIMAGE_get(const char *contents, U_PMF_CMN_HDR *Header, + uint32_t *ImgID, int *ctype, + uint32_t *ImgAttrID, int32_t *SrcUnit, U_PMF_RECTF *SrcRect, + U_PMF_RECTF *DstRect){ + if(!contents || !ImgID || !ctype || !ImgAttrID || !SrcUnit || !SrcRect || !DstRect){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *ctype = (Flags & U_PPF_C ? 1 : 0 ); + *ImgID = (Flags >> U_FF_SHFT_OID8) & U_FF_MASK_OID8; + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, ImgAttrID, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, SrcUnit, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, SrcRect, 4, 4, U_LE); + U_PMF_SERIAL_get(&contents, DstRect, 4, 4, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMR_DRAWIMAGEPOINTS record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param ImgID U_PMF_IMAGE object in the EMF+ object table (0-63, inclusive) + \param ctype Set: int16_t coordinates; Clear: U_FLOAT coordinates + \param etype Set: effect from previous U_PMR_SERIALIZABLEOBJECT record will be applied; Clear: no effect applied + \param RelAbs Set: Data is relative, Clear: if it is absolute + \param ImgAttrID EmfPlusImageAttributes object + \param SrcUnit UnitType enumeration + \param SrcRect Region of image + \param Elements Number of members in Points, must be 3 + \param Points Caller must free. 3 points of a parallelogram.. Coordinate type set by ctype and RelAbs. + + EMF+ manual 2.3.4.9, Microsoft name: EmfPlusDrawImagePoints Record, Index 0x1B +*/ +int U_PMR_DRAWIMAGEPOINTS_get(const char *contents, U_PMF_CMN_HDR *Header, + uint32_t *ImgID, int *ctype, int *etype, int *RelAbs, + uint32_t *ImgAttrID, int32_t *SrcUnit, U_PMF_RECTF *SrcRect, uint32_t *Elements, + U_PMF_POINTF **Points){ + if(!contents || !ImgID || !ctype || !etype || !RelAbs || !ImgAttrID || !SrcUnit || !Elements || !Points){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *ctype = (Flags & U_PPF_C ? 1 : 0 ); + *etype = (Flags & U_PPF_E ? 1 : 0 ); + *RelAbs = (Flags & U_PPF_P ? 1 : 0 ); + *ImgID = (Flags >> U_FF_SHFT_OID8) & U_FF_MASK_OID8; + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, ImgAttrID, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, SrcUnit, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, SrcRect, 4, 4, U_LE); + U_PMF_SERIAL_get(&contents, Elements, 4, 1, U_LE); + U_PMF_VARPOINTS_get(&contents, Flags, *Elements, Points); + return(1); +} + +/** + \brief Get data from a U_PMR_DRAWLINES record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param PenID U_PMF_PEN object in the EMF+ object table (0-63, inclusive) + \param ctype Set: int16_t coordinates; Clear: U_FLOAT coordinates + \param dtype Set: path must be closed, Clear: path is open + \param RelAbs Set: Coordinates are relative; Clear: Coordinates are absolute and their type is set by ctype + \param Elements Number of members in Points + \param Points Caller must free. Array of U_POINT_F = Sequence of points to connect. Coordinate type set by ctype and RelAbs. + + EMF+ manual 2.3.4.10, Microsoft name: EmfPlusDrawLines Record, Index 0x0D +*/ +int U_PMR_DRAWLINES_get(const char *contents, U_PMF_CMN_HDR *Header, + uint32_t *PenID, int *ctype, int *dtype, int *RelAbs, + uint32_t *Elements, + U_PMF_POINTF **Points){ + if(!contents || !PenID || !ctype || !dtype || !RelAbs || !Elements || !Points){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *ctype = (Flags & U_PPF_C ? 1 : 0 ); + *dtype = (Flags & U_PPF_D ? 1 : 0 ); + *RelAbs = (Flags & U_PPF_P ? 1 : 0 ); + *PenID = (Flags >> U_FF_SHFT_OID8) & U_FF_MASK_OID8; + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, Elements, 4, 1, U_LE); + U_PMF_VARPOINTS_get(&contents, Flags, *Elements, Points); + return(1); +} + +/** + \brief Get data from a U_PMR_DRAWPATH record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param PathID U_PMF_PATH object in the EMF+ object table (0-63, inclusive) + \param PenID U_PMF_PEN object in the EMF+ object table (0-63, inclusive) + + EMF+ manual 2.3.4.11, Microsoft name: EmfPlusDrawPath Record, Index 0x15 +*/ +int U_PMR_DRAWPATH_get(const char *contents, U_PMF_CMN_HDR *Header, + uint32_t *PathID, uint32_t *PenID){ + if(!contents || !PathID || !PenID){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *PathID = (Flags >> U_FF_SHFT_OID8) & U_FF_MASK_OID8; + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, PenID, 4, 1, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMR_DRAWPIE record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param PenID U_PMF_PEN object in the EMF+ object table (0-63, inclusive) + \param ctype Set: int16_t coordinates; Clear: U_FLOAT coordinates + \param Start Start angle, >=0.0, degrees clockwise from 3:00 + \param Sweep Sweep angle, -360<= angle <=360, degrees clockwise from Start + \param Rect Caller must free. Bounding rectangle. Coordinate type set by ctype. + + EMF+ manual 2.3.4.12, Microsoft name: EmfPlusDrawPie Record, Index 0x0D +*/ +int U_PMR_DRAWPIE_get(const char *contents, U_PMF_CMN_HDR *Header, + uint32_t *PenID, int *ctype, + U_FLOAT *Start, U_FLOAT *Sweep, + U_PMF_RECTF *Rect){ + if(!contents || !PenID || !ctype || !Start || !Sweep || !Rect){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *ctype = (Flags & U_PPF_C ? 1 : 0 ); + *PenID = (Flags >> U_FF_SHFT_OID8) & U_FF_MASK_OID8; + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, Start, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Sweep, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Rect, 4, 4, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMR_DRAWRECTS record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param PenID U_PMF_PEN object in the EMF+ object table (0-63, inclusive) + \param ctype Set: int16_t coordinates; Clear: U_FLOAT coordinates + \param Elements Number of members in Rects + \param Rects Caller must free. Array of U_PMF_RECTF rectangles to draw. + + EMF+ manual 2.3.4.13, Microsoft name: EmfPlusDrawRects Record, Index 0x0B + + Rects in record may be either U_PMF_RECT or U_PMF_RECTF, but this function always + returns U_PMF_RECTF +*/ +int U_PMR_DRAWRECTS_get(const char *contents, U_PMF_CMN_HDR *Header, + uint32_t *PenID, int *ctype, + uint32_t *Elements, + U_PMF_RECTF **Rects){ + if(!contents || !PenID || !Elements || !Rects){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *PenID = (Flags >> U_FF_SHFT_OID8) & U_FF_MASK_OID8; + *ctype = (Flags & U_PPF_C ? 1 : 0 ); + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, Elements, 4, 1, U_LE); + U_PMF_VARRECTS_get(&contents, Flags, *Elements, Rects); + return(1); +} + +/** + \brief Get data from a U_PMR_DRAWSTRING record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param FontID U_PMF_FONT object in the EMF+ object table (0-63, inclusive) + \param btype Set: BrushID is an U_PFM_ARGB; Clear: index of U_PMF_BRUSH object in EMF+ object table. + \param BrushID Color or index of U_PMF_BRUSH object in the EMF+ object table, depending on btype. + \param FormatID U_PMF_STRINGFORMAT object in EMF+ Object Table. + \param Elements Number of characters in the string. + \param Rect String's bounding box. + \param String Caller must free. Array of UFT-16LE unicode characters. + + EMF+ manual 2.3.4.14, Microsoft name: EmfPlusDrawString Record, Index 0x1C +*/ +int U_PMR_DRAWSTRING_get(const char *contents, U_PMF_CMN_HDR *Header, + uint32_t *FontID, int *btype, + uint32_t *BrushID, uint32_t *FormatID, uint32_t *Elements, U_PMF_RECTF *Rect, + uint16_t **String){ + if(!contents || !FontID || !btype || !BrushID || !FormatID || !Elements || !String){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *btype = (Flags & U_PPF_B ? 1 : 0 ); + *FontID = (Flags >> U_FF_SHFT_OID8) & U_FF_MASK_OID8; + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, BrushID, 4, 1, (*btype ? U_XE : U_LE)); /* color is not byte swapped, ID integer is */ + U_PMF_SERIAL_get(&contents, FormatID, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Elements, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Rect, 4, 4, U_LE); + if(!U_PMF_SERIAL_array_copy_get(&contents, (void **)String, 2, *Elements, U_XE, 1)){ return(0); } + return(1); +} + +/** + \brief Get data from a U_PMR_FILLCLOSEDCURVE record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param btype Set: BrushID is an U_PFM_ARGB; Clear: is index of U_PMF_BRUSH object in EMF+ object table. + \param ctype Set: int16_t coordinates; Clear: U_FLOAT coordinates + \param ftype Set: winding fill; Clear: alternate fill + \param RelAbs Set: Coordinates are relative; Clear: Coordinates are absolute and their type is set by ctype + \param BrushID Color or index of U_PMF_BRUSH object in the EMF+ object table, depending on btype. + \param Tension Controls splines, 0 is straight line, >0 is curved + \param Elements Number of members in Points + \param Points Caller must free. Array of U_POINT_F = Sequence of points to connect. Coordinate type set by ctype and RelAbs. + + EMF+ manual 2.3.4.15, Microsoft name: EmfPlusFillClosedCurve Record, Index 0x16 +*/ +int U_PMR_FILLCLOSEDCURVE_get(const char *contents, U_PMF_CMN_HDR *Header, + int *btype, int *ctype, int *ftype, int *RelAbs, + uint32_t *BrushID, U_FLOAT *Tension, uint32_t *Elements, + U_PMF_POINTF **Points){ + if(!contents || !btype || !ctype || !ftype || !RelAbs || !BrushID || !Tension || !Elements || !Points){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *btype = (Flags & U_PPF_B ? 1 : 0 ); + *ctype = (Flags & U_PPF_C ? 1 : 0 ); + *ftype = (Flags & U_PPF_F ? 1 : 0 ); + *RelAbs = (Flags & U_PPF_P ? 1 : 0 ); + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, BrushID, 4, 1, (*btype ? U_XE : U_LE)); /* color is not byte swapped, ID integer is */ + U_PMF_SERIAL_get(&contents, Tension, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Elements, 4, 1, U_LE); + U_PMF_VARPOINTS_get(&contents, Flags, *Elements, Points); + return(1); +} + +/** + \brief Get data from a U_PMR_FILLELLIPSE record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param btype Set: BrushID is an U_PFM_ARGB; Clear: is index of U_PMF_BRUSH object in EMF+ object table. + \param ctype Set: int16_t coordinates; Clear: U_FLOAT coordinates + \param BrushID Color or index of U_PMF_BRUSH object in the EMF+ object table, depending on btype. + \param Rect Caller must free. Bounding box for elliptical pie segment being drawn. Coordinate type set by ctype. + + EMF+ manual 2.3.4.16, Microsoft name: EmfPlusFillEllipse Record, Index 0x0E +*/ +int U_PMR_FILLELLIPSE_get(const char *contents, U_PMF_CMN_HDR *Header, + int *btype, int *ctype, + uint32_t *BrushID, + U_PMF_RECTF *Rect){ + if(!contents || !btype || !ctype || !BrushID || !Rect){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *btype = (Flags & U_PPF_B ? 1 : 0 ); + *ctype = (Flags & U_PPF_C ? 1 : 0 ); + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, BrushID, 4, 1, (*btype ? U_XE : U_LE)); /* color is not byte swapped, ID integer is */ + U_PMF_SERIAL_get(&contents, Rect, 4, 4, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMR_FILLPATH record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param btype Set: BrushID is an U_PFM_ARGB; Clear: is index of U_PMF_BRUSH object in EMF+ object table. + \param PathID U_PMF_PATH object in the EMF+ object table (0-63, inclusive) + \param BrushID Color or index of U_PMF_BRUSH object in the EMF+ object table, depending on btype. + + EMF+ manual 2.3.4.17, Microsoft name: EmfPlusFillPath Record, Index 0x14 + + Note: U_PMF_FILLPATHOBJ is the object, U_PMF_FILLPATH is the file record +*/ +int U_PMR_FILLPATH_get(const char *contents, U_PMF_CMN_HDR *Header, + uint32_t *PathID, int *btype, + uint32_t *BrushID){ + if(!contents || !PathID || !btype || !BrushID){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *btype = (Flags & U_PPF_B ? 1 : 0 ); + *PathID = (Flags >> U_FF_SHFT_OID8) & U_FF_MASK_OID8; + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, BrushID, 4, 1, (*btype ? U_XE : U_LE)); /* color is not byte swapped, ID integer is */ + return(1); +} + +/** + \brief Get data from a U_PMR_FILLPIE record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param btype Set: BrushID is an U_PFM_ARGB; Clear: is index of U_PMF_BRUSH object in EMF+ object table. + \param ctype Set: int16_t coordinates; Clear: U_FLOAT coordinates + \param BrushID Color or index of U_PMF_BRUSH object in the EMF+ object table, depending on btype. + \param Start Start angle, >=0.0, degrees clockwise from 3:00 + \param Sweep Sweep angle, -360<= angle <=360, degrees clockwise from Start + \param Rect Bounding box for elliptical pie segment being filled. Coordinate type set by ctype. + + EMF+ manual 2.3.4.18, Microsoft name: EmfPlusFillPie Record, Index 0x10 +*/ +int U_PMR_FILLPIE_get(const char *contents, U_PMF_CMN_HDR *Header, + int *btype, int *ctype, + uint32_t *BrushID, U_FLOAT *Start, U_FLOAT *Sweep, + U_PMF_RECTF *Rect){ + if(!contents || !btype || !ctype || !BrushID || !Start || !Sweep || !Rect){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *btype = (Flags & U_PPF_B ? 1 : 0 ); + *ctype = (Flags & U_PPF_C ? 1 : 0 ); + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, BrushID, 4, 1, (*btype ? U_XE : U_LE)); /* color is not byte swapped, ID integer is */ + U_PMF_SERIAL_get(&contents, Start, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Sweep, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Rect, 4, 4, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMR_FILLPOLYGON record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param btype Set: BrushID is an U_PFM_ARGB; Clear: is index of U_PMF_BRUSH object in EMF+ object table. + \param ctype Set: int16_t coordinates; Clear: U_FLOAT coordinates + \param RelAbs Set: U_PMF_PathPointTypeRLE and/or U_PMF_PathPointType objects; Clear: only U_PMF_PathPointType + \param BrushID Color or index of U_PMF_BRUSH object in the EMF+ object table, depending on btype. + \param Elements Number of members in Data. + \param Points Sequence of points to connect with line segments. Coordinate type set by ctype and RelAbs. + + EMF+ manual 2.3.4.19, Microsoft name: EmfPlusFillPolygon Record, Index 0x0C +*/ +int U_PMR_FILLPOLYGON_get(const char *contents, U_PMF_CMN_HDR *Header, + int *btype, int *ctype, int *RelAbs, + uint32_t *BrushID, uint32_t *Elements, + U_PMF_POINTF **Points){ + if(!contents || !btype || !ctype || !RelAbs || !BrushID || !Elements || !Points){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *btype = (Flags & U_PPF_B ? 1 : 0 ); + *ctype = (Flags & U_PPF_C ? 1 : 0 ); + *RelAbs = (Flags & U_PPF_R ? 1 : 0 ); + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, BrushID, 4, 1, (*btype ? U_XE : U_LE)); /* color is not byte swapped, ID integer is */ + U_PMF_SERIAL_get(&contents, Elements, 4, 1, U_LE); + U_PMF_VARPOINTS_get(&contents, Flags, *Elements, Points); + return(1); +} + +/** + \brief Get data from a U_PMR_FILLRECTS record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param btype Set: BrushID is an U_PFM_ARGB; Clear: is index of U_PMF_BRUSH object in EMF+ object table. + \param ctype Set: int16_t coordinates; Clear: U_FLOAT coordinates + \param BrushID Color or index of U_PMF_BRUSH object in the EMF+ object table, depending on btype. + \param Elements Number of members in Data. + \param Rects Caller must free. Array of U_PMF_RECTF rectangles to draw. + + EMF+ manual 2.3.4.20, Microsoft name: EmfPlusFillRects Record, Index 0x0A + + EMF+ files have been encountered where BrushID must be a color, because it has a value like FFFF0000 but + the flags are set wrong, so that U_PPF_B is not set. Detect these by BrushID >63 for btype=0 and correct. + If the opposite problem occurs it cannot be reliably detected, so it cannot be corrected. + + Rects in record may be either U_PMF_RECT or U_PMF_RECTF, but this function always + returns U_PMF_RECTF +*/ +int U_PMR_FILLRECTS_get(const char *contents, U_PMF_CMN_HDR *Header, + int *btype, int *ctype, + uint32_t *BrushID, uint32_t *Elements, + U_PMF_RECTF **Rects){ + if(!contents || !btype || !ctype || !BrushID || !Elements || !Rects){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *btype = (Flags & U_PPF_B ? 1 : 0 ); + *ctype = (Flags & U_PPF_C ? 1 : 0 ); + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, BrushID, 4, 1, (*btype ? U_XE : U_LE)); /* color is not byte swapped, ID integer is */ + U_PMF_SERIAL_get(&contents, Elements, 4, 1, U_LE); + U_PMF_VARRECTS_get(&contents, Flags, *Elements, Rects); + /* correct btype, if necessary, for invalid EMF+ input */ + if((*BrushID > 63) & !*btype)*btype=1; + return(1); +} + + +/** + \brief Get data from a U_PMR_FILLREGION record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param RgnID U_PMF_REGION object in the EMF+ object table (0-63, inclusive) + \param btype Set: BrushID is an U_PFM_ARGB; Clear: is index of U_PMF_BRUSH object in EMF+ object table. + \param ctype Set: int16_t coordinates; Clear: U_FLOAT coordinates + \param BrushID Color or index of U_PMF_BRUSH object in the EMF+ object table, depending on btype. + + EMF+ manual 2.3.4.21, Microsoft name: EmfPlusFillRegion Record, Index 0x13 +*/ +int U_PMR_FILLREGION_get(const char *contents, U_PMF_CMN_HDR *Header, + uint32_t *RgnID, int *btype, int *ctype, + uint32_t *BrushID){ + if(!contents || !RgnID || !btype || !ctype || !BrushID){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *btype = (Flags & U_PPF_B ? 1 : 0 ); + *ctype = (Flags & U_PPF_C ? 1 : 0 ); + *RgnID = (Flags >> U_FF_SHFT_OID8) & U_FF_MASK_OID8; + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, BrushID, 4, 1, (*btype ? U_XE : U_LE)); /* color is not byte swapped, ID integer is */ + return(1); +} + +/** + \brief Get data from a U_PMR_OBJECT record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param ObjID Index for this object in the EMF+ object table (0-63, inclusive) + \param otype ObjectType enumeration + \param ntype Set: object definition continue bit is set + \param TSize If ntype is set, holds the total number of data bytes split across multiple records. If ntype is clear, has no meaning. + \param Data Object's data. Type from otype. + + EMF+ manual 2.3.5.1, Microsoft name: EmfPlusObject Record, Index 0x13 + + OTHER NOTES: + All objects are to be stored in the same table and retrieved by index. + Documentation indicates that this table contains only 64 slots, although the index + field which references it can code for values 0-127. + If a new object has the same index as an existing object the old one is deleted and + the new one goes into its storage slot. + The continuation bit (U_PPF_N) is documented as indicating that the object is continued into + the next record. Examination of emf+ records in emf files produced by PowerPoint 2003 + show that changing the ObjID also serves as a continued record terminator, and that it apparently + overrides the value for the continue bit. That is, even though the preceding records said + that it was continued, the change of ObjID terminates that preceding record without adding + any more data to it. In one example the sequential emf+ records were: + ObjID type size continue + 0 5 65008 Y + 0 5 65008 Y + 0 5 63104 Y + 1 8 24 N + A DrawImagePoints record followed that referenced ObjID 0. + Examination of the records with continue set showed that data in each + was preceded by a uint32_t size value equivalent to the size of the + data that had been split across multiple records, in this case + 0x0002F254 = 193108. It is not clear at present if this size value + will also be present at the end of a continued series that terminates + by not using the continue bit, rather than changing the ObjID. +*/ +int U_PMR_OBJECT_get(const char *contents, U_PMF_CMN_HDR *Header, + uint32_t *ObjID, int *otype, int *ntype, uint32_t *TSize, + const char **Data){ + if(!contents || !ObjID || !otype || !ntype || !Data){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *ntype = (Flags & U_PPF_N ? 1 : 0 ); + *ObjID = (Flags >> U_FF_SHFT_OID8) & U_FF_MASK_OID8; + *otype = (Flags >> U_FF_SHFT_OT) & U_FF_MASK_OT; + U_PMF_CMN_HDR_get(&contents, Header); + if(*ntype){ U_PMF_SERIAL_get(&contents, TSize, 4, 1, U_LE); } + else { *TSize = 0; } + U_PMF_PTRSAV_SHIFT(Data, &contents, 0); + return(1); +} + +/** + \brief Get data from a U_PMR_SERIALIZABLEOBJECT record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param GUID ImageEffects identifier. + \param Size Bytes in Data. + \param Data "Serialized image effects parameter block". One of the ImageEffects objects. + + EMF+ manual 2.3.5.2, Microsoft name: EmfPlusSerializableObject Record, Index 0x38 +*/ +int U_PMR_SERIALIZABLEOBJECT_get(const char *contents, U_PMF_CMN_HDR *Header, + uint8_t *GUID, uint32_t *Size, + const char **Data){ + if(!contents || !GUID || !Size || !Data){ return(0); } + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, GUID, 1, 16, U_XE); + U_PMF_SERIAL_get(&contents, Size, 4, 1, U_LE); + U_PMF_PTRSAV_SHIFT(Data, &contents, 0); + return(1); +} + +/** + \brief Get data from a U_PMR_SETANTIALIASMODE record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param SMenum SmoothingMode enumeration + \param aatype Set: anti-aliasing on; Clear: anti-aliasing off + + EMF+ manual 2.3.6.1, Microsoft name: EmfPlusSetAntiAliasMode Record, Index 0x1E +*/ +int U_PMR_SETANTIALIASMODE_get(const char *contents, U_PMF_CMN_HDR *Header, + int *SMenum, int *aatype){ + if(!contents || !SMenum || !aatype){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *aatype = (Flags & U_PPF_AA ? 1 : 0 ); + *SMenum = (Flags >> U_FF_SHFT_AA) & U_FF_MASK_AA; + U_PMF_CMN_HDR_get(&contents, Header); + return(1); +} + +/** + \brief Get data from a U_PMR_SETCOMPOSITINGMODE record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param CMenum CompositingMode enumeration + + EMF+ manual 2.3.6.2, Microsoft name: EmfPlusSetCompositingMode Record, Index 0x23 +*/ +int U_PMR_SETCOMPOSITINGMODE_get(const char *contents, U_PMF_CMN_HDR *Header, + int *CMenum){ + if(!contents || !CMenum){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *CMenum = (Flags >> U_FF_SHFT_CM) & U_FF_MASK_CM; + U_PMF_CMN_HDR_get(&contents, Header); + return(1); +} + +/** + \brief Get data from a U_PMR_SETCOMPOSITINGQUALITY record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param CQenum CompositingQuality enumeration + + EMF+ manual 2.3.6.3, Microsoft name: EmfPlusSetCompositingQuality Record, Index 0x24 +*/ +int U_PMR_SETCOMPOSITINGQUALITY_get(const char *contents, U_PMF_CMN_HDR *Header, + int *CQenum){ + if(!contents || !CQenum){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *CQenum = (Flags >> U_FF_SHFT_CQ) & U_FF_MASK_CQ; + U_PMF_CMN_HDR_get(&contents, Header); + return(1); +} + +/** + \brief Get data from a U_PMR_SETINTERPOLATIONMODE record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param IMenum InterpolationMode enumeration + + EMF+ manual 2.3.6.4, Microsoft name: EmfPlusSetInterpolationMode Record, Index 0x21 +*/ +int U_PMR_SETINTERPOLATIONMODE_get(const char *contents, U_PMF_CMN_HDR *Header, + int *IMenum){ + if(!contents || !IMenum){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *IMenum = (Flags >> U_FF_SHFT_IM) & U_FF_MASK_IM; + U_PMF_CMN_HDR_get(&contents, Header); + return(1); +} + +/** + \brief Get data from a U_PMR_SETPIXELOFFSETMODE record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param POMenum PixelOffsetMode enumeration. + + EMF+ manual 2.3.6.5, Microsoft name: EmfPlusSetPixelOffsetMode Record, Index 0x22 +*/ +int U_PMR_SETPIXELOFFSETMODE_get(const char *contents, U_PMF_CMN_HDR *Header, + int *POMenum){ + if(!contents || !POMenum){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *POMenum = (Flags >> U_FF_SHFT_PxOffM) & U_FF_MASK_PxOffM; + U_PMF_CMN_HDR_get(&contents, Header); + return(1); +} + +/** + \brief Get data from a U_PMR_SETRENDERINGORIGIN record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header. + \param X X coordinate of rendering origin. + \param Y Y coordinate of rendering origin. + + EMF+ manual 2.3.6.6, Microsoft name: EmfPlusSetRenderingOrigin Record, Index 0x1D +*/ +int U_PMR_SETRENDERINGORIGIN_get(const char *contents, U_PMF_CMN_HDR *Header, + int32_t *X, int32_t *Y){ + if(!contents || !X || !Y){ return(0); } + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, X, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Y, 4, 1, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMR_SETTEXTCONTRAST record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header. + \param TGC Text Gamma correction value (x 1000). + + EMF+ manual 2.3.6.7, Microsoft name: EmfPlusSetTextContrast Record, Index 0x20 +*/ +int U_PMR_SETTEXTCONTRAST_get(const char *contents, U_PMF_CMN_HDR *Header, + int *TGC){ + if(!contents || !TGC){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *TGC = (Flags >> U_FF_SHFT_TGC) & U_FF_MASK_TGC; + U_PMF_CMN_HDR_get(&contents, Header); + return(1); +} + +/** + \brief Get data from a U_PMR_SETTEXTRENDERINGHINT record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header. + \param TRHenum TextRenderingHint enumeration + + EMF+ manual 2.3.6.8, Microsoft name: EmfPlusSetTextRenderingHint Record, Index 0x1F +*/ +int U_PMR_SETTEXTRENDERINGHINT_get(const char *contents, U_PMF_CMN_HDR *Header, + int *TRHenum){ + if(!contents || !TRHenum){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *TRHenum = (Flags >> U_FF_SHFT_TRH) & U_FF_MASK_TRH; + U_PMF_CMN_HDR_get(&contents, Header); + return(1); +} + +/** + \brief Get data from a U_PMR_BEGINCONTAINER record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param UTenum UnitType enumeration + \param DstRect with SrcRect specifies a transformation + \param SrcRect with DstRect specifies a transformation + \param StackID EMF+ Object Stack Index to use for this graphics container + + EMF+ manual 2.3.7.1, Microsoft name: EmfPlusBeginContainer Record, Index 0x27 +*/ +int U_PMR_BEGINCONTAINER_get(const char *contents, U_PMF_CMN_HDR *Header, + int *UTenum, + U_PMF_RECTF *DstRect, U_PMF_RECTF *SrcRect, uint32_t *StackID){ + if(!contents || !UTenum || !DstRect || !SrcRect || !StackID){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *UTenum = (Flags >> U_FF_SHFT_UT) & U_FF_MASK_UT; + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, DstRect, 4, 4, U_LE); + U_PMF_SERIAL_get(&contents, SrcRect, 4, 4, U_LE); + U_PMF_SERIAL_get(&contents, StackID, 4, 1, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMR_BEGINCONTAINERNOPARAMS record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param StackID EMF+ Object Stack Index to use for this graphics container + + EMF+ manual 2.3.7.2, Microsoft name: EmfPlusBeginContainerNoParams Record, Index 0x28 +*/ +int U_PMR_BEGINCONTAINERNOPARAMS_get(const char *contents, U_PMF_CMN_HDR *Header, uint32_t *StackID){ + if(!contents || !StackID){ return(0); } + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, StackID, 4, 1, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMR_ENDCONTAINER record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param StackID EMF+ Object Stack Index of this graphics container + + EMF+ manual 2.3.7.3, Microsoft name: EmfPlusEndContainer Record, Index 0x29 +*/ +int U_PMR_ENDCONTAINER_get(const char *contents, U_PMF_CMN_HDR *Header, + uint32_t *StackID){ + if(!contents || !StackID){ return(0); } + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, StackID, 4, 1, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMR_RESTORE record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param StackID State (level) to restore from the EMF+ Graphics Stack. Must have been put on the GS with a U_PMR_SAVE. + + EMF+ manual 2.3.7.4, Microsoft name: EmfPlusRestore Record, Index 0x26 +*/ +int U_PMR_RESTORE_get(const char *contents, U_PMF_CMN_HDR *Header, uint32_t *StackID){ + if(!contents || !StackID){ return(0); } + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, StackID, 4, 1, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMR_SAVE record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param StackID State (level) to save.on the EMF+ Graphics Stack + + EMF+ manual 2.3.7.5, Microsoft name: EmfPlusSave Record, Index 0x25 +*/ +int U_PMR_SAVE_get(const char *contents, U_PMF_CMN_HDR *Header, uint32_t *StackID){ + if(!contents || !StackID){ return(0); } + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, StackID, 4, 1, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMR_SETTSCLIP record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param ctype Set: int16_t coordinates; Clear: U_FLOAT coordinates + \param Elements Number of members in Data. + \param Rects Caller must free. Array of rectangles to draw. Coordinate type set by ctype. + + EMF+ manual 2.3.8.1, Microsoft name: EmfPlusSetTSClip Record, Index 0x3A +*/ +int U_PMR_SETTSCLIP_get(const char *contents, U_PMF_CMN_HDR *Header, + int *ctype, uint32_t *Elements, + U_PMF_RECTF **Rects){ + if(!contents || !ctype || !Elements || !Rects){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *ctype = (Flags & U_PPF_K ? 1 : 0 ); + *Elements = (Flags >> U_FF_SHFT_TSC) & U_FF_MASK_TSC; + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_VARRECTS_get(&contents, Flags, *Elements, Rects); + return(1); +} + +/** + \brief Get data from a U_PMR_SETTSGRAPHICS record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param vgatype Set: Palette is VGA basic colors; Clear: Palette is ??? + \param pptype Set: Palette is present; Clear: Palette is absent. + \param AntiAliasMode SmoothingMode enumeration + \param TextRenderHint TextRenderingHint enumeration + \param CompositingMode CompositingMode enumeration + \param CompositingQuality CompositingQuality enumeration + \param RenderOriginX Origin X for halftoning and dithering + \param RenderOriginY Origin Y for halftoning and dithering + \param TextContrast Gamma correction, range 0 to 12 + \param FilterType FilterType enumeraton + \param PixelOffset PixelOffsetMode enumeration + \param WorldToDevice world to device transform + \param Data Palette (optional) + + EMF+ manual 2.3.8.2, Microsoft name: EmfPlusSetTSGraphics Record, Index 0x39 +*/ +int U_PMR_SETTSGRAPHICS_get(const char *contents, U_PMF_CMN_HDR *Header, + int *vgatype, int *pptype, + uint8_t *AntiAliasMode, uint8_t *TextRenderHint, uint8_t *CompositingMode, uint8_t *CompositingQuality, + int16_t *RenderOriginX, int16_t *RenderOriginY, uint16_t *TextContrast, uint8_t *FilterType, + uint8_t *PixelOffset, U_PMF_TRANSFORMMATRIX *WorldToDevice, + const char **Data){ + if(!contents || !vgatype || !pptype || + !AntiAliasMode || !TextRenderHint || !CompositingMode || !CompositingQuality || + !RenderOriginX || !RenderOriginY || !TextContrast || !FilterType || + !PixelOffset || !WorldToDevice || !Data){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *vgatype = (Flags & U_PPF_VGA ? 1 : 0 ); + *pptype = (Flags & U_PPF_PP ? 1 : 0 ); + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, AntiAliasMode, 1, 1, U_XE); + U_PMF_SERIAL_get(&contents, TextRenderHint, 1, 1, U_XE); + U_PMF_SERIAL_get(&contents, CompositingMode, 1, 1, U_XE); + U_PMF_SERIAL_get(&contents, CompositingQuality, 1, 1, U_XE); + U_PMF_SERIAL_get(&contents, RenderOriginX, 2, 1, U_LE); + U_PMF_SERIAL_get(&contents, RenderOriginY, 2, 1, U_LE); + U_PMF_SERIAL_get(&contents, TextContrast, 2, 1, U_LE); + U_PMF_SERIAL_get(&contents, FilterType, 1, 1, U_XE); + U_PMF_SERIAL_get(&contents, WorldToDevice, 4, 6, U_LE); + U_PMF_PTRSAV_COND(Data, contents, *pptype); + return(1); +} + +/** + \brief Get data from a U_PMR_MULTIPLYWORLDTRANSFORM record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param xmtype Set: Post multiply; Clear: Pre multiply + \param Matrix Transformation matrix + + EMF+ manual 2.3.9.1, Microsoft name: EmfPlusMultiplyWorldTransform Record, Index 0x2C +*/ +int U_PMR_MULTIPLYWORLDTRANSFORM_get(const char *contents, U_PMF_CMN_HDR *Header, + int *xmtype, + U_PMF_TRANSFORMMATRIX *Matrix){ + if(!contents || !xmtype || !Matrix){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *xmtype = (Flags & U_PPF_XM ? 1 : 0 ); + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, Matrix, 4, 6, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMR_RESETWORLDTRANSFORM record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + + EMF+ manual 2.3.9.2, Microsoft name: EmfPlusResetWorldTransform Record, Index 0x2B +*/ +int U_PMR_RESETWORLDTRANSFORM_get(const char *contents, U_PMF_CMN_HDR *Header){ + if(!contents){ return(0); } + U_PMF_CMN_HDR_get(&contents, Header); + return(1); +} + +/** + \brief Get data from a U_PMR_ROTATEWORLDTRANSFORM record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param xmtype Set: Post multiply; Clear: Pre multiply + \param Angle Rotation angle, in degrees + + EMF+ manual 2.3.9.3, Microsoft name: EmfPlusRotateWorldTransform Record, Index 0x2F +*/ +int U_PMR_ROTATEWORLDTRANSFORM_get(const char *contents, U_PMF_CMN_HDR *Header, + int *xmtype, + U_FLOAT *Angle){ + if(!contents || !xmtype || !Angle){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *xmtype = (Flags & U_PPF_XM ? 1 : 0 ); + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, Angle, 4, 1, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMR_SCALEWORLDTRANSFORM record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param xmtype Set: Post multiply; Clear: Pre multiply. + \param Sx X scale factor. + \param Sy Y scale factor. + + EMF+ manual 2.3.9.4, Microsoft name: EmfPlusScaleWorldTransform Record, Index 0x2E +*/ +int U_PMR_SCALEWORLDTRANSFORM_get(const char *contents, U_PMF_CMN_HDR *Header, + int *xmtype, + U_FLOAT *Sx, U_FLOAT *Sy){ + if(!contents || !xmtype || !Sx || !Sy){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *xmtype = (Flags & U_PPF_XM ? 1 : 0 ); + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, Sx, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Sy, 4, 1, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMR_SETPAGETRANSFORM record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param PUenum Page Unit, UnitType enumeration + \param Scale Scale factor to convert page space to device space + + EMF+ manual 2.3.9.5, Microsoft name: EmfPlusSetPageTransform Record, Index 0x30 +*/ +int U_PMR_SETPAGETRANSFORM_get(const char *contents, U_PMF_CMN_HDR *Header, + int *PUenum, + U_FLOAT *Scale){ + if(!contents || !PUenum || !Scale){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *PUenum = (Flags >> U_FF_SHFT_PU) & U_FF_MASK_PU; + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, Scale, 4, 1, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMR_SETWORLDTRANSFORM record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param Matrix Transformation matrix + + EMF+ manual 2.3.9.6, Microsoft name: EmfPlusSetWorldTransform Record, Index 0x2A +*/ +int U_PMR_SETWORLDTRANSFORM_get(const char *contents, U_PMF_CMN_HDR *Header, + U_PMF_TRANSFORMMATRIX *Matrix){ + if(!contents || !Matrix){ return(0); } + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, Matrix, 4, 6, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMR_TRANSLATEWORLDTRANSFORM record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header + \param xmtype Set: Post multiply; Clear: Pre multiply + \param Dx X offset + \param Dy Y offset + + EMF+ manual 2.3.9.7, Microsoft name: EmfPlusTranslateWorldTransform Record, Index 0x2D +*/ +int U_PMR_TRANSLATEWORLDTRANSFORM_get(const char *contents, U_PMF_CMN_HDR *Header, + int *xmtype, + U_FLOAT *Dx, U_FLOAT *Dy){ + if(!contents || !xmtype || !Dx || !Dy){ return(0); } + uint16_t Flags = U_PMF_HEADERFLAGS_get(contents); + *xmtype = (Flags & U_PPF_XM ? 1 : 0 ); + U_PMF_CMN_HDR_get(&contents, Header); + U_PMF_SERIAL_get(&contents, Dx, 4, 1, U_LE); + U_PMF_SERIAL_get(&contents, Dy, 4, 1, U_LE); + return(1); +} + +/** + \brief Get data from a U_PMR_STROKEFILLPATH record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header (ignore flags) + + + EMF+ manual mentioned in 2.1.1.1, not otherwise documented, Microsoft name: EmfPlusStrokeFillPath Record, Index 0x37 + + "This record closes any open figures in a path, strokes the outline of + the path by using the current pen, and fills its interior by using the current brush." +*/ +int U_PMR_STROKEFILLPATH_get(const char *contents, U_PMF_CMN_HDR *Header){ + if(!contents){ return(0); } + U_PMF_CMN_HDR_get(&contents, Header); + return(1); +} + +/** + \brief Get data from a U_PMR_MULTIFORMATSTART record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header (ignore flags) + + EMF+ manual mentioned in 2.1.1.1, reserved, not otherwise documented, Microsoft name: EmfPlusMultiFormatStart Record, Index 0x05 +*/ +int U_PMR_MULTIFORMATSTART_get(const char *contents, U_PMF_CMN_HDR *Header){ + if(!contents){ return(0); } + U_PMF_CMN_HDR_get(&contents, Header); + return(1); +} + +/** + \brief Get data from a U_PMR_MULTIFORMATSECTION record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header (ignore flags) + + EMF+ manual mentioned in 2.1.1.1, reserved, not otherwise documented, Microsoft name: EmfPlusMultiFormatSection Record, Index 0x06 +*/ +int U_PMR_MULTIFORMATSECTION_get(const char *contents, U_PMF_CMN_HDR *Header){ + if(!contents){ return(0); } + U_PMF_CMN_HDR_get(&contents, Header); + return(1); +} + +/** + \brief Get data from a U_PMR_MULTIFORMATEND record + \return 1 on success, 0 on error + \param contents Record from which to extract data + \param Header Common header (ignore flags) + + EMF+ manual mentioned in 2.1.1.1, reserved, not otherwise documented, Microsoft name: EmfPlusMultiFormatEnd Record, Index 0x06 +*/ +int U_PMR_MULTIFORMATEND_get(const char *contents, U_PMF_CMN_HDR *Header){ + if(!contents){ return(0); } + U_PMF_CMN_HDR_get(&contents, Header); + return(1); +} + + +#ifdef __cplusplus +} +#endif diff --git a/src/libuemf/upmf.h b/src/libuemf/upmf.h new file mode 100644 index 000000000..48fc9bf53 --- /dev/null +++ b/src/libuemf/upmf.h @@ -0,0 +1,3177 @@ +/** + @file upmf.h + + @brief Structures, definitions, and function prototypes for EMF+ files. + + EMF+ file Record structure derived from Microsoft's EMF+ Information pdf, releade date July 5,2012, link from + here: + + http://msdn.microsoft.com/en-us/library/cc230724.aspx + + If the direct link fails the document may be found + by searching for: "[MS-EMFPLUS]: Enhanced Metafile Format Plus Extensions " + + EMR records and structures are EMF or common with EMF+ + PMR records and structures are specific to EMF+ + + Using PMF instead of EMF+ because "+" is a problem in symbol names. + + ***************************************************************************************** + * WARNING: Microsoft's EMF+ documentation is little-endian for everything EXCEPT * + * bitfields, which are big-endian. See section 1.3.2 * + * That documentation also uses 0 as the MOST significant bit, N-1 as the least. * + * This code is little-endian throughout, and 0 is the LEAST significant bit * + ***************************************************************************************** + +*/ + +/* +File: upmf.h +Version: 0.0.2 +Date: 04-NOV-2013 +Author: David Mathog, Biology Division, Caltech +email: mathog@caltech.edu +Copyright: 2013 David Mathog and California Institute of Technology (Caltech) +*/ + +#ifndef _UPMF_ +#define _UPMF_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include "uemf.h" + + +/** \defgroup U_PMF_PMF_Misc PMF Miscellaneous defines + @{ +*/ +#define U_PMF_DROP_ELEMENTS 1 //!< Remove leading Elements value from data. +#define U_PMF_KEEP_ELEMENTS 0 //!< Retain leading Elements value from data. + +#define U_SEG_NEW 1 //!< start a new segment in the path +#define U_SEG_OLD 0 //!< continue the old (current) segment in the path + +#define U_FILTER_APPLY 1 //!< With U_PMR_DRAWIMAGEPOINTS_set, use whatever filter has been set up up. +#define U_FILTER_IGNORE 0 //!< With U_PMR_DRAWIMAGEPOINTS_set, ignore whatever filter has been set up up. +#define U_OBJRECLIM 65020 //!< Longest U_PMR_OBJECT that GDI+ will process + // used 9728 to test fragmenting of emitted object records + +/** @} */ + +/** \defgroup U_PMF_DD_ PMF "standard" custom Dash Dot patterns for lines. + + U_DD_DASH, U_DD_DOT, U_DD_DASHDOT, and U_DD_DASHDOTDOT are the only ones with corresponding + standard EMF and EMF+ dash/dot patterns. + + These values are used to tell U_PMF_DASHEDLINEDATA_set2() to create one of 27 custom line patterns. + Other custom line patterns may be created using U_PMF_DASHEDLINEDATA_set(), but this provides an easier + way to get the same result if one of these patterns is acceptable. + + The length is divided by 2X the number of elements, so dashdash has twice as many + dashes of half the length as just dash. + + Dot is 1/8 of (sub)unit length + Dash is 1/2 of (sub)unit length + Long is 3/4 of (sub)unit length + Example: DotDot has (sub)unit length 1/2, so each dot will be 1/16 of unit length. + + @{ +*/ +#define U_DD_Solid 0 //!< Solid line. +#define U_DD_Dash 1 //!< Dash line. +#define U_DD_DashDash 2 //!< Dash Dash line. +#define U_DD_DashDashDash 3 //!< Dash Dash Dash line. +#define U_DD_DashDashDashDash 4 //!< Dash Dash Dash Dash line. +#define U_DD_Dot 5 //!< Dot line. +#define U_DD_DotDot 6 //!< Dot Dot line. +#define U_DD_DotDotDot 7 //!< Dot Dot Dot line. +#define U_DD_DotDotDotDot 8 //!< Dot Dot Dot Dot line. +#define U_DD_DashDot 9 //!< Dash Dot line. +#define U_DD_DashDashDot 10 //!< Dash Dash Dot line. +#define U_DD_DashDashDotDot 11 //!< Dash Dash Dot Dot line. +#define U_DD_DashDashDashDot 12 //!< Dash Dash Das hDot line. +#define U_DD_DashDotDot 13 //!< Dash Dot Dot line. +#define U_DD_DashDotDotDot 14 //!< Dash Dot Dot Dot line. +#define U_DD_DashDotDashDot 15 //!< Dash Dot Dash Dot line. +#define U_DD_Long 16 //!< Long line. +#define U_DD_LongLong 17 //!< Long Long line. +#define U_DD_LongLongLong 18 //!< Long Long Long line. +#define U_DD_LongLongLongLong 19 //!< Long Long Long Long line. +#define U_DD_LongDot 20 //!< Long Dot line. +#define U_DD_LongLongDot 21 //!< Long Long Dot line. +#define U_DD_LongLongDotDot 22 //!< Long Long Dot Dot line. +#define U_DD_LongLongLongDot 23 //!< Long Long Long Dot line. +#define U_DD_LongDotDot 24 //!< Long Dot Dot line. +#define U_DD_LongDotDotDot 25 //!< Long Dot Dot Dot line. +#define U_DD_LongDotLongDot 26 //!< Long Dot Long Dot line. +#define U_DD_Types 27 //!< Types + +/** @} */ + + +/** \defgroup U_PMF_PMR_Qualifiers PMF RecordType Enumeration + EMF+ manual 2.1.1.1, Microsoft name: RecordType Enumeration + @{ +*/ +#define U_PMR_HEADER 0x0001 //!< U_PMRHeader record +#define U_PMR_ENDOFFILE 0x0002 //!< U_PMREndOfFile record +#define U_PMR_COMMENT 0x0003 //!< U_PMRComment record +#define U_PMR_GETDC 0x0004 //!< U_PMRGetDC record +#define U_PMR_MULTIFORMATSTART 0x0005 //!< U_PMRMultiFormatStart record +#define U_PMR_MULTIFORMATSECTION 0x0006 //!< U_PMRMultiFormatSection record +#define U_PMR_MULTIFORMATEND 0x0007 //!< U_PMRMultiFormatEnd record +#define U_PMR_OBJECT 0x0008 //!< U_PMRObject record +#define U_PMR_CLEAR 0x0009 //!< U_PMRClear record +#define U_PMR_FILLRECTS 0x000A //!< U_PMRFillRects record +#define U_PMR_DRAWRECTS 0x000B //!< U_PMRDrawRects record +#define U_PMR_FILLPOLYGON 0x000C //!< U_PMRFillPolygon record +#define U_PMR_DRAWLINES 0x000D //!< U_PMRDrawLines record +#define U_PMR_FILLELLIPSE 0x000E //!< U_PMRFillEllipse record +#define U_PMR_DRAWELLIPSE 0x000F //!< U_PMRDrawEllipse record +#define U_PMR_FILLPIE 0x0010 //!< U_PMRFillPie record +#define U_PMR_DRAWPIE 0x0011 //!< U_PMRDrawPie record +#define U_PMR_DRAWARC 0x0012 //!< U_PMRDrawArc record +#define U_PMR_FILLREGION 0x0013 //!< U_PMRFillRegion record +#define U_PMR_FILLPATH 0x0014 //!< U_PMRFillPath record +#define U_PMR_DRAWPATH 0x0015 //!< U_PMRDrawPath record +#define U_PMR_FILLCLOSEDCURVE 0x0016 //!< U_PMRFillClosedCurve record +#define U_PMR_DRAWCLOSEDCURVE 0x0017 //!< U_PMRDrawClosedCurve record +#define U_PMR_DRAWCURVE 0x0018 //!< U_PMRDrawCurve record +#define U_PMR_DRAWBEZIERS 0x0019 //!< U_PMRDrawBeziers record +#define U_PMR_DRAWIMAGE 0x001A //!< U_PMRDrawImage record +#define U_PMR_DRAWIMAGEPOINTS 0x001B //!< U_PMRDrawImagePoints record +#define U_PMR_DRAWSTRING 0x001C //!< U_PMRDrawString record +#define U_PMR_SETRENDERINGORIGIN 0x001D //!< U_PMRSetRenderingOrigin record +#define U_PMR_SETANTIALIASMODE 0x001E //!< U_PMRSetAntiAliasMode record +#define U_PMR_SETTEXTRENDERINGHINT 0x001F //!< U_PMRSetTextRenderingHint record +#define U_PMR_SETTEXTCONTRAST 0x0020 //!< U_PMRSetTextContrast record +#define U_PMR_SETINTERPOLATIONMODE 0x0021 //!< U_PMRSetInterpolationMode record +#define U_PMR_SETPIXELOFFSETMODE 0x0022 //!< U_PMRSetPixelOffsetMode record +#define U_PMR_SETCOMPOSITINGMODE 0x0023 //!< U_PMRSetCompositingMode record +#define U_PMR_SETCOMPOSITINGQUALITY 0x0024 //!< U_PMRSetCompositingQuality record +#define U_PMR_SAVE 0x0025 //!< U_PMRSave record +#define U_PMR_RESTORE 0x0026 //!< U_PMRRestore record +#define U_PMR_BEGINCONTAINER 0x0027 //!< U_PMRBeginContainer record +#define U_PMR_BEGINCONTAINERNOPARAMS 0x0028 //!< U_PMRBeginContainerNoParams record +#define U_PMR_ENDCONTAINER 0x0029 //!< U_PMREndContainer record +#define U_PMR_SETWORLDTRANSFORM 0x002A //!< U_PMRSetWorldTransform record +#define U_PMR_RESETWORLDTRANSFORM 0x002B //!< U_PMRResetWorldTransform record +#define U_PMR_MULTIPLYWORLDTRANSFORM 0x002C //!< U_PMRMultiplyWorldTransform record +#define U_PMR_TRANSLATEWORLDTRANSFORM 0x002D //!< U_PMRTranslateWorldTransform record +#define U_PMR_SCALEWORLDTRANSFORM 0x002E //!< U_PMRScaleWorldTransform record +#define U_PMR_ROTATEWORLDTRANSFORM 0x002F //!< U_PMRRotateWorldTransform record +#define U_PMR_SETPAGETRANSFORM 0x0030 //!< U_PMRSetPageTransform record +#define U_PMR_RESETCLIP 0x0031 //!< U_PMRResetClip record +#define U_PMR_SETCLIPRECT 0x0032 //!< U_PMRSetClipRect record +#define U_PMR_SETCLIPPATH 0x0033 //!< U_PMRSetClipPath record +#define U_PMR_SETCLIPREGION 0x0034 //!< U_PMRSetClipRegion record +#define U_PMR_OFFSETCLIP 0x0035 //!< U_PMROffsetClip record +#define U_PMR_DRAWDRIVERSTRING 0x0036 //!< U_PMRDrawDriverstring record +#define U_PMR_STROKEFILLPATH 0x0037 //!< U_PMRStrokeFillPath record +#define U_PMR_SERIALIZABLEOBJECT 0x0038 //!< U_PMRSerializableObject record +#define U_PMR_SETTSGRAPHICS 0x0039 //!< U_PMRSetTSGraphics record +#define U_PMR_SETTSCLIP 0x003A //!< U_PMRSetTSClip record +#define U_PMR_RECFLAG 0x4000 //!< In EMF+ files the type is one of the above + this flag +#define U_PMR_TYPE_MASK 0x003F //!< mask for EMF+ types +#define U_PMR_MIN 1 //!< Minimum U_PMR_ value. +#define U_PMR_MAX 58 //!< Maximum U_PMR_ value. + +/** @} */ + +/** \defgroup U_PMF_PID_Values PMF Identifiers for PseudoObjects + These are used by the *_set routines to identify types of PseudoObject. + Note that records are U_PMR_*_OID and other objects are U_PMF_*_OID + The numbers are derived from the EMF+ manual sections, as in 2.2.1.3 become + 02020103. Numbers 40000000 and up are not derived from manual setions. + @{ +*/ +#define U_UNDEFINED_OID 0x00000000 //!< Undefined PseudoObject +#define U_PMF_BRUSH_OID 0x02020101 //!< PMF_BRUSH PseudoObject type. +#define U_PMF_CUSTOMLINECAP_OID 0x02020102 //!< PMF_CUSTOMLINECAP PseudoObject type. +#define U_PMF_FONT_OID 0x02020103 //!< PMF_FONT PseudoObject type. +#define U_PMF_IMAGE_OID 0x02020104 //!< PMF_IMAGE PseudoObject type. +#define U_PMF_IMAGEATTRIBUTES_OID 0x02020105 //!< PMF_IMAGEATTRIBUTES PseudoObject type. +#define U_PMF_PATH_OID 0x02020106 //!< PMF_PATH PseudoObject type. +#define U_PMF_PEN_OID 0x02020107 //!< PMF_PEN PseudoObject type. +#define U_PMF_REGION_OID 0x02020108 //!< PMF_REGION PseudoObject type. +#define U_PMF_STRINGFORMAT_OID 0x02020109 //!< PMF_STRINGFORMAT PseudoObject type. +#define U_PMF_ARGB_OID 0x02020201 //!< PMF_ARGB PseudoObject type. +#define U_PMF_BITMAP_OID 0x02020202 //!< PMF_BITMAP PseudoObject type. +#define U_PMF_BITMAPDATA_OID 0x02020203 //!< PMF_BITMAPDATA PseudoObject type. +#define U_PMF_BLENDCOLORS_OID 0x02020204 //!< PMF_BLENDCOLORS PseudoObject type. +#define U_PMF_BLENDFACTORS_OID 0x02020205 //!< PMF_BLENDFACTORS PseudoObject type. +#define U_PMF_BOUNDARYPATHDATA_OID 0x02020206 //!< PMF_BOUNDARYPATHDATA PseudoObject type. +#define U_PMF_BOUNDARYPOINTDATA_OID 0x02020207 //!< PMF_BOUNDARYPOINTDATA PseudoObject type. +#define U_PMF_CHARACTERRANGE_OID 0x02020208 //!< PMF_CHARACTERRANGE PseudoObject type. +#define U_PMF_COMPOUNDLINEDATA_OID 0x02020209 //!< PMF_COMPOUNDLINEDATA PseudoObject type. +#define U_PMF_COMPRESSEDIMAGE_OID 0x02020210 //!< PMF_COMPRESSEDIMAGE PseudoObject type. +#define U_PMF_CUSTOMENDCAPDATA_OID 0x02020211 //!< PMF_CUSTOMENDCAPDATA PseudoObject type. +#define U_PMF_CUSTOMLINECAPARROWDATA_OID 0x02020212 //!< PMF_CUSTOMLINECAPARROWDATA PseudoObject type. +#define U_PMF_CUSTOMLINECAPDATA_OID 0x02020213 //!< PMF_CUSTOMLINECAPDATA PseudoObject type. +#define U_PMF_CUSTOMLINECAPOPTIONALDATA_OID 0x02020214 //!< PMF_CUSTOMLINECAPOPTIONALDATA PseudoObject type. +#define U_PMF_CUSTOMSTARTCAPDATA_OID 0x02020215 //!< PMF_CUSTOMSTARTCAPDATA PseudoObject type. +#define U_PMF_DASHEDLINEDATA_OID 0x02020216 //!< PMF_DASHEDLINEDATA PseudoObject type. +#define U_PMF_FILLPATHOBJ_OID 0x02020217 //!< PMF_FILLPATHOBJ PseudoObject type. +#define U_PMF_FOCUSSCALEDATA_OID 0x02020218 //!< PMF_FOCUSSCALEDATA PseudoObject type. +#define U_PMF_GRAPHICSVERSION_OID 0x02020219 //!< PMF_GRAPHICSVERSION PseudoObject type. +#define U_PMF_HATCHBRUSHDATA_OID 0x02020220 //!< PMF_HATCHBRUSHDATA PseudoObject type. +#define U_PMF_INTEGER7_OID 0x02020221 //!< PMF_INTEGER7 PseudoObject type. +#define U_PMF_INTEGER15_OID 0x02020222 //!< PMF_INTEGER15 PseudoObject type. +#define U_PMF_LANGUAGEIDENTIFIER_OID 0x02020223 //!< PMF_LANGUAGEIDENTIFIER PseudoObject type. +#define U_PMF_LINEARGRADIENTBRUSHDATA_OID 0x02020224 //!< PMF_LINEARGRADIENTBRUSHDATA PseudoObject type. +#define U_PMF_LINEARGRADIENTBRUSHOPTIONALDATA_OID 0x02020225 //!< PMF_LINEARGRADIENTBRUSHOPTIONALDATA PseudoObject type. +#define U_PMF_LINEPATH_OID 0x02020226 //!< PMF_LINEPATH PseudoObject type. +#define U_PMF_METAFILE_OID 0x02020227 //!< PMF_METAFILE PseudoObject type. +#define U_PMF_PALETTE_OID 0x02020228 //!< PMF_PALETTE PseudoObject type. +#define U_PMF_PATHGRADIENTBRUSHDATA_OID 0x02020229 //!< PMF_PATHGRADIENTBRUSHDATA PseudoObject type. +#define U_PMF_PATHGRADIENTBRUSHOPTIONALDATA_OID 0x02020230 //!< PMF_PATHGRADIENTBRUSHOPTIONALDATA PseudoObject type. +#define U_PMF_PATHPOINTTYPE_OID 0x02020231 //!< PMF_PATHPOINTTYPE PseudoObject type. +#define U_PMF_PATHPOINTTYPERLE_OID 0x02020232 //!< PMF_PATHPOINTTYPERLE PseudoObject type. +#define U_PMF_PENDATA_OID 0x02020233 //!< PMF_PENDATA PseudoObject type. +#define U_PMF_PENOPTIONALDATA_OID 0x02020234 //!< PMF_PENOPTIONALDATA PseudoObject type. +#define U_PMF_POINT_OID 0x02020235 //!< PMF_POINT PseudoObject type. +#define U_PMF_POINTF_OID 0x02020236 //!< PMF_POINTF PseudoObject type. +#define U_PMF_POINTR_OID 0x02020237 //!< PMF_POINTR PseudoObject type. +#define U_PMF_RECT_OID 0x02020238 //!< PMF_RECT PseudoObject type. +#define U_PMF_RECTF_OID 0x02020239 //!< PMF_RECTF PseudoObject type. +#define U_PMF_REGIONNODE_OID 0x02020240 //!< PMF_REGIONNODE PseudoObject type. +#define U_PMF_REGIONNODECHILDNODES_OID 0x02020241 //!< PMF_REGIONNODECHILDNODES PseudoObject type. +#define U_PMF_REGIONNODEPATH_OID 0x02020242 //!< PMF_REGIONNODEPATH PseudoObject type. +#define U_PMF_SOLIDBRUSHDATA_OID 0x02020243 //!< PMF_SOLIDBRUSHDATA PseudoObject type. +#define U_PMF_STRINGFORMATDATA_OID 0x02020244 //!< PMF_STRINGFORMATDATA PseudoObject type. +#define U_PMF_TEXTUREBRUSHDATA_OID 0x02020245 //!< PMF_TEXTUREBRUSHDATA PseudoObject type. +#define U_PMF_TEXTUREBRUSHOPTIONALDATA_OID 0x02020246 //!< PMF_TEXTUREBRUSHOPTIONALDATA PseudoObject type. +#define U_PMF_TRANSFORMMATRIX_OID 0x02020247 //!< PMF_TRANSFORMMATRIX PseudoObject type. +#define U_PMF_IE_BLUR_OID 0x02020301 //!< PMF_IE_BLUR PseudoObject type. +#define U_PMF_IE_BRIGHTNESSCONTRAST_OID 0x02020302 //!< PMF_IE_BRIGHTNESSCONTRAST PseudoObject type. +#define U_PMF_IE_COLORBALANCE_OID 0x02020303 //!< PMF_IE_COLORBALANCE PseudoObject type. +#define U_PMF_IE_COLORCURVE_OID 0x02020304 //!< PMF_IE_COLORCURVE PseudoObject type. +#define U_PMF_IE_COLORLOOKUPTABLE_OID 0x02020305 //!< PMF_IE_COLORLOOKUPTABLE PseudoObject type. +#define U_PMF_IE_COLORMATRIX_OID 0x02020306 //!< PMF_IE_COLORMATRIX PseudoObject type. +#define U_PMF_IE_HUESATURATIONLIGHTNESS_OID 0x02020307 //!< PMF_IE_HUESATURATIONLIGHTNESS PseudoObject type. +#define U_PMF_IE_LEVELS_OID 0x02020308 //!< PMF_IE_LEVELS PseudoObject type. +#define U_PMF_IE_REDEYECORRECTION_OID 0x02020309 //!< PMF_IE_REDEYECORRECTION PseudoObject type. +#define U_PMF_IE_SHARPEN_OID 0x02020310 //!< PMF_IE_SHARPEN PseudoObject type. +#define U_PMF_IE_TINT_OID 0x02020311 //!< PMF_IE_TINT PseudoObject type. +#define U_PMR_STROKEFILLPATH_OID 0x02010101 //!< PMR_STROKEFILLPATH PseudoObject type. (Mentioned in passing here). +#define U_PMR_OFFSETCLIP_OID 0x02030101 //!< PMR_OFFSETCLIP PseudoObject type. +#define U_PMR_RESETCLIP_OID 0x02030102 //!< PMR_RESETCLIP PseudoObject type. +#define U_PMR_SETCLIPPATH_OID 0x02030103 //!< PMR_SETCLIPPATH PseudoObject type. +#define U_PMR_SETCLIPRECT_OID 0x02030104 //!< PMR_SETCLIPRECT PseudoObject type. +#define U_PMR_SETCLIPREGION_OID 0x02030105 //!< PMR_SETCLIPREGION PseudoObject type. +#define U_PMR_COMMENT_OID 0x02030201 //!< PMR_COMMENT PseudoObject type. +#define U_PMR_ENDOFFILE_OID 0x02030301 //!< PMR_ENDOFFILE PseudoObject type. +#define U_PMR_GETDC_OID 0x02030302 //!< PMR_GETDC PseudoObject type. +#define U_PMR_HEADER_OID 0x02030303 //!< PMR_HEADER PseudoObject type. +#define U_PMR_CLEAR_OID 0x02030401 //!< PMR_CLEAR PseudoObject type. +#define U_PMR_DRAWARC_OID 0x02030402 //!< PMR_DRAWARC PseudoObject type. +#define U_PMR_DRAWBEZIERS_OID 0x02030403 //!< PMR_DRAWBEZIERS PseudoObject type. +#define U_PMR_DRAWCLOSEDCURVE_OID 0x02030404 //!< PMR_DRAWCLOSEDCURVE PseudoObject type. +#define U_PMR_DRAWCURVE_OID 0x02030405 //!< PMR_DRAWCURVE PseudoObject type. +#define U_PMR_DRAWDRIVERSTRING_OID 0x02030406 //!< PMR_DRAWDRIVERSTRING PseudoObject type. +#define U_PMR_DRAWELLIPSE_OID 0x02030407 //!< PMR_DRAWELLIPSE PseudoObject type. +#define U_PMR_DRAWIMAGE_OID 0x02030408 //!< PMR_DRAWIMAGE PseudoObject type. +#define U_PMR_DRAWIMAGEPOINTS_OID 0x02030409 //!< PMR_DRAWIMAGEPOINTS PseudoObject type. +#define U_PMR_DRAWLINES_OID 0x02030410 //!< PMR_DRAWLINES PseudoObject type. +#define U_PMR_DRAWPATH_OID 0x02030411 //!< PMR_DRAWPATH PseudoObject type. +#define U_PMR_DRAWPIE_OID 0x02030412 //!< PMR_DRAWPIE PseudoObject type. +#define U_PMR_DRAWRECTS_OID 0x02030413 //!< PMR_DRAWRECTS PseudoObject type. +#define U_PMR_DRAWSTRING_OID 0x02030414 //!< PMR_DRAWSTRING PseudoObject type. +#define U_PMR_FILLCLOSEDCURVE_OID 0x02030415 //!< PMR_FILLCLOSEDCURVE PseudoObject type. +#define U_PMR_FILLELLIPSE_OID 0x02030416 //!< PMR_FILLELLIPSE PseudoObject type. +#define U_PMR_FILLPATH_OID 0x02030417 //!< PMR_FILLPATH PseudoObject type. +#define U_PMR_FILLPIE_OID 0x02030418 //!< PMR_FILLPIE PseudoObject type. +#define U_PMR_FILLPOLYGON_OID 0x02030419 //!< PMR_FILLPOLYGON PseudoObject type. +#define U_PMR_FILLRECTS_OID 0x02030420 //!< PMR_FILLRECTS PseudoObject type. +#define U_PMR_FILLREGION_OID 0x02030421 //!< PMR_FILLREGION PseudoObject type. +#define U_PMR_OBJECT_OID 0x02030501 //!< PMR_OBJECT PseudoObject type. +#define U_PMR_SERIALIZABLEOBJECT_OID 0x02030502 //!< PMR_SERIALIZABLEOBJECT PseudoObject type. +#define U_PMR_SETANTIALIASMODE_OID 0x02030601 //!< PMR_SETANTIALIASMODE PseudoObject type. +#define U_PMR_SETCOMPOSITINGMODE_OID 0x02030602 //!< PMR_SETCOMPOSITINGMODE PseudoObject type. +#define U_PMR_SETCOMPOSITINGQUALITY_OID 0x02030603 //!< PMR_SETCOMPOSITINGQUALITY PseudoObject type. +#define U_PMR_SETINTERPOLATIONMODE_OID 0x02030604 //!< PMR_SETINTERPOLATIONMODE PseudoObject type. +#define U_PMR_SETPIXELOFFSETMODE_OID 0x02030605 //!< PMR_SETPIXELOFFSETMODE PseudoObject type. +#define U_PMR_SETRENDERINGORIGIN_OID 0x02030606 //!< PMR_SETRENDERINGORIGIN PseudoObject type. +#define U_PMR_SETTEXTCONTRAST_OID 0x02030607 //!< PMR_SETTEXTCONTRAST PseudoObject type. +#define U_PMR_SETTEXTRENDERINGHINT_OID 0x02030608 //!< PMR_SETTEXTRENDERINGHINT PseudoObject type. +#define U_PMR_BEGINCONTAINER_OID 0x02030701 //!< PMR_BEGINCONTAINER PseudoObject type. +#define U_PMR_BEGINCONTAINERNOPARAMS_OID 0x02030702 //!< PMR_BEGINCONTAINERNOPARAMS PseudoObject type. +#define U_PMR_ENDCONTAINER_OID 0x02030703 //!< PMR_ENDCONTAINER PseudoObject type. +#define U_PMR_RESTORE_OID 0x02030704 //!< PMR_RESTORE PseudoObject type. +#define U_PMR_SAVE_OID 0x02030705 //!< PMR_SAVE PseudoObject type. +#define U_PMR_SETTSCLIP_OID 0x02030801 //!< PMR_SETTSCLIP PseudoObject type. +#define U_PMR_SETTSGRAPHICS_OID 0x02030802 //!< PMR_SETTSGRAPHICS PseudoObject type. +#define U_PMR_MULTIPLYWORLDTRANSFORM_OID 0x02030901 //!< PMR_MULTIPLYWORLDTRANSFORM PseudoObject type. +#define U_PMR_RESETWORLDTRANSFORM_OID 0x02030902 //!< PMR_RESETWORLDTRANSFORM PseudoObject type. +#define U_PMR_ROTATEWORLDTRANSFORM_OID 0x02030903 //!< PMR_ROTATEWORLDTRANSFORM PseudoObject type. +#define U_PMR_SCALEWORLDTRANSFORM_OID 0x02030904 //!< PMR_SCALEWORLDTRANSFORM PseudoObject type. +#define U_PMR_SETPAGETRANSFORM_OID 0x02030905 //!< PMR_SETPAGETRANSFORM PseudoObject type. +#define U_PMR_SETWORLDTRANSFORM_OID 0x02030906 //!< PMR_SETWORLDTRANSFORM PseudoObject type. +#define U_PMR_TRANSLATEWORLDTRANSFORM_OID 0x02030907 //!< PMR_TRANSLATEWORLDTRANSFORM PseudoObject type. +#define U_PMR_TRANSLATEWORLDTRANSFORM_OID 0x02030907 //!< PMR_TRANSLATEWORLDTRANSFORM PseudoObject type. +#define U_PMR_CMN_HDR_OID 0x40000000 //!< PMR_CMN_HDR PseudoObject type. +#define U_PMF_4NUM_OID 0x40000001 //!< PMF_4NUM PseudoObject type. PseudoObject contains a 4 unsigned int in EMF+ file byte order, used in some contexts to indicate an object index number.. +#define U_PMF_RAW_OID 0x40000002 //!< PMF_RAW PseudoObject type. Raw data: no preceding elements, data has native endianness. +#define U_PMF_ARRAY_OID 0x80000000 //!< PMF_ARRAY PseudoObject type modifier. PseudoObject contains an array of the data type revealed when this bit is cleared. +#define U_PMF_MASK_OID 0x7FFFFFFF //!< PMF_MASK. Select PseudoObject data type without regard to PMF_ARRAY. + +/** @} */ + + +/** \defgroup U_PMF_BDT_ PMF BitmapDataType Enumeration + For + EMF+ manual 2.1.1.2, Microsoft name: BitmapDataType Enumeration (U_BDT_*) + @{ +*/ +#define U_BDT_Pixel 0x00 //!< Data is a bitmap. +#define U_BDT_Compressed 0x01 //!< Data is a compressed bitmap (like a PNG). +/** @} */ + +/** \defgroup U_PMF_BT_ PMF BrushType Enumeration + For + EMF+ manual 2.1.1.3, Microsoft name: BrushType Enumeration (U_BT_*) + @{ +*/ +#define U_BT_SolidColor 0x00 //!< Solid Color brush. +#define U_BT_HatchFill 0x01 //!< Hatch Fill brush. +#define U_BT_TextureFill 0x02 //!< Texture Fill brush. +#define U_BT_PathGradient 0x03 //!< Path Gradient brush. +#define U_BT_LinearGradient 0x04 //!< Linear Gradient brush. +/** @} */ + +/** \defgroup U_PMF_CM_ PMF CombineMode Enumeration + For + EMF+ manual 2.1.1.4, Microsoft name: CombineMode Enumeration (U_CM_*) + @{ +*/ +#define U_CM_Replace 0x00 //!< Region becomes new region. +#define U_CM_Intersect 0x01 //!< Region becomes intersection of existing region and new region. +#define U_CM_Union 0x02 //!< Region becomes union of existing and new regions. +#define U_CM_XOR 0x03 //!< Region becomes XOR of existing and new regions. +#define U_CM_Exclude 0x04 //!< Region becomes part of existing region not in new region. +#define U_CM_Complement 0x05 //!< Region becomes part of new region not in existing region. +/** @} */ + +/** \defgroup U_PMF_CMS_ PMF CompositingMode Enumeration + For + EMF+ manual 2.1.1.5, Microsoft name: CompositingMode Enumeration (U_CMS_* [S==Source]) + @{ +*/ +#define U_CMS_Over 0x00 //!< Source is alpha blends with destination. +#define U_CMS_Copy 0x01 //!< Source over writes destination. +/** @} */ + +/** \defgroup U_PMF_CQ_ PMF CompositingQuality Enumeration + For + EMF+ manual 2.1.1.6, Microsoft name: CompositingQuality Enumeration (U_CQ_*) + @{ +*/ +#define U_CQ_Default 0x01 //!< Default compositing quality +#define U_CQ_HighSpeed 0x02 //!< High Speed compositing quality +#define U_CQ_HighQuality 0x03 //!< High Quality compositing quality +#define U_CQ_GammaCorrected 0x04 //!< Gamma Corrected compositing quality +#define U_CQ_AssumeLinear 0x05 //!< Assume Linear compositing quality +/** @} */ + +/** \defgroup U_PMF_CA_ PMF CurveAdjustments Enumeration + For + EMF+ manual 2.1.1.7, Microsoft name: CurveAdjustments Enumeration (U_CA_*) + @{ +*/ +#define U_CA_Exposure 0x00 //!< Exposure color curve adjustment +#define U_CA_Density 0x01 //!< Density color curve adjustment +#define U_CA_Contrast 0x02 //!< Contrast color curve adjustment +#define U_CA_Highlight 0x03 //!< Highlight color curve adjustment +#define U_CA_Shadow 0x04 //!< Shadow color curve adjustment +#define U_CA_Midtone 0x05 //!< Midtone color curve adjustment +#define U_CA_WhiteSaturation 0x06 //!< White Saturation color curve adjustment +#define U_CA_BlackSaturation 0x07 //!< Black Saturation color curve adjustment +/** @} */ + +/** \defgroup U_PMF_CC_ PMF CurveChannel Enumeration + For + EMF+ manual 2.1.1.8, Microsoft name: CurveChannel Enumeration (U_CC_*) + @{ +*/ +#define U_CC_All 0x00 //!< All color channels +#define U_CC_Red 0x01 //!< Red color channel +#define U_CC_Green 0x02 //!< Green color channel +#define U_CC_Blue 0x03 //!< Blue color channel +/** @} */ + +/** \defgroup U_PMF_CLCDT_ PMF CustomLineCapDataType Enumeration + For + EMF+ manual 2.1.1.9, Microsoft name: CustomLineCapDataType Enumeration (U_CLCDT_*) + @{ +*/ +#define U_CLCDT_Default 0x00 //!< Default custom line cap +#define U_CLCDT_AdjustableArrow 0x01 //!< Adjustable Arrow custom line cap +/** @} */ + +/** \defgroup U_PMF_DLCT_ PMF DashedLineCapType Enumeration + For + EMF+ manual 2.1.1.10, Microsoft name: DashedLineCapType Enumeration (U_DLCT_*) + @{ +*/ +#define U_DLCT_Flat 0x00 //!< Flat dashed line cap +#define U_DLCT_Round 0x02 //!< Round dashed line cap +#define U_DLCT_Triangle 0x03 //!< Triangle dashed line cap +/** @} */ + +/** \defgroup U_PMF_FT_ PMF FilterType Enumeration + For + EMF+ manual 2.1.1.11, Microsoft name: FilterType Enumeration (U_FT_*) + @{ +*/ +#define U_FT_None 0x00 //!< No filtering +#define U_FT_Point 0x01 //!< Point filtering +#define U_FT_Linear 0x02 //!< Linear filtering +#define U_FT_Triangle 0x03 //!< Triangle filtering +#define U_FT_Box 0x04 //!< Box filtering +#define U_FT_PyramidalQuad 0x06 //!< Pyramidal Quad filtering +#define U_FT_GaussianQuad 0x07 //!< Gaussian Quad filtering +/** @} */ + +/** \defgroup U_PMF_GV_ PMF GraphicsVersion Enumeration + For + EMF+ manual 2.1.1.12, Microsoft name: GraphicsVersion Enumeration (U_GV_*) + @{ +*/ +#define U_GV_1 0x01 //!< 1 graphics version +#define U_GV_1_1 0x02 //!< 1.1 graphics version +/** @} */ + +/** \defgroup U_PMF_HSP_ PMF HatchStyle Enumeration + For + EMF+ manual 2.1.1.13, Microsoft name: HatchStyle Enumeration (U_HSP_* [U_HS_ already used for EMF]) + @{ +*/ +#define U_HSP_Horizontal 0x00000000 //!< Horizontal +#define U_HSP_Vertical 0x00000001 //!< Vertical +#define U_HSP_ForwardDiagonal 0x00000002 //!< Forward Diagonal +#define U_HSP_BackwardDiagonal 0x00000003 //!< Backward Diagonal +#define U_HSP_LargeGrid 0x00000004 //!< Large Grid +#define U_HSP_DiagonalCross 0x00000005 //!< Diagonal Cross +#define U_HSP_05Percent 0x00000006 //!< 05 Percent +#define U_HSP_10Percent 0x00000007 //!< 10 Percent +#define U_HSP_20Percent 0x00000008 //!< 20 Percent +#define U_HSP_25Percent 0x00000009 //!< 25 Percent +#define U_HSP_30Percent 0x0000000A //!< 30 Percent +#define U_HSP_40Percent 0x0000000B //!< 40 Percent +#define U_HSP_50Percent 0x0000000C //!< 50 Percent +#define U_HSP_60Percent 0x0000000D //!< 60 Percent +#define U_HSP_70Percent 0x0000000E //!< 70 Percent +#define U_HSP_75Percent 0x0000000F //!< 75 Percent +#define U_HSP_80Percent 0x00000010 //!< 80 Percent +#define U_HSP_90Percent 0x00000011 //!< 90 Percent +#define U_HSP_LightDownwardDiagonal 0x00000012 //!< Light Downward Diagonal +#define U_HSP_LightUpwardDiagonal 0x00000013 //!< Light Upward Diagonal +#define U_HSP_DarkDownwardDiagonal 0x00000014 //!< Dark Downward Diagonal +#define U_HSP_DarkUpwardDiagonal 0x00000015 //!< Dark Upward Diagonal +#define U_HSP_WideDownwardDiagonal 0x00000016 //!< Wide Downward Diagonal +#define U_HSP_WideUpwardDiagonal 0x00000017 //!< Wide Upward Diagonal +#define U_HSP_LightVertical 0x00000018 //!< Light Vertical +#define U_HSP_LightHorizontal 0x00000019 //!< Light Horizontal +#define U_HSP_NarrowVertical 0x0000001A //!< Narrow Vertical +#define U_HSP_NarrowHorizontal 0x0000001B //!< Narrow Horizontal +#define U_HSP_DarkVertical 0x0000001C //!< Dark Vertical +#define U_HSP_DarkHorizontal 0x0000001D //!< Dark Horizontal +#define U_HSP_DashedDownwardDiagonal 0x0000001E //!< Dashed Downward Diagonal +#define U_HSP_DashedUpwardDiagonal 0x0000001F //!< Dashed Upward Diagonal +#define U_HSP_DashedHorizontal 0x00000020 //!< Dashed Horizontal +#define U_HSP_DashedVertical 0x00000021 //!< Dashed Vertical +#define U_HSP_SmallConfetti 0x00000022 //!< Small Confetti +#define U_HSP_LargeConfetti 0x00000023 //!< LargeC onfetti +#define U_HSP_ZigZag 0x00000024 //!< Zig Zag +#define U_HSP_Wave 0x00000025 //!< Wave +#define U_HSP_DiagonalBrick 0x00000026 //!< Diagonal Brick +#define U_HSP_HorizontalBrick 0x00000027 //!< Horizontal Brick +#define U_HSP_Weave 0x00000028 //!< Weave +#define U_HSP_Plaid 0x00000029 //!< Plaid +#define U_HSP_Divot 0x0000002A //!< Divot +#define U_HSP_DottedGrid 0x0000002B //!< DottedGrid +#define U_HSP_DottedDiamond 0x0000002C //!< DottedDiamond +#define U_HSP_Shingle 0x0000002D //!< Shingle +#define U_HSP_Trellis 0x0000002E //!< Trellis +#define U_HSP_Sphere 0x0000002F //!< Sphere +#define U_HSP_SmallGrid 0x00000030 //!< Small Grid +#define U_HSP_SmallCheckerBoard 0x00000031 //!< Small Checker Board +#define U_HSP_LargeCheckerBoard 0x00000032 //!< Large Checker Board +#define U_HSP_OutlinedDiamond 0x00000033 //!< Outlined Diamond +#define U_HSP_SolidDiamond 0x00000034 //!< Solid Diamond +/** @} */ + +/** \defgroup U_PMF_HKP_ PMF HotkeyPrefix Enumeration + For + EMF+ manual 2.1.1.14, Microsoft name: HotkeyPrefix Enumeration (U_HKP_*) + @{ +*/ +#define U_HKP_None 0x00 //!< No hot key prefix +#define U_HKP_Show 0x01 //!< Show hot key prefix +#define U_HKP_Hide 0x02 //!< Hide hot key prefix +/** @} */ + +/** \defgroup U_PMF_IDT_ PMF ImageDataType Enumeration + For + EMF+ manual 2.1.1.15, Microsoft name: ImageDataType Enumeration (U_IDT_*) + @{ +*/ +#define U_IDT_Unknown 0x00 //!< Unknown image data type +#define U_IDT_Bitmap 0x01 //!< Bitmap image data type +#define U_IDT_Metafile 0x02 //!< Metafile image data type +/** @} */ + +/** \defgroup U_PMF_IM_ PMF InterpolationMode Enumeration + For + EMF+ manual 2.1.1.16, Microsoft name: InterpolationMode Enumeration (U_IM_*) + @{ +*/ +#define U_IM_Default 0x00 //!< Default interpolation mode +#define U_IM_LowQuality 0x01 //!< Low Quality interpolation mode +#define U_IM_HighQuality 0x02 //!< High Quality interpolation mode +#define U_IM_Bilinear 0x03 //!< Bilinear interpolation mode +#define U_IM_Bicubic 0x04 //!< Bicubic interpolation mode +#define U_IM_NearestNeighbor 0x05 //!< Nearest Neighbor interpolation mode +#define U_IM_HighQualityBilinear 0x06 //!< High Quality Bilinear interpolation mode +#define U_IM_HighQualityBicubic 0x07 //!< High Quality Bicubic interpolation mode +/** @} */ + +/** \defgroup U_PMF_LID_ PMF LanguageIdentifier Enumeration + For + EMF+ manual 2.1.1.17, Microsoft name: LanguageIdentifier Enumeration (U_LID_*) + @{ +*/ +#define U_LID_LANG_NEUTRAL 0x0000 //!< LANG_NEUTRAL +#define U_LID_zh_CHS 0x0004 //!< zh_CHS +#define U_LID_LANG_INVARIANT 0x007F //!< LANG_INVARIANT +#define U_LID_LANG_NEUTRAL_USER_DEFAULT 0x0400 //!< LANG_NEUTRAL_USER_DEFAULT +#define U_LID_ar_SA 0x0401 //!< ar_SA +#define U_LID_bg_BG 0x0402 //!< bg_BG +#define U_LID_ca_ES 0x0403 //!< ca_ES +#define U_LID_zh_CHT 0x0404 //!< zh_CHT +#define U_LID_cs_CZ 0x0405 //!< cs_CZ +#define U_LID_da_DK 0x0406 //!< da_DK +#define U_LID_de_DE 0x0407 //!< de_DE +#define U_LID_el_GR 0x0408 //!< el_GR +#define U_LID_en_US 0x0409 //!< en_US +#define U_LID_es_Tradnl_ES 0x040A //!< es_Tradnl_ES +#define U_LID_fi_FI 0x040B //!< fi_FI +#define U_LID_fr_FR 0x040C //!< fr_FR +#define U_LID_he_IL 0x040D //!< he_IL +#define U_LID_hu_HU 0x040E //!< hu_HU +#define U_LID_is_IS 0x040F //!< is_IS +#define U_LID_it_IT 0x0410 //!< it_IT +#define U_LID_ja_JA 0x0411 //!< ja_JA +#define U_LID_ko_KR 0x0412 //!< ko_KR +#define U_LID_nl_NL 0x0413 //!< nl_NL +#define U_LID_nb_NO 0x0414 //!< nb_NO +#define U_LID_pl_PL 0x0415 //!< pl_PL +#define U_LID_pt_BR 0x0416 //!< pt_BR +#define U_LID_rm_CH 0x0417 //!< rm_CH +#define U_LID_ro_RO 0x0418 //!< ro_RO +#define U_LID_ru_RU 0x0419 //!< ru_RU +#define U_LID_hr_HR 0x041A //!< hr_HR +#define U_LID_sk_SK 0x041B //!< sk_SK +#define U_LID_sq_AL 0x041C //!< sq_AL +#define U_LID_sv_SE 0x041D //!< sv_SE +#define U_LID_th_TH 0x041E //!< th_TH +#define U_LID_tr_TR 0x041F //!< tr_TR +#define U_LID_ur_PK 0x0420 //!< ur_PK +#define U_LID_id_ID 0x0421 //!< id_ID +#define U_LID_uk_UA 0x0422 //!< uk_UA +#define U_LID_be_BY 0x0423 //!< be_BY +#define U_LID_sl_SI 0x0424 //!< sl_SI +#define U_LID_et_EE 0x0425 //!< et_EE +#define U_LID_lv_LV 0x0426 //!< lv_LV +#define U_LID_lt_LT 0x0427 //!< lt_LT +#define U_LID_tg_TJ 0x0428 //!< tg_TJ +#define U_LID_fa_IR 0x0429 //!< fa_IR +#define U_LID_vi_VN 0x042A //!< vi_VN +#define U_LID_hy_AM 0x042B //!< hy_AM +#define U_LID_az_Latn_AZ 0x042C //!< az_Latn_AZ +#define U_LID_eu_ES 0x042D //!< eu_ES +#define U_LID_wen_DE 0x042E //!< wen_DE +#define U_LID_mk_MK 0x042F //!< mk_MK +#define U_LID_st_ZA 0x0430 //!< st_ZA +#define U_LID_tn_ZA 0x0432 //!< tn_ZA +#define U_LID_xh_ZA 0x0434 //!< xh_ZA +#define U_LID_zu_ZA 0x0435 //!< zu_ZA +#define U_LID_af_ZA 0x0436 //!< af_ZA +#define U_LID_ka_GE 0x0437 //!< ka_GE +#define U_LID_fa_FA 0x0438 //!< fa_FA +#define U_LID_hi_IN 0x0439 //!< hi_IN +#define U_LID_mt_MT 0x043A //!< mt_MT +#define U_LID_se_NO 0x043B //!< se_NO +#define U_LID_ga_GB 0x043C //!< ga_GB +#define U_LID_ms_MY 0x043E //!< ms_MY +#define U_LID_kk_KZ 0x043F //!< kk_KZ +#define U_LID_ky_KG 0x0440 //!< ky_KG +#define U_LID_sw_KE 0x0441 //!< sw_KE +#define U_LID_tk_TM 0x0442 //!< tk_TM +#define U_LID_uz_Latn_UZ 0x0443 //!< uz_Latn_UZ +#define U_LID_tt_Ru 0x0444 //!< tt_Ru +#define U_LID_bn_IN 0x0445 //!< bn_IN +#define U_LID_pa_IN 0x0446 //!< pa_IN +#define U_LID_gu_IN 0x0447 //!< gu_IN +#define U_LID_or_IN 0x0448 //!< or_IN +#define U_LID_ta_IN 0x0449 //!< ta_IN +#define U_LID_te_IN 0x044A //!< te_IN +#define U_LID_kn_IN 0x044B //!< kn_IN +#define U_LID_ml_IN 0x044C //!< ml_IN +#define U_LID_as_IN 0x044D //!< as_IN +#define U_LID_mr_IN 0x044E //!< mr_IN +#define U_LID_sa_IN 0x044F //!< sa_IN +#define U_LID_mn_MN 0x0450 //!< mn_MN +#define U_LID_bo_CN 0x0451 //!< bo_CN +#define U_LID_cy_GB 0x0452 //!< cy_GB +#define U_LID_km_KH 0x0453 //!< km_KH +#define U_LID_lo_LA 0x0454 //!< lo_LA +#define U_LID_gl_ES 0x0456 //!< gl_ES +#define U_LID_kok_IN 0x0457 //!< kok_IN +#define U_LID_sd_IN 0x0459 //!< sd_IN +#define U_LID_syr_SY 0x045A //!< syr_SY +#define U_LID_si_LK 0x045B //!< si_LK +#define U_LID_iu_Cans_CA 0x045D //!< iu_Cans_CA +#define U_LID_am_ET 0x045E //!< am_ET +#define U_LID_ne_NP 0x0461 //!< ne_NP +#define U_LID_fy_NL 0x0462 //!< fy_NL +#define U_LID_ps_AF 0x0463 //!< ps_AF +#define U_LID_fil_PH 0x0464 //!< fil_PH +#define U_LID_div_MV 0x0465 //!< div_MV +#define U_LID_ha_Latn_NG 0x0468 //!< ha_Latn_NG +#define U_LID_yo_NG 0x046A //!< yo_NG +#define U_LID_quz_BO 0x046B //!< quz_BO +#define U_LID_nzo_ZA 0x046C //!< nzo_ZA +#define U_LID_ba_RU 0x046D //!< ba_RU +#define U_LID_lb_LU 0x046E //!< lb_LU +#define U_LID_kl_GL 0x046F //!< kl_GL +#define U_LID_ig_NG 0x0470 //!< ig_NG +#define U_LID_so_SO 0x0477 //!< so_SO +#define U_LID_ii_CN 0x0478 //!< ii_CN +#define U_LID_arn_CL 0x047A //!< arn_CL +#define U_LID_moh_CA 0x047C //!< moh_CA +#define U_LID_br_FR 0x047E //!< br_FR +#define U_LID_ug_CN 0x0480 //!< ug_CN +#define U_LID_ mi_NZ 0x0481 //!< mi_NZ +#define U_LID_oc_FR 0x0482 //!< oc_FR +#define U_LID_co_FR 0x0483 //!< co_FR +#define U_LID_gsw_FR 0x0484 //!< gsw_FR +#define U_LID_sah_RU 0x0485 //!< sah_RU +#define U_LID_qut_GT 0x0486 //!< qut_GT +#define U_LID_rw_RW 0x0487 //!< rw_RW +#define U_LID_wo_SN 0x0488 //!< wo_SN +#define U_LID_gbz_AF 0x048C //!< gbz_AF +#define U_LID_LANG_NEUTRAL_SYS_DEFAULT 0x0800 //!< LANG_NEUTRAL_SYS_DEFAULT +#define U_LID_ar_IQ 0x0801 //!< ar_IQ +#define U_LID_zh_CN 0x0804 //!< zh_CN +#define U_LID_de_CH 0x0807 //!< de_CH +#define U_LID_en_GB 0x0809 //!< en_GB +#define U_LID_es_MX 0x080A //!< es_MX +#define U_LID_fr_BE 0x080C //!< fr_BE +#define U_LID_it_CH 0x0810 //!< it_CH +#define U_LID_ko_Johab_KR 0x0812 //!< ko_Johab_KR +#define U_LID_nl_BE 0x0813 //!< nl_BE +#define U_LID_nn_NO 0x0814 //!< nn_NO +#define U_LID_pt_PT 0x0816 //!< pt_PT +#define U_LID_sr_Latn_SP 0x081A //!< sr_Latn_SP +#define U_LID_sv_FI 0x081D //!< sv_FI +#define U_LID_ur_IN 0x0820 //!< ur_IN +#define U_LID_lt_C_LT 0x0827 //!< lt_C_LT +#define U_LID_az_Cyrl_AZ 0x082C //!< az_Cyrl_AZ +#define U_LID_wee_DE 0x082E //!< wee_DE +#define U_LID_se_SE 0x083B //!< se_SE +#define U_LID_ga_IE 0x083C //!< ga_IE +#define U_LID_ms_BN 0x083E //!< ms_BN +#define U_LID_uz_Cyrl_UZ 0x0843 //!< uz_Cyrl_UZ +#define U_LID_bn_BD 0x0845 //!< bn_BD +#define U_LID_mn_Mong_CN 0x0850 //!< mn_Mong_CN +#define U_LID_sd_PK 0x0859 //!< sd_PK +#define U_LID_iu_Latn_CA 0x085D //!< iu_Latn_CA +#define U_LID_tzm_Latn_DZ 0x085F //!< tzm_Latn_DZ +#define U_LID_quz_EC 0x086B //!< quz_EC +#define U_LID_LANG_NEUTRAL_CUSTOM_DEFAULT 0x0C00 //!< LANG_NEUTRAL_CUSTOM_DEFAULT +#define U_LID_ar_EG 0x0C01 //!< ar_EG +#define U_LID_zh_HK 0x0C04 //!< zh_HK +#define U_LID_de_AT 0x0C07 //!< de_AT +#define U_LID_en_AU 0x0C09 //!< en_AU +#define U_LID_es_ES 0x0C0A //!< es_ES +#define U_LID_fr_CA 0x0C0C //!< fr_CA +#define U_LID_sr_Cyrl_CS 0x0C1A //!< sr_Cyrl_CS +#define U_LID_se_FI 0x0C3B //!< se_FI +#define U_LID_quz_PE 0x0C6B //!< quz_PE +#define U_LID_LANG_NEUTRAL_CUSTOM 0x1000 //!< LANG_NEUTRAL_CUSTOM +#define U_LID_ar_LY 0x1001 //!< ar_LY +#define U_LID_zh_SG 0x1004 //!< zh_SG +#define U_LID_de_LU 0x1007 //!< de_LU +#define U_LID_en_CA 0x1009 //!< en_CA +#define U_LID_es_GT 0x100A //!< es_GT +#define U_LID_fr_CH 0x100C //!< fr_CH +#define U_LID_hr_BA 0x101A //!< hr_BA +#define U_LID_smj_NO 0x103B //!< smj_NO +#define U_LID_LANG_NEUTRAL_CUSTOM_DEFAULT_MUI 0x1400 //!< LANG_NEUTRAL_CUSTOM_DEFAULT_MUI +#define U_LID_ar_DZ 0x1401 //!< ar_DZ +#define U_LID_zh_MO 0x1404 //!< zh_MO +#define U_LID_de_LI 0x1407 //!< de_LI +#define U_LID_en_NZ 0x1409 //!< en_NZ +#define U_LID_es_CR 0x140A //!< es_CR +#define U_LID_fr_LU 0x140C //!< fr_LU +#define U_LID_bs_Latn_BA 0x141A //!< bs_Latn_BA +#define U_LID_smj_SE 0x143B //!< smj_SE +#define U_LID_ar_MA 0x1801 //!< ar_MA +#define U_LID_en_IE 0x1809 //!< en_IE +#define U_LID_es_PA 0x180A //!< es_PA +#define U_LID_ar_MC 0x180C //!< ar_MC +#define U_LID_sr_Latn_BA 0x181A //!< sr_Latn_BA +#define U_LID_sma_NO 0x183B //!< sma_NO +#define U_LID_ar_TN 0x1C01 //!< ar_TN +#define U_LID_en_ZA 0x1C09 //!< en_ZA +#define U_LID_es_DO 0x1C0A //!< es_DO +#define U_LID_sr_Cyrl_BA 0x1C1A //!< sr_Cyrl_BA +#define U_LID_sma_SE 0x1C3B //!< sma_SE +#define U_LID_ar_OM 0x2001 //!< ar_OM +#define U_LID_el_2_GR 0x2008 //!< el_2_GR +#define U_LID_en_JM 0x2009 //!< en_JM +#define U_LID_es_VE 0x200A //!< es_VE +#define U_LID_bs_Cyrl_BA 0x201A //!< bs_Cyrl_BA +#define U_LID_sms_FI 0x203B //!< sms_FI +#define U_LID_ar_YE 0x2401 //!< ar_YE +#define U_LID_ar_029 0x2409 //!< ar_029 +#define U_LID_es_CO 0x240A //!< es_CO +#define U_LID_smn_FI 0x243B //!< smn_FI +#define U_LID_ar_SY 0x2801 //!< ar_SY +#define U_LID_en_BZ 0x2809 //!< en_BZ +#define U_LID_es_PE 0x280A //!< es_PE +#define U_LID_ar_JO 0x2C01 //!< ar_JO +#define U_LID_en_TT 0x2C09 //!< en_TT +#define U_LID_es_AR 0x2C0A //!< es_AR +#define U_LID_ar_LB 0x3001 //!< ar_LB +#define U_LID_en_ZW 0x3009 //!< en_ZW +#define U_LID_es_EC 0x300A //!< es_EC +#define U_LID_ar_KW 0x3401 //!< ar_KW +#define U_LID_en_PH 0x3409 //!< en_PH +#define U_LID_es_CL 0x340A //!< es_CL +#define U_LID_ar_AE 0x3801 //!< ar_AE +#define U_LID_es_UY 0x380A //!< es_UY +#define U_LID_ar_BH 0x3C01 //!< ar_BH +#define U_LID_es_PY 0x3C0A //!< es_PY +#define U_LID_ar_QA 0x4001 //!< ar_QA +#define U_LID_en_IN 0x4009 //!< en_IN +#define U_LID_es_BO 0x400A //!< es_BO +#define U_LID_en_MY 0x4409 //!< en_MY +#define U_LID_es_SV 0x440A //!< es_SV +#define U_LID_en_SG 0x4809 //!< en_SG +#define U_LID_es_HN 0x480A //!< es_HN +#define U_LID_es_NI 0x4C0A //!< es_NI +#define U_LID_es_PR 0x500A //!< es_PR +#define U_LID_es_US 0x540A //!< es_US +#define U_LID_zh_Hant 0x7C04 //!< zh_Hant +#define U_LID_SEC_MASK 0xFB00 //!< Mask for region part of LID +#define U_LID_PRI_MASK 0x03FF //!< MASK for languagepart of LID +/** @} */ + +/** \defgroup U_PMF_LCT_ PMF LineCapType Enumeration + For + EMF+ manual 2.1.1.18, Microsoft name: LineCapType Enumeration (U_LCT_*) + @{ +*/ +#define U_LCT_Flat 0x00 //!< Flat line cap +#define U_LCT_Square 0x01 //!< Square line cap +#define U_LCT_Round 0x02 //!< Round line cap +#define U_LCT_Triangle 0x03 //!< Triangle line cap +#define U_LCT_NoAnchor 0x10 //!< No Anchor line cap +#define U_LCT_SquareAnchor 0x11 //!< Square Anchor line cap +#define U_LCT_RoundAnchor 0x12 //!< Round Anchor line cap +#define U_LCT_DiamondAnchor 0x13 //!< Diamond Anchor line cap +#define U_LCT_ArrowAnchor 0x14 //!< Arrow Anchor line cap +#define U_LCT_AnchorMask 0xF0 //!< Ancho rMask line cap +#define U_LCT_Custom 0xFF //!< Custom line cap +/** @} */ + +/** \defgroup U_PMF_LJT_ PMF LineJoinType Enumeration + For + EMF+ manual 2.1.1.19, Microsoft name: LineJoinType Enumeration (U_LJT_*) + @{ +*/ +#define U_LJT_Miter 0x00 //!< Miter line join +#define U_LJT_Bevel 0x01 //!< Bevel line join +#define U_LJT_Round 0x02 //!< Round line join +#define U_LJT_MiterClipped 0x03 //!< Miter Clipped line join +/** @} */ + +/** \defgroup U_PMF_LS_ PMF LineStyle Enumeration + For + EMF+ manual 2.1.1.20, Microsoft name: LineStyle Enumeration (U_LS_*) + @{ +*/ +#define U_LS_Solid 0x00 //!< Solid line +#define U_LS_Dash 0x01 //!< Dashed line +#define U_LS_Dot 0x02 //!< Dotted line +#define U_LS_DashDot 0x03 //!< Dash Dot line +#define U_LS_DashDotDot 0x04 //!< Dash Dot Dot line +#define U_LS_Custom 0x05 //!< Custom line +/** @} */ + +/** \defgroup U_PMF_MDT_ PMF MetafileDataType Enumeration + For + EMF+ manual 2.1.1.21, Microsoft name: MetafileDataType Enumeration (U_MDT_*) + @{ +*/ +#define U_MDT_Wmf 0x01 //!< WMF metafile +#define U_MDT_WmfPlaceable 0x02 //!< WMF placeable metafile +#define U_MDT_Emf 0x03 //!< EMF metafile +#define U_MDT_EmfPlusOnly 0x04 //!< EMF+ single mode metafile +#define U_MDT_EmfPlusDual 0x05 //!< EMF+ dual mode metafile +/** @} */ + +/** \defgroup U_PMF_OT_ PMF ObjectType Enumeration + For + EMF+ manual 2.1.1.22, Microsoft name: ObjectType Enumeration (U_OT_*) + @{ +*/ +#define U_OT_Invalid 0x00 //!< Invalid object +#define U_OT_Brush 0x01 //!< Brush object +#define U_OT_Pen 0x02 //!< Pen object +#define U_OT_Path 0x03 //!< Path object +#define U_OT_Region 0x04 //!< Region object +#define U_OT_Image 0x05 //!< Image object +#define U_OT_Font 0x06 //!< Font object +#define U_OT_StringFormat 0x07 //!< StringFormat object +#define U_OT_ImageAttributes 0x08 //!< ImageAttributes object +#define U_OT_CustomLineCap 0x09 //!< CustomLineCap object +/** @} */ + +/** \defgroup U_PMF_PPT_ PMF PathPointType Enumeration + For + EMF+ manual 2.1.1.23, Microsoft name: PathPointType Enumeration (U_PPT_*) + @{ +*/ +#define U_PPT_Start 0x00 //!< Start of path +#define U_PPT_Line 0x01 //!< Line path +#define U_PPT_Bezier 0x03 //!< Bezier path +#define U_PPT_MASK 0x0F //!< MASK for bits in flag +/** @} */ + +/** \defgroup U_PMF_PA_ PMF PenAlignment Enumeration + For + EMF+ manual 2.1.1.24, Microsoft name: PenAlignment Enumeration (U_PA_*) + @{ +*/ +#define U_PA_Center 0x00 //!< Center pen alignment +#define U_PA_Inset 0x01 //!< Inset pen alignment +#define U_PA_Left 0x02 //!< Left pen alignment +#define U_PA_Outset 0x03 //!< Outset pen alignment +#define U_PA_Right 0x04 //!< Right pen alignment +/** @} */ + +/** \defgroup U_PMF_PF_ PMF PixelFormat Enumeration + For U_PMF_BITMAP PxFormat field + EMF+ manual 2.1.1.25, Microsoft name: PixelFormat Enumeration (U_PF_*) + + Bitmap for this 32 bit value is: + 0-9 ignored + 10 Set: 32 bit ARGB; Clear: !32 bit ARGB + 11 Set: 16 bits/channel; Clear: !16 bits + 12 Set: colors premultiplied by alpha; Clear: !premultiplied + 13 Set: has Alpha; Clear: !has Alpha + 14 Set: Windows GDI supports; Clear: !Windows GDI supports + 15 Set: uses LUT; Clear !uses LUT + 16-23 = total number of BITS per pixel + 24-31 = pixel format enumeration index (0->15) + @{ +*/ +#define U_PF_Undefined 0x00000000 //!< undefined Pixel Format +#define U_PF_1bppIndexed 0x00030101 //!< monochrome with LUT +#define U_PF_4bppIndexed 0x00030402 //!< 4 bit with LUT +#define U_PF_8bppIndexed 0x00030803 //!< 8 bit with LUT +#define U_PF_16bppGrayScale 0x00101004 //!< 16 bits grey values +#define U_PF_16bppRGB555 0x00021005 //!< 16 bit RGB values (5,5,5,(1 ignored)) +#define U_PF_16bppRGB565 0x00021006 //!< 16 bit RGB values (5,6,5) +#define U_PF_16bppARGB1555 0x00061007 //!< 16 bit ARGB values (1 alpha, 5,5,5 colors) +#define U_PF_24bppRGB 0x00021808 //!< 24 bit RGB values (8,8.8) +#define U_PF_32bppRGB 0x00022009 //!< 32 bit RGB value (8,8,8,(8 ignored)) +#define U_PF_32bppARGB 0x0026200A //!< 32 bit ARGB values (8 alpha,8,8,8) +#define U_PF_32bppPARGB 0x000E200B //!< 32 bit PARGB values (8,8,8,8, but RGB already multiplied by A) +#define U_PF_48bppRGB 0x0010300C //!< 48 bit RGB (16,16,16) +#define U_PF_64bppARGB 0x0034400D //!< 64 bit ARGB (16 alpha, 16,16,16) +#define U_PF_64bppPARGB 0x001A400E //!< 64 bit PARGB (16,16,16,16, but RGB already multiplied by A) +/** @} */ + +/** \defgroup U_PMF_POM_ PMF PixelOffsetMode Enumeration + For + EMF+ manual 2.1.1.26, Microsoft name: PixelOffsetMode Enumeration (U_POM_*) + @{ +*/ +#define U_POM_Default 0x00 //!< center at {0.0,0.0} +#define U_POM_HighSpeed 0x01 //!< center at {0.0,0.0} +#define U_POM_HighQuality 0x02 //!< center at {0.5,0.5} +#define U_POM_None 0x03 //!< center at {0.0,0.0} +#define U_POM_Half 0x04 //!< center at {0.5,0.5} +/** @} */ + +/** \defgroup U_PMF_RNDT_ PMF RegionNodeDataType Enumeration + For + EMF+ manual 2.1.1.27, Microsoft name: RegionNodeDataType Enumeration (U_RNDT_*) + @{ +*/ +#define U_RNDT_Kids 0x00000000 //!< One of the next 5 is to be applied +#define U_RNDT_And 0x00000001 //!< AND the child nodes +#define U_RNDT_Or 0x00000002 //!< OR the child nodes +#define U_RNDT_Xor 0x00000003 //!< XOR the child nodes +#define U_RNDT_Exclude 0x00000004 //!< Part of 1st child node not in 2nd child node +#define U_RNDT_Complement 0x00000005 //!< Part of 2nd child node not in 1st child node +#define U_RNDT_Rect 0x10000000 //!< Child node is a rectangle +#define U_RNDT_Path 0x10000001 //!< Child node is a path +#define U_RNDT_Empty 0x10000002 //!< Child node is empty +#define U_RNDT_Infinite 0x10000003 //!< Child node has infinite extent (?) +/** @} */ + +/** \defgroup U_PMF_SM_ PMF SmoothingMode Enumeration + For + EMF+ manual 2.1.1.28, Microsoft name: SmoothingMode Enumeration (U_SM_*) + @{ +*/ +#define U_SM_Default 0x00 //!< Default smoothing +#define U_SM_HighSpeed 0x01 //!< High Speed smoothing +#define U_SM_HighQuality 0x02 //!< High Quality smoothing +#define U_SM_None 0x03 //!< No smoothing +#define U_SM_AntiAlias8x4 0x04 //!< Anti Alias 8x4 smoothing +#define U_SM_AntiAlias8x8 0x05 //!< Anti Alias 8x8 smoothing +/** @} */ + +/** \defgroup U_PMF_SA_ PMF StringAlignment Enumeration + For + EMF+ manual 2.1.1.29, Microsoft name: StringAlignment Enumeration (U_SA_*) + + Note, that unlike EMF these are with respect to the bounding rectangle, not to a single point. So + to draw centered text, for instance, U_SA_Center must be used, and the bounding rectangle must also be + centered. + + For horizontal positioning of L->R text Near is all the way left in the box, Far is all the way right, + and Center puts the center of the text in the center of the box. + + For vertical positioning things are a little strange. Near is a certain distance down from the top, Far is a + certain distance up from the bottom, and center puts the center of the text in the center of the box. The + "certain distance" is not specified in the EMF+ documentation. See the function U_PMR_drawstring() for an + implementation that places text on the baseline. + @{ +*/ +#define U_SA_Near 0x00 //!< Position near +#define U_SA_Center 0x01 //!< Position center +#define U_SA_Far 0x02 //!< Position far +/** @} */ + +/** \defgroup U_PMF_SDS_ PMF StringDigitSubstitution Enumeration + For + EMF+ manual 2.1.1.30, Microsoft name: StringDigitSubstitution Enumeration (U_SDS_*) + @{ +*/ +#define U_SDS_User 0x00 //!< Digit substitution is set by implementation +#define U_SDS_None 0x01 //!< No Digit substitution +#define U_SDS_National 0x02 //!< Digit substitution by official locale +#define U_SDS_Traditional 0x03 //!< Digit substitution by traditional locale +/** @} */ + +/** \defgroup U_PMF_ST_ PMF StringTrimming Enumeration + For + EMF+ manual 2.1.1.31, Microsoft name: StringTrimming Enumeration (U_ST_*) + @{ +*/ +#define U_ST_None 0x00 //!< no string trimming +#define U_ST_Character 0x01 //!< Trim at Character +#define U_ST_Word 0x02 //!< Trim at Word +#define U_ST_EllipsisCharacter 0x03 //!< Trim at Ellipsis Character +#define U_ST_EllipsisWord 0x04 //!< Trim at Ellipsis Word +#define U_ST_EllipsisPath 0x05 //!< Trim at Ellipsis Path +/** @} */ + +/** \defgroup U_PMF_TRH_ PMF TextRenderingHint Enumeration + For + EMF+ manual 2.1.1.32, Microsoft name: TextRenderingHint Enumeration (U_TRH_*) + @{ +*/ +#define U_TRH_SystemDefault 0x00 //!< System Default +#define U_TRH_SingleBitPerPixelGridFit 0x01 //!< Single Bit Per Pixel Grid Fit +#define U_TRH_SingleBitPerPixel 0x02 //!< Single Bit Per Pixel +#define U_TRH_AntialiasGridFit 0x03 //!< Antialias Grid Fit +#define U_TRH_Antialias 0x04 //!< Antialias +#define U_TRH_ClearTypeGridFit 0x05 //!< ClearType Grid Fit +/** @} */ + +/** \defgroup U_PMF_UT_ PMF UnitType Enumeration + For + EMF+ manual 2.1.1.33, Microsoft name: UnitType Enumeration (U_UT_*) + @{ +*/ +#define U_UT_World 0x00 //!< World units +#define U_UT_Display 0x01 //!< Display units +#define U_UT_Pixel 0x02 //!< Pixel units +#define U_UT_Point 0x03 //!< Point units +#define U_UT_Inch 0x04 //!< Inch units +#define U_UT_Document 0x05 //!< Document units +#define U_UT_Millimeter 0x06 //!< Millimeter units +/** @} */ + +/** \defgroup U_PMF_WM_ PMF WrapMode Enumeration + For + EMF+ manual 2.1.1.34, Microsoft name: WrapMode Enumeration (U_WM_*) + @{ +*/ +#define U_WM_Tile 0x00000000 //!< Tile +#define U_WM_TileFlipX 0x00000001 //!< Reverse horizontally then tile +#define U_WM_TileFlipY 0x00000002 //!< Reverse vertically then tile +#define U_WM_TileFlipXY 0x00000003 //!< Reverse horizontally and vertically then tile +#define U_WM_Clamp 0x00000004 //!< Clamp pattern to the object boundary +/** @} */ + +/** \defgroup U_PMF_BD_ PMF BrushData Flags + For + EMF+ manual 2.1.2.1, Microsoft name: BrushData Flags (U_BD_*) + + Bit flags allowed in brush object types. Each bit indicates a type of object which is included. + There are 5 brush types abbreviated A through E, and each uses a subset of the + BrushData Flags, as summarized in the following table: + + Bits Brush____Type EMF+ Manual + used Abbrev. Name + 5 A U_PMF_LINEARGRADIENTBRUSHDATA 2.2.2.24 + 6 B U_PMF_PATHGRADIENTBRUSHDATA 2.2.2.29 + 3 C U_PMF_TEXTUREBRUSHDATA 2.2.2.45 + 0 D U_PMF_HATCHBRUSHDATA 2.2.2.20 + 0 E U_PMF_SOLIDBRUSHDATA 2.2.2.45 + @{ +*/ +#define U_BD_None 0x0000 //!< no bits set +#define U_BD_Path 0x0001 //!< Path, in {B} +#define U_BD_Transform 0x0002 //!< Transform in {ABC} +#define U_BD_PresetColors 0x0004 //!< PresetColors in {AB} +#define U_BD_BlendFactorsH 0x0008 //!< BlendFactorsH in {AB} +#define U_BD_BlendFactorsV 0x0010 //!< BlendFactorsV in {A} - Note, not actually implemented in GDI+. +#define U_BD_NoBit 0x0020 //!< unused bit +#define U_BD_FocusScales 0x0040 //!< Focus Scales in {B} +#define U_BD_IsGammaCorrected 0x0080 //!< GammaCorrected in {ABC} +#define U_BD_DoNotTransform 0x0100 //!< Ignore world to device transform in {C} +#define U_BD_MASKA 0x009E //!< all bits that MAY be set in A +#define U_BD_MASKB 0x00CF //!< all bits that MAY be set in B +#define U_BD_MASKC 0x0182 //!< all bits that MAY be set in C +/** @} */ + +/** \defgroup U_PMF_CLCD_ PMF CustomLineCapData Flags + For + EMF+ manual 2.1.2.2, Microsoft name: CustomLineCapData Flags (U_CLCD_*) + @{ +*/ +#define U_CLCD_None 0x00 //!< no bits set +#define U_CLCD_FillPath 0x01 //!< Fill Path +#define U_CLCD_LinePath 0x02 //!< Line Path +/** @} */ + +/** \defgroup U_PMF_DSO_ PMF DriverStringOptions Flags + For + EMF+ manual 2.1.2.3, Microsoft name: DriverStringOptions Flags (U_DSO_*) + @{ +*/ +#define U_DSO_None 0x00 //!< no bits set +#define U_DSO_CmapLookup 0x01 //!< Set: value is a Unicode character; Clear: value is an index into Glyph table in a font +#define U_DSO_Vertical 0x02 //!< Set: draw string verically; Clear: draw horizontally +#define U_DSO_RealizedAdvance 0x04 /**< Set: U_PMF_DRAWDRIVERSTRING Positions field specifies only position of first of Glyphs field, + with the rest calculated from font information; Clear: Positions specifies coordinates for each Glyphs member.*/ +#define U_DSO_LimitSubpixel 0x08 //!< Set: use less memory to cache anti-aliased glyphs; Clear: use more +/** @} */ + +/** \defgroup U_PMF_FS_ PMF FontStyle Flags + For + EMF+ manual 2.1.2.4, Microsoft name: FontStyle Flags (U_FS_*) +# @{ +*/ +#define U_FS_None 0x00 //!< no bits set +#define U_FS_Bold 0x01 //!< Bold +#define U_FS_Italic 0x02 //!< Italic +#define U_FS_Underline 0x04 //!< Underline +#define U_FS_Strikeout 0x08 //!< Strikeout +/** @} */ + +/** \defgroup U_PMF_PLTS_ PMF PaletteStyle Flags + For + EMF+ manual 2.1.2.5, Microsoft name: PaletteStyle Flags (U_PLTS_*) + @{ +*/ +#define U_PLTS_None 0x00 //!< no bits set +#define U_PLTS_HasAlpha 0x01 //!< Has Alpha +#define U_PLTS_GrayScale 0x02 //!< Gray Scale +#define U_PLTS_Halftone 0x04 //!< Halftone +/** @} */ + +/** \defgroup U_PMF_PTP_ PMF PathPointType Flags + For + EMF+ manual 2.1.2.6, Microsoft name: PathPointType Flags (U_PTP_*) + @{ +*/ +#define U_PTP_None 0x00 //!< no bits set +#define U_PTP_DashMode 0x10 //!< Dash Mode +#define U_PTP_PathMarker 0x20 //!< Path Marker +#define U_PTP_NoBit 0x40 //!< unused bit +#define U_PTP_CloseSubpath 0x80 //!< CloseSubpath +#define U_PTP_NotClose 0x70 //!< Everything but close +#define U_PTP_MASK 0xF0 //!< Everything +#define U_PTP_SHIFT 4 //!< offset to this bitfield +/** @} */ + +/** \defgroup U_PMF_PD_ PMF PenData Flags + For + EMF+ manual 2.1.2.7, Microsoft name: PenData Flags (U_PD_*) + +If bit is set the corresponding object must be specfied in the OptionalData field + + @{ +*/ +#define U_PD_None 0x0000 //!< no bits set +#define U_PD_Transform 0x0001 //!< Transform +#define U_PD_StartCap 0x0002 //!< Start Cap +#define U_PD_EndCap 0x0004 //!< End Cap +#define U_PD_Join 0x0008 //!< Join +#define U_PD_MiterLimit 0x0010 //!< Miter Limit +#define U_PD_LineStyle 0x0020 //!< Line Style +#define U_PD_DLCap 0x0040 //!< Dashed Line Cap +#define U_PD_DLOffset 0x0080 //!< Dashed Line Offset +#define U_PD_DLData 0x0100 //!< Dashed Line Data +#define U_PD_NonCenter 0x0200 //!< Alignment must be specified with optinal data +#define U_PD_CLData 0x0400 //!< Compound Line Data +#define U_PD_CustomStartCap 0x0800 //!< Custom Start Cap +#define U_PD_CustomEndCap 0x1000 //!< Custom End Cap +/** @} */ + +/** \defgroup U_PMF_SF_ PMF StringFormat Flags + For EmfPlusStringFormat + EMF+ manual 2.1.2.8, Microsoft name: StringFormat Flags (U_SF_*) + @{ +*/ +#define U_SF_None 0x00000000 //!< no bits set +#define U_SF_DirectionRightToLeft 0x00000001 //!< text Right to Left +#define U_SF_DirectionVertical 0x00000002 //!< text Left to Right +#define U_SF_NoFitBlackBox 0x00000004 //!< text not restricted to layout bbox +#define U_SF_NoBit4 0x00000008 //!< unused bit +#define U_SF_NoBit5 0x00000010 //!< unused bit +#define U_SF_DisplayFormatControl 0x00000020 //!< control codes display as "representative" glyphs +#define U_SF_NoBit7 0x00000040 //!< unused bit +#define U_SF_NoBit8 0x00000080 //!< unused bit +#define U_SF_NoBit9 0x00000100 //!< unused bit +#define U_SF_NoBit10 0x00000200 //!< unused bit +#define U_SF_NoFontFallback 0x00000400 //!< show as missing glyph if not in font +#define U_SF_MeasureTrailingSpaces 0x00000800 //!< trailing spaces included in line length +#define U_SF_NoWrap 0x00001000 //!< text does not wrap +#define U_SF_LineLimit 0x00002000 //!< emit whole lines if not clipped +#define U_SF_NoClip 0x00004000 //!< text is not clipped +#define U_SF_BypassGDI 0x80000000 //!< use implementation specific text rendering instead of GDI +/** @} */ + +/** \defgroup U_PMF_IE_ PMF ImageEffects Identifiers + For + EMF+ manual 2.1.3.1, Microsoft name: ImageEffects Identifiers (U_IE_*) + @{ +*/ +#define U_IE_BlurEffectGuid "{633C80A4-1843-482B-9EF2-BE2834C5FDD4}" //!< Blur Effect +#define U_IE_BrightnessContrastEffectGuid "{D3A1DBE1-8EC4-4C17-9F4C-EA97AD1C343D}" //!< Brightness Contrast Effect +#define U_IE_ColorBalanceEffectGuid "{537E597D-251E-48DA-9664-29CA496B70F8}" //!< Color Balance Effect +#define U_IE_ColorCurveEffectGuid "{DD6A0022-58E4-4A67-9D9B-D48EB881A53D}" //!< Color Curve Effect +#define U_IE_ColorLookupTableEffectGuid "{A7CE72A9-0F7F-40D7-B3CC-D0C02D5C3212}" //!< Color Lookup Table Effect +#define U_IE_ColorMatrixEffectGuid "{718F2615-7933-40E3-A511-5F68FE14DD74}" //!< Color Matrix Effect +#define U_IE_HueSaturationLightnessEffectGuid "{8B2DD6C3-EB07-4D87-A5F0-7108E26A9C5F}" //!< Hue Saturation Lightness Effect +#define U_IE_LevelsEffectGuid "{99C354EC-2A31-4F3A-8C34-17A803B33A25}" //!< Levels Effect +#define U_IE_RedEyeCorrectionEffectGuid "{74D29D05-69A4-4266-9549-3CC52836B632}" //!< Red Eye Correction Effect +#define U_IE_SharpenEffectGuid "{63CBF3EE-C526-402C-8F71-62C540BF5142}" //!< Sharpen Effect +#define U_IE_TintEffectGuid "{1077AF00-2848-4441-9489-44AD4C2D7A2C}" //!< Tint Effect +/** @} */ + +/** \defgroup U_PMF_IEE_ PMF ImageEffects Enumerators + based on U_IE_ + These may be used by a parser to set up for a switch() statement. + @{ +*/ +#define U_IEE_Unknown 0 //!< none of the following +#define U_IEE_BlurEffectGuid 1 //!< Blur Effect +#define U_IEE_BrightnessContrastEffectGuid 2 //!< Brightness Contrast Effect +#define U_IEE_ColorBalanceEffectGuid 3 //!< Color Balance Effect +#define U_IEE_ColorCurveEffectGuid 4 //!< Color Curve Effect +#define U_IEE_ColorLookupTableEffectGuid 5 //!< Color Lookup Table Effect +#define U_IEE_ColorMatrixEffectGuid 6 //!< Color Matrix Effect +#define U_IEE_HueSaturationLightnessEffectGuid 7 //!< Hue Saturation Lightness Effect +#define U_IEE_LevelsEffectGuid 8 //!< Levels Effect +#define U_IEE_RedEyeCorrectionEffectGuid 9 //!< Red Eye Correction Effect +#define U_IEE_SharpenEffectGuid 10 //!< Sharpen Effect +#define U_IEE_TintEffectGuid 11 //!< Tint Effect +/** @} */ + +/** \defgroup U_PMF_OC_ PMF ObjectClamp Identifiers + For U_PMF_IMAGEATTRIBUTES ObjectClamp field + EMF+ manual 2.2.1.5, Microsoft name: ImageEffects Identifiers (U_OC_*) + @{ +*/ +#define U_OC_Rect 0x00 //!< Clamp object to rectangle. +#define U_OC_Bitmap 0x01 //!< Clamp object to bitmap. +/** @} */ + +/** \defgroup U_PMF_PPF_ PMF PathPoint Flags + For U_PMF_PATH Flags field + For U_PMF_CMN_HDR Flags field + EMF+ manual 2.2.1.6, Microsoft name: PathPoint Flags (U_PPF_*) + For U_PMF_CMN_HDR Flags the bits are scattered all over the EMF+ manual. + NOTE: bitfields in manual are BIG endian and MSB 0. + This code reads the 16 bit flag field as LITTLE endian and uses LSB 0. + The values shown are AFTER the data has been read into a uint16_t and the byte order set + appropriately. + All of these come out of a 16 bit field. + @{ +*/ +#define U_PPF_B 0x8000 //!< 15 Set: BrushID is an U_PFM_ARGB; Clear: is index of U_PMF_BRUSH object in EMF+ object table. +#define U_PPF_BZ 0x8000 //!< 15 Set: Points are on a Bezier curve; Clear: Points are on a line +#define U_PPF_N 0x8000 //!< 15 Set: object definition continues in next record; Clear: this is the final object definition record +#define U_PPF_K 0x8000 //!< 15 Set: int16_t coordinates; Clear: use U_FLOAT coordinates +#define U_PPF_C 0x4000 //!< 14 Set: int16_t coordinates; Clear: use U_FLOAT coordinates +#define U_PPF_XM 0x2000 //!< 13 Set: Post multiply matrix; Clear: Pre multiply matrix +#define U_PPF_F 0x2000 //!< 13 Set: winding fill; Clear: alternate fill +#define U_PPF_E 0x2000 //!< 13 Set: effect from previous U_PMF_SERIALIZABLEOBJECT record will be applied,; Clear: no effect applied +#define U_PPF_R 0x1000 //!< 12 Set: U_PMF_PathPointTypeRLE and/or U_PMF_PathPointType objects; Clear: only U_PMF_PathPointType +#define U_PPF_P 0x0800 //!< 11 Set: relative coordinates; Clear absolute coordinates +#define U_PPF_D 0x0400 //!< 10 Set: draw path closed; Clear: draw path open +#define U_PPF_VGA 0x0002 //!< 1 Set: Palette is VGA basic colors; Clear: Palette is ??? +#define U_PPF_PP 0x0001 //!< 0 Set: Palette field is present; Clear: Palette field is absent +#define U_PPF_DM 0x0001 //!< 0 Set: Dual-mode file; Clear: EMF+ only file +#define U_PPF_AA 0x0001 //!< 0 Set: anti-aliasing on; Clear: anti-aliasing off +#define U_PPF_VIDEO 0x0001 //!< 0 Set: reference device is video display; Clear: reference devis is printer +/** @} */ + +/** \defgroup U_PMF_FF_ PMF Masks and offsets for 16 bit flag fields + Documenting the OBSERVED positions of fields in 16 bit flag integers + after they have been read in Little Ended from files. + + Note, some of these are used in more than one record type, only a single reference is provided + @{ +*/ + +#define U_FF_MASK_SUBLID 0x003F //!< EMF+ manual 2.2.2.23, Microsoft name: EmfPlusLanguageIdentifier +#define U_FF_SHFT_SUBLID 0x000A //!< EMF+ manual 2.2.2.23, Microsoft name: EmfPlusLanguageIdentifier +#define U_FF_MASK_PRILID 0x03FF //!< EMF+ manual 2.2.2.23, Microsoft name: EmfPlusLanguageIdentifier +#define U_FF_SHFT_PRILID 0x0000 //!< EMF+ manual 2.2.2.23, Microsoft name: EmfPlusLanguageIdentifier +#define U_FF_MASK_LID 0xFFFF //!< EMF+ manual 2.2.2.23, Microsoft name: EmfPlusLanguageIdentifier +#define U_FF_SHFT_LID 0x0000 //!< EMF+ manual 2.2.2.23, Microsoft name: EmfPlusLanguageIdentifier +#define U_FF_MASK_RL 0x003F //!< EMF+ manual 2.2.2.32, Microsoft name: EmfPlusPathPointTypeRLE +#define U_FF_SHFT_RL 0x0008 //!< EMF+ manual 2.2.2.32, Microsoft name: EmfPlusPathPointTypeRLE +#define U_FF_MASK_PPT 0x00FF //!< EMF+ manual 2.2.2.32, Microsoft name: EmfPlusPathPointTypeRLE +#define U_FF_SHFT_PPT 0x0000 //!< EMF+ manual 2.2.2.32, Microsoft name: EmfPlusPathPointTypeRLE +/* the next one is used most places an object ID is specified */ +#define U_FF_MASK_OID8 0x00FF //!< EMF+ manual 2.3.1.3, Microsoft name: EmfPlusSetClipPath +#define U_FF_SHFT_OID8 0x0000 //!< EMF+ manual 2.3.1.3, Microsoft name: EmfPlusSetClipPath +#define U_FF_MASK_CM4 0x000F //!< EMF+ manual 2.3.1.3, Microsoft name: EmfPlusSetClipPath +#define U_FF_SHFT_CM4 0x0008 //!< EMF+ manual 2.3.1.3, Microsoft name: EmfPlusSetClipPath +#define U_FF_MASK_OT 0x003F //!< EMF+ manual 2.3.5.1, Microsoft name: EmfPlusObject +#define U_FF_SHFT_OT 0x0008 //!< EMF+ manual 2.3.5.1, Microsoft name: EmfPlusObject +#define U_FF_MASK_AA 0x007F //!< EMF+ manual 2.3.6.1, Microsoft name: EmfPlusSetAntiAliasMode +#define U_FF_SHFT_AA 0x0001 //!< EMF+ manual 2.3.6.1, Microsoft name: EmfPlusSetAntiAliasMode +#define U_FF_MASK_CM 0x00FF //!< EMF+ manual 2.3.6.2, Microsoft name: EmfPlusSetCompositingMode +#define U_FF_SHFT_CM 0x0000 //!< EMF+ manual 2.3.6.2, Microsoft name: EmfPlusSetCompositingMode +#define U_FF_MASK_CQ 0x00FF //!< EMF+ manual 2.3.6.3, Microsoft name: EmfPlusSetCompositingQuality +#define U_FF_SHFT_CQ 0x0000 //!< EMF+ manual 2.3.6.3, Microsoft name: EmfPlusSetCompositingQuality +#define U_FF_MASK_IM 0x00FF //!< EMF+ manual 2.3.6.4, Microsoft name: EmfPlusSetInterpolationMode +#define U_FF_SHFT_IM 0x0000 //!< EMF+ manual 2.3.6.4, Microsoft name: EmfPlusSetInterpolationMode +#define U_FF_MASK_PxOffM 0x00FF //!< EMF+ manual 2.3.6.5, Microsoft name: EmfPlusSetPixelOffsetMode +#define U_FF_SHFT_PxOffM 0x0000 //!< EMF+ manual 2.3.6.5, Microsoft name: EmfPlusSetPixelOffsetMode +#define U_FF_MASK_TGC 0x0FFF //!< EMF+ manual 2.3.6.7, Microsoft name: EmfPlusSetTextContrast +#define U_FF_SHFT_TGC 0x0000 //!< EMF+ manual 2.3.6.7, Microsoft name: EmfPlusSetTextContrast +#define U_FF_MASK_TRH 0x00FF //!< EMF+ manual 2.3.6.8, Microsoft name: EmfPlusSetTextRenderingHint +#define U_FF_SHFT_TRH 0x0000 //!< EMF+ manual 2.3.6.8, Microsoft name: EmfPlusSetTextRenderingHint +#define U_FF_MASK_UT 0x00FF //!< EMF+ manual 2.3.7.1, Microsoft name: EmfPlusBeginContainer +#define U_FF_SHFT_UT 0x0008 //!< EMF+ manual 2.3.7.1, Microsoft name: EmfPlusBeginContainer +#define U_FF_MASK_TSC 0x7FFF //!< EMF+ manual 2.3.8.1, Microsoft name: EmfPlusSetTSClip +#define U_FF_SHFT_TSC 0x0000 //!< EMF+ manual 2.3.8.1, Microsoft name: EmfPlusSetTSClip +#define U_FF_MASK_PU 0x00FF //!< EMF+ manual 2.3.9.5, Microsoft name: EmfPlusSetPageTransform +#define U_FF_SHFT_PU 0x0000 //!< EMF+ manual 2.3.9.5, Microsoft name: EmfPlusSetPageTransform +/** @} */ + + +/** \defgroup U_PMF_GFVR_ PMF MetafileSignature + For U_PMF_GRAPHICSVERSION Signature field + EMF+ manual 2.2.2.19, Microsoft name: (none) (U_GFVR_*) + @{ +*/ +#define U_GFVR_PMF 0x000DBC01 //!< indicates an EMF+ metafile +#define U_GFVR_MASKHI 0xFFFFF000 //!< mask for the signature bit field (20 bits) +#define U_GFVR_MASKLO 0x00000FFF //!< mask for the version bit field (12 bits) +/** @} */ + +/** \defgroup U_PMF_XM_ PMF Matrix Multiplication Enumerator + For U_PMF_RotateWorldTransform and others + EMF+ manual 2.3.9.3, Microsoft name: (none) (U_XM_*) + @{ +*/ +#define U_XM_PostX 1 //!< Post Multiply change to current Transformation Matrix +#define U_XM_PreX 0 //!< Pre Multiply change to current Transformation Matrix +/** @} */ + + +/* Utility objects, not defined in EMF+ spec */ + +/** @brief Used to accumulate data for objects continued over multiple records. + see EMF+ manual 2.3.5.1 +*/ +typedef struct { + char *accum; /**< data accumulates here */ + uint32_t space; /**< bytes allocated */ + uint32_t used; /**< bytes in use */ + int Type; /**< ObjectType enumeration */ + int Id; /**< Object ID */ +} U_OBJ_ACCUM; + +/** @brief Holds EMF+ objects and records in EMF+ file format byte order. +*/ +typedef struct { + char *Data; /**< Buffer that hold's the PseudoObject's data */ + size_t Size; /**< Number of bytes allocated in Data (may be >Used if padding is present) */ + size_t Used; /**< Number of data bytes that are stored in Data */ + uint32_t Type; /**< Type numbers are from manual section: 1.2.3.4 -> 10203040 */ +} U_PSEUDO_OBJ; + +/** @brief DoublePseudoObject holds pairs of PseudoObjects. Used for constructing paths along with their types. + The data stored in the PsuedoObjects maintains LittleEndian-ness, as expected in the final file. + The type is U_RAW_OID, and there is no elements count at the beginning of Data +*/ +typedef struct { + uint32_t Elements; /**< Element count, applies to both PseudoObjects */ + U_PSEUDO_OBJ *poPoints; /**< Points in path */ + U_PSEUDO_OBJ *poTypes; /**< Types of points in path */ +} U_DPSEUDO_OBJ; + +/** @brief Serializer description records. + +An array of these are passed to U_PMF_SERIAL_set() to construct EMF+ objects from their component parts. +The U_PMF_SERIAL_set() function should not ever be called directly by end user code. +*/ +typedef struct { + const void *Ptr; /**< Pointer to the first byte of the data field. + Each data field is an array of a basic type of Units + bytes repeated Reps times */ + size_t Units; /**< Number of bytes in each unit of each data field. */ + size_t Reps; /**< MNumber of repeats of Units in eah data field. */ + int TE; /**< (Target Endian). Only relevant for Units of 2 or 4*/ +} U_SERIAL_DESC; + +/** @brief FontInfoParams hold font information that is needed by U_PMR_drawstring so that it can + place text on the baseline. This must be extracted from the font file using + an appropriate utility. (See testbed_pmf.c for a table of these values for some + common fonts.) +*/ +typedef struct { + char *name; /**< Font name (like "Arial") */ + int Ascent; /**< in Font units (positive) */ + int Descent; /**< in Font units (negative) */ + int LineGap; /**< in Font units (positive) */ + int EmSize; /**< Y extent of Em square, usually 2048 */ + int yMax; /**< in Font units (positive) */ + int yMin; /**< in Font units (negative) */ +} U_FontInfoParams; + + + +/* EMF+ objects */ + +/** @brief EMF+ manual 2.2.1.1, Microsoft name: EmfPlusBrush Object + +variable part of object follows structure: + uint32_t Data[]; // one of the 5 types of Brush data (2.2.2 20, 24, 29, 43, or 45) +*/ +typedef struct { + uint32_t Version; //!< EmfPlusGraphicsVersion object + uint32_t Type; //!< BrushType Enumeration +} U_PMF_BRUSH; + +/** @brief EMF+ manual 2.2.1.2, Microsoft name: EmfPlusCustomLineCap Object */ +typedef struct { +/*@{*/ + uint32_t Version; //!< EmfPlusGraphicsVersion object + uint32_t Type; //!< BrushType Enumeration +/* variable part of object, not part of structure + uint32_t Data[]; //!< one of the 2 types of Linecap data (2.2.2 12, 13) +*/ +/*@}*/ +} U_PMF_CUSTOMLINECAP; + +/** @brief EMF+ manual 2.2.1.3, Microsoft name: EmfPlusFont Object */ +typedef struct { +/*@{*/ + uint32_t Version; //!< EmfPlusGraphicsVersion object + U_FLOAT EmSize; //!< em size in units of SizeUnit + uint32_t SizeUnit; //!< UnitType enumeration + int32_t FSFlags; //!< FontStyle flags + uint32_t Reserved; //!< ignored + uint32_t Length; //!< Number of Unicode Characters in FamilyName +/* variable part of object, not part of structure + uint16_t FamilyName[]; //!< Unicode (UTF-16LE) name of font family +*/ +/*@}*/ +} U_PMF_FONT; + +/** @brief EMF+ manual 2.2.1.4, Microsoft name: EmfPlusImage Object */ +typedef struct { +/*@{*/ + uint32_t Version; //!< EmfPlusGraphicsVersion object + uint32_t Type; //!< ImageDataType Enumeration +/* variable part of object, not part of structure + uint32_t Data[]; //!< one of the 2 types of image data (2.2.2 2 or 27) +*/ +/*@}*/ +} U_PMF_IMAGE; + +/** @brief EMF+ manual 2.2.2.1, Microsoft name: EmfPlusARGB Object, out of order, needed for 2.2.1.5 */ +typedef struct { +/*@{*/ + uint8_t Blue; //!< Blue color (0-255) + uint8_t Green; //!< Green color (0-255) + uint8_t Red; //!< Red color (0-255) + uint8_t Alpha; //!< Alpha (0-255) +/*@}*/ +} U_PMF_ARGB; + +/** @brief EMF+ manual 2.2.1.5, Microsoft name: EmfPlusImageAttributes Object */ +typedef struct { + /*@{*/ + uint32_t Version; //!< EmfPlusGraphicsVersion object + uint32_t Reserved1; //!< ignored + uint32_t WrapMode; //!< WrapMode object + U_PMF_ARGB ClampColor; //!< EmfPlusARGB object + int32_t ObjectClamp; //!< ObjectClamp Identifiers + uint32_t Reserved2; //!< ignored +/*@}*/ +} U_PMF_IMAGEATTRIBUTES; + +/** @brief EMF+ manual 2.2.1.6, Microsoft name: EmfPlusPath Object */ +typedef struct { +/*@{*/ + uint32_t Version; //!< EmfPlusGraphicsVersion object + uint32_t Count; //!< points and point types in this object + uint16_t Flags; //!< PathPoint Flags +/* variable part of object, not part of structure + points array of points like: + U_PPF_P U_PPF_C Type + 1 x U_PMF_POINTR + 0 1 U_PMF_POINT + 0 0 U_PMF_POINTF + types array of:. + U_PPF_R Type + 1 U_PMF_PATHPOINTTYPERLE and/or U_PMF_PATHPOINTTYPE + 0 U_PMF_PathPointType (only) + alignment padding up to 3 bytes +*/ +/*@}*/ +} U_PMF_PATH; + +/** @brief EMF+ manual 2.2.1.7, Microsoft name: EmfPlusPen Object */ + +typedef struct { + uint32_t Version; //!< EmfPlusGraphicsVersion object + uint32_t type; //!< must be zero +/* variable part of object, not part of structure + U_PMF_PENDATA pen + U_PMF_BRUSH brush +*/ +} U_PMF_PEN; + +/** @brief EMF+ manual 2.2.2.40, Microsoft name: EmfPlusRegionNode Object, out of order, needed for 2.2.1.8 */ +typedef struct { + uint32_t Type; //!< RegionNodeDataType +/* variable part of object, not part of structure, will be absent in object for some types + data data is a tree made up of some combination of these objects + U_PMF_REGIONNODEPATH 2.2.2.42 terminal node + U_PMF_RECTF 2.2.2.39 terminal node + U_PMF_REGIONNODECHILDNODES 2.2.2.41 non-terminal node +*/ +} U_PMF_REGIONNODE; + +/** @brief EMF+ manual 2.2.1.8, Microsoft name: EmfPlusRegion Object */ +typedef struct { + uint32_t Version; //!< EmfPlusGraphicsVersion object + uint32_t Elements; //!< Number of members in Nodes array +/* variable part of object, not part of structure, will be absent in object for some types + U_PMF_REGIONNODE Nodes[1]; //!< Nodes defining region +*/ +} U_PMF_REGION; + +/** @brief EMF+ manual 2.2.2.23, Microsoft name: EmfPlusLanguageIdentifier Object, out of order, needed for 2.2.1.9 + +Bit fields are not used in structs in this implementation, these are serialized/deserialized in +the corresponding routines. Bitfields in the FILE (LITTLE endian here, manual uses BIG endian) are: + int SubLId : 6; Example: code for USA + int PriLId : 10; Example: code for English + +This type is defined as 16 bits in the manual section, but it is only ever used as part of a 32 bit field! +*/ +typedef uint32_t U_PMF_LANGUAGEIDENTIFIER; + +/** @brief EMF+ manual 2.2.1.9, Microsoft name: EmfPlusStringFormat Object */ +typedef struct { + uint32_t Version; //!< EmfPlusGraphicsVersion object + uint32_t Flags; //!< StringFormat flags + U_PMF_LANGUAGEIDENTIFIER + Language; //!< String's Language + uint32_t StringAlignment; //!< StringAlignment enumeration. + uint32_t LineAlign; //!< StringAlignment enumeration. + uint32_t DigitSubstitution; //!< StringDigitSubstitution enumeration + U_PMF_LANGUAGEIDENTIFIER + DigitLanguage; //!< Digit's Language (overrides Language, above) + U_FLOAT FirstTabOffset; //!< the number of spaces to the first tab stop. + int32_t HotkeyPrefix; //!< HotkeyPrefix enumeration + U_FLOAT LeadingMargin; //!< space before starting position (text) of a string + U_FLOAT TrailingMargin; //!< space after last position (text) of a string + U_FLOAT Tracking; //!< horizontal space alotted per character/font specification per character + uint32_t Trimming; //!< StringTrimming enumeration + uint32_t TabStopCount; //!< Number of tab stops in data field. + uint32_t RangeCount; //!< Number of U_PMF_CHARACTERRANGE objects in data field. +/* variable part of object, not part of structure. + U_PMF_STRINGFORMATDATA data + + Note that U_PMF_STRINGFORMATDATA has no struct as it is entirely variable + and the size of the two fields in it are specified by the two preceding fields in this object type. +*/ +} U_PMF_STRINGFORMAT; + +/** U_PMF_ARGB EMF+ manual 2.2.2.1, Microsoft name: EmfPlusARGB Object, defined above, before 2.2.1.6*/ + +/** @brief EMF+ manual 2.2.2.2, Microsoft name: EmfPlusBitmap Object */ +typedef struct { + int32_t Width; //!< Width in pixels + int32_t Height; //!< Height in pixels + int32_t Stride; //!< length in bytes of 1 scan line (multiple of 4) + uint32_t PxFormat; //!< PixelFormat enumeration + uint32_t Type; //!< BitmapDataType enumeration (section 2.1.1.2). +/* variable part of object, not part of structure. + (various types) BitmapData //!< is either an U_PMF_BITMAPDATA or U_PMF_COMPRESSEDIMAGE object +*/ +} U_PMF_BITMAP; + +/** U_PMF_BITMAPDATA EMF+ manual 2.2.2.3, Microsoft name: EmfPlusBitmapData Object +U_PMF_BITMAPDATA is an entirely variable object, there is no corresponding struct. It consists of + + Colors U_PMF_PALETTE object + PixelData An array of bytes, meaning depends on fields in U_PMF_BITMAP object and the PixelFormat enumeration. + +*/ + +/** @brief EMF+ manual 2.2.2.4, Microsoft name: EmfPlusBlendColors Object + For Pattern field of U_PMF_LINEARGRADIENTBRUSHOPTIONALDATA +*/ +typedef struct { + uint32_t Elements; //!< members in each array +/* variable part of object, not part of structure. + U_FLOAT Positions //!< positions along gradient line. The first position MUST be 0.0 and the last MUST be 1.0. + U_PMF_ARGB Colors //!< colors at positions on gradient line +*/ +} U_PMF_BLENDCOLORS; + +/** @brief EMF+ manual 2.2.2.5, Microsoft name: EmfPlusBlendFactors Object */ +typedef struct { + uint32_t Elements; //!< Members in each array +/* variable part of object, not part of structure. + U_FLOAT Positions //!< positions along gradient line. The first position MUST be 0.0 and the last MUST be 1.0. + U_FLOAT Factors //!< blending factors, 0.0->1.0 values, inclusive +*/ +} U_PMF_BLENDFACTORS; + +/** @brief EMF+ manual 2.2.2.6, Microsoft name: EmfPlusBoundaryPathData Object */ +typedef struct { + int32_t Size; //!< Bytes in Data +/* variable part of object, not part of structure. + U_PMF_PATH Data //!< Boundary of the brush +*/ +} U_PMF_BOUNDARYPATHDATA; + +/** @brief EMF+ manual 2.2.2.7, Microsoft name: EmfPlusBoundaryPointData Object */ +typedef struct { + int32_t Elements; //!< Members in the array +/* variable part of object, not part of structure. + U_PMF_POINTF Points //!< Boundary of the brush +*/ +} U_PMF_BOUNDARYPOINTDATA; + +/** @brief EMF+ manual 2.2.2.8, Microsoft name: EmfPlusCharacterRange Object */ +typedef struct { + int32_t First; //!< First position in range + int32_t Length; //!< Range length +} U_PMF_CHARACTERRANGE; + +/** @brief EMF+ manual 2.2.2.9, Microsoft name: EmfPlusCompoundLineData Object +Compound lines are pens that draw several parallel lines at once. The data here +alternates (sub)line width (as fraction of total width and gaps (also as fraction +of total width). +*/ +typedef struct { + int32_t Elements; //!< Members in the array +/* variable part of object, not part of structure. + U_FLOAT Data //!< Line or gap width (0.0 <-> 1.0, fraction of total line width ) +*/ +} U_PMF_COMPOUNDLINEDATA; + +/** @brief EMF+ manual 2.2.2.10, Microsoft name: EmfPlusCompressedImage Object +Holds an EXIF, GIF, JFIF, PNG, or TIFF image. + For U_PMF_BITMAP BitmapData field + + object has no assocated struct! + U_PMF_COMPRESSEDIMAGE +*/ + +/** @brief EMF+ manual 2.2.2.11, Microsoft name: EmfPlusCustomEndCapData Object */ +typedef struct { + int32_t Size; //!< Bytes in Data +/* variable part of object, not part of structure. + U_PMF_CUSTOMLINECAP Data //!< Description of linecap +*/ +} U_PMF_CUSTOMENDCAPDATA; + +/** @brief EMF+ manual 2.2.2.12, Microsoft name: EmfPlusCustomLineCapArrowData Object */ +typedef struct { + U_FLOAT Width; //!< Arrow cap width (is multiplied by line width before draw) + U_FLOAT Height; //!< Arrow cap length (is multiplied by line width before draw) + U_FLOAT MiddleInset; //!< Pixels between outer edge and filled region + uint32_t FillState; //!< If set, fill, otherwise, only border + uint32_t StartCap; //!< LineCap enumeration (type of cap) + uint32_t EndCap; //!< LineCap enumeration + uint32_t Join; //!< LineJoin enumeration + U_FLOAT MiterLimit; //!< Maximum (miter length / line width) + U_FLOAT WidthScale; //!< Scale for U_PMF_CUSTOMLINECAP object + U_FLOAT FillHotSpot[2]; //!< must be 0.0, 0.0 + U_FLOAT LineHotSpot[2]; //!< must be 0.0, 0.0 +} U_PMF_CUSTOMLINECAPARROWDATA; + +/** @brief EMF+ manual 2.2.2.13, Microsoft name: EmfPlusCustomLineCapData Object */ +typedef struct { + uint32_t Flags; //!< CustomLineCapData flags + uint32_t Cap; //!< LineCap enumeration (type of cap) + U_FLOAT Inset; //!< Distance line cap start -> line end + uint32_t StartCap; //!< LineCap enumeration + uint32_t EndCap; //!< LineCap enumeration + uint32_t Join; //!< LineJoin enumeration + U_FLOAT MiterLimit; //!< Maximum (miter length / line width) + U_FLOAT WidthScale; //!< Scale for U_PMF_CUSTOMLINECAP object + U_FLOAT FillHotSpot[2]; //!< must be 0.0, 0.0 + U_FLOAT LineHotSpot[2]; //!< must be 0.0, 0.0 +/* variable part of object, not part of structure. + U_PMF_CUSTOMLINECAPOPTIONALDATA Data //!< meaning determined by Flags +*/ +} U_PMF_CUSTOMLINECAPDATA; + +/** U_PMF_CUSTOMLINECAPOPTIONALDATA EMF+ manual 2.2.2.14, Microsoft name: EmfPlusCustomLineCapOptionalData Object + + object has no assocated struct! + + U_PMF_FILLPATHO FillData; //!< path to fill (optional) + U_PMF_LINEPATH LineData; //!< path to stroke (optional) +*/ + +/** @brief EMF+ manual 2.2.2.15, Microsoft name: EmfPlusCustomStartCapData Object */ +typedef struct { + int32_t Size; //!< Bytes in Data +/* variable part of object, not part of structure. + U_PMF_CUSTOMLINECAP Data //!< Description of linecap +*/ +} U_PMF_CUSTOMSTARTCAPDATA; + +/** @brief EMF+ manual 2.2.2.16, Microsoft name: EmfPlusDashedLineData Object */ +typedef struct { + int32_t Elements; //!< Elements in Data +/* variable part of object, not part of structure. + U_FLOAT Data; //!< Array of lengths of dashes and spaces +*/ +} U_PMF_DASHEDLINEDATA; + +/** @brief EMF+ manual 2.2.2.17, Microsoft name: EmfPlusFillPath Object +Note: U_PMF_FILLPATHOBJ is the object, U_PMF_FILLPATH is the file record +*/ + +typedef struct { + int32_t Size; //!< Bytes in Data +/* variable part of object, not part of structure. + U_PMF_PATH Data; //!< Path specification +*/ +} U_PMF_FILLPATHO; + +/** @brief EMF+ manual 2.2.2.18, Microsoft name: EmfPlusFocusScaleData Object + for U_PMF_PATHGRADIENTBRUSHOPTIONALDATA data field + +Used with path gradient brushes. May be used to expand the center color +of a gradient, which would otherwise only be found at the center point. +The expanded area is the width, height X scale factor, but in no case +less than 1 pixel. + +*/ +typedef struct { + uint32_t Count; //!< must be 2 + U_FLOAT ScaleX; //!< value 0.0 <-> 1.0 + U_FLOAT ScaleY; //!< value 0.0 <-> 1.0 +} U_PMF_FOCUSSCALEDATA; + +/** @brief EMF+ manual 2.2.2.19, Microsoft name: EmfPlusGraphicsVersion Object + +Bit fields are not used in structs in this implementation, these are serialized/deserialized in +the corresponding routines. Bitfields in the FILE (LITTLE endian here, manual uses BIG endian) are: + unsigned int GrfVersion : 12; GraphicsVersion enumeration + unsigned int Signature : 20; Must be U_GFVR_PMF (0xDBC01) + @{ +*/ +typedef uint32_t U_PMF_GRAPHICSVERSION; //!< EMF+ manual 2.2.2.19, Microsoft name: EmfPlusGraphicsVersion Object +/** @} */ + +/** @brief EMF+ manual 2.2.2.20, Microsoft name: EmfPlusHatchBrushData Object */ +typedef struct { + uint32_t Style; //!< HatchStyle enumeration + U_PMF_ARGB Foreground; //!< Hatch pattern line color + U_PMF_ARGB Background; //!< Hatch pattern bkground color +} U_PMF_HATCHBRUSHDATA; + +/** \defgroup U_PMF_Int7 PMF 7 bit signed integer + @brief EMF+ manual 2.2.2.21, Microsoft name: EmfPlusInteger7 Object + + bit 7 U_INT7 Clear in Integer7 objects + bits 0-6 7 bit signed integer value + @{ +*/ +#define U_TEST_INT7 0x80 //!< This bit is clear in Integer7 objects. +#define U_SIGN_INT7 0x40 //!< Sign bit on an Integer7 object. +#define U_MASK_INT7 0x7F //!< xMask to retrieve integer7 bits. +/** @} */ + +/** \defgroup U_PMF_Int15 PMF 15 bit signed integer + @brief EMF+ manual 2.2.2.22, Microsoft name: EmfPlusInteger15 Object + + bit 15 U_INT15 Set in Integer15 objects + bits 0-15 15 bit signed integer value + + This is the one data type that really does seem to be stored into the file in Big Endian order. + It has to be this way because the bit that determines if data is int7 or int15 must be in the first byte + the parser sees, and that byte is the high order byte. + @{ +*/ +#define U_TEST_INT15 0x8000 //!< This bit is set in Integer15 objects. +#define U_SIGN_INT15 0x4000 //!< Sign bit on an Integer15 object. +#define U_MASK_INT15 0x7FFF //!< Mask to retrieve integer15 bits. +/** @} */ + +/* EMF+ manual 2.2.2.23, Microsoft name: EmfPlusLanguageIdentifier Object, defined above, before 2.2.1.9 */ + +/** @brief EMF+ manual 2.2.2.39, Microsoft name: EmfPlusRectF Object, out of order, needed for 2.2.2.24 */ +typedef struct { + U_FLOAT X; //!< UL X value + U_FLOAT Y; //!< UL Y value + U_FLOAT Width; //!< Width + U_FLOAT Height; //!< Height +} U_PMF_RECTF; + +/** @brief EMF+ manual 2.2.2.24, Microsoft name: EmfPlusLinearGradientBrushData Object +Manual says that Reserved1 and Reserved2 must be ignored. In practice if Reserved1 is not set to StartColor +and Reserved2 is not set to EndColor, then XP Preview will not display the gradient. +*/ +typedef struct { + uint32_t Flags; //!< BrushData flags + int32_t WrapMode; //!< WrapMode enumeration + U_PMF_RECTF RectF; //!< UL=start, LR=end of gradient + U_PMF_ARGB StartColor; //!< Gradient start color + U_PMF_ARGB EndColor; //!< Gradient end color + uint32_t Reserved1; //!< ignore + uint32_t Reserved2; //!< ignore +/* variable part of object, not part of structure. + U_PMF_LINEARGRADIENTBRUSHOPTIONALDATA data; //!< presence and meaning depend on Flags field +*/ +} U_PMF_LINEARGRADIENTBRUSHDATA; + +/** @brief EMF+ manual 2.2.2.47, Microsoft name: EmfPlusTransformMatrix Object, out of order, needed for 2.2.2.25 */ +typedef struct { + U_FLOAT m11; //!< Rotation matrix m11 element + U_FLOAT m12; //!< Rotation matrix m12 element + U_FLOAT m21; //!< Rotation matrix m21 element + U_FLOAT m22; //!< Rotation matrix m22 element + U_FLOAT dX; //!< Translation in X + U_FLOAT dY; //!< Translation in Y +} U_PMF_TRANSFORMMATRIX; + +/** NOT DOCUMENTED. Encountered in actual EmfPlusLinearGradientBrushOptionalData Object made by PowerPoint 2003. This + structure is needed for the next. */ +typedef struct { + U_FLOAT m11; //!< Rotation matrix m11 element + U_FLOAT m12; //!< Rotation matrix m12 element + U_FLOAT m21; //!< Rotation matrix m21 element + U_FLOAT m22; //!< Rotation matrix m22 element +} U_PMF_ROTMATRIX; + +/** @brief EMF+ manual 2.2.2.25, Microsoft name: EmfPlusLinearGradientBrushOptionalData Object + For U_PMF_LINEARGRADIENTBRUSHDATA data field +*/ +typedef struct { + U_PMF_ROTMATRIX Matrix; //!< Rotation matrix, Manuals says that this should be Transformation matrix, but last two values are missing +/* variable part of object, not part of structure. + (various) pattern; //!< Presence and meaning depend on Flags field, see below + + Flag values + U_BD_PresetColors U_BD_BlendFactorsH U_BD_BlendFactorsV pattern(s) present? + 0 0 0 none + 1 0 0 U_PMF_BLENDCOLORS + 0 1 0 U_PMF_BLENDFACTORS + 0 0 1 U_PMF_BLENDFACTORS + 0 1 1 U_PMF_BLENDFACTORS, U_PMF_BLENDFACTORS +*/ +} U_PMF_LINEARGRADIENTBRUSHOPTIONALDATA; + +/** @brief EMF+ manual 2.2.2.26, Microsoft name: EmfPlusLinePath Object */ +typedef struct { + int32_t Size; //!< Bytes in Data +/* variable part of object, not part of structure. + U_PMF_PATH Data; //!< Outline path +*/ +} U_PMF_LINEPATH; + +/** @brief EMF+ manual 2.2.2.27, Microsoft name: EmfPlusMetafile Object */ +typedef struct { + uint32_t Type; //!< MetaFileDatatype enumeration + uint32_t Size; //!< Bytes in Data +/* variable part of object, not part of structure. + U_PMF_IMAGE Data; //!< Various types of data, like an EMF metafile, WMF metafile, another EMF+ metafile +*/ +} U_PMF_METAFILE; + +/** @brief EMF+ manual 2.2.2.28, Microsoft name: EmfPlusPalette Object */ +typedef struct { + uint32_t Flags; //!< PaletteStyle flags + uint32_t Elements; //!< elements in Data +/* variable part of object, not part of structure. + U_PMF_ARGB Data; //!< Palette data (array of colors) +*/ +} U_PMF_PALETTE; + +/** @brief EMF+ manual 2.2.2.36, Microsoft name: EmfPlusPointF Object, out of order, needed for 2.2.2.29 */ +typedef struct { + U_FLOAT X; //!< UL X value + U_FLOAT Y; //!< UL Y value +} U_PMF_POINTF; + +/** @brief EMF+ manual 2.2.2.29, Microsoft name: EmfPlusPathGradientBrushData Object */ +typedef struct { + uint32_t Flags; //!< BrushData flags + int32_t WrapMode; //!< WrapMode enumeration + U_PMF_ARGB CenterColor; //!< Gradient center color + U_PMF_POINTF Center; //!< Center coordinates + uint32_t Elements; //!< Number of elements in gradient (not counting center) +/* variable part of object, not part of structure. + U_PMF_ARGB Gradient; //!< Color Gradient with Elements members + (varies) Boundary; //!< U_PMF_BOUNDARYPATHDATA object if BrushDataPath bit set in Flag, else U_PMF_BOUNDARYPOINTDATA object + U_PMF_GRADIENTBRUSHOPTIONALDATA data; //!< exact composition depends on Flags +*/ +} U_PMF_PATHGRADIENTBRUSHDATA; + +/** EMF+ manual 2.2.2.30, Microsoft name: EmfPlusPathGradientBrushOptionalData Object + for U_PMF_PATHGRADIENTNBRUSHDATA data field +*/ +/* Entire thing is variable or optional. +typedef struct { + U_PMF_TRANSFORMMATRIX Matrix; //!< Optional Transformation matrix + U_PMF_BLENDCOLORS Pattern; //!< presence and meaning depend on Flags field + Flag values + U_BD_PresetColors U_BD_BlendFactorsH pattern? + 0 0 none + 1 0 U_PMF_BLENDCOLORS + 0 1 U_PMF_BLENDFACTORS + U_PMF_FOCUSSSCALEDATA data //!< Present if U_BD_FocusScales bit set in Flags in U_PMF_PATHGRADIENTNBRUSHDATA object +} U_PMF_PATHGRADIENTBRUSHOPTIONALDATA; +*/ + +/** \defgroup U_PMF_PPTYPE PMF Path Point Types + @brief EMF+ manual 2.2.2.31, Microsoft name: EmfPlusPathPointType Object + +Bitfields in the FILE (LITTLE endian here, manual uses BIG endian) are: + bits 4-7 PathPointType flags + bits 0-3 PathPointType enumeration +*/ + +/** \defgroup U_PMF_PPTYPERLE PMF Run Length Encoded Path Point Types + @brief EMF+ manual 2.2.2.32, Microsoft name: EmfPlusPathPointTypeRLE Object + +U_PMF_PATHPOINTTYPERLE fields specify point types in a path where the path is Run Length Encoded. +Bit fields are not used in structs in this implementation, these are serialized/deserialized in +the corresponding routines. Bitfields in the FILE (LITTLE endian here, manual uses BIG endian) are: + bit 15 Set: Bezier curve; Clear: straight line + bit 14 ignored + bits 8-13 Run count + bits 0-7 PathPointType enumeration + @{ +*/ +typedef uint16_t U_PMF_PATHPOINTTYPERLE; //!< EMF+ manual 2.2.2.32, Microsoft name: EmfPlusPathPointTypeRLE Object +/** @} */ + +/** @brief EMF+ manual 2.2.2.33, Microsoft name: EmfPlusPenData Object + +Variable part of object follows structure: + U_PMF_PENOPTIONALDATA data; Optional pen data, exact composition depends on Flags +*/ +typedef struct { + uint32_t Flags; //!< PenData flags + uint32_t Unit; //!< UnitType enumeration + U_FLOAT Width; //!< Width in units set by Unit +} U_PMF_PENDATA; + +/** @brief EMF+ manual 2.2.2.34, Microsoft name: EmfPlusPenOptionalData Object + +Every part of this object is variable or optional, there is no corresponding struct + + Present if Flag What is it + U_PMF_TRANSFORMMATRIX Matrix //!< U_PD_Transform Transformation matrix + int32_t StartCap //!< U_PD_StartCap LineCapType enumeration + int32_t EndCap //!< U_PD_EndCap LineCapType enumeration + uint32_t Join //!< U_PD_Join LineJoinType enumeration + U_FLOAT MiterLimit //!< U_PD_MiterLimit Maximum (miter length / line width) + int32_t Style //!< U_PD_LineStyle LineStyle enumeration + int32_t DLCap //!< U_PD_DLCap DashedLineCapType enumeration + U_FLOAT DLOffset //!< U_PD_DLOffset Distance line start to first dash start + U_PMF_DASHEDLINEDATA DLData //!< U_PD_DLData Dash and space widths + int32_t PenAlignment //!< U_PD_NonCenter PenAlignment enumeration + U_PMF_COMPOUNDLINEDATA CLData //!< U_PD_CompoundLineData Compount Line (parallel lines drawn instead of one) + U_PMF_CUSTOMSTARTCAPDATA CSCapData //!< U_PD_CustomStartCap Custom start cap + U_PMF_CUSTOMENDCAPDATA CECapData //!< U_PD_CustomEndCap Custom end cap + */ + +/** @brief EMF+ manual 2.2.2.35, Microsoft name: EmfPlusPoint Object */ +typedef struct { + int16_t X; //!< X coordinate + int16_t Y; //!< Y coordinate +} U_PMF_POINT; + +/** U_PMF_POINTF EMF+ manual 2.2.2.36, Microsoft name: EmfPlusPointF Object, defined above, before 2.2.2.29 */ + +/** U_PMF_POINTR EMF+ manual 2.2.2.37, Microsoft name: EmfPlusPointR Object + For U_PMF_DRAWBEZIERS data field (optionally). + Both parts of this object are variable, there is no corresponding struct. + Any combination of the two allowed types of integer is valid. + + (varies) X; //!< U_PMF_INTEGER7 or U_PMF_INTEGER15 + (varies) Y; //!< U_PMF_INTEGER7 or U_PMF_INTEGER15 + +*/ + +/** @brief EMF+ manual 2.2.2.38, Microsoft name: EmfPlusRect Object */ +typedef struct { + int16_t X; //!< UL X value + int16_t Y; //!< UL Y value + int16_t Width; //!< Width + int16_t Height; //!< Height +} U_PMF_RECT; + +/** U_PMF_RECTF EMF+ manual 2.2.2.39, Microsoft name: EmfPlusRectF Object, defined above, before 2.2.2.24 */ + +/** U_PMF_REGIONNODE EMF+ manual 2.2.2.40, Microsoft name: EmfPlusRegionNode Object, defined above, before 2.2.1.8 */ + +/** U_PMF_REGIONNODECHILDNODES EMF+ manual 2.2.2.41, Microsoft name: EmfPlusRegionNodeChildNodes Object + For U_PMF_REGIONNODE data field (optionally). + Both parts of this object are variable, there is no corresponding struct. + U_PMF_REGIONNODE Left; //!< Left child + U_PMF_REGIONNODE Right; //!< Right child +*/ + +/** @brief EMF+ manual 2.2.2.42, Microsoft name: EmfPlusRegionNodePath Object */ +typedef struct { + int32_t Size; //!< Bytes in Data +/* variable part of object, not part of structure. + U_PMF_PATH Data; //!< Boundary of region node +*/ +} U_PMF_REGIONNODEPATH; + +/** @brief EMF+ manual 2.2.2.43, Microsoft name: EmfPlusSolidBrushData Object + For U_PMF_BRUSH data field (one type of brush) +*/ +typedef struct { + U_PMF_ARGB Color; //!< Color of brush +} U_PMF_SOLIDBRUSHDATA; + +/** U_PMF_STRINGFORMATDATA EMF+ manual 2.2.2.44, Microsoft name: EmfPlusStringFormatData Object + Both parts of this object are variable and optional, there is no corresponding struct + U_FLOAT TabStops[]; //!< Array of tabstop locations + U_PMF_CHARACTERRANGE CharRange[]; //!< Array of character ranges in the text +*/ + +/** @brief EMF+ manual 2.2.2.45, Microsoft name: EmfPlusTextureBrushData Object */ +typedef struct { + uint32_t Flags; //!< BrushData flags + int32_t WrapMode; //!< WrapMode enumeration +/* variable part of object, not part of structure. + U_PMF_TEXTUREBRUSHOPTIONALDATA data; //!< Optional texture data +*/ +} U_PMF_TEXTUREBRUSHDATA; + +/** U_PMF_TEXTUREBRUSHOPTIONALDATA EMF+ manual 2.2.2.46, Microsoft name: EmfPlusTextureBrushOptionalData Object + +Every part of this object is variable or optional, there is no corresponding struct + + U_PMF_TRANSFORMMATRIX Matrix; Transformation matrix, present if Flag BrushDataTransform is set. + U_PMF_IMAGE Image Image that contains the texture. Present if the PMR record that includes this object still has space + for an U_PMF_IMAGE after all the other variable and optional data + within it has been accounted for. +*/ + +/** U_PMF_TRANSFORMMATRIX EMF+ manual 2.2.2.47, Microsoft name: EmfPlusTransformMatrix Object, defined above, before 2.2.2.25 */ + +/** common structure present at the beginning of all(*) EMF+ records */ +typedef struct { + uint16_t Type; //!< Recordtype enumeration (what this record is) + uint16_t Flags; //!< Flags (meaning varies by record type) + uint32_t Size; //!< Bytes in record, including this struct (will be a multiple of 4) + uint32_t DataSize; //!< Bytes of data that follow, may not be a multiple of 4. +} U_PMF_CMN_HDR; + +/** These are the Image Effect Objects 2.2.3.* They specify parameters for "filters" that may be applied to bitmaps. */ + +/** @brief EMF+ manual 2.2.3.1, Microsoft name: BlurEffect Object */ +typedef struct { + U_FLOAT Radius; //!< Blur radius in pixels + uint32_t ExpandEdge; //!< 1: expand bitmap by Radius; 0: bitmap size unchanged +} U_PMF_IE_BLUR; + + +/** @brief EMF+ manual 2.2.3.2, Microsoft name: BrightnessContrastEffect Object */ +typedef struct { + int32_t Brightness; //!< -255 to 255, 0 is unchanged, positive increases, negative decreases + int32_t Contrast; //!< -100 to 100, 0 is unchanged, positive increases, negative decreases +} U_PMF_IE_BRIGHTNESSCONTRAST; + +/** @brief EMF+ manual 2.2.3.3, Microsoft name: ColorBalanceEffect Object */ +typedef struct { + int32_t CyanRed; //!< -100 to 100, 0 is unchanged, positive increases Red & decreases Cyan, negative is opposite + int32_t MagentaGreen; //!< -100 to 100, 0 is unchanged, positive increases Green & decreases Magenta, negative is opposite + int32_t YellowBlue; //!< -100 to 100, 0 is unchanged, positive increases Blue & decreases Yellow, negative is opposite +} U_PMF_IE_COLORBALANCE; + +/** @brief EMF+ manual 2.2.3.4, Microsoft name: ColorCurveEffect Object + Adjust Range + Exposure -255 to 255, 0 is unchanged + Density -255 to 255, 0 is unchanged + Contrast -100 to 100, 0 is unchanged + Highlight -100 to 100, 0 is unchanged + Shadow -100 to 100, 0 is unchanged + WhiteSaturation 0 to 255 + BlackSaturation 0 to 255 +*/ +typedef struct { + uint32_t Adjust; //!< CurveAdjustment enumeration + uint32_t Channel; //!< CurveChannel enumeration + int32_t Intensity; //!< adjustment to apply. "Adjust" determines what field this is and range values. +} U_PMF_IE_COLORCURVE; + +/** @brief EMF+ manual 2.2.3.5, Microsoft name: ColorLookupTableEffect Object */ +typedef struct { + uint8_t BLUT[256]; //!< Blue color lookup table + uint8_t GLUT[256]; //!< Green color lookup table + uint8_t RLUT[256]; //!< Red color lookup table + uint8_t ALUT[256]; //!< Alpha color lookup table +} U_PMF_IE_COLORLOOKUPTABLE; + +/** @brief EMF+ manual 2.2.3.6, Microsoft name: ColorMatrixEffect Object */ +typedef struct { + U_FLOAT M[5][5]; //!< 5 x 5 color transformation matrix, First 4 rows are [{4 multiplier values},0.0] for R,G,B,A, last Row is [{4 color translation valuess}, 1.0] +} U_PMF_IE_COLORMATRIX; + +/** @brief EMF+ manual 2.2.3.7, Microsoft name: HueSaturationLightnessEffect Object */ +typedef struct { + int32_t Hue; //!< -180 to 180, 0 is unchanged + int32_t Saturation; //!< -100 to 100, 0 is unchanged + int32_t Lightness; //!< -100 to 100, 0 is unchanged +} U_PMF_IE_HUESATURATIONLIGHTNESS; + +/** @brief EMF+ manual 2.2.3.8, Microsoft name: LevelsEffect Object */ +typedef struct { + int32_t Highlight; //!< 0 to 100, 100 is unchanged + int32_t Midtone; //!< -100 to 100, 0 is unchanged + int32_t Shadow; //!< 0 to 100, 0 is unchanged +} U_PMF_IE_LEVELS; + +/** @brief EMF+ manual 2.2.3.9, Microsoft name: RedEyeCorrectionEffect Object */ +typedef struct { + int32_t Elements; //!< Number of members in Rects +/* variable part of object, not included in structure + U_RECTL Rects[]; //!< Array of rectangular area(s) to apply red eye correction +*/ +} U_PMF_IE_REDEYECORRECTION; + +/** @brief EMF+ manual 2.2.3.10, Microsoft name: SharpenEffect Object */ +typedef struct { + U_FLOAT Radius; //!< Sharpening radius in pixels + int32_t Sharpen; //!< 0 to 100, 0 is unchanged +} U_PMF_IE_SHARPEN; + +/** @brief EMF+ manual 2.2.3.11, Microsoft name: TintEffect Object */ +typedef struct { + int32_t Hue; //!< -180 to 180, [positive==clockwise] rotation in degrees starting from blue + int32_t Amount; //!< -100 [add black] to 100[add white], 0 is unchanged. Change in hue on specified axis +} U_PMF_IE_TINT; + +/* ************************** EMF+ Records ******************************** */ + +/** @brief EMF+ manual 2.3.1.1, Microsoft name: EmfPlusOffsetClip Record, Index 0x35 */ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header (ignore flags) + U_FLOAT dX; //!< horizontal translation offset to apply to clipping region + U_FLOAT dY; //!< vertical translation offset to apply to clipping region +} U_PMF_OFFSETCLIP; + +/** @brief U_PMF_RESETCLIP EMF+ manual 2.3.1.2, Microsoft name: EmfPlusResetClip Record, Index 0x31 */ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header (ignore flags) +} U_PMF_RESETCLIP; + +/** @brief EMF+ manual 2.3.1.3, Microsoft name: EmfPlusSetClipPath Record, Index 0x33 + +flags (LITTLE endian here, manual uses BIG endian) + bits 8-11 CombineMode enumeration + bits 0-7 Index of an U_PMF_PATH object in the EMF+ object table (0-63, inclusive) +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header +} U_PMF_SETCLIPPATH; + +/** @brief EMF+ manual 2.3.1.4, Microsoft name: EmfPlusSetClipRect Record, Index 0x32 + +flags (LITTLE endian here, manual uses BIG endian) + bits 8-11 CombineMode enumeration +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + U_PMF_RECTF Rect; //!< Rectangle used with CombineMode enumeration from Header.Flags +} U_PMF_SETCLIPRECT; + +/** @brief EMF+ manual 2.3.1.5, Microsoft name: EmfPlusSetClipRegion Record, Index 0x34 + + flags (LITTLE endian here, manual uses BIG endian) + bits 12-15 CombineMode enumeration + bits 0-7 Index of an U_PMF_REGION object in the EMF+ object table (0-63, inclusive) +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header +} U_PMF_SETCLIPREGION; + +/** @brief EMF+ manual 2.3.2.1, Microsoft name: EmfPlusComment Record, Index 0x03 + + variable part of record, not included in structure + char data[]; //!< Private data, may be anything +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header (ignore flags and set to zero) +} U_PMF_COMMENT; + +/** @brief EMF+ manual 2.3.3.1, Microsoft name: EmfPlusEndOfFile Record, Index 0x02 */ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header (ignore flags and set to zero) +} U_PMF_ENDOFFILE; + +/** @brief EMF+ manual 2.3.3.2, Microsoft name: EmfPlusGetDC Record, Index 0x04 */ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header (ignore flags and set to zero) +} U_PMF_GETDC; + +/** @brief EMF+ manual 2.3.3.3, Microsoft name: EmfPlusHeader Record, Index 0x01 + + flags (LITTLE endian here, manual uses BIG endian) + bit 0 Set indicates "dual mode" EMF+ +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header (ignore flags and set to zero) + U_PMF_GRAPHICSVERSION Version; //!< EmfPlusGraphicsVersion object + uint32_t EmfPlusFlags; //!< Reference device 0 bit: set = video device, clear= printer. Ignore all other bits. + uint32_t LogicalDpiX; //!< Horizontal resolution reference device in DPI + uint32_t LogicalDpiY; //!< Vertical resolution reference device in DPI +} U_PMF_HEADER; + +/** @brief EMF+ manual 2.3.4.1, Microsoft name: EmfPlusClear Record, Index 0x09 */ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header (ignore flags and set to zero) + U_PMF_ARGB Color; //!< Erase everything preceding, set background ARGB color. +} U_PMF_CLEAR; + +/** @brief EMF+ manual 2.3.4.2, Microsoft name: EmfPlusDrawArc Record, Index 0x12 + + flags (LITTLE endian here, manual uses BIG endian) + bit 9 U_PPF_C Set: Rect is U_PMF_RECT; Clear: Rect is U_PMF_RECTF + bits 0-7 Index of an U_PMF_PEN object in the EMF+ object table (0-63, inclusive) +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + U_FLOAT Start; //!< Start angle, >=0.0, degrees clockwise from 3:00 + U_FLOAT Sweep; //!< Sweep angle, -360<= angle <=360, degrees clockwise from Start +/* variable part of record, not included in structure + U_RECT or U_RECTF Rect; //!< Bounding box for elliptical arc being drawn. +*/ +} U_PMF_DRAWARC; + +/** @brief EMF+ manual 2.3.4.3, Microsoft name: EmfPlusDrawBeziers Record, Index 0x19 + flags (LITTLE endian here, manual uses BIG endian) + bit 9 U_PPF_C Set: int16_t coordinates; Clear: U_FLOAT coordinates (IGNORE if bit 4 is set) + bit 12 U_PPF_P Set: Coordinates are relative; Clear: they are absolute + bits 0-7 Index of an U_PMF_PEN object in the EMF+ object table (0-63, inclusive) + + bit1 bit4 Type of Data + 1 0 U_EMF_POINT + 0 0 U_EMF_POINTF + 0 1 U_EMF_POINTR +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + uint32_t Elements; //!< Number of members in the Points array +/* + variable part of record, not included in structure + (varies) Points; //!< Points, for type see table above +*/ +} U_PMF_DRAWBEZIERS; + +/** @brief EMF+ manual 2.3.4.4, Microsoft name: EmfPlusDrawClosedCurve Record, Index 0x17 + + flags (LITTLE endian here, manual uses BIG endian) + bit 9 U_PPF_C Set: int16_t coordinates; Clear: U_FLOAT coordinates (IGNORE if bit 4 is set) + bit 12 U_PPF_P Set: Coordinates are relative; Clear: they are absolute + bits 0-7 Index of an U_PMF_PEN object in the EMF+ object table (0-63, inclusive) + + bit1 bit4 Type of Data + 1 0 U_EMF_POINT + 0 0 U_EMF_POINTF + 0 1 U_EMF_POINTR + +Curve is a cardinal spline. +References sent by MS support: + +http://alvyray.com/Memos/CG/Pixar/spline77.pdf +http://msdn.microsoft.com/en-us/library/4cf6we5y(v=vs.110).aspx + +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + U_FLOAT Tension; //!< Controls splines, 0 is straight line, >0 is curved +/* + variable part of record, not included in structure + (varies) Points; //!< Points, for type see table above +*/ +} U_PMF_DRAWCLOSEDCURVE; + +/** @brief EMF+ manual 2.3.4.5, Microsoft name: EmfPlusDrawCurve Record, Index 0x18 + flags (LITTLE endian here, manual uses BIG endian) + bit 9 U_PPF_C Set: int16_t coordinates; Clear: U_FLOAT coordinates (IGNORE if bit 4 is set) + bits 0-7 Index of an U_PMF_PEN object in the EMF+ object table (0-63, inclusive) + + bit1 Type of Data + 1 U_EMF_POINT + 0 U_EMF_POINTF + +Curve is a cardinal spline, using doubled terminator points to generate curves for the terminal segments. +References sent by MS support: + +http://alvyray.com/Memos/CG/Pixar/spline77.pdf +http://msdn.microsoft.com/en-us/library/4cf6we5y(v=vs.110).aspx +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + U_FLOAT Tension; //!< Controls splines, 0 is straight line, >0 is curved + uint32_t Offset; //!< Element in Points that is the spline's starting point + uint32_t NSegs; //!< Number of segments + uint32_t Elements; //!< Number of members in Points array +/* + variable part of record, not included in structure + (varies) Points; //!< Points, for type see table above +*/ +} U_PMF_DRAWCURVE; + +/** @brief EMF+ manual 2.3.4.6, Microsoft name: EmfPlusDrawDriverString Record, Index 0x36 + + flags (LITTLE endian here, manual uses BIG endian) +. bit 15 U_PPF_B Set: BrushID is an U_PFM_ARGB; Clear: is index of U_PMF_BRUSH object in EMF+ object table + bits 0-7 Index of an U_PMF_FONT object in the EMF+ object table (0-63, inclusive) +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + U_FLOAT Tension; //!< Controls splines, 0 is straight line, >0 is curved + uint32_t BrushID; //!< Color or index to Brush object, depends on Flags bit0 + uint32_t DSOFlags; //!< DriverStringOptions flags + uint32_t HasMatrix; //!< If 1 record contains a TransformMatrix field, if 0 it does not. + uint32_t Elements; //!< Number of members in Glyphs and Positions array +/* + variable part of record, not included in structure + uint16_t Glyphs; //!< If U_DSO_CmapLookup is set in DSOFlags this is an array + of UTF16LE characters, otherwise, it is an array of indices into the U_PMF_FONT + object indexed by Object_ID in flags. + U_PMF_POINTF Positions; //!< Coordinates of each member of Glyphs. U_DSO_RealizedAdvance set in DSOFlags + Relative then positions are calculated relative to the first glyph which is stored + in Positions, otherwise, all glyph positions are stored in Positions. + U_PMF_TRANSFORMMATRIX Matrix; //!< Transformation to apply to Glyphs & Positions. Present if HasMatrix is 1 +*/ +} U_PMF_DRAWDRIVERSTRING; + +/** @brief EMF+ manual 2.3.4.7, Microsoft name: EmfPlusDrawEllipse Record, Index 0x0F + + flags (LITTLE endian here, manual uses BIG endian) + bit 9 U_PPF_C Set: Rect is U_PMF_RECT; Clear: Rect is U_PMF_RECTF + bits 0-7 Index of an U_PMF_PEN object in the EMF+ object table (0-63, inclusive) +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header +/* + variable part of record, not included in structure + (varies) Rect; //!< Bounding rectangle, data type set by bit1 of Header.Flags +*/ +} U_PMF_DRAWELLIPSE; + +/** @brief EMF+ manual 2.3.4.8, Microsoft name: EmfPlusDrawImage Record, Index 0x1A + + flags (LITTLE endian here, manual uses BIG endian) + bit 9 U_PPF_C Set: DstRect is U_PMF_RECT; Clear: DstRect is U_PMF_RECTF + bits 0-7 Index of an U_PMF_Image object in the EMF+ object table (0-63, inclusive) +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + uint32_t ImgAttrID; //!< EmfPlusImageAttributes object + int32_t SrcUnit; //!< UnitType enumeration + U_PMF_RECTF SrcRect; //!< Region of image +/* + variable part of record, not included in structure + (varies) DstRect; //!< Destination rectangle for image. Type controlled by bit1 of Header.Flags +*/ +} U_PMF_DRAWIMAGE; + +/** @brief EMF+ manual 2.3.4.9, Microsoft name: EmfPlusDrawImagePoints Record, Index 0x1B + + flags (LITTLE endian here, manual uses BIG endian) + bit 14 U_PPF_C Set: Points is U_PMF_POINT; Clear: Points is U_PMF_POINTF + bit 13 U_PPF_E Set: effect from previous U_PMF_SERIALIZABLEOBJECT record will be applied; Clear: no effect applied + bit 11 U_PPF_P Set: Points has relative coordinates; Clear: Points has absolute coordinates + bits 0-7 Index of an U_PMF_Image object in the EMF+ object table (0-63, inclusive) + + bit1 bit4 Type of Data + 1 0 U_EMF_POINT + 0 0 U_EMF_POINTF + 0 1 U_EMF_POINTR + + WARNING! Windows XP Preview does not show filter effects, whether or not U_PPF_E is set. They are visible if the EMF+ + file is inserted as an image into PowerPoint. +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + uint32_t ImgAttrID; //!< EmfPlusImageAttributes object + int32_t SrcUnit; //!< UnitType enumeration + U_PMF_RECTF SrcRect; //!< Region of image + uint32_t Elements; //!< Number of members in Points, must be 3 +/* + variable part of record, not included in structure + (varies) Points; //!< 3 points of a parallelogram. Type from bit1 and bit4 of Header.Flags, see table above +*/ +} U_PMF_DRAWIMAGEPOINTS; + +/** @brief EMF+ manual 2.3.4.10, Microsoft name: EmfPlusDrawLines Record, Index 0x0D + + flags (LITTLE endian here, manual uses BIG endian) + bit 9 U_PPF_C Set: Points is U_PMF_POINT; Clear: Points is U_PMF_POINTF + bit 10 U_PPF_D Set: close shape by connecting last point to first; Clear: leave path open + bit 12 U_PPF_P Set: Points has relative coordinates; Clear: Points has absolute coordinates + bits 0-7 Index of an U_PMF_Image object in the EMF+ object table (0-63, inclusive) + + bit1 bit4 Type of Data + 1 0 U_EMF_POINT + 0 0 U_EMF_POINTF + 0 1 U_EMF_POINTR +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + uint32_t Elements; //!< Number of members in Points +/* + variable part of record, not included in structure + (varies) Points; //!< Sequence of points to connect with line segments. Type from bit1 and bit4 of Header.Flags, see table above +*/ +} U_PMF_DRAWLINES; + +/** @brief EMF+ manual 2.3.4.11, Microsoft name: EmfPlusDrawPath Record, Index 0x15 + + flags (LITTLE endian here, manual uses BIG endian) + bits 0-7 Index of an U_PMF_PATH object in the EMF+ object table (0-63, inclusive) +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + uint32_t PenID; //!< U_PMF_PEN object in the EMF+ object table (0-63, inclusive) +} U_PMF_DRAWPATH; + +/** @brief EMF+ manual 2.3.4.12, Microsoft name: EmfPlusDrawPie Record, Index 0x0D + + flags (LITTLE endian here, manual uses BIG endian) + bit 9 U_PPF_C Set: Rect is U_PMF_RECT; Clear: Rect is U_PMF_RECTF + bits 0-7 Index of an U_PMF_Pen object in the EMF+ object table (0-63, inclusive) +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + U_FLOAT Start; //!< Start angle, >=0.0, degrees clockwise from 3:00 + U_FLOAT Sweep; //!< Sweep angle, -360<= angle <=360, degrees clockwise from Start +/* + variable part of record, not included in structure + U_RECT or U_RECTF Rect; //!< Bounding box for elliptical pie segment being drawn. Type from bit1 of Header.Flags, see above +*/ +} U_PMF_DRAWPIE; + +/** @brief EMF+ manual 2.3.4.13, Microsoft name: EmfPlusDrawRects Record, Index 0x0B + + flags (LITTLE endian here, manual uses BIG endian) + bit 9 U_PPF_C Set: Rect is U_PMF_RECT; Clear: Rect is U_PMF_RECTF + bits 0-7 Index of an U_PMF_Pen object in the EMF+ object table (0-63, inclusive) +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + uint32_t Elements; //!< Number of members in Rects +/* + variable part of record, not included in structure + U_RECT or U_RECTF Rects; //!< Array of rectangles to draw. Type from bit1 of Header.Flags, see above +*/ +} U_PMF_DRAWRECTS; + +/** @brief EMF+ manual 2.3.4.14, Microsoft name: EmfPlusDrawString Record, Index 0x1C + + flags (LITTLE endian here, manual uses BIG endian) + bit 15 U_PPF_B Set: BrushID is an U_PFM_ARGB; Clear: is index of U_PMF_BRUSH object in EMF+ object table. + bits 0-7 Index of an U_PMF_FONT object in the EMF+ object table (0-63, inclusive) +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + uint32_t BrushID; //!< Color or index to Brush object, depends on Flags bit0 + uint32_t FormatID; //!< U_PMF_STRINGFORMAT object in EMF+ Object Table. + uint32_t Length; //!< Number of characters in the string. + U_PMF_RECTF Rect; //!< String's bounding box. +/* + variable part of record, not included in structure + uint16_t String; //!< Array of UFT-16LE unicode characters. +*/ +} U_PMF_DRAWSTRING; + +/** @brief EMF+ manual 2.3.4.15, Microsoft name: EmfPlusFillClosedCurve Record, Index 0x16 + + flags (LITTLE endian here, manual uses BIG endian) + bit 15 U_PPF_B Set: BrushID is an U_PFM_ARGB; Clear: is index of U_PMF_BRUSH object in EMF+ object table. + bit 9 U_PPF_C Set: Points is U_PMF_POINT; Clear: Points is U_PMF_POINTF + bit 10 U_PPF_F Set: winding fill; Clear: alternate fill + bit 12 U_PPF_P Set: Points has relative coordinates; Clear: Points has absolute coordinates + + bit1 bit4 Type of Data + 1 0 U_EMF_POINT + 0 0 U_EMF_POINTF + 0 1 U_EMF_POINTR +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + uint32_t BrushID; //!< Color or index to Brush object, depends on Header.Flags bit0 + U_FLOAT Tension; //!< Controls splines, 0 is straight line, >0 is curved + uint32_t Elements; //!< Number of members in Points +/* + variable part of record, not included in structure + (varies) Points; //!< Sequence of points to connect. Type from bit1 and bit4 of Header.Flags, see table above +*/ +} U_PMF_FILLCLOSEDCURVE; + +/** @brief EMF+ manual 2.3.4.16, Microsoft name: EmfPlusFillEllipse Record, Index 0x0E + + flags (LITTLE endian here, manual uses BIG endian) + bit 15 U_PPF_B Set: BrushID is an U_PFM_ARGB; Clear: is index of U_PMF_BRUSH object in EMF+ object table. + bit 9 U_PPF_C Set: Rect is U_PMF_RECT; Clear: Rect is U_PMF_RECTF +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + uint32_t BrushID; //!< Color or index to Brush object, depends on Header.Flags bit0 +/* + variable part of record, not included in structure + U_RECT or U_RECTF Rect; //!< Bounding box for elliptical pie segment being drawn. Type from bit1 of Header.Flags, see above +*/ +} U_PMF_FILLELLIPSE; + +/** @brief EMF+ manual 2.3.4.17, Microsoft name: EmfPlusFillPath Record, Index 0x14 +Note: U_PMF_FILLPATHOBJ is the object, U_PMF_FILLPATH is the file record + + flags (LITTLE endian here, manual uses BIG endian) + bit 15 U_PPF_B Set: BrushID is an U_PFM_ARGB; Clear: is index of U_PMF_BRUSH object in EMF+ object table. + bits 0-7 Index of an U_PMF_PATH object in the EMF+ object table (0-63, inclusive) +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + uint32_t BrushID; //!< Color or index to Brush object, depends on Header.Flags bit0 +} U_PMF_FILLPATH; + +/** @brief EMF+ manual 2.3.4.18, Microsoft name: EmfPlusFillPie Record, Index 0x10 + + flags (LITTLE endian here, manual uses BIG endian) + bit 15 U_PPF_B Set: BrushID is an U_PFM_ARGB; Clear: is index of U_PMF_BRUSH object in EMF+ object table. + bit 9 U_PPF_C Set: Rect is U_PMF_RECT; Clear: Rect is U_PMF_RECTF +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + uint32_t BrushID; //!< Color or index to Brush object, depends on Header.Flags bit0 + U_FLOAT Start; //!< Start angle, >=0.0, degrees clockwise from 3:00 + U_FLOAT Sweep; //!< Sweep angle, -360<= angle <=360, degrees clockwise from Start +/* + variable part of record, not included in structure + U_RECT or U_RECTF Rect; //!< Bounding box for elliptical pie segment being filled. Type from bit1 of Header.Flags, see above +*/ +} U_PMF_FILLPIE; + +/** @brief EMF+ manual 2.3.4.19, Microsoft name: EmfPlusFillPolygon Record, Index 0x0C + + flags (LITTLE endian here, manual uses BIG endian) + bit 15 U_PPF_B Set: BrushID is an U_PFM_ARGB; Clear: is index of U_PMF_BRUSH object in EMF+ object table. + bit 9 U_PPF_C Set: Points is U_PMF_POINT; Clear: Points is U_PMF_POINTF + bit 12 U_PPF_P Set: Points has relative coordinates; Clear: Points has absolute coordinates + + bit1 bit4 Type of Data + 1 0 U_EMF_POINT + 0 0 U_EMF_POINTF + 0 1 U_EMF_POINTR +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + uint32_t BrushID; //!< Color or index to Brush object, depends on Header.Flags bit0 + uint32_t Elements; //!< Number of members in Points +/* + variable part of record, not included in structure + (varies) Points; //!< Sequence of points to connect with line segments. Type from bit1 and bit4 of Header.Flags, see table above +*/ +} U_PMF_FILLPOLYGON; + +/** @brief EMF+ manual 2.3.4.20, Microsoft name: EmfPlusFillRects Record, Index 0x0A + + flags (LITTLE endian here, manual uses BIG endian) + bit 15 U_PPF_B Set: BrushID is an U_PFM_ARGB; Clear: is index of U_PMF_BRUSH object in EMF+ object table. + bit 9 U_PPF_C Set: Rect is U_PMF_RECT; Clear: Rect is U_PMF_RECTF +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + uint32_t BrushID; //!< Color or index to Brush object, depends on Header.Flags bit0 + uint32_t Elements; //!< Number of members in Rects +/* + variable part of record, not included in structure + U_RECT or U_RECTF Rects; //!< Array of rectangles to draw. Type from bit1 of Header.Flags, see above +*/ +} U_PMF_FILLRECTS; + +/** @brief EMF+ manual 2.3.4.21, Microsoft name: EmfPlusFillRegion Record, Index 0x13 + + flags (LITTLE endian here, manual uses BIG endian) + bit 15 U_PPF_B Set: BrushID is an U_PFM_ARGB; Clear: is index of U_PMF_BRUSH object in EMF+ object table. + bits 0-7 Index of an U_PMF_REGION object in the EMF+ object table (0-63, inclusive) +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + uint32_t BrushID; //!< Color or index to Brush object, depends on Header.Flags bit0 +} U_PMF_FILLREGION; + +/** @brief EMF+ manual 2.3.5.1, Microsoft name: EmfPlusObject Record, Index 0x13 + + flags (LITTLE endian here, manual uses BIG endian) + bit 15 U_PPF_N Set: object definition continues in next record; Clear: this is the final object definition record + bits 8-14 Type of object being created, ObjectType enumeration + bits 0-7 Index of an U_PMF_REGION object in the EMF+ object table (0-63, inclusive) +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header +/* + variable part of record, not included in structure + uint8_t Data; //!< Object's data. Type from bits1-7 and bits8-15 of Header.Flags, see above +*/ +} U_PMF_OBJECT; + +/** @brief EMF+ manual 2.3.5.2, Microsoft name: EmfPlusSerializableObject Record, Index 0x38 + + WARNING! Windows XP Preview does not show filter effects, whether or not U_PPF_E is set. They are visible if the EMF+ + file is inserted as an image into PowerPoint. + +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header (ignore flags and set to zero) + uint8_t GUID[16]; //!< ImageEffects identifier. Composed of Data1[4]-Data2[2]-Data3[2]-Data4[8] + //!< Data1-Data3 are stored as little endian integers. Data4 is stored big endian (like a string) + uint32_t Size; //!< Bytes in Data. +/* + variable part of record, not included in structure + uint8_t Data; //!< "Serialized image effects parameter block". One of the ImageEffects objects. +*/ +} U_PMF_SERIALIZABLEOBJECT; + +/** @brief EMF+ manual 2.3.6.1, Microsoft name: EmfPlusSetAntiAliasMode Record, Index 0x1E + + flags (LITTLE endian here, manual uses BIG endian) + bits 7-1 SmoothingMode enumeration + bit 0 U_PPF_AA Set: anti-aliasing on; Clear: anti-aliasing off +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header +} U_PMF_SETANTIALIASMODE; + +/** @brief EMF+ manual 2.3.6.2, Microsoft name: EmfPlusSetCompositingMode Record, Index 0x23 + + flags (LITTLE endian here, manual uses BIG endian) + bits 0-7 CompositingMode enumeration +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header +} U_PMF_SETCOMPOSITINGMODE; + +/** @brief EMF+ manual 2.3.6.3, Microsoft name: EmfPlusSetCompositingQuality Record, Index 0x24 + + flags (LITTLE endian here, manual uses BIG endian) + bits 0-7 CompositingQuality enumeration +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header +} U_PMF_SETCOMPOSITINGQUALITY; + +/** @brief EMF+ manual 2.3.6.4, Microsoft name: EmfPlusSetInterpolationMode Record, Index 0x21 + + flags (LITTLE endian here, manual uses BIG endian) + bits 0-7 InterpolationMode enumeration +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header +} U_PMF_SETINTERPOLATIONMODE; + +/** @brief EMF+ manual 2.3.6.5, Microsoft name: EmfPlusSetPixelOffsetMode Record, Index 0x22 + + flags (LITTLE endian here, manual uses BIG endian) + bits 0-7 PixelOffsetMode enumeration +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header +} U_PMF_SETPIXELOFFSETMODE; + +/** @brief EMF+ manual 2.3.6.6, Microsoft name: EmfPlusSetRenderingOrigin Record, Index 0x1D */ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header (ignore flags and set to zero) + int32_t X; //!< X coordinate of rendering origin + int32_t Y; //!< Y coordinate of rendering origin +} U_PMF_SETRENDERINGORIGIN; + +/** @brief EMF+ manual 2.3.6.7, Microsoft name: EmfPlusSetTextContrast Record, Index 0x20 + + flags (LITTLE endian here, manual uses BIG endian) + bits 12-0 1000 x Gamma correction value. Range 1000-2200 = gamma 1.0-2.2 +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header +} U_PMF_SETTEXTCONTRAST; + +/** @brief EMF+ manual 2.3.6.8, Microsoft name: EmfPlusSetTextRenderingHint Record, Index 0x1F + + flags (LITTLE endian here, manual uses BIG endian) + bits 0-7 TextRenderingHint enumeration +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header +} U_PMF_SETTEXTRENDERINGHINT; + +/** @brief EMF+ manual 2.3.7.1, Microsoft name: EmfPlusBeginContainer Record, Index 0x27 + + flags (LITTLE endian here, manual uses BIG endian) + bits 8-15 UnitType enumeration + bits 0-7 (all zero) +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + U_PMF_RECTF DstRect; //!< with SrcRect specifies a transformation + U_PMF_RECTF SrcRect; //!< with DstRect specifies a transformation + uint32_t Index; //!< Index to apply to this graphics container +} U_PMF_BEGINCONTAINER; + +/** @brief EMF+ manual 2.3.7.2, Microsoft name: EmfPlusBeginContainerNoParams Record, Index 0x28 */ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header (ignore flags and set to zero) + uint32_t Index; //!< Index to apply to this graphics container +} U_PMF_BEGINCONTAINERNOPARAMS; + +/** @brief EMF+ manual 2.3.7.3, Microsoft name: EmfPlusEndContainer Record, Index 0x29 */ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header (ignore flags and set to zero) + uint32_t Index; //!< Index of container being closed, from U_PMF_BEGINCONTAINERNOPARAMS or U_PMF_BEGINCONTAINER +} U_PMF_ENDCONTAINER; + +/** @brief EMF+ manual 2.3.7.4, Microsoft name: EmfPlusRestore Record, Index 0x26 */ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header (ignore flags and set to zero) + uint32_t Index; //!< Index of Graphics State being restored, from U_PMF_SAVE +} U_PMF_RESTORE; + +/** @brief EMF+ manual 2.3.7.5, Microsoft name: EmfPlusSave Record, Index 0x25 */ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header (ignore flags and set to zero) + uint32_t Index; //!< Index of Graphics State being saved +} U_PMF_SAVE; + +/** @brief EMF+ manual 2.3.8.1, Microsoft name: EmfPlusSetTSClip Record, Index 0x3A + + flags (LITTLE endian here, manual uses BIG endian) + bit 15 U_PPF_K Set: Rect is U_PMF_RECT; Clear: Rect is U_PMF_RECTF + bits 14-0 Number of rectangles in Rects field +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header +/* + variable part of record, not included in structure + U_RECT or U_RECTF Rects; //!< Array of rectangles to draw. Type from bit0 of Header.Flags, see above +*/ +} U_PMF_SETTSCLIP; + +/** @brief EMF+ manual 2.3.8.2, Microsoft name: EmfPlusSetTSGraphics Record, Index 0x39 + + flags (LITTLE endian here, manual uses BIG endian) + bit 1 U_PPF_VGA Set: Palette is VGA basic colors; Clear: Palette is a U_PMF_PALETTE object. + bit 0 U_PPF_PP Set: Palette field is present; Clear: Palette field is absent +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + uint8_t AntiAliasMode; //!< SmoothingMode enumeration + uint8_t TextRenderHint; //!< TextRenderingHint enumeration + uint8_t CompositingMode; //!< CompositingMode enumeration + uint8_t CompositingQuality; //!< CompositingQuality enumeration + int16_t RenderOriginX; //!< Origin X for halftoning and dithering + int16_t RenderOriginY; //!< Origin Y for halftoning and dithering + uint16_t TextContrast; //!< Gamma correction, range 0 to 12 + uint8_t FilterType; //!< FilterType enumeraton + uint8_t PixelOffset; //!< PixelOffsetMode enumeration + U_PMF_TRANSFORMMATRIX WorldToDevice; //!< world to device transform +/* + optional part of record, not included in structure + U_PMF_PALETTE Palette; //!< Present if bit15 of Header.Flags is set +*/ +} U_PMF_SETTSGRAPHICS; + +/** @brief EMF+ manual 2.3.9.1, Microsoft name: EmfPlusMultiplyWorldTransform Record, Index 0x2C + + flags (LITTLE endian here, manual uses BIG endian) + bit 13 U_PPF_XM Set: Post multiply; Clear: Pre multiply +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + U_PMF_TRANSFORMMATRIX Matrix; //!< Transformation matrix +} U_PMF_MULTIPLYWORLDTRANSFORM; + +/** @brief EMF+ manual 2.3.9.2, Microsoft name: EmfPlusResetWorldTransform Record, Index 0x2B +Sets transformation matrix to identity matrix. +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header (ignore flags and set to zero) +} U_PMF_RESETWORLDTRANSFORM; + +/** @brief EMF+ manual 2.3.9.3, Microsoft name: EmfPlusRotateWorldTransform Record, Index 0x2F + Construct transformation matrix from Angle: + sin(Angle) cos(Angle) 0 + cos(Angle) -sin(Angle) 0 + Multiply this against current world space transform, result becomes new world space transform. + + flags (LITTLE endian here, manual uses BIG endian) + bit 13 U_PPF_XM Set: Post multiply; Clear: Pre multiply +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + U_FLOAT Angle; //!< Rotation angle, in degrees +} U_PMF_ROTATEWORLDTRANSFORM; + +/** @brief EMF+ manual 2.3.9.4, Microsoft name: EmfPlusScaleWorldTransform Record, Index 0x2E + Construct transformation matrix: + Sx 0 0 + 0 Sy 0 + Multiply this against current world space transform, result becomes new world space transform. + + flags (LITTLE endian here, manual uses BIG endian) + bit 13 U_PPF_XM Set: Post multiply; Clear: Pre multiply +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + U_FLOAT Sx; //!< X scale factor + U_FLOAT Sy; //!< Y scale factor +} U_PMF_SCALEWORLDTRANSFORM; + +/** @brief EMF+ manual 2.3.9.5, Microsoft name: EmfPlusSetPageTransform Record, Index 0x30 + flags (LITTLE endian here, manual uses BIG endian) + bits 0-7 UnitType enumeration +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + U_FLOAT Scale; //!< Scale factor to convert page space to device space +} U_PMF_SETPAGETRANSFORM; + + +/** @brief EMF+ manual 2.3.9.6, Microsoft name: EmfPlusSetWorldTransform Record, Index 0x2A */ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header (ignore flags and set to zero) + U_PMF_TRANSFORMMATRIX Matrix; //!< Transformation matrix +} U_PMF_SETWORLDTRANSFORM; + +/** @brief EMF+ manual 2.3.9.7, Microsoft name: EmfPlusTranslateWorldTransform Record, Index 0x2D + Construct transformation matrix: + 1 0 Dx + 0 1 Dy + Multiply this against current world space transform, result becomes new world space transform. + + flags (LITTLE endian here, manual uses BIG endian) + bit 13 U_PPF_XM Set: Post multiply; Clear: Pre multiply +*/ +typedef struct { + U_PMF_CMN_HDR Header; //!< Common header + U_FLOAT Dx; //!< X offset + U_FLOAT Dy; //!< Y offset +} U_PMF_TRANSLATEWORLDTRANSFORM; + +//! \cond + +/* EMF+ prototypes (helper functions) */ +void U_PMR_write(U_PSEUDO_OBJ *po, U_PSEUDO_OBJ *sum, EMFTRACK *et); +int U_PMR_drawline(uint32_t PenID, uint32_t PathID, U_PMF_POINTF Start, U_PMF_POINTF End, int Dashed, U_PSEUDO_OBJ *sum, EMFTRACK *et); +int U_PMR_drawstring( const char *string, int Vpos, uint32_t FontID, const U_PSEUDO_OBJ *BrushID, uint32_t FormatID, + U_PMF_STRINGFORMAT Sfs, const char *FontName, U_FLOAT Height, U_FontInfoParams *fip, uint32_t FontFlags, + U_FLOAT x, U_FLOAT y, U_PSEUDO_OBJ *sum, EMFTRACK *et); +U_PMF_POINT *POINTF_To_POINT16_LE(U_PMF_POINTF *points, int count); +int U_PMF_LEN_REL715(const char *contents, int Elements); +int U_PMF_LEN_FLOATDATA(const char *contents); +int U_PMF_LEN_BYTEDATA(const char *contents); +int U_PMF_LEN_PENDATA(const char *PenData); +int U_PMF_LEN_OPTPENDATA(const char *PenData, uint32_t Flags); +char *U_PMF_CURLYGUID_set(uint8_t *GUID); +int U_PMF_KNOWNCURLYGUID_set(const char *string); +void U_PMF_MEMCPY_SRCSHIFT(void *Dst, const char **Src, size_t Size); +void U_PMF_MEMCPY_DSTSHIFT(char **Dst, const void *Src, size_t Size); +void U_PMF_REPCPY_DSTSHIFT(char **Dst, const void *Src, size_t Size, size_t Reps); +void U_PMF_PTRSAV_SHIFT(const char **Dst, const char **Src, size_t Size); +uint16_t U_PMF_HEADERFLAGS_get(const char *contents); +int U_PMF_CMN_HDR_get(const char **contents, U_PMF_CMN_HDR *Header); +int U_OID_To_OT(uint32_t OID); +int U_OID_To_BT(uint32_t OID); +int U_OID_To_CLCDT(uint32_t OID); +int U_OID_To_IDT(uint32_t OID); +int U_OID_To_RNDT(uint32_t OID); +uint8_t *U_OID_To_GUID(uint32_t OID); +int U_OA_append(U_OBJ_ACCUM *oa, const char *data, int size, int Type, int Id); +int U_OA_clear(U_OBJ_ACCUM *oa); +int U_OA_release(U_OBJ_ACCUM *oa); +U_PSEUDO_OBJ *U_PO_create(char *Data, size_t Size, size_t Use, uint32_t Type); +U_PSEUDO_OBJ *U_PO_append(U_PSEUDO_OBJ *po, const char *Data, size_t Size); +U_PSEUDO_OBJ *U_PO_po_append(U_PSEUDO_OBJ *po, U_PSEUDO_OBJ *src, int StripE); +int U_PO_free(U_PSEUDO_OBJ **po); +U_DPSEUDO_OBJ *U_PATH_create(int Elements, const U_PMF_POINTF *Points, uint8_t First, uint8_t Others); +int U_DPO_free(U_DPSEUDO_OBJ **dpo); +int U_DPO_clear(U_DPSEUDO_OBJ *dpo); +int U_PATH_moveto(U_DPSEUDO_OBJ *path, U_PMF_POINTF Point, uint8_t Flags); +int U_PATH_lineto(U_DPSEUDO_OBJ *path, U_PMF_POINTF Point, uint8_t Flags); +int U_PATH_closepath(U_DPSEUDO_OBJ *path); +int U_PATH_polylineto(U_DPSEUDO_OBJ *path, uint32_t Elements, const U_PMF_POINTF *Points, uint8_t Flags, uint8_t StartSeg); +int U_PATH_polybezierto(U_DPSEUDO_OBJ *path, uint32_t Elements, const U_PMF_POINTF *Points, uint8_t Flags, uint8_t StartSeg); +int U_PATH_polygon(U_DPSEUDO_OBJ *Path, uint32_t Elements, const U_PMF_POINTF *Points, uint8_t Flags); +int U_PATH_arcto(U_DPSEUDO_OBJ *Path, U_FLOAT Start, U_FLOAT Sweep, U_FLOAT Rot, U_PMF_RECTF *Rect, uint8_t Flags, int StartSeg); +U_PMF_POINTF *pointfs_transform(U_PMF_POINTF *points, int count, U_XFORM xform); +U_PMF_RECTF *rectfs_transform(U_PMF_RECTF *rects, int count, U_XFORM xform); +U_PMF_TRANSFORMMATRIX tm_for_gradrect(U_FLOAT Angle, U_FLOAT w, U_FLOAT h, U_FLOAT x, U_FLOAT y, U_FLOAT Periods); +U_PSEUDO_OBJ *U_PMR_drawfill(uint32_t PathID, uint32_t PenID, const U_PSEUDO_OBJ *BrushID); + + +char *U_pmr_names(unsigned int idx); + +/* EMF+ prototypes (objects_set) */ + +U_PSEUDO_OBJ *U_PMF_BRUSH_set(uint32_t Version, const U_PSEUDO_OBJ *po); +U_PSEUDO_OBJ *U_PMF_CUSTOMLINECAP_set(uint32_t Version, const U_PSEUDO_OBJ *po); +U_PSEUDO_OBJ *U_PMF_FONT_set(uint32_t Version, U_FLOAT EmSize, uint32_t SizeUnit, + int32_t FSFlags, uint32_t Length, const uint16_t *Font); +U_PSEUDO_OBJ *U_PMF_IMAGE_set(uint32_t Version, const U_PSEUDO_OBJ *po); +U_PSEUDO_OBJ *U_PMF_IMAGEATTRIBUTES_set(uint32_t Version, uint32_t WrapMode, uint32_t ClampColor, uint32_t ObjectClamp); +U_PSEUDO_OBJ *U_PMF_PATH_set(uint32_t Version, const U_PSEUDO_OBJ *Points, const U_PSEUDO_OBJ *Types); +U_PSEUDO_OBJ *U_PMF_PATH_set2(uint32_t Version, const U_DPSEUDO_OBJ *Path); +U_PSEUDO_OBJ *U_PMF_PATH_set3(uint32_t Version, const U_DPSEUDO_OBJ *Path); +U_PSEUDO_OBJ *U_PMF_PEN_set(uint32_t Version, const U_PSEUDO_OBJ *PenData, const U_PSEUDO_OBJ *Brush); +U_PSEUDO_OBJ *U_PMF_REGION_set(uint32_t Version, uint32_t Count, const U_PSEUDO_OBJ *Nodes); +U_PSEUDO_OBJ *U_PMF_STRINGFORMAT_set(U_PMF_STRINGFORMAT *Sfs, const U_PSEUDO_OBJ *Sfd); +U_PSEUDO_OBJ *U_PMF_4NUM_set(uint32_t BrushID); +U_PSEUDO_OBJ *U_PMF_ARGB_set(uint8_t Alpha, uint8_t Red, uint8_t Green, uint8_t Blue); +U_PSEUDO_OBJ *U_PMF_ARGBN_set(uint32_t Count, U_PMF_ARGB *Colors); +U_PMF_ARGB U_PMF_ARGBOBJ_set(uint8_t Alpha, uint8_t Red, uint8_t Green, uint8_t Blue); +U_PSEUDO_OBJ *U_PMF_BITMAP_set(const U_PMF_BITMAP *Bs, const U_PSEUDO_OBJ *Bm); +U_PSEUDO_OBJ *U_PMF_BITMAPDATA_set( const U_PSEUDO_OBJ *Ps, int cbBm, const char *Bm); +U_PSEUDO_OBJ *U_PMF_BLENDCOLORS_set(uint32_t Elements, const U_FLOAT *Positions, const U_PSEUDO_OBJ *Colors); +U_PSEUDO_OBJ *U_PMF_BLENDCOLORS_linear_set(uint32_t Elements,U_PMF_ARGB StartColor, U_PMF_ARGB EndColor); +U_PSEUDO_OBJ *U_PMF_BLENDFACTORS_set(uint32_t Elements, const U_FLOAT *Positions, const U_FLOAT *Factors); +U_PSEUDO_OBJ *U_PMF_BLENDFACTORS_linear_set(uint32_t Elements, U_FLOAT StartFactor, U_FLOAT EndFactor); +U_PSEUDO_OBJ *U_PMF_BOUNDARYPATHDATA_set(const U_PSEUDO_OBJ *Path); +U_PSEUDO_OBJ *U_PMF_BOUNDARYPOINTDATA_set(uint32_t Elements, const U_PMF_POINTF *Points); +U_PSEUDO_OBJ *U_PMF_CHARACTERRANGE_set(int32_t First, int32_t Length); +U_PSEUDO_OBJ *U_PMF_COMPOUNDLINEDATA_set(int32_t Elements, const char *Widths); +U_PSEUDO_OBJ *U_PMF_COMPRESSEDIMAGE_set(int32_t cbImage, const char *Image); +U_PSEUDO_OBJ *U_PMF_CUSTOMENDCAPDATA_set(const U_PSEUDO_OBJ *Clc); +U_PSEUDO_OBJ *U_PMF_CUSTOMLINECAPARROWDATA_set(U_FLOAT Width, U_FLOAT Height, + U_FLOAT MiddleInset, uint32_t FillState, uint32_t StartCap, uint32_t EndCap, uint32_t Join, + U_FLOAT MiterLimit, U_FLOAT WidthScale); +U_PSEUDO_OBJ *U_PMF_CUSTOMLINECAPDATA_set(uint32_t Flags, uint32_t Cap, + U_FLOAT Inset, uint32_t StartCap, uint32_t EndCap, + uint32_t Join, U_FLOAT MiterLimit, U_FLOAT WidthScale, + const U_PSEUDO_OBJ *Clcod); +U_PSEUDO_OBJ *U_PMF_CUSTOMLINECAPOPTIONALDATA_set(const U_PSEUDO_OBJ *Fill, const U_PSEUDO_OBJ *Line); +U_PSEUDO_OBJ *U_PMF_CUSTOMSTARTCAPDATA_set(const U_PSEUDO_OBJ *Clc); +U_PSEUDO_OBJ *U_PMF_DASHEDLINEDATA_set(int32_t Elements, const U_FLOAT *Lengths); +U_PSEUDO_OBJ *U_PMF_DASHEDLINEDATA_set2(U_FLOAT Unit, int StdPat); +U_PSEUDO_OBJ *U_PMF_DASHEDLINEDATA_set3(U_FLOAT Unit, uint32_t BitPat); +U_PSEUDO_OBJ *U_PMF_FILLPATHOBJ_set(const U_PSEUDO_OBJ *Path); +U_PSEUDO_OBJ *U_PMF_FOCUSSCALEDATA_set(U_FLOAT ScaleX, U_FLOAT ScaleY); +U_PSEUDO_OBJ *U_PMF_GRAPHICSVERSION_set(int GrfVersion); +U_PMF_GRAPHICSVERSION U_PMF_GRAPHICSVERSIONOBJ_set(int GrfVersion); +U_PSEUDO_OBJ *U_PMF_HATCHBRUSHDATA_set(uint32_t Style, const U_PSEUDO_OBJ *Fg, const U_PSEUDO_OBJ *Bg); +U_PSEUDO_OBJ *U_PMF_INTEGER7_set(int value); +U_PSEUDO_OBJ *U_PMF_INTEGER15_set(int value); +U_PMF_LANGUAGEIDENTIFIER U_PMF_LANGUAGEIDENTIFIEROBJ_set(int SubLId, int PriLId); +U_PSEUDO_OBJ *U_PMF_LANGUAGEIDENTIFIER_set(U_PMF_LANGUAGEIDENTIFIER LId); +U_PSEUDO_OBJ *U_PMF_LINEARGRADIENTBRUSHDATA_set(const U_PMF_LINEARGRADIENTBRUSHDATA *Lgbd, const U_PSEUDO_OBJ *Lgbod); +U_PSEUDO_OBJ *U_PMF_LINEARGRADIENTBRUSHOPTIONALDATA_set(uint32_t *Flags, const U_PSEUDO_OBJ *Tm, const U_PSEUDO_OBJ *Bc, const U_PSEUDO_OBJ *BfH, const U_PSEUDO_OBJ *BfV); +U_PSEUDO_OBJ *U_PMF_LINEPATH_set(const U_PSEUDO_OBJ *Path); +U_PSEUDO_OBJ *U_PMF_METAFILE_set(void); +U_PSEUDO_OBJ *U_PMF_PALETTE_set(uint32_t Flags, uint32_t Elements, const U_PMF_ARGB *Pd); +U_PSEUDO_OBJ *U_PMF_PATHGRADIENTBRUSHDATA_set(uint32_t Flags, int32_t WrapMode, U_PMF_ARGB CenterColor, + U_PMF_POINTF Center, const U_PSEUDO_OBJ *Gradient, const U_PSEUDO_OBJ *Boundary, const U_PSEUDO_OBJ *Data); +U_PSEUDO_OBJ *U_PMF_PATHGRADIENTBRUSHOPTIONALDATA_set(uint32_t Flags, + const U_PSEUDO_OBJ *Tm, const U_PSEUDO_OBJ *Pd, const U_PSEUDO_OBJ *Fsd); +U_PSEUDO_OBJ *U_PMF_PATHPOINTTYPE_set(uint32_t Elements, const uint8_t *Ppt); +U_PSEUDO_OBJ *U_PMF_PATHPOINTTYPE_set2(uint32_t Elements, uint8_t Start, uint8_t Others); +U_PSEUDO_OBJ *U_PMF_PATHPOINTTYPERLE_set(uint32_t Elements, const uint8_t *Bz, const uint8_t *RL, const uint8_t *Ppte); +U_PSEUDO_OBJ *U_PMF_PENDATA_set(uint32_t Unit, U_FLOAT Width, const U_PSEUDO_OBJ *Pod); +U_PSEUDO_OBJ *U_PMF_PENOPTIONALDATA_set(uint32_t Flags, U_PSEUDO_OBJ *Tm, int32_t StartCap, int32_t EndCap, uint32_t Join, + U_FLOAT MiterLimit, int32_t Style, int32_t DLCap, U_FLOAT DLOffset, + U_PSEUDO_OBJ *DLData, int32_t PenAlignment, U_PSEUDO_OBJ *CmpndLineData, U_PSEUDO_OBJ *CSCapData, + U_PSEUDO_OBJ *CECapData); +U_PSEUDO_OBJ *U_PMF_POINT_set(uint32_t Elements, const U_PMF_POINT *Coords); +U_PSEUDO_OBJ *U_PMF_POINTF_set(uint32_t Elements, const U_PMF_POINTF *Coords); +U_PSEUDO_OBJ *U_PMF_POINTR_set(uint32_t Elements, const U_PMF_POINTF *Coords); +U_PSEUDO_OBJ *U_PMF_RECT4_set(int16_t X, int16_t Y, int16_t Width, int16_t Height); +U_PSEUDO_OBJ *U_PMF_RECT_set(U_PMF_RECT *Rect); +U_PSEUDO_OBJ *U_PMF_RECTN_set(uint32_t Elements, U_PMF_RECT *Rects); +U_PSEUDO_OBJ *U_PMF_RECTF4_set(U_FLOAT X, U_FLOAT Y, U_FLOAT Width, U_FLOAT Height); +U_PSEUDO_OBJ *U_PMF_RECTF_set(U_PMF_RECTF *Rect); +U_PSEUDO_OBJ *U_PMF_RECTFN_set(uint32_t Elements, U_PMF_RECTF *Rects); +U_PSEUDO_OBJ *U_PMF_REGIONNODE_set(int32_t Type, const U_PSEUDO_OBJ *Rnd); +U_PSEUDO_OBJ *U_PMF_REGIONNODECHILDNODES_set(const U_PSEUDO_OBJ *Left, const U_PSEUDO_OBJ *Right); +U_PSEUDO_OBJ *U_PMF_REGIONNODEPATH_set(const U_PSEUDO_OBJ *Path); +U_PSEUDO_OBJ *U_PMF_SOLIDBRUSHDATA_set(const U_PSEUDO_OBJ *Color); +U_PSEUDO_OBJ *U_PMF_STRINGFORMATDATA_set(uint32_t TabStopCount, U_FLOAT *TabStops, const U_PSEUDO_OBJ *Ranges); +U_PSEUDO_OBJ *U_PMF_TEXTUREBRUSHDATA_set(uint32_t Flags, uint32_t WrapMode, const U_PSEUDO_OBJ *Tbod); +U_PSEUDO_OBJ *U_PMF_TEXTUREBRUSHOPTIONALDATA_set(const U_PSEUDO_OBJ *Tm, const U_PSEUDO_OBJ *Image); +U_PSEUDO_OBJ *U_PMF_TRANSFORMMATRIX_set(U_PMF_TRANSFORMMATRIX *Tm); +U_PSEUDO_OBJ *U_PMF_IE_BLUR_set(U_FLOAT Radius, uint32_t ExpandEdge); +U_PSEUDO_OBJ *U_PMF_IE_BRIGHTNESSCONTRAST_set(int32_t Brightness, int32_t Contrast); +U_PSEUDO_OBJ *U_PMF_IE_COLORBALANCE_set(int32_t CyanRed, int32_t MagentaGreen, int32_t YellowBlue); +U_PSEUDO_OBJ *U_PMF_IE_COLORCURVE_set(uint32_t Adjust, uint32_t Channel, int32_t Intensity); +U_PSEUDO_OBJ *U_PMF_IE_COLORLOOKUPTABLE_set(const uint8_t *BLUT, const uint8_t *GLUT, const uint8_t *RLUT, const uint8_t *ALUT); +U_PSEUDO_OBJ *U_PMF_IE_COLORMATRIX_set(const U_FLOAT *Matrix); +U_PSEUDO_OBJ *U_PMF_IE_HUESATURATIONLIGHTNESS_set(int32_t Hue, int32_t Saturation, int32_t Lightness); +U_PSEUDO_OBJ *U_PMF_IE_LEVELS_set(int32_t Highlight, int32_t Midtone, int32_t Shadow); +U_PSEUDO_OBJ *U_PMF_IE_REDEYECORRECTION_set(uint32_t Elements, const U_RECTL *rects); +U_PSEUDO_OBJ *U_PMF_IE_SHARPEN_set(U_FLOAT Radius, int32_t Sharpen); +U_PSEUDO_OBJ *U_PMF_IE_TINT_set(int32_t Hue, int32_t Amount); +U_PSEUDO_OBJ *U_PMR_SERIALIZABLEOBJECT_set(const U_PSEUDO_OBJ *Siepb); + +/* EMF+ prototypes (records_set) */ + +U_PSEUDO_OBJ *U_PMR_OFFSETCLIP_set(U_FLOAT dX, U_FLOAT dY); +U_PSEUDO_OBJ *U_PMR_RESETCLIP_set(void); +U_PSEUDO_OBJ *U_PMR_SETCLIPPATH_set(uint32_t PathID, uint32_t CMenum); +U_PSEUDO_OBJ *U_PMR_SETCLIPRECT_set(uint32_t CMenum, const U_PSEUDO_OBJ *Rect); +U_PSEUDO_OBJ *U_PMR_SETCLIPREGION_set(uint32_t PathID, uint32_t CMenum); +U_PSEUDO_OBJ *U_PMR_COMMENT_set(size_t cbData, const void *Data); +U_PSEUDO_OBJ *U_PMR_ENDOFFILE_set(void); +U_PSEUDO_OBJ *U_PMR_GETDC_set(void); +U_PSEUDO_OBJ *U_PMR_HEADER_set(int IsDual, int IsVideo, const U_PSEUDO_OBJ *Version, + uint32_t LogicalDpiX, uint32_t LogicalDpiY); +U_PSEUDO_OBJ *U_PMR_CLEAR_set(const U_PSEUDO_OBJ *Color); +U_PSEUDO_OBJ *U_PMR_DRAWARC_set(uint32_t PenID, U_FLOAT Start, U_FLOAT Sweep, const U_PSEUDO_OBJ *Rect); +U_PSEUDO_OBJ *U_PMR_DRAWBEZIERS_set(uint32_t PenID, const U_PSEUDO_OBJ *Points); +U_PSEUDO_OBJ *U_PMR_DRAWCLOSEDCURVE_set(uint32_t PenID, U_FLOAT Tension, const U_PSEUDO_OBJ *Points); +U_PSEUDO_OBJ *U_PMR_DRAWCURVE_set(uint32_t PenID, U_FLOAT Tension,uint32_t Offset, uint32_t NSegs, const U_PSEUDO_OBJ *Points); +U_PSEUDO_OBJ *U_PMR_DRAWDRIVERSTRING_set(uint32_t FontID, U_FLOAT Tension, const U_PSEUDO_OBJ *BrushID, + uint32_t DSOFlags, uint32_t HasMatrix, uint32_t GlyphCount, + const uint16_t *Glyphs, const U_PSEUDO_OBJ *Points, const U_PSEUDO_OBJ *Tm); +U_PSEUDO_OBJ *U_PMR_DRAWELLIPSE_set(uint32_t PenID, const U_PSEUDO_OBJ *Rect); +U_PSEUDO_OBJ *U_PMR_DRAWIMAGE_set(uint32_t ImgID, int32_t ImgAttrID, int32_t SrcUnit, const U_PSEUDO_OBJ *SrcRect, const U_PSEUDO_OBJ *DstRect); +U_PSEUDO_OBJ *U_PMR_DRAWIMAGEPOINTS_set(uint32_t ImgID, int etype, int32_t ImgAttrID, int32_t SrcUnit, const U_PSEUDO_OBJ *SrcRect, const U_PSEUDO_OBJ *Points); +U_PSEUDO_OBJ *U_PMR_DRAWLINES_set(uint32_t PenID, int dtype, const U_PSEUDO_OBJ *Points); +U_PSEUDO_OBJ *U_PMR_DRAWPATH_set(uint32_t PathID, uint32_t PenID); +U_PSEUDO_OBJ *U_PMR_DRAWPIE_set(uint32_t PenID, U_FLOAT Start, U_FLOAT Sweep, const U_PSEUDO_OBJ *Rect); +U_PSEUDO_OBJ *U_PMR_DRAWRECTS_set(uint32_t PenID, const U_PSEUDO_OBJ *Rects); +U_PSEUDO_OBJ *U_PMR_DRAWSTRING_set(uint32_t FontID, const U_PSEUDO_OBJ *BrushID, + uint32_t FormatID, uint32_t Length, const U_PSEUDO_OBJ *Rect, const uint16_t *Text); +U_PSEUDO_OBJ *U_PMR_FILLCLOSEDCURVE_set(int ftype, U_FLOAT Tension, const U_PSEUDO_OBJ * BrushID, const U_PSEUDO_OBJ *Points); +U_PSEUDO_OBJ *U_PMR_FILLELLIPSE_set(const U_PSEUDO_OBJ * BrushID, const U_PSEUDO_OBJ *Rect); +U_PSEUDO_OBJ *U_PMR_FILLPATH_set(uint32_t PathID, const U_PSEUDO_OBJ * BrushID); +U_PSEUDO_OBJ *U_PMR_FILLPIE_set(U_FLOAT Start, U_FLOAT Sweep, const U_PSEUDO_OBJ *BrushID, const U_PSEUDO_OBJ *Rect); +U_PSEUDO_OBJ *U_PMR_FILLPOLYGON_set(const U_PSEUDO_OBJ *BrushID, const U_PSEUDO_OBJ *Points); +U_PSEUDO_OBJ *U_PMR_FILLRECTS_set(const U_PSEUDO_OBJ *BrushID, const U_PSEUDO_OBJ *Rects); +U_PSEUDO_OBJ *U_PMR_FILLREGION_set(uint32_t RgnID, const U_PSEUDO_OBJ *BrushID); +U_PSEUDO_OBJ *U_PMR_OBJECT_PO_set(uint32_t ObjID, U_PSEUDO_OBJ *Po); +U_PSEUDO_OBJ *U_PMR_OBJECT_set(uint32_t ObjID, int otype, int ntype, uint32_t TSize, size_t cbData, const char *Data); +U_PSEUDO_OBJ *U_PMR_SETANTIALIASMODE_set(int SMenum, int aatype); +U_PSEUDO_OBJ *U_PMR_SETCOMPOSITINGMODE_set(int CMenum); +U_PSEUDO_OBJ *U_PMR_SETCOMPOSITINGQUALITY_set(int CQenum); +U_PSEUDO_OBJ *U_PMR_SETINTERPOLATIONMODE_set(int IMenum); +U_PSEUDO_OBJ *U_PMR_SETPIXELOFFSETMODE_set(int POMenum); +U_PSEUDO_OBJ *U_PMR_SETRENDERINGORIGIN_set(int32_t X, int32_t Y); +U_PSEUDO_OBJ *U_PMR_SETTEXTCONTRAST_set(int GC); +U_PSEUDO_OBJ *U_PMR_SETTEXTRENDERINGHINT_set(int TRHenum); +U_PSEUDO_OBJ *U_PMR_BEGINCONTAINER_set(int UTenum, U_PSEUDO_OBJ *DstRect, U_PSEUDO_OBJ *SrcRect, uint32_t StackID); +U_PSEUDO_OBJ *U_PMR_BEGINCONTAINERNOPARAMS_set(int StackID); +U_PSEUDO_OBJ *U_PMR_ENDCONTAINER_set(int StackID); +U_PSEUDO_OBJ *U_PMR_RESTORE_set(int StackID); +U_PSEUDO_OBJ *U_PMR_SAVE_set(int StackID); +U_PSEUDO_OBJ *U_PMR_SETTSCLIP_set(U_PSEUDO_OBJ *Rects); +U_PSEUDO_OBJ *U_PMR_SETTSGRAPHICS_set(int vgatype, U_PMF_SETTSGRAPHICS *Tsg, U_PSEUDO_OBJ *Palette); +U_PSEUDO_OBJ *U_PMR_MULTIPLYWORLDTRANSFORM_set(int xmtype, U_PSEUDO_OBJ *Tm); +U_PSEUDO_OBJ *U_PMR_RESETWORLDTRANSFORM_set(void); +U_PSEUDO_OBJ *U_PMR_ROTATEWORLDTRANSFORM_set(int xmtype, U_FLOAT Angle); +U_PSEUDO_OBJ *U_PMR_SCALEWORLDTRANSFORM_set(int xmtype, U_FLOAT X, U_FLOAT Y); +U_PSEUDO_OBJ *U_PMR_SETPAGETRANSFORM_set(int PUenum, U_FLOAT Sale); +U_PSEUDO_OBJ *U_PMR_SETWORLDTRANSFORM_set(U_PSEUDO_OBJ *Tm); +U_PSEUDO_OBJ *U_PMR_TRANSLATEWORLDTRANSFORM_set(int xmtype, U_FLOAT Dx, U_FLOAT Dy); +U_PSEUDO_OBJ *U_PMR_STROKEFILLPATH_set(void); + + + + +/* EMF+ prototypes (objects_get) */ + +int U_PMF_BRUSH_get(const char *contents, uint32_t *Version, uint32_t *Type, const char **Data); +int U_PMF_CUSTOMLINECAP_get(const char *contents, uint32_t *Version, uint32_t *Type, const char **Data); +int U_PMF_FONT_get(const char *contents, uint32_t *Version, U_FLOAT *EmSize, uint32_t *SizeUnit, int32_t *FSFlags, uint32_t *Length, const char **Data); +int U_PMF_IMAGE_get(const char *contents, uint32_t *Version, uint32_t *Type, const char **Data); +int U_PMF_IMAGEATTRIBUTES_get(const char *contents, uint32_t *Version, uint32_t *WrapMode, uint32_t *ClampColor, uint32_t *ObjectClamp); +int U_PMF_PATH_get(const char *contents, uint32_t *Version, uint32_t *Count, uint16_t *Flags, const char **Points, const char **Types); +int U_PMF_PEN_get(const char *contents, uint32_t *Version, uint32_t *Type, const char **PenData, const char **Brush); +int U_PMF_REGION_get(const char *contents, uint32_t *Version, uint32_t *Count, const char **Nodes); +int U_PMF_STRINGFORMAT_get(const char *contents, U_PMF_STRINGFORMAT *Sfs, const char **Data); +int U_PMF_ARGB_get(const char *contents, uint8_t *Blue, uint8_t *Green, uint8_t *Red, uint8_t *Alpha); +int U_PMF_BITMAP_get(const char *contents, U_PMF_BITMAP *Bs, const char **Data); +int U_PMF_BITMAPDATA_get(const char *contents, U_PMF_PALETTE *Ps, const char **Colors, const char **Data); +int U_PMF_BLENDCOLORS_get(const char *contents, uint32_t *Elements, U_FLOAT **Positions, const char **Colors); +int U_PMF_BLENDFACTORS_get(const char *contents, uint32_t *Elements, U_FLOAT **Positions, U_FLOAT **Factors); +int U_PMF_BOUNDARYPATHDATA_get(const char *contents, int32_t *Size, const char **Data); +int U_PMF_BOUNDARYPOINTDATA_get(const char *contents, int32_t *Elements, U_PMF_POINTF **Points); +int U_PMF_CHARACTERRANGE_get(const char *contents, int32_t *First, int32_t *Length); +int U_PMF_COMPOUNDLINEDATA_get(const char *contents, int32_t *Elements, U_FLOAT **Widths); +int U_PMF_COMPRESSEDIMAGE_get(const char *contents, const char **Data); +int U_PMF_CUSTOMENDCAPDATA_get(const char *contents, int32_t *Size, const char **Data); +int U_PMF_CUSTOMLINECAPARROWDATA_get(const char *contents, U_PMF_CUSTOMLINECAPARROWDATA *Ccad); +int U_PMF_CUSTOMLINECAPDATA_get(const char *contents, U_PMF_CUSTOMLINECAPDATA *Clcd, const char **Data); +int U_PMF_CUSTOMLINECAPOPTIONALDATA_get(const char *contents, uint32_t Flags, const char **FillData, const char **LineData); +int U_PMF_CUSTOMSTARTCAPDATA_get(const char *contents, int32_t *Size, const char **Data); +int U_PMF_DASHEDLINEDATA_get(const char *contents, int32_t *Elements, U_FLOAT **Lengths); +int U_PMF_FILLPATHOBJ_get(const char *contents, int32_t *Size, const char **Data); +int U_PMF_FOCUSSCALEDATA_get(const char *contents, uint32_t *Count, U_FLOAT *ScaleX, U_FLOAT *ScaleY); +int U_PMF_GRAPHICSVERSION_get(const char *contents, int *Signature, int *GrfVersion); +int U_PMF_HATCHBRUSHDATA_get(const char *contents, uint32_t *Style, U_PMF_ARGB *Foreground, U_PMF_ARGB *Background); +int U_PMF_INTEGER7_get(const char **contents, U_FLOAT *Value); +int U_PMF_INTEGER15_get(const char **contents, U_FLOAT *Value); +int U_PMF_LANGUAGEIDENTIFIER_get(U_PMF_LANGUAGEIDENTIFIER LId, int *SubLId, int *PriLId); +int U_PMF_LINEARGRADIENTBRUSHDATA_get(const char *contents, U_PMF_LINEARGRADIENTBRUSHDATA *Lgbd, const char **Data); +int U_PMF_LINEARGRADIENTBRUSHOPTIONALDATA_get(const char *contents, uint32_t Flags, U_PMF_TRANSFORMMATRIX *Tm, const char **Bc, const char **BfH, const char **BfV); +int U_PMF_LINEPATH_get(const char *contents, int32_t *Size, const char **Data); +int U_PMF_METAFILE_get(const char *contents, uint32_t *Type, uint32_t *Size, const char **Data); +int U_PMF_PALETTE_get(const char *contents, uint32_t *Flags, uint32_t *Elements, const char **Data); +int U_PMF_PATHGRADIENTBRUSHDATA_get(const char *contents, U_PMF_PATHGRADIENTBRUSHDATA *Pgbd, const char **Gradient, const char **Boundary, const char **Data); +int U_PMF_PATHGRADIENTBRUSHOPTIONALDATA_get(const char *contents, uint32_t Flags, U_PMF_TRANSFORMMATRIX *Matrix, const char **Pattern, const char **Data); +int U_PMF_PATHPOINTTYPE_get(const char *contents, int *Flags, int *Type); +int U_PMF_PATHPOINTTYPERLE_get(const char *contents, int *Bezier, int *RL, int *Ppt); +int U_PMF_PENDATA_get(const char *contents, uint32_t *Flags, uint32_t *Unit, U_FLOAT *Width, const char **Data); +int U_PMF_PENOPTIONALDATA_get(const char *contents, uint32_t Flags, U_PMF_TRANSFORMMATRIX *Matrix, + int32_t *StartCap, int32_t *EndCap, uint32_t *Join, U_FLOAT *MiterLimit, int32_t *Style, int32_t *DLCap, U_FLOAT *DLOffset, + const char **DLData, int32_t *Alignment, const char **CmpndLineData, const char **CSCapData, const char **CECapData); +int U_PMF_POINT_get(const char **contents, U_FLOAT *X, U_FLOAT *Y); +int U_PMF_POINTF_get(const char **contents, U_FLOAT *X, U_FLOAT *Y); +int U_PMF_POINTR_get(const char **contents, U_FLOAT *X, U_FLOAT *Y); +int U_PMF_RECT_get(const char **contents, int16_t *X, int16_t *Y, int16_t *Width, int16_t *Height); +int U_PMF_RECTF_get(const char **contents, U_FLOAT *X, U_FLOAT *Y, U_FLOAT *Width, U_FLOAT *Height); +int U_PMF_REGIONNODE_get(const char *contents, uint32_t *Type, const char **Data); +/* There is no U_PMF_REGIONNODECHILDNODES_get, see the note in upmf.c */ +int U_PMF_REGIONNODEPATH_get(const char *contents, int32_t *Size, const char **Data); +int U_PMF_SOLIDBRUSHDATA_get(const char *contents, U_PMF_ARGB *Color); +int U_PMF_STRINGFORMATDATA_get(const char *contents, uint32_t TabStopCount, uint32_t RangeCount, + const U_FLOAT **TabStops, const U_PMF_CHARACTERRANGE **CharRange); +int U_PMF_TEXTUREBRUSHDATA_get(const char *contents, uint32_t *Flags, int32_t *WrapMode, const char **Data); +int U_PMF_TEXTUREBRUSHOPTIONALDATA_get(const char *contents, int HasImage, U_PMF_TRANSFORMMATRIX *Matrix, const char **Image); +int U_PMF_TRANSFORMMATRIX_get(const char *contents, U_PMF_TRANSFORMMATRIX *Matrix); +int U_PMF_IE_BLUR_get(const char *contents, U_FLOAT *Radius, uint32_t *ExpandEdge); +int U_PMF_IE_BRIGHTNESSCONTRAST_get(const char *contents, int32_t *Brightness, int32_t *Contrast); +int U_PMF_IE_COLORBALANCE_get(const char *contents, int32_t *CyanRed, int32_t *MagentaGreen, int32_t *YellowBlue); +int U_PMF_IE_COLORCURVE_get(const char *contents, uint32_t *Adjust, uint32_t *Channel, int32_t *Intensity); +int U_PMF_IE_COLORLOOKUPTABLE_get(const char *contents, + const uint8_t **BLUT, const uint8_t **GLUT, const uint8_t **RLUT, const uint8_t **ALUT); +int U_PMF_IE_COLORMATRIX_get(const char *contents, U_PMF_IE_COLORMATRIX *Matrix); +int U_PMF_IE_HUESATURATIONLIGHTNESS_get(const char *contents, int32_t *Hue, int32_t *Saturation, int32_t *Lightness); +int U_PMF_IE_LEVELS_get(const char *contents, int32_t *Highlight, int32_t *Midtone, int32_t *Shadow); +int U_PMF_IE_REDEYECORRECTION_get(const char *contents, int32_t *Elements, U_RECTL **Rects); +int U_PMF_IE_SHARPEN_get(const char *contents, U_FLOAT *Radius, int32_t *Sharpen); +int U_PMF_IE_TINT_get(const char *contents, int32_t *Hue, int32_t *Amount); + +/* EMF+ prototypes (records_get) */ + +int U_PMR_OFFSETCLIP_get(const char *contents, U_PMF_CMN_HDR *Header, U_FLOAT *dX, U_FLOAT *dY); +int U_PMR_RESETCLIP_get(const char *contents, U_PMF_CMN_HDR *Header); +int U_PMR_SETCLIPPATH_get(const char *contents, U_PMF_CMN_HDR *Header, uint32_t *PathID, int *CMenum); +int U_PMR_SETCLIPRECT_get(const char *contents, U_PMF_CMN_HDR *Header, int *CMenum, U_PMF_RECTF *Rect); +int U_PMR_SETCLIPREGION_get(const char *contents, U_PMF_CMN_HDR *Header, uint32_t *PathID, int *CMenum); +int U_PMR_COMMENT_get(const char *contents, U_PMF_CMN_HDR *Header, const char **Data); +int U_PMR_ENDOFFILE_get(const char *contents, U_PMF_CMN_HDR *Header); +int U_PMR_GETDC_get(const char *contents, U_PMF_CMN_HDR *Header); +int U_PMR_HEADER_get(const char *contents, U_PMF_CMN_HDR *Header, U_PMF_GRAPHICSVERSION *Version, int *IsDual, int *IsVideo, uint32_t *LogicalDpiX, uint32_t *LogicalDpiY); +int U_PMR_CLEAR_get(const char *contents, U_PMF_CMN_HDR *Header, U_PMF_ARGB *Color); +int U_PMR_DRAWARC_get(const char *contents, U_PMF_CMN_HDR *Header, uint32_t *PenID, int *ctype, U_FLOAT *Start, U_FLOAT *Sweep, U_PMF_RECTF *Rect); +int U_PMR_DRAWBEZIERS_get(const char *contents, U_PMF_CMN_HDR *Header, uint32_t *PenID, int *ctype, int *RelAbs, uint32_t *Elements, U_PMF_POINTF **Points); +int U_PMR_DRAWCLOSEDCURVE_get(const char *contents, U_PMF_CMN_HDR *Header, uint32_t *PenID, int *ctype, int *RelAbs, U_FLOAT *Tension, uint32_t *Elements, U_PMF_POINTF **Points); +int U_PMR_DRAWCURVE_get(const char *contents, U_PMF_CMN_HDR *Header, uint32_t *PenID, int *ctype, U_FLOAT *Tension, uint32_t *Offset, uint32_t *NSegs, uint32_t *Elements, U_PMF_POINTF **Points); +int U_PMR_DRAWDRIVERSTRING_get(const char *contents, U_PMF_CMN_HDR *Header, uint32_t *FontID, int *btype, U_FLOAT *Tension, uint32_t *BrushID, uint32_t *DSOFlags, uint32_t *HasMatrix, uint32_t *Elements, uint16_t **Glyphs, U_PMF_POINTF **Points, U_PMF_TRANSFORMMATRIX **Matrix); +int U_PMR_DRAWELLIPSE_get(const char *contents, U_PMF_CMN_HDR *Header, uint32_t *PenID, int *ctype, U_PMF_RECTF *Rect); +int U_PMR_DRAWIMAGE_get(const char *contents, U_PMF_CMN_HDR *Header, uint32_t *ImgID, int *ctype, uint32_t *ImgAttrID, int32_t *SrcUnit, U_PMF_RECTF *SrcRect, U_PMF_RECTF *DstRect); +int U_PMR_DRAWIMAGEPOINTS_get(const char *contents, U_PMF_CMN_HDR *Header, uint32_t *ImgID, int *ctype, int *etype, int *RelAbs, uint32_t *ImgAttrID, int32_t *SrcUnit, U_PMF_RECTF *SrcRect, uint32_t *Elements, U_PMF_POINTF **Points); +int U_PMR_DRAWLINES_get(const char *contents, U_PMF_CMN_HDR *Header, uint32_t *PenID, int *ctype, int *dtype, int *RelAbs, uint32_t *Elements, U_PMF_POINTF **Points); +int U_PMR_DRAWPATH_get(const char *contents, U_PMF_CMN_HDR *Header, uint32_t *PathID, uint32_t *PenID); +int U_PMR_DRAWPIE_get(const char *contents, U_PMF_CMN_HDR *Header, uint32_t *PenID, int *ctype, U_FLOAT *Start, U_FLOAT *Sweep, U_PMF_RECTF *Rect); +int U_PMR_DRAWRECTS_get(const char *contents, U_PMF_CMN_HDR *Header, uint32_t *PenID, int *ctype, uint32_t *Elements, U_PMF_RECTF **Rects); +int U_PMR_DRAWSTRING_get(const char *contents, U_PMF_CMN_HDR *Header, uint32_t *FontID, int *btype, uint32_t *BrushID, uint32_t *FormatID, uint32_t *Elements, U_PMF_RECTF *Rect, uint16_t **String); +int U_PMR_FILLCLOSEDCURVE_get(const char *contents, U_PMF_CMN_HDR *Header, int *btype, int *ctype, int *ftype, int *RelAbs, uint32_t *BrushID, U_FLOAT *Tension, uint32_t *Elements, U_PMF_POINTF **Points); +int U_PMR_FILLELLIPSE_get(const char *contents, U_PMF_CMN_HDR *Header, int *btype, int *ctype, uint32_t *BrushID, U_PMF_RECTF *Rect); +int U_PMR_FILLPATH_get(const char *contents, U_PMF_CMN_HDR *Header, uint32_t *PathID, int *btype, uint32_t *BrushID); +int U_PMR_FILLPIE_get(const char *contents, U_PMF_CMN_HDR *Header, int *btype, int *ctype, uint32_t *BrushID, U_FLOAT *Start, U_FLOAT *Sweep, U_PMF_RECTF *Rect); +int U_PMR_FILLPOLYGON_get(const char *contents, U_PMF_CMN_HDR *Header, int *btype, int *ctype, int *RelAbs, uint32_t *BrushID, uint32_t *Elements, U_PMF_POINTF **Points); +int U_PMR_FILLRECTS_get(const char *contents, U_PMF_CMN_HDR *Header, int *btype, int *ctype, uint32_t *BrushID, uint32_t *Elements, U_PMF_RECTF **Rects); +int U_PMR_FILLREGION_get(const char *contents, U_PMF_CMN_HDR *Header, uint32_t *RgnID, int *btype, int *ctype, uint32_t *BrushID); +int U_PMR_OBJECT_get(const char *contents, U_PMF_CMN_HDR *Header, uint32_t *ObjID, int *otype, int *ntype, uint32_t *TSize, const char **Data); +int U_PMR_SERIALIZABLEOBJECT_get(const char *contents, U_PMF_CMN_HDR *Header, uint8_t *GUID, uint32_t *Size, const char **Data); +int U_PMR_SETANTIALIASMODE_get(const char *contents, U_PMF_CMN_HDR *Header, int *SMenum, int *aatype); +int U_PMR_SETCOMPOSITINGMODE_get(const char *contents, U_PMF_CMN_HDR *Header, int *CMenum); +int U_PMR_SETCOMPOSITINGQUALITY_get(const char *contents, U_PMF_CMN_HDR *Header, int *CQenum); +int U_PMR_SETINTERPOLATIONMODE_get(const char *contents, U_PMF_CMN_HDR *Header, int *IMenum); +int U_PMR_SETPIXELOFFSETMODE_get(const char *contents, U_PMF_CMN_HDR *Header, int *POMenum); +int U_PMR_SETRENDERINGORIGIN_get(const char *contents, U_PMF_CMN_HDR *Header, int32_t *X, int32_t *Y); +int U_PMR_SETTEXTCONTRAST_get(const char *contents, U_PMF_CMN_HDR *Header, int *TGC); +int U_PMR_SETTEXTRENDERINGHINT_get(const char *contents, U_PMF_CMN_HDR *Header, int *TRHenum); +int U_PMR_BEGINCONTAINER_get(const char *contents, U_PMF_CMN_HDR *Header, int *UTenum, U_PMF_RECTF *DstRect, U_PMF_RECTF *SrcRect, uint32_t *StackID); +int U_PMR_BEGINCONTAINERNOPARAMS_get(const char *contents, U_PMF_CMN_HDR *Header, uint32_t *StackID); +int U_PMR_ENDCONTAINER_get(const char *contents, U_PMF_CMN_HDR *Header, uint32_t *StackID); +int U_PMR_RESTORE_get(const char *contents, U_PMF_CMN_HDR *Header, uint32_t *StackID); +int U_PMR_SAVE_get(const char *contents, U_PMF_CMN_HDR *Header, uint32_t *StackID); +int U_PMR_SETTSCLIP_get(const char *contents, U_PMF_CMN_HDR *Header, int *ctype, uint32_t *Elements, U_PMF_RECTF **Rects); +int U_PMR_SETTSGRAPHICS_get(const char *contents, U_PMF_CMN_HDR *Header, int *vgatype, int *pptype, uint8_t *AntiAliasMode, uint8_t *TextRenderHint, uint8_t *CompositingMode, uint8_t *CompositingQuality, int16_t *RenderOriginX, int16_t *RenderOriginY, uint16_t *TextContrast, uint8_t *FilterType, uint8_t *PixelOffset, U_PMF_TRANSFORMMATRIX *WorldToDevice, const char **Data); +int U_PMR_MULTIPLYWORLDTRANSFORM_get(const char *contents, U_PMF_CMN_HDR *Header, int *xmtype, U_PMF_TRANSFORMMATRIX *Matrix); +int U_PMR_RESETWORLDTRANSFORM_get(const char *contents, U_PMF_CMN_HDR *Header); +int U_PMR_ROTATEWORLDTRANSFORM_get(const char *contents, U_PMF_CMN_HDR *Header, int *xmtype, U_FLOAT *Angle); +int U_PMR_SCALEWORLDTRANSFORM_get(const char *contents, U_PMF_CMN_HDR *Header, int *xmtype, U_FLOAT *Sx, U_FLOAT *Sy); +int U_PMR_SETPAGETRANSFORM_get(const char *contents, U_PMF_CMN_HDR *Header, int *PUenum, U_FLOAT *Scale); +int U_PMR_SETWORLDTRANSFORM_get(const char *contents, U_PMF_CMN_HDR *Header, U_PMF_TRANSFORMMATRIX *Matrix); +int U_PMR_TRANSLATEWORLDTRANSFORM_get(const char *contents, U_PMF_CMN_HDR *Header, int *xmtype, U_FLOAT *Dx, U_FLOAT *Dy); +int U_PMR_STROKEFILLPATH_get(const char *contents, U_PMF_CMN_HDR *Header); +int U_PMR_MULTIFORMATSTART_get(const char *contents, U_PMF_CMN_HDR *Header); +int U_PMR_MULTIFORMATSECTION_get(const char *contents, U_PMF_CMN_HDR *Header); +int U_PMR_MULTIFORMATEND_get(const char *contents, U_PMF_CMN_HDR *Header); +//! \endcond + + +#ifdef __cplusplus +} +#endif + +#endif /* _UPMF_ */ diff --git a/src/libuemf/upmf_print.c b/src/libuemf/upmf_print.c new file mode 100644 index 000000000..f446d6caf --- /dev/null +++ b/src/libuemf/upmf_print.c @@ -0,0 +1,3138 @@ +/** + @file upmf_print.c + + @brief Functions for printing EMF records +*/ + +/* +File: upmf_print.c +Version: 0.0.2 +Date: 17-OCT-2013 +Author: David Mathog, Biology Division, Caltech +email: mathog@caltech.edu +Copyright: 2013 David Mathog and California Institute of Technology (Caltech) +*/ + +/* compiler options: + +-DNOBRUSH causes brush objects to be treated as pen objects. PowerPoint 2003 and 2010 define pen objects +as brush objects, and this is one way to see their structure even though they are misidentified. +This option should only be used for tiny test files, consisting of just line objects. +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include /* for offsetof() macro */ +#include +#include "upmf_print.h" +#include "uemf_print.h" + + +//! \cond + +#define UNUSED(x) (void)(x) //! Please ignore - Doxygen simply insisted on including this + +/* + this function is not visible in the API. Print "data" for one of the many records that has none. +*/ +int U_PMR_NODATAREC_print(const char *contents){ + U_PMF_CMN_HDR Header; + int status = U_PMR_RESETCLIP_get(contents,&Header); /* One of many possibilities */ + if(status)status = Header.Size; + return(status); +} + +/* + this function is not visible in the API. Common routine used by many functions that draw points. +*/ +void U_PMF_VARPOINTS_print(const char **contents, int Flags, uint32_t Elements){ + unsigned int i; + U_FLOAT Xpos, Ypos; + + if( Flags & U_PPF_P){ printf(" + Points(Relative):"); } + else if(Flags & U_PPF_C){ printf(" + Points(Int16):"); } + else { printf(" + Points(Float):"); } + for(Xpos = Ypos = i = 0; i U_PMR_MAX)return(-1); /* unknown EMF+ record type */ + status = U_PMF_CMN_HDR_print(Header, recnum, off); /* EMF+ part */ + + /* Buggy EMF+ can set the continue bit and then do something else. In that case, force out the pending + Object. Side effect - clears the pending object. */ + if((type != U_PMR_OBJECT) && (ObjCont.used > 0)){ + U_PMR_OBJECT_print(contents, blimit, &ObjCont, 1); + } + + switch(type){ + case (U_PMR_HEADER): U_PMR_HEADER_print(contents); break; + case (U_PMR_ENDOFFILE): U_PMR_ENDOFFILE_print(contents); + U_OA_release(&ObjCont); break; + case (U_PMR_COMMENT): U_PMR_COMMENT_print(contents); break; + case (U_PMR_GETDC): U_PMR_GETDC_print(contents); break; + case (U_PMR_MULTIFORMATSTART): U_PMR_MULTIFORMATSTART_print(contents); break; + case (U_PMR_MULTIFORMATSECTION): U_PMR_MULTIFORMATSECTION_print(contents); break; + case (U_PMR_MULTIFORMATEND): U_PMR_MULTIFORMATEND_print(contents); break; + case (U_PMR_OBJECT): U_PMR_OBJECT_print(contents,blimit,&ObjCont,0); break; + case (U_PMR_CLEAR): U_PMR_CLEAR_print(contents); break; + case (U_PMR_FILLRECTS): U_PMR_FILLRECTS_print(contents, blimit); break; + case (U_PMR_DRAWRECTS): U_PMR_DRAWRECTS_print(contents, blimit); break; + case (U_PMR_FILLPOLYGON): U_PMR_FILLPOLYGON_print(contents); break; + case (U_PMR_DRAWLINES): U_PMR_DRAWLINES_print(contents); break; + case (U_PMR_FILLELLIPSE): U_PMR_FILLELLIPSE_print(contents); break; + case (U_PMR_DRAWELLIPSE): U_PMR_DRAWELLIPSE_print(contents); break; + case (U_PMR_FILLPIE): U_PMR_FILLPIE_print(contents); break; + case (U_PMR_DRAWPIE): U_PMR_DRAWPIE_print(contents); break; + case (U_PMR_DRAWARC): U_PMR_DRAWARC_print(contents); break; + case (U_PMR_FILLREGION): U_PMR_FILLREGION_print(contents); break; + case (U_PMR_FILLPATH): U_PMR_FILLPATH_print(contents); break; + case (U_PMR_DRAWPATH): U_PMR_DRAWPATH_print(contents); break; + case (U_PMR_FILLCLOSEDCURVE): U_PMR_FILLCLOSEDCURVE_print(contents); break; + case (U_PMR_DRAWCLOSEDCURVE): U_PMR_DRAWCLOSEDCURVE_print(contents); break; + case (U_PMR_DRAWCURVE): U_PMR_DRAWCURVE_print(contents); break; + case (U_PMR_DRAWBEZIERS): U_PMR_DRAWBEZIERS_print(contents); break; + case (U_PMR_DRAWIMAGE): U_PMR_DRAWIMAGE_print(contents); break; + case (U_PMR_DRAWIMAGEPOINTS): U_PMR_DRAWIMAGEPOINTS_print(contents); break; + case (U_PMR_DRAWSTRING): U_PMR_DRAWSTRING_print(contents); break; + case (U_PMR_SETRENDERINGORIGIN): U_PMR_SETRENDERINGORIGIN_print(contents); break; + case (U_PMR_SETANTIALIASMODE): U_PMR_SETANTIALIASMODE_print(contents); break; + case (U_PMR_SETTEXTRENDERINGHINT): U_PMR_SETTEXTRENDERINGHINT_print(contents); break; + case (U_PMR_SETTEXTCONTRAST): U_PMR_SETTEXTCONTRAST_print(contents); break; + case (U_PMR_SETINTERPOLATIONMODE): U_PMR_SETINTERPOLATIONMODE_print(contents); break; + case (U_PMR_SETPIXELOFFSETMODE): U_PMR_SETPIXELOFFSETMODE_print(contents); break; + case (U_PMR_SETCOMPOSITINGMODE): U_PMR_SETCOMPOSITINGMODE_print(contents); break; + case (U_PMR_SETCOMPOSITINGQUALITY): U_PMR_SETCOMPOSITINGQUALITY_print(contents); break; + case (U_PMR_SAVE): U_PMR_SAVE_print(contents); break; + case (U_PMR_RESTORE): U_PMR_RESTORE_print(contents); break; + case (U_PMR_BEGINCONTAINER): U_PMR_BEGINCONTAINER_print(contents); break; + case (U_PMR_BEGINCONTAINERNOPARAMS): U_PMR_BEGINCONTAINERNOPARAMS_print(contents); break; + case (U_PMR_ENDCONTAINER): U_PMR_ENDCONTAINER_print(contents); break; + case (U_PMR_SETWORLDTRANSFORM): U_PMR_SETWORLDTRANSFORM_print(contents); break; + case (U_PMR_RESETWORLDTRANSFORM): U_PMR_RESETWORLDTRANSFORM_print(contents); break; + case (U_PMR_MULTIPLYWORLDTRANSFORM): U_PMR_MULTIPLYWORLDTRANSFORM_print(contents); break; + case (U_PMR_TRANSLATEWORLDTRANSFORM): U_PMR_TRANSLATEWORLDTRANSFORM_print(contents); break; + case (U_PMR_SCALEWORLDTRANSFORM): U_PMR_SCALEWORLDTRANSFORM_print(contents); break; + case (U_PMR_ROTATEWORLDTRANSFORM): U_PMR_ROTATEWORLDTRANSFORM_print(contents); break; + case (U_PMR_SETPAGETRANSFORM): U_PMR_SETPAGETRANSFORM_print(contents); break; + case (U_PMR_RESETCLIP): U_PMR_RESETCLIP_print(contents); break; + case (U_PMR_SETCLIPRECT): U_PMR_SETCLIPRECT_print(contents); break; + case (U_PMR_SETCLIPPATH): U_PMR_SETCLIPPATH_print(contents); break; + case (U_PMR_SETCLIPREGION): U_PMR_SETCLIPREGION_print(contents); break; + case (U_PMR_OFFSETCLIP): U_PMR_OFFSETCLIP_print(contents); break; + case (U_PMR_DRAWDRIVERSTRING): U_PMR_DRAWDRIVERSTRING_print(contents); break; + case (U_PMR_STROKEFILLPATH): U_PMR_STROKEFILLPATH_print(contents); break; + case (U_PMR_SERIALIZABLEOBJECT): U_PMR_SERIALIZABLEOBJECT_print(contents); break; + case (U_PMR_SETTSGRAPHICS): U_PMR_SETTSGRAPHICS_print(contents); break; + case (U_PMR_SETTSCLIP): U_PMR_SETTSCLIP_print(contents); break; + } + return(status); +} + +/** + \brief Print data from a U_PMF_CMN_HDR object + \return number of bytes in record, 0 on error + \param Header Header of the record + \param precnum EMF+ record number in file. + \param off Offset in file to the start of this EMF+ record. + common structure present at the beginning of all(*) EMF+ records +*/ +int U_PMF_CMN_HDR_print(U_PMF_CMN_HDR Header, int precnum, int off){ + printf(" %-29srec+:%5d type:%X offset:%8d rsize:%8u dsize:%8u flags:%4.4X\n", + U_pmr_names(Header.Type &U_PMR_TYPE_MASK),precnum, Header.Type,off,Header.Size,Header.DataSize,Header.Flags); + return((int) Header.Size); +} + +/** + \brief Print data from a an array of uint8_t values + \return 1 + \param Start Text to lead array data + \param Array uint8_t array of data passed as char * + \param Elements Number of elements in Array + \param End Text to follow array data +*/ +int U_PMF_UINT8_ARRAY_print(const char *Start, const uint8_t *Array, int Elements, char *End){ + if(Start)printf("%s",Start); + for(; Elements--; Array++){ printf(" %u", *Array); } + if(End)printf("%s",End); + return(1); +} + +/** + \brief Print value of an BrushType Enumeration + \returns record 1 on sucess, 0 on error + \param otype Value to print. + EMF+ manual 2.1.1.3, Microsoft name: BrushType Enumeration +*/ +int U_PMF_BRUSHTYPEENUMERATION_print(int otype){ + int status=1; + switch(otype){ + case U_BT_SolidColor: printf("SolidColor"); break; + case U_BT_HatchFill: printf("HatchFill"); break; + case U_BT_TextureFill: printf("TextureFill"); break; + case U_BT_PathGradient: printf("PathGradient"); break; + case U_BT_LinearGradient: printf("LinearGradient"); break; + default: status=0; printf("INVALID(%d)",otype); break; + } + return(status); +} + +/** + \brief Print value of an BrushType Enumeration + \returns record 1 on sucess, 0 on error + \param otype Value to print. + EMF+ manual 2.1.1.4, Microsoft name: BrushType Enumeration +*/ +int U_PMF_COMBINEMODEENUMERATION_print(int otype){ + int status=1; + switch(otype){ + case U_CM_Replace: printf("Replace" ); break; + case U_CM_Intersect: printf("Intersect" ); break; + case U_CM_Union: printf("Union" ); break; + case U_CM_XOR: printf("XOR" ); break; + case U_CM_Exclude: printf("Exclude" ); break; + case U_CM_Complement: printf("Complement"); break; + default: status=0; printf("INVALID(%d)",otype); break; + } + return(status); +} + +/** + \brief Print value of a HatchStyle Enumeration + \returns record 1 on sucess, 0 on error + \param hstype Value to print. + EMF+ manual 2.1.1.13, Microsoft name: HatchStyle Enumeration +*/ +int U_PMF_HATCHSTYLEENUMERATION_print(int hstype){ + int status=1; + switch(hstype){ + case U_HSP_Horizontal: printf("Horizontal"); break; + case U_HSP_Vertical: printf("Vertical"); break; + case U_HSP_ForwardDiagonal: printf("ForwardDiagonal"); break; + case U_HSP_BackwardDiagonal: printf("BackwardDiagonal"); break; + case U_HSP_LargeGrid: printf("LargeGrid"); break; + case U_HSP_DiagonalCross: printf("DiagonalCross"); break; + case U_HSP_05Percent: printf("05Percent"); break; + case U_HSP_10Percent: printf("10Percent"); break; + case U_HSP_20Percent: printf("20Percent"); break; + case U_HSP_25Percent: printf("25Percent"); break; + case U_HSP_30Percent: printf("30Percent"); break; + case U_HSP_40Percent: printf("40Percent"); break; + case U_HSP_50Percent: printf("50Percent"); break; + case U_HSP_60Percent: printf("60Percent"); break; + case U_HSP_70Percent: printf("70Percent"); break; + case U_HSP_75Percent: printf("75Percent"); break; + case U_HSP_80Percent: printf("80Percent"); break; + case U_HSP_90Percent: printf("90Percent"); break; + case U_HSP_LightDownwardDiagonal: printf("LightDownwardDiagonal"); break; + case U_HSP_LightUpwardDiagonal: printf("LightUpwardDiagonal"); break; + case U_HSP_DarkDownwardDiagonal: printf("DarkDownwardDiagonal"); break; + case U_HSP_DarkUpwardDiagonal: printf("DarkUpwardDiagonal"); break; + case U_HSP_WideDownwardDiagonal: printf("WideDownwardDiagonal"); break; + case U_HSP_WideUpwardDiagonal: printf("WideUpwardDiagonal"); break; + case U_HSP_LightVertical: printf("LightVertical"); break; + case U_HSP_LightHorizontal: printf("LightHorizontal"); break; + case U_HSP_NarrowVertical: printf("NarrowVertical"); break; + case U_HSP_NarrowHorizontal: printf("NarrowHorizontal"); break; + case U_HSP_DarkVertical: printf("DarkVertical"); break; + case U_HSP_DarkHorizontal: printf("DarkHorizontal"); break; + case U_HSP_DashedDownwardDiagonal: printf("DashedDownwardDiagonal"); break; + case U_HSP_DashedUpwardDiagonal: printf("DashedUpwardDiagonal"); break; + case U_HSP_DashedHorizontal: printf("DashedHorizontal"); break; + case U_HSP_DashedVertical: printf("DashedVertical"); break; + case U_HSP_SmallConfetti: printf("SmallConfetti"); break; + case U_HSP_LargeConfetti: printf("LargeConfetti"); break; + case U_HSP_ZigZag: printf("ZigZag"); break; + case U_HSP_Wave: printf("Wave"); break; + case U_HSP_DiagonalBrick: printf("DiagonalBrick"); break; + case U_HSP_HorizontalBrick: printf("HorizontalBrick"); break; + case U_HSP_Weave: printf("Weave"); break; + case U_HSP_Plaid: printf("Plaid"); break; + case U_HSP_Divot: printf("Divot"); break; + case U_HSP_DottedGrid: printf("DottedGrid"); break; + case U_HSP_DottedDiamond: printf("DottedDiamond"); break; + case U_HSP_Shingle: printf("Shingle"); break; + case U_HSP_Trellis: printf("Trellis"); break; + case U_HSP_Sphere: printf("Sphere"); break; + case U_HSP_SmallGrid: printf("SmallGrid"); break; + case U_HSP_SmallCheckerBoard: printf("SmallCheckerBoard"); break; + case U_HSP_LargeCheckerBoard: printf("LargeCheckerBoard"); break; + case U_HSP_OutlinedDiamond: printf("OutlinedDiamond"); break; + case U_HSP_SolidDiamond: printf("SolidDiamond"); break; + default: status=0; printf("INVALID(%d)",hstype); break; + } + return(status); +} + +/** + \brief Print value of an ObjectType Enumeration + \returns record 1 on sucess, 0 on error + \param otype Value to print. + EMF+ manual 2.1.1.22, Microsoft name: ObjectType Enumeration +*/ +int U_PMF_OBJECTTYPEENUMERATION_print(int otype){ + int status=1; + switch(otype){ + case U_OT_Invalid: printf("Invalid"); break; + case U_OT_Brush: printf("Brush"); break; + case U_OT_Pen: printf("Pen"); break; + case U_OT_Path: printf("Path"); break; + case U_OT_Region: printf("Region"); break; + case U_OT_Image: printf("Image"); break; + case U_OT_Font: printf("Font"); break; + case U_OT_StringFormat: printf("StringFormat"); break; + case U_OT_ImageAttributes: printf("ImageAttributes"); break; + case U_OT_CustomLineCap: printf("CustomLineCap"); break; + default: + status=0; printf("INVALID(%d)",otype); break; + } + return(status); +} + +/** + \brief Print value of a U_PMF_PATHPOINTTYPE_ENUM object + \return 1 + \param Type Value to print + EMF+ manual 2.1.1.23, Microsoft name: PathPointType Enumeration +*/ +int U_PMF_PATHPOINTTYPE_ENUM_print(int Type){ + switch(Type & U_PPT_MASK){ + case U_PPT_Start : printf("Start"); break; + case U_PPT_Line : printf("Line"); break; + case U_PPT_Bezier: printf("Bezier"); break; + default: printf("INVALID(%d)",Type); break; + } + return(1); +} + +/** + \brief Print data from a PixelFormat Enumeration value + \return 1 always + \param pfe A PixelFormat Enumeration value + EMF+ manual 2.1.1.25, Microsoft name: PixelFormat Enumeration (U_PF_*) +*/ +int U_PMF_PX_FMT_ENUM_print(int pfe){ + uint8_t idx; + printf(" + PxFmtEnum: "); + printf(" 32Bit:%c", (pfe & 1<< 9 ? 'Y' : 'N')); + printf(" 16Bit:%c", (pfe & 1<<10 ? 'Y' : 'N')); + printf(" PreAlpha:%c", (pfe & 1<<11 ? 'Y' : 'N')); + printf(" Alpha:%c", (pfe & 1<<12 ? 'Y' : 'N')); + printf(" GDI:%c", (pfe & 1<<13 ? 'Y' : 'N')); + printf(" LUT:%c", (pfe & 1<<14 ? 'Y' : 'N')); + printf(" BitsPerPx:%u", (pfe >> 16) & 0xFF); + idx = pfe >> 24; + printf(" Type:%u(",idx); + switch(idx){ + case 0: printf("undefined"); break; + case 1: printf("monochrome with LUT"); break; + case 2: printf("4 bit with LUT"); break; + case 3: printf("8 bit with LUT"); break; + case 4: printf("16 bits grey values"); break; + case 5: printf("16 bit RGB values (5,5,5,(1 ignored))"); break; + case 6: printf("16 bit RGB values (5,6,5)"); break; + case 7: printf("16 bit ARGB values (1 alpha, 5,5,5 colors)"); break; + case 8: printf("24 bit RGB values (8,8.8)"); break; + case 9: printf("32 bit RGB value (8,8,8,(8 ignored))"); break; + case 10: printf("32 bit ARGB values (8 alpha,8,8,8)"); break; + case 11: printf("32 bit PARGB values (8,8,8,8, but RGB already multiplied by A)"); break; + case 12: printf("48 bit RGB (16,16,16)"); break; + case 13: printf("64 bit ARGB (16 alpha, 16,16,16)"); break; + case 14: printf("64 bit PARGB (16,16,16,16, but RGB already multiplied by A)"); break; + default: printf("INVALID(%d)",idx); break; + } + printf(")"); + return(1); +} + +/** + \brief Print as text a RegionNodeDataType Enumeration + \return 1 + \param Type RegionNodeDataType Enumeration + EMF+ manual 2.1.1.27, Microsoft name: RegionNodeDataType Enumeration (U_RNDT_*) +*/ +int U_PMF_NODETYPE_print(int Type){ + if( Type == U_RNDT_And ){ printf("And" ); } + else if(Type == U_RNDT_Or ){ printf("Or" ); } + else if(Type == U_RNDT_Xor ){ printf("Xor" ); } + else if(Type == U_RNDT_Exclude ){ printf("Exclude" ); } + else if(Type == U_RNDT_Complement){ printf("Complement"); } + else if(Type == U_RNDT_Rect ){ printf("Rect" ); } + else if(Type == U_RNDT_Path ){ printf("Path" ); } + else if(Type == U_RNDT_Empty ){ printf("Empty" ); } + else if(Type == U_RNDT_Infinite ){ printf("Infinite" ); } + else { printf("Undefined" ); return(0); } + return(1); +} + +/** + \brief Print data from a U_PMF_BRUSH object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.1.1, Microsoft name: EmfPlusBrush Object +*/ +int U_PMF_BRUSH_print(const char *contents){ + uint32_t Version, Type; + const char *Data; + int status = U_PMF_BRUSH_get(contents, &Version, &Type, &Data); + if(status){ + printf(" + Brush:"); + (void) U_PMF_GRAPHICSVERSION_print((char *)&Version); + printf(" Type:%X(",Type); + (void) U_PMF_BRUSHTYPEENUMERATION_print(Type); + printf(")"); + switch(Type){ + case U_BT_SolidColor: + status = U_PMF_ARGB_print(Data); + break; + case U_BT_HatchFill: + printf("\n"); + status = U_PMF_HATCHBRUSHDATA_print(Data); + break; + case U_BT_TextureFill: + printf("\n"); + status = U_PMF_TEXTUREBRUSHDATA_print(Data); + break; + case U_BT_PathGradient: + printf("\n"); + status = U_PMF_PATHGRADIENTBRUSHDATA_print(Data); + break; + case U_BT_LinearGradient: + printf("\n"); + status = U_PMF_LINEARGRADIENTBRUSHDATA_print(Data); + break; + default: + status = 0; + } + printf("\n"); + } + return(status); +} + +/** + \brief Print data from a U_PMF_CUSTOMLINECAP object + \return 1 on success, 0 on error + \param contents Record from which to print data + \param Which A string which is either "Start" or "End". + EMF+ manual 2.2.1.2, Microsoft name: EmfPlusCustomLineCap Object +*/ +int U_PMF_CUSTOMLINECAP_print(const char *contents, const char *Which){ + uint32_t Version, Type; + const char *Data; + int status = U_PMF_CUSTOMLINECAP_get(contents, &Version, &Type, &Data); + + if(status){ + printf(" + %sLineCap:",Which); + (void) U_PMF_GRAPHICSVERSION_print((char *)&Version); + printf(", Type %X\n",Type); + switch(Type){ + case U_CLCDT_Default: + status = U_PMF_CUSTOMLINECAPDATA_print(Data); + break; + case U_CLCDT_AdjustableArrow: + status = U_PMF_CUSTOMLINECAPARROWDATA_print(Data); + break; + default: + status = 0; + } + } + return(status); +} + +/** + \brief Print data from a U_PMF_FONT object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.1.3, Microsoft name: EmfPlusFont Object +*/ +int U_PMF_FONT_print(const char *contents){ + uint32_t Version, SizeUnit, Length; + U_FLOAT EmSize; + int32_t FSFlags; + const char *Data; + char *string; + int status = U_PMF_FONT_get(contents, &Version, &EmSize, &SizeUnit, &FSFlags, &Length, &Data); + if(status){ + printf(" + Font:"); + (void) U_PMF_GRAPHICSVERSION_print((char *)&Version); + printf(" EmSize:%f ", EmSize ); + printf(" SizeUnit:%d ",SizeUnit); + printf(" FSFlags:%d ", FSFlags ); + printf(" Length:%d", Length ); + string = U_Utf16leToUtf8((uint16_t *)Data, Length, NULL); + if(string){ + printf(" Family:<%s>\n",string); + free(string); + } + else { + printf(" Family:<>\n"); + } + } + return(status); +} + + +/** + \brief Print data from a U_PMF_IMAGE object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.1.4, Microsoft name: EmfPlusImage Object +*/ +int U_PMF_IMAGE_print(const char *contents){ + uint32_t Version, Type; + const char *Data; + int status = U_PMF_IMAGE_get(contents, &Version, &Type, &Data); + if(status){ + printf(" + Image:"); + (void) U_PMF_GRAPHICSVERSION_print((char *)&Version); + printf(" Type:%X\n",Type); + switch(Type){ + case U_IDT_Unknown: + printf(" + Unknown Image Type\n"); + break; + case U_IDT_Bitmap: + status = U_PMF_BITMAP_print(Data); + break; + case U_IDT_Metafile: + status = U_PMF_METAFILE_print(Data); + break; + default: + status = 0; + } + } + return(status); +} + + +/** + \brief Print data from a U_PMF_IMAGEATTRIBUTES object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.1.5, Microsoft name: EmfPlusImageAttributes Object +*/ +int U_PMF_IMAGEATTRIBUTES_print(const char *contents){ + uint32_t Version, WrapMode, ClampColor, ObjectClamp; + int status = U_PMF_IMAGEATTRIBUTES_get(contents, &Version, &WrapMode, &ClampColor, &ObjectClamp); + + if(status){ + printf(" + Image Attributes: "); + (void) U_PMF_GRAPHICSVERSION_print((char *)&Version); + printf(" WrapMode:%X", WrapMode); + printf(" ClampColor:%X", ClampColor); + printf(" ObjectClamp:%X\n", ObjectClamp); + } + return(status); +} + + + +/** + \brief Print data from a U_PMF_PATH object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.1.6, Microsoft name: EmfPlusPath Object +*/ +int U_PMF_PATH_print(const char *contents){ + unsigned int i, pos; + uint32_t Version, Count; + uint16_t Flags; + const char *Points; + const char *Types; + int status = U_PMF_PATH_get(contents, &Version, &Count, &Flags, &Points, &Types); + if(status){ + printf(" + Path: Version:%X Count:%d Flags:%X\n",Version, Count, Flags); + + /* Points part */ + U_PMF_VARPOINTS_print(&Points, Flags, Count); + + /* Types part */ + printf(" + Types:"); + pos = 0; + for(i=0; iX, Point->Y); + return(1); +} + +/** + \brief Print data from a U_PMF_POINTF object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.2.36, Microsoft name: EmfPlusPointF Object +*/ +int U_PMF_POINTF_print(const char **contents){ + U_FLOAT X, Y; + int status = U_PMF_POINTF_get(contents, &X, &Y); + if(status){ + printf("{%f,%f}", X, Y); + } + return(status); +} + +/** + \brief Print data from a U_PMF_POINTF Structure + \return 1 on success, 0 on error + \param Point U_PMF_POINTF Structure to print + EMF+ manual 2.2.2.36, Microsoft name: EmfPlusPointF Object +*/ +int U_PMF_POINTF_S_print(U_PMF_POINTF *Point){ + if(!Point){ return(0); } + printf("{%f,%f}", Point->X, Point->Y); + return(1); +} + +/** + \brief Print data from a U_PMF_POINTR object + \return bytes traversed on success, 0 on error + \param contents Pointer to next data to print + \param Xpos X coordinate for current point + \param Ypos Y coordinate for current point + + On each call the next relative offset is extracted, the current + coordinates are modified with that offset, and the pointer is + advanced to the next data point. + + EMF+ manual 2.2.2.37, Microsoft name: EmfPlusPointR Object +*/ +int U_PMF_POINTR_print(const char **contents, U_FLOAT *Xpos, U_FLOAT *Ypos){ + U_FLOAT X, Y; + int status = U_PMF_POINTR_get(contents, &X, &Y); + *Xpos += X; + *Ypos += Y; + if(status){ + printf("{%f,%f(%f,%f)}", *Xpos, *Ypos, X, Y); + } + return(status); +} + +/** + \brief Print data from a U_PMF_RECT object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.2.38, Microsoft name: EmfPlusRect Object +*/ +int U_PMF_RECT_print(const char **contents){ + int16_t X, Y, Width, Height; + int status = U_PMF_RECT_get(contents, &X, &Y, &Width, &Height); + if(status){ + printf("{UL{%d,%d},WH{%d,%d}}", X, Y, Width, Height); + } + return(status); +} + +/** + \brief Print data from a U_PMF_RECT Structure + \return 1 on success, 0 on error + \param Rect U_PMF_RECT structure + EMF+ manual 2.2.2.39, Microsoft name: EmfPlusRectF Object +*/ +int U_PMF_RECT_S_print(U_PMF_RECT *Rect){ + printf("{UL{%d,%d},WH{%d,%d}}", Rect->X, Rect->Y, Rect->Width, Rect->Height); + return(1); +} + +/** + \brief Print data from a U_PMF_RECTF object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.2.39, Microsoft name: EmfPlusRectF Object +*/ +int U_PMF_RECTF_print(const char **contents){ + U_FLOAT X, Y, Width, Height; + int status = U_PMF_RECTF_get(contents, &X, &Y, &Width, &Height); + if(status){ + printf("{UL{%f,%f},WH{%f,%f}}", X, Y, Width, Height); + } + return(status); +} + +/** + \brief Print data from a U_PMF_RECTF Structure + \return 1 on success, 0 on error + \param Rect U_PMF_RECTF Structure + EMF+ manual 2.2.2.39, Microsoft name: EmfPlusRectF Object +*/ +int U_PMF_RECTF_S_print(U_PMF_RECTF *Rect){ + printf("{UL{%f,%f},WH{%f,%f}}", Rect->X, Rect->Y, Rect->Width, Rect->Height); + return(1); +} + +/** + \brief Print data from a U_PMF_REGIONNODE object + \return size on success, 0 on error + \param contents Record from which to print data + \param Level Tree level. This routine is recursive and could go down many levels. 1 is the top, >1 are child nodes. + EMF+ manual 2.2.2.40, Microsoft name: EmfPlusRegionNode Object +*/ +int U_PMF_REGIONNODE_print(const char *contents, int Level){ + int len=4; /* Type will always be present */ + uint32_t Type; + const char *Data; + int status = U_PMF_REGIONNODE_get(contents, &Type, &Data); + if(status){ + printf("\n + RegionNode(Level:%d) { Type:%X(",Level,Type); + U_PMF_NODETYPE_print(Type); + printf(")"); + if(Type >= U_RNDT_And && Type <= U_RNDT_Complement){ + len += U_PMF_REGIONNODECHILDNODES_print(Data, Level+1); + } + else if(Type == U_RNDT_Rect){ + len += sizeof(U_PMF_RECTF); + (void) U_PMF_RECTF_print(&Data); + printf("\n"); + } + else if(Type == U_RNDT_Path){ + len += U_PMF_REGIONNODEPATH_print(Data); + } + /* U_RNDT_Empty and U_RNDT_Infinite do not change the length */ + else if(Type == U_RNDT_Empty ){ printf(" Empty" ); } + else if(Type == U_RNDT_Infinite ){ printf(" Infinite" ); } + printf(" + RegionNode(Level:%d) }",Level); + status = len; /* length of data + length of type */ + } + printf("\n"); + return(status); +} + +/** + \brief Print data from a U_PMF_REGIONNODECHILDNODES object + \return size on success, 0 on error + \param contents Record from which to print data + \param Level Tree level. This routine is recursive and could go down many levels. 1 is the top, >1 are child nodes. + EMF+ manual 2.2.2.41, Microsoft name: EmfPlusRegionNodeChildNodes Object +*/ +int U_PMF_REGIONNODECHILDNODES_print(const char *contents, int Level){ + uint32_t size,rsize; + printf(" RegionNodeChildNodes:\n"); + printf(" + RNCN__Left(Level:%d) {", Level); + size = U_PMF_REGIONNODE_print(contents, Level); + printf(" + RNCN__Left(Level:%d) },\n", Level); + if(size){ + contents += size; + printf(" + RNCN_Right(Level:%d) {", Level); + rsize = U_PMF_REGIONNODE_print(contents, Level); + size += rsize; + printf(" + RNCN_Right(Level:%d) },\n",Level); + } + return(size); +} + +/** + \brief Print data from a U_PMF_REGIONNODEPATH object + \return Size of data on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.2.42, Microsoft name: EmfPlusRegionNodePath Object +*/ +int U_PMF_REGIONNODEPATH_print(const char *contents){ + int32_t Size; + const char *Data; + int status = U_PMF_REGIONNODEPATH_get(contents, &Size, &Data); + if(status){ + printf(" RegionNodePath: \n"); + (void) U_PMF_PATH_print(Data); + status = Size + 4; /* data sizee + the 4 bytes encoding the size */ + } + return(status); +} + + +/** + \brief Print data from a U_PMF_SOLIDBRUSHDATA object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.2.43, Microsoft name: EmfPlusSolidBrushData Object +*/ +int U_PMF_SOLIDBRUSHDATA_print(const char *contents){ + U_PMF_ARGB Color; + int status = U_PMF_SOLIDBRUSHDATA_get(contents, &Color); + if(status){ + printf(" SolidBrushData: "); + (void) U_PMF_ARGB_print((char *) &Color); + } + return(status); +} + +/** + \brief Print data from a U_PMF_STRINGFORMATDATA object + \return 1 on success, 0 on error + \param contents Record from which to print data + \param TabStopCount Entries in TabStop array + \param RangeCount Entries in CharRange array + EMF+ manual 2.2.2.44, Microsoft name: EmfPlusStringFormatData Object +*/ +int U_PMF_STRINGFORMATDATA_print(const char *contents, uint32_t TabStopCount, uint32_t RangeCount){ + const U_FLOAT *TabStops; + const U_PMF_CHARACTERRANGE *CharRange; + int status = U_PMF_STRINGFORMATDATA_get(contents, TabStopCount, RangeCount, &TabStops, &CharRange); + if(status){ + printf(" SFdata: TabStopCount:%u RangeCount:%u\n", TabStopCount, RangeCount); + + printf(" Tabstops:"); + for(; TabStopCount; TabStopCount--,TabStops++){ printf(" %f",*TabStops); } + printf("\n"); + + printf(" CharRange:"); + for(; RangeCount; RangeCount--,CharRange++){ printf(" {%d,%d}",CharRange->First,CharRange->Length); } + printf("\n"); + + } + return(status); +} + +/** + \brief Print data from a U_PMF_TEXTUREBRUSHDATA object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.2.45, Microsoft name: EmfPlusTextureBrushData Object +*/ +int U_PMF_TEXTUREBRUSHDATA_print(const char *contents){ + uint32_t Flags; + int32_t WrapMode; + const char *Data; + int status = U_PMF_TEXTUREBRUSHDATA_get(contents, &Flags, &WrapMode, &Data); + if(status){ + printf(" + TBdata: Flags:%X WrapMode:%d", Flags, WrapMode); + } + return(status); +} + +/** + \brief Print data from a U_PMF_TEXTUREBRUSHOPTIONALDATA object + \return 1 on success, 0 on error + \param contents Record from which to print data + \param HasImage True if the record contains an image. + + EMF+ manual 2.2.2.46, Microsoft name: EmfPlusTextureBrushOptionalData Object +*/ +int U_PMF_TEXTUREBRUSHOPTIONALDATA_print(const char *contents, int HasImage){ + U_PMF_TRANSFORMMATRIX Matrix; + const char *Image; + int status = U_PMF_TEXTUREBRUSHOPTIONALDATA_get(contents, HasImage, &Matrix, &Image); + if(status){ + printf(" + TBOptdata: Image:%c", (HasImage ? 'Y' : 'N')); + (void) U_PMF_TRANSFORMMATRIX2_print(&Matrix); + (void) U_PMF_IMAGE_print(Image); + } + return(status); +} + +/** + \brief Print data from a U_PMF_TRANSFORMMATRIX object stored in file byte order. + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.2.47, Microsoft name: EmfPlusTransformMatrix Object +*/ +int U_PMF_TRANSFORMMATRIX_print(const char *contents){ + U_PMF_TRANSFORMMATRIX Tm; + int status = U_PMF_TRANSFORMMATRIX_get(contents, &Tm); + if(status){ + U_PMF_TRANSFORMMATRIX2_print(&Tm); + } + return(status); +} + +/** + \brief Print data from a U_PMF_TRANSFORMMATRIX structure + \return 1 on success, 0 on error + \param Tm U_PMF_TRANSFORMMATRIX structure + EMF+ manual 2.2.2.47, Microsoft name: EmfPlusTransformMatrix Object +*/ +int U_PMF_TRANSFORMMATRIX2_print(U_PMF_TRANSFORMMATRIX *Tm){ + printf(" Matrix:{%f,%f,%f,%f,%f,%f}", Tm->m11, Tm->m12, Tm->m21, Tm->m22, Tm->dX, Tm->dY); + return(1); +} + +/** + \brief Print data from a U_PMF_ROTMATRIX object + \return 1 on success, 0 on error + \param Rm U_PMF_ROTMATRIX object + NOT DOCUMENTED, like EMF+ manual 2.2.2.47, Microsoft name: EmfPlusTransformMatrix Object, but missing offset values +*/ +int U_PMF_ROTMATRIX2_print(U_PMF_ROTMATRIX *Rm){ + printf(" Matrix:{%f,%f,%f,%f}", Rm->m11, Rm->m12, Rm->m21, Rm->m22); + return(1); +} + +/** + \brief Print data from a U_PMF_IE_BLUR object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.3.1, Microsoft name: BlurEffect Object +*/ +int U_PMF_IE_BLUR_print(const char *contents){ + U_FLOAT Radius; + uint32_t ExpandEdge; + int status = U_PMF_IE_BLUR_get(contents, &Radius, &ExpandEdge); + if(status){ + printf("BlurEffect Radius:%f ExpandEdge:%u\n", Radius, ExpandEdge); + } + return(status); +} + +/** + \brief Print data from a U_PMF_IE_BRIGHTNESSCONTRAST object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.3.2, Microsoft name: BrightnessContrastEffect Object +*/ +int U_PMF_IE_BRIGHTNESSCONTRAST_print(const char *contents){ + int32_t Brightness, Contrast; + int status = U_PMF_IE_BRIGHTNESSCONTRAST_get(contents, &Brightness, &Contrast); + if(status){ + printf("BrightnessContrastEffect Brightness:%d Contrast:%d\n", Brightness, Contrast); + } + return(status); +} + +/** + \brief Print data from a U_PMF_IE_COLORBALANCE object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.3.3, Microsoft name: ColorBalanceEffect Object +*/ +int U_PMF_IE_COLORBALANCE_print(const char *contents){ + int32_t CyanRed, MagentaGreen, YellowBlue; + int status = U_PMF_IE_COLORBALANCE_get(contents, &CyanRed, &MagentaGreen, &YellowBlue); + if(status){ + printf("ColorBalanceEffect CyanRed:%d MagentaGreen:%d YellowBlue:%d\n", CyanRed, MagentaGreen, YellowBlue); + } + return(status); +} + +/** + \brief Print data from a U_PMF_IE_COLORCURVE object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.3.4, Microsoft name: ColorCurveEffect Object +*/ +int U_PMF_IE_COLORCURVE_print(const char *contents){ + uint32_t Adjust, Channel; + int32_t Intensity; + int status = U_PMF_IE_COLORCURVE_get(contents, &Adjust, &Channel, &Intensity); + if(status){ + printf("ColorBalanceEffect Adjust:%u Channel:%u Intensity:%d\n", Adjust, Channel, Intensity); + } + return(status); +} + +/** + \brief Print data from a U_PMF_IE_COLORLOOKUPTABLE object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.3.5, Microsoft name: ColorLookupTableEffect Object +*/ +int U_PMF_IE_COLORLOOKUPTABLE_print(const char *contents){ + const uint8_t *BLUT, *GLUT, *RLUT, *ALUT; + int status = U_PMF_IE_COLORLOOKUPTABLE_get(contents, &BLUT, &GLUT, &RLUT, &ALUT); + if(status){ + printf("ColorLookupTableEffect \n"); + U_PMF_UINT8_ARRAY_print(" BLUT:", BLUT, 256, "\n"); + U_PMF_UINT8_ARRAY_print(" GLUT:", GLUT, 256, "\n"); + U_PMF_UINT8_ARRAY_print(" RLUT:", RLUT, 256, "\n"); + U_PMF_UINT8_ARRAY_print(" ALUT:", ALUT, 256, "\n"); + } + return(status); +} + +/** + \brief Print data from a U_PMF_IE_COLORMATRIX object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.3.6, Microsoft name: ColorMatrixEffect Object +*/ +int U_PMF_IE_COLORMATRIX_print(const char *contents){ + U_PMF_IE_COLORMATRIX Matrix; + int i,j; + int status = U_PMF_IE_COLORMATRIX_get(contents, &Matrix); + if(status){ + printf("ColorMatrixEffect\n"); + for(i=0;i<5;i++){ + printf(" {"); + for(j=0;j<4;i++){ printf("%f,",Matrix.M[i][j]); } + printf("%f}",Matrix.M[i][j]); + } + printf("\n"); + } + return(status); +} + +/** + \brief Print data from a U_PMF_IE_HUESATURATIONLIGHTNESS object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.3.7, Microsoft name: HueSaturationLightnessEffect Object +*/ +int U_PMF_IE_HUESATURATIONLIGHTNESS_print(const char *contents){ + int32_t Hue, Saturation, Lightness; + int status = U_PMF_IE_HUESATURATIONLIGHTNESS_get(contents, &Hue, &Saturation, &Lightness); + if(status){ + printf("HueSaturationLightnessEffect Hue:%d Saturation:%d Lightness:%d\n", Hue, Saturation, Lightness); + } + return(status); +} + +/** + \brief Print data from a U_PMF_IE_LEVELS object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.3.8, Microsoft name: LevelsEffect Object +*/ +int U_PMF_IE_LEVELS_print(const char *contents){ + int32_t Highlight, Midtone, Shadow; + int status = U_PMF_IE_LEVELS_get(contents, &Highlight, &Midtone, &Shadow); + if(status){ + printf("LevelEffect Highlight:%d Midtone:%d Shadow:%d\n", Highlight, Midtone, Shadow); + } + return(status); +} + +/** + \brief Print data from a U_PMF_IE_REDEYECORRECTION object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.3.9, Microsoft name: RedEyeCorrectionEffect Object +*/ +int U_PMF_IE_REDEYECORRECTION_print(const char *contents){ + int32_t Elements; + U_RECTL *Rects; + int status = U_PMF_IE_REDEYECORRECTION_get(contents, &Elements, &Rects); + if(status){ + printf("RedEyeCorrectionEffect Elements:%u", Elements); + for(; Elements; Elements--, Rects++){ + printf(" "); + rectl_print(*Rects); + } + printf("\n"); + } + return(status); +} + +/** + \brief Print data from a U_PMF_IE_SHARPEN object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.3.10, Microsoft name: SharpenEffect Object +*/ +int U_PMF_IE_SHARPEN_print(const char *contents){ + U_FLOAT Radius; + int32_t Sharpen; + int status = U_PMF_IE_SHARPEN_get(contents, &Radius, &Sharpen); + if(status){ + printf("SharpenEffect Radius:%f Sharpen:%u\n", Radius, Sharpen); + } + return(status); +} + +/** + \brief Print data from a U_PMF_IE_TINT object + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.2.3.11, Microsoft name: TintEffect Object +*/ +int U_PMF_IE_TINT_print(const char *contents){ + int32_t Hue, Amount; + int status = U_PMF_IE_TINT_get(contents, &Hue, &Amount); + if(status){ + printf("TintEffect Hue:%d Amount:%d\n", Hue, Amount); + } + return(status); +} + +/* ***************************************************************************************** */ +/* EMF+ records, the EMF+ record header is printed separately, these print the contents only */ +/* ***************************************************************************************** */ + + +/** + \brief Print data from a U_PMR_OFFSETCLIP record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.1.1, Microsoft name: EmfPlusOffsetClip Record, Index 0x35 +*/ +int U_PMR_OFFSETCLIP_print(const char *contents){ + U_PMF_CMN_HDR Header; + U_FLOAT dX,dY; + int status = U_PMR_OFFSETCLIP_get(contents, &Header, &dX, &dY); + if(status){ + printf(" + dx:%f dy:%f\n",dX,dY); + } + return(status); +} + +/** + \brief Print data from a U_PMR_OFFSETCLIP record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.1.2, Microsoft name: EmfPlusResetClip Record, Index 0x31 +*/ +int U_PMR_RESETCLIP_print(const char *contents){ + return(U_PMR_NODATAREC_print(contents)); +} + +/** + \brief Print data from a U_PMR_SETCLIPPATH record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.1.3, Microsoft name: EmfPlusSetClipPath Record, Index 0x33 +*/ +int U_PMR_SETCLIPPATH_print(const char *contents){ + int CMenum; + uint32_t PathID; + int status = U_PMR_SETCLIPPATH_get(contents, NULL, &PathID, &CMenum); + if(status){ + printf(" + PathID:%u CMenum:%d\n",PathID,CMenum); + } + return(status); +} + +/** + \brief Print data from a U_PMR_SETCLIPRECT record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.1.4, Microsoft name: EmfPlusSetClipRect Record, Index 0x32 +*/ +int U_PMR_SETCLIPRECT_print(const char *contents){ + int CMenum; + U_PMF_RECTF Rect; + int status = U_PMR_SETCLIPRECT_get(contents, NULL, &CMenum, &Rect); + if(status){ + printf(" + CMenum:%d(", CMenum); + U_PMF_COMBINEMODEENUMERATION_print(CMenum); + printf(") Rect:"); + U_PMF_RECTF_S_print(&Rect); + printf("\n"); + } + return(status); +} + +/** + \brief Print data from a U_PMR_SETCLIPREGION record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.1.5, Microsoft name: EmfPlusSetClipRegion Record, Index 0x34 +*/ +int U_PMR_SETCLIPREGION_print(const char *contents){ + int CMenum; + uint32_t PathID; + int status = U_PMR_SETCLIPREGION_get(contents, NULL, &PathID, &CMenum); + if(status){ + printf(" + PathID:%u CMenum:%d(",PathID, CMenum); + U_PMF_COMBINEMODEENUMERATION_print(CMenum); + printf(")\n"); + } + return(status); +} + + +/** + \brief Print data from a U_PMR_COMMENT record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.2.1, Microsoft name: EmfPlusComment Record, Index 0x03 +*/ +int U_PMR_COMMENT_print(const char *contents){ + U_PMF_CMN_HDR Header; + const char *Data; + unsigned int i=0; + int status = U_PMR_COMMENT_get(contents, &Header, &Data); + if(status){ + /* try to print it, but only ASCII, bail on anything that is not ASCII */ + printf(" + Data:"); + for(i=0; i< Header.DataSize; i++,Data++){ + if(!*Data)break; + if(*(unsigned const char *)Data <128){ printf("%c",*Data); } + else { break; } + } + printf("\n"); + } + return(status); +} + +/** + \brief Print data from a U_PMR_ENDOFFILE record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.3.1, Microsoft name: EmfPlusEndOfFile Record, Index 0x02 +*/ +int U_PMR_ENDOFFILE_print(const char *contents){ + return(U_PMR_NODATAREC_print(contents)); +} + +/** + \brief Print data from a U_PMR_ENDOFFILE record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.3.2, Microsoft name: EmfPlusGetDC Record, Index 0x04 +*/ +int U_PMR_GETDC_print(const char *contents){ + return(U_PMR_NODATAREC_print(contents)); +} + +/** + \brief Print data from a U_PMR_HEADER record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.3.3, Microsoft name: EmfPlusHeader Record, Index 0x01 +*/ +int U_PMR_HEADER_print(const char *contents){ + U_PMF_GRAPHICSVERSION Version; + int IsDual, IsVideo; + uint32_t LogicalDpiX, LogicalDpiY; + int status = U_PMR_HEADER_get(contents, NULL, &Version, &IsDual, &IsVideo, &LogicalDpiX, &LogicalDpiY); + if(status){ + /* try to print it, but only ASCII, bail on anything that is not ASCII */ + printf(" + "); + (void) U_PMF_GRAPHICSVERSION_print((char *) &Version); + printf(" IsDual:%c IsVideo:%d LogicalDpiX,y:{%u,%u}\n",(IsDual ? 'Y' : 'N'),IsVideo,LogicalDpiX, LogicalDpiY); + } + return(status); +} + +/** + \brief Print data from a U_PMR_CLEAR record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.4.1, Microsoft name: EmfPlusClear Record, Index 0x09 +*/ +int U_PMR_CLEAR_print(const char *contents){ + U_PMF_ARGB Color; + int status = U_PMR_CLEAR_get(contents, NULL, &Color); + if(status){ + /* try to print it, but only ASCII, bail on anything that is not ASCII */ + printf(" + Color:"); + (void) U_PMF_ARGB_print((char *) &Color); + } + return(status); +} + +/** + \brief Print data from a U_PMR_DRAWARC record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.4.2, Microsoft name: EmfPlusDrawArc Record, Index 0x12 +*/ +int U_PMR_DRAWARC_print(const char *contents){ + uint32_t PenID; + int ctype; + U_FLOAT Start, Sweep; + U_PMF_RECTF Rect; + int status = U_PMR_DRAWARC_get(contents, NULL, &PenID, &ctype, &Start, &Sweep, &Rect); + if(status){ + printf(" + PenID:%u ctype:%d Start:%f Sweep:%f Rect:", PenID,ctype,Start,Sweep); + (void) U_PMF_VARRECTF_S_print(&Rect, 1); + printf("\n"); + } + return(status); +} + +/** + \brief Print data from a U_PMR_DRAWBEZIERS record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.4.3, Microsoft name: EmfPlusDrawBeziers Record, Index 0x19 +*/ +int U_PMR_DRAWBEZIERS_print(const char *contents){ + uint32_t PenID; + int ctype, RelAbs; + uint32_t Elements; + U_PMF_POINTF *Points; + int status = U_PMR_DRAWBEZIERS_get(contents, NULL, &PenID, &ctype, &RelAbs, &Elements, &Points); + if(status){ + printf(" + PenIdx:%u ctype:%d RelAbs:%d Elements:%u\n", PenID, ctype, RelAbs, Elements); + U_PMF_VARPOINTF_S_print(Points, Elements); + free(Points); + } + return(status); +} + +/** + \brief Print data from a U_PMR_DRAWCLOSEDCURVE record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + + Curve is a cardinal spline. + References sent by MS support: + http://alvyray.com/Memos/CG/Pixar/spline77.pdf + http://msdn.microsoft.com/en-us/library/4cf6we5y(v=vs.110).aspx + + EMF+ manual 2.3.4.4, Microsoft name: EmfPlusDrawClosedCurve Record, Index 0x17 +*/ +int U_PMR_DRAWCLOSEDCURVE_print(const char *contents){ + uint32_t PenID; + int ctype, RelAbs; + U_FLOAT Tension; + uint32_t Elements; + U_PMF_POINTF *Points; + int status = U_PMR_DRAWCLOSEDCURVE_get(contents, NULL, &PenID, &ctype, &RelAbs, &Tension, &Elements, &Points); + if(status){ + printf(" + PenID:%u ctype:%d RelAbs:%d Tension:%f\n", PenID, ctype, RelAbs, Tension); + U_PMF_VARPOINTF_S_print(Points, Elements); + free(Points); + } + return(status); +} + +/** + \brief Print data from a U_PMR_DRAWCURVE record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + + Curve is a cardinal spline, using doubled terminator points to generate curves for the terminal segments. + References sent by MS support: + http://alvyray.com/Memos/CG/Pixar/spline77.pdf + http://msdn.microsoft.com/en-us/library/4cf6we5y(v=vs.110).aspx + + EMF+ manual 2.3.4.5, Microsoft name: EmfPlusDrawCurve Record, Index 0x18 +*/ +int U_PMR_DRAWCURVE_print(const char *contents){ + uint32_t PenID; + int ctype; + U_FLOAT Tension; + uint32_t Offset, NSegs, Elements; + U_PMF_POINTF *Points; + int status = U_PMR_DRAWCURVE_get(contents, NULL, &PenID, &ctype, &Tension, &Offset, &NSegs, &Elements, &Points); + if(status){ + printf(" + PenID:%u ctype:%d Tension:%f Offset:%u NSegs:%u Elements:%u\n", PenID, ctype, Tension, Offset, NSegs, Elements); + U_PMF_VARPOINTF_S_print(Points, Elements); + free(Points); + } + return(status); +} + +/** + \brief Print data from a U_PMR_DRAWDRIVERSTRING record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.4.6, Microsoft name: EmfPlusDrawDriverString Record, Index 0x36 +*/ +int U_PMR_DRAWDRIVERSTRING_print(const char *contents){ + unsigned int i; + uint32_t FontID; + int btype; + U_FLOAT Tension; + uint32_t BrushID, DSOFlags, HasMatrix, Elements; + uint16_t *Glyphs; + U_PMF_POINTF *Points; + U_PMF_TRANSFORMMATRIX *Matrix; + int status = U_PMR_DRAWDRIVERSTRING_get(contents, NULL, &FontID, &btype, + &Tension, &BrushID, &DSOFlags, &HasMatrix, &Elements,&Glyphs, &Points, &Matrix); + if(status){ + printf(" + FontID:%u btype:%d Tension:%f BrushID:%u DSOFlags:%X Elements:%u\n", FontID,btype,Tension, BrushID, DSOFlags, Elements); + + printf(" + Glyphs:"); + if(*Glyphs){ + for(i=0; i= blimit)return(0); + printf(" + PenID:%u ctype:%d Elements:%u Rect:", PenID,ctype,Elements); + (void) U_PMF_VARRECTF_S_print(Rects, Elements); + printf("\n"); + } + if(Rects)free(Rects); + return(status); +} + +/** + \brief Print data from a U_PMR_DRAWSTRING record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.4.14, Microsoft name: EmfPlusDrawString Record, Index 0x1C +*/ +int U_PMR_DRAWSTRING_print(const char *contents){ + char *String8=NULL; + uint32_t FontID, BrushID, FormatID, Length; + int btype; + U_PMF_RECTF Rect; + uint16_t *String16; + int status = U_PMR_DRAWSTRING_get(contents, NULL, &FontID, &btype, + &BrushID, &FormatID, &Length, &Rect, &String16); + if(status){ + printf(" + FontID:%u StringFormatID:%u btype:%d Length:%u Rect:", FontID, FormatID, btype, Length); + (void) U_PMF_RECTF_S_print(&Rect); + (void) U_PMF_VARBRUSHID_print(btype, BrushID); + if(String16){ + String8 = U_Utf16leToUtf8(String16, Length, NULL); + free(String16); + if(String8){ + printf(" String(as_UTF8):<%s>\n",String8); + free(String8); + } + } + else { + printf(" String(as_UTF8):(none)\n"); + } + } + return(status); +} + +/** + \brief Print data from a U_PMR_FILLCLOSEDCURVE record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.4.15, Microsoft name: EmfPlusFillClosedCurve Record, Index 0x16 +*/ +int U_PMR_FILLCLOSEDCURVE_print(const char *contents){ + uint32_t BrushID; + int btype, ctype, ftype, RelAbs; + U_FLOAT Tension; + uint32_t Elements; + U_PMF_POINTF *Points; + int status = U_PMR_FILLCLOSEDCURVE_get(contents, NULL, &btype, &ctype, &ftype, &RelAbs, + &BrushID, &Tension, &Elements, &Points); + if(status){ + printf(" + btype:%d ctype:%d ftype:%d RelAbs:%d Elements:%u", + btype, ctype, ftype, RelAbs, Elements); + (void) U_PMF_VARBRUSHID_print(btype, BrushID); + printf("\n"); + U_PMF_VARPOINTF_S_print(Points, Elements); + free(Points); + } + return(status); +} + + +/** + \brief Print data from a U_PMR_FILLELLIPSE record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.4.16, Microsoft name: EmfPlusFillEllipse Record, Index 0x0E +*/ +int U_PMR_FILLELLIPSE_print(const char *contents){ + int btype, ctype; + uint32_t BrushID; + U_PMF_RECTF Rect; + int status = U_PMR_FILLELLIPSE_get(contents, NULL, &btype, &ctype, &BrushID, &Rect); + if(status){ + printf(" + btype:%d ctype:%d",btype,ctype); + (void) U_PMF_VARBRUSHID_print(btype, BrushID); + (void) U_PMF_VARRECTF_S_print(&Rect, 1); + printf("\n"); + } + return(status); +} + +/** + \brief Print data from a U_PMR_FILLPATH record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.4.17, Microsoft name: EmfPlusFillPath Record, Index 0x14 +*/ +int U_PMR_FILLPATH_print(const char *contents){ + int btype; + uint32_t PathID, BrushID; + int status = U_PMR_FILLPATH_get(contents, NULL, &PathID, &btype, &BrushID); + if(status){ + printf(" + PathID:%u btype:%d",PathID, btype); + (void) U_PMF_VARBRUSHID_print(btype, BrushID); + printf("\n"); + } + return(status); +} + +/** + \brief Print data from a U_PMR_FILLPIE record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.4.18, Microsoft name: EmfPlusFillPie Record, Index 0x10 +*/ +int U_PMR_FILLPIE_print(const char *contents){ + int btype, ctype; + U_FLOAT Start, Sweep; + uint32_t BrushID; + U_PMF_RECTF Rect; + int status = U_PMR_FILLPIE_get(contents, NULL, &btype, &ctype, &BrushID, &Start, &Sweep, &Rect); + if(status){ + printf(" + btype:%d ctype:%d",btype,ctype); + (void) U_PMF_VARBRUSHID_print(btype, BrushID); + (void) U_PMF_VARRECTF_S_print(&Rect, 1); + printf("\n"); + } + return(status); +} + +/** + \brief Print data from a U_PMR_FILLPOLYGON record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.4.19, Microsoft name: EmfPlusFillPolygon Record, Index 0x0C +*/ +int U_PMR_FILLPOLYGON_print(const char *contents){ + int btype, ctype, RelAbs; + uint32_t BrushID, Elements; + U_PMF_POINTF *Points; + int status = U_PMR_FILLPOLYGON_get(contents, NULL, &btype, &ctype, &RelAbs, &BrushID, &Elements, &Points); + if(status){ + printf(" + btype:%d ctype:%d RelAbs:%d Elements:%u",btype,ctype,RelAbs,Elements); + (void) U_PMF_VARBRUSHID_print(btype, BrushID); + printf("\n"); + U_PMF_VARPOINTF_S_print(Points, Elements); + free(Points); + } + return(status); +} + +/** + \brief Print data from a U_PMR_FILLRECTS record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + \param blimit One byte past the last record in memory. + EMF+ manual 2.3.4.20, Microsoft name: EmfPlusFillRects Record, Index 0x0A +*/ +int U_PMR_FILLRECTS_print(const char *contents, const char *blimit){ + int btype, ctype; + uint32_t BrushID, Elements; + U_PMF_RECTF *Rects; + U_PMF_CMN_HDR hdr; + int status = U_PMR_FILLRECTS_get(contents, &hdr, &btype,&ctype, &BrushID, &Elements, &Rects); + if(status){ + if(contents + hdr.Size >= blimit)return(0); + printf(" + btype:%d ctype:%d Elements:%u",btype,ctype,Elements); + (void) U_PMF_VARBRUSHID_print(btype, BrushID); + (void) U_PMF_VARRECTF_S_print(Rects, Elements); + free(Rects); + printf("\n"); + } + return(status); +} + +/** + \brief Print data from a U_PMR_FILLREGION record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.4.21, Microsoft name: EmfPlusFillRegion Record, Index 0x13 +*/ +int U_PMR_FILLREGION_print(const char *contents){ + uint32_t RgnID, BrushID; + int btype, ctype; + int status = U_PMR_FILLREGION_get(contents, NULL, &RgnID, &btype, &ctype, &BrushID); + if(status){ + printf(" + RgnID:%u btype:%d ctype:%d", RgnID, btype, ctype); + (void) U_PMF_VARBRUSHID_print(btype, BrushID); + printf("\n"); + } + return(status); +} + +/** + \brief Print data from a U_PMR_OBJECT record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + \param blimit One byte past the last record in memory. + \param ObjCont Structure that holds accumulated object. + \param term Flag used when an abnormal termination of a series of continuation records is encountered. + EMF+ manual 2.3.5.1, Microsoft name: EmfPlusObject Record, Index 0x13 +*/ +int U_PMR_OBJECT_print(const char *contents, const char *blimit, U_OBJ_ACCUM *ObjCont, int term){ + U_PMF_CMN_HDR Header; + uint32_t ObjID; + int otype, ntype; + uint32_t TSize; + const char *Data; + int ttype,status; + +//int k; const char *cptr; for(cptr=contents, k=0; k<608;k++,cptr++){ printf("%3.3d %2.2X\n",k,*(uint8_t*)cptr); }; fflush(stdout); + + /* Continued records are a pain. Each contains the total size of the continued object in the first 4 bytes + of data. When the total hits that then then the record is complete, even though the continuation bit will + still be set on that last record. Check for this and then print the terminated continued series. + */ + + if(term){ /* mode for handling unexpected end of accumulated object */ + if(ObjCont->used == 0)return(0); /* no continued object pending */ + printf(" + START Forced Termination of Accumulating object Bytes:%u ObjID:%u DeclaredType:%d(", + ObjCont->used, ObjCont->Id, ObjCont->Type); + U_PMF_OBJECTTYPEENUMERATION_print(ObjCont->Type); + ttype = ObjCont->Type & 0x3F; + printf(")\n"); + status = 1; + } + else { + status = U_PMR_OBJECT_get(contents, &Header, &ObjID, &otype, &ntype, &TSize, &Data); + /* In a corrupt EMF+ file we might hit a new type of record before all the continuation records + expected have been found. If that happens terminate whatever we have accumulated so far, and then go on + to emit the new (unexpected) record. */ + if(contents + Header.Size >= blimit)return(0); + if(!status)return(status); + if((ObjCont->used > 0) && (U_OA_append(ObjCont, NULL, 0, otype, ObjID) < 0)){ + U_PMR_OBJECT_print(contents, blimit, ObjCont, 1); + } + printf(" + ObjID:%u ObjType:%d(", ObjID, otype); + U_PMF_OBJECTTYPEENUMERATION_print(otype); + printf(") ntype:%d", ntype); + printf(" ContinueD:%c",( ObjCont->used ? 'Y' : 'N')); + printf(" ContinueB:%c",( ntype ? 'Y' : 'N')); + if(ntype){ + U_OA_append(ObjCont, Data, Header.DataSize - 4, otype, ObjID); // The total byte count is not added to the object + printf(" TotalSize:%u",TSize); + printf(" Accumulated:%u",ObjCont->used); + } + else { + U_OA_append(ObjCont, Data, Header.DataSize, otype, ObjID); // The total byte count is not added to the object + } + printf("\n"); + if(ntype && ObjCont->used < TSize)return(status); + /* preceding terminates any continued series for >= accumulated bytes */ + ttype = otype; + } + if(status){ + switch(ttype){ + case U_OT_Brush: (void) U_PMF_BRUSH_print(ObjCont->accum); break; + case U_OT_Pen: (void) U_PMF_PEN_print(ObjCont->accum); break; + case U_OT_Path: (void) U_PMF_PATH_print(ObjCont->accum); break; + case U_OT_Region: (void) U_PMF_REGION_print(ObjCont->accum); break; + case U_OT_Image: (void) U_PMF_IMAGE_print(ObjCont->accum); break; + case U_OT_Font: (void) U_PMF_FONT_print(ObjCont->accum); break; + case U_OT_StringFormat: (void) U_PMF_STRINGFORMAT_print(ObjCont->accum); break; + case U_OT_ImageAttributes: (void) U_PMF_IMAGEATTRIBUTES_print(ObjCont->accum); break; + case U_OT_CustomLineCap: (void) U_PMF_CUSTOMLINECAP_print(ObjCont->accum,""); break; + case U_OT_Invalid: + default: + printf("INVALID OBJECT TYPE!!!!\n"); + break; + } + U_OA_clear(ObjCont); + } + if(term)printf(" + END Forced Termination of Accumulating object\n"); + return(status); +} + +/** + \brief Print data from a U_PMR_SERIALIZABLEOBJECT record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.5.2, Microsoft name: EmfPlusSerializableObject Record, Index 0x38 +*/ +int U_PMR_SERIALIZABLEOBJECT_print(const char *contents){ + uint8_t GUID[16]; + uint32_t Size; + const char *Data; + char *string=NULL; + int iee; + int status = U_PMR_SERIALIZABLEOBJECT_get(contents, NULL, &GUID[0], &Size, &Data); + if(status){ + string = U_PMF_CURLYGUID_set(&GUID[0]); + if(string){ + printf(" + GUID:%s Size:%u",string,Size); + iee = U_PMF_KNOWNCURLYGUID_set(string); /* overwrites string with short text form */ + printf("\n + Effect:"); + free(string); + switch(iee){ + case U_IEE_Unknown: printf("(undefined)\n"); break; + case U_IEE_BlurEffectGuid: U_PMF_IE_BLUR_print(Data); break; + case U_IEE_BrightnessContrastEffectGuid: U_PMF_IE_BRIGHTNESSCONTRAST_print(Data); break; + case U_IEE_ColorBalanceEffectGuid: U_PMF_IE_COLORBALANCE_print(Data); break; + case U_IEE_ColorCurveEffectGuid: U_PMF_IE_COLORCURVE_print(Data); break; + case U_IEE_ColorLookupTableEffectGuid: U_PMF_IE_COLORLOOKUPTABLE_print(Data); break; + case U_IEE_ColorMatrixEffectGuid: U_PMF_IE_COLORMATRIX_print(Data); break; + case U_IEE_HueSaturationLightnessEffectGuid: U_PMF_IE_HUESATURATIONLIGHTNESS_print(Data); break; + case U_IEE_LevelsEffectGuid: U_PMF_IE_LEVELS_print(Data); break; + case U_IEE_RedEyeCorrectionEffectGuid: U_PMF_IE_REDEYECORRECTION_print(Data); break; + case U_IEE_SharpenEffectGuid: U_PMF_IE_SHARPEN_print(Data); break; + case U_IEE_TintEffectGuid: U_PMF_IE_TINT_print(Data); break; + } + } + else { + printf(" + GUID:ERROR Size:%u\n",Size); + } + } + return(status); +} + +/** + \brief Print data from a U_PMR_SETANTIALIASMODE record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.6.1, Microsoft name: EmfPlusSetAntiAliasMode Record, Index 0x1E +*/ +int U_PMR_SETANTIALIASMODE_print(const char *contents){ + int SMenum, aatype; + int status = U_PMR_SETANTIALIASMODE_get(contents, NULL, &SMenum, &aatype); + if(status){ + printf(" + SMenum:%d AntiAlias:%c\n",SMenum,(aatype ? 'Y' : 'N')); + } + return(status); +} + +/** + \brief Print data from a U_PMR_SETCOMPOSITINGMODE record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.6.2, Microsoft name: EmfPlusSetCompositingMode Record, Index 0x23 +*/ +int U_PMR_SETCOMPOSITINGMODE_print(const char *contents){ + int CMenum; + int status = U_PMR_SETCOMPOSITINGMODE_get(contents, NULL, &CMenum); + if(status){ + printf(" + CMenum:%d\n",CMenum); + } + return(status); +} + +/** + \brief Print data from a U_PMR_SETCOMPOSITINGQUALITY record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.6.3, Microsoft name: EmfPlusSetCompositingQuality Record, Index 0x24 +*/ +int U_PMR_SETCOMPOSITINGQUALITY_print(const char *contents){ + int CQenum; + int status = U_PMR_SETCOMPOSITINGQUALITY_get(contents, NULL, &CQenum); + if(status){ + printf(" + CQenum:%d\n",CQenum); + } + return(status); +} + +/** + \brief Print data from a U_PMR_SETINTERPOLATIONMODE record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.6.4, Microsoft name: EmfPlusSetInterpolationMode Record, Index 0x21 +*/ +int U_PMR_SETINTERPOLATIONMODE_print(const char *contents){ + int IMenum; + int status = U_PMR_SETINTERPOLATIONMODE_get(contents, NULL, &IMenum); + if(status){ + printf(" + IMenum:%d\n",IMenum); + } + return(status); +} + +/** + \brief Print data from a U_PMR_SETPIXELOFFSETMODE record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.6.5, Microsoft name: EmfPlusSetPixelOffsetMode Record, Index 0x22 +*/ +int U_PMR_SETPIXELOFFSETMODE_print(const char *contents){ + int POMenum; + int status = U_PMR_SETPIXELOFFSETMODE_get(contents, NULL, &POMenum); + if(status){ + printf(" + POMenum:%d\n",POMenum); + } + return(status); +} + +/** + \brief Print data from a U_PMR_SETRENDERINGORIGIN record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.6.6, Microsoft name: EmfPlusSetRenderingOrigin Record, Index 0x1D +*/ +int U_PMR_SETRENDERINGORIGIN_print(const char *contents){ + int32_t X, Y; + int status = U_PMR_SETRENDERINGORIGIN_get(contents, NULL, &X, &Y); + if(status){ + printf(" + X:%d Y:%d\n", X, Y); + } + return(status); +} + +/** + \brief Print data from a U_PMR_SETTEXTCONTRAST record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.6.7, Microsoft name: EmfPlusSetTextContrast Record, Index 0x20 +*/ +int U_PMR_SETTEXTCONTRAST_print(const char *contents){ + int GC; + int status = U_PMR_SETTEXTCONTRAST_get(contents, NULL, &GC); + if(status){ + printf(" + GC:%d\n", GC); + } + return(status); +} + +/** + \brief Print data from a U_PMR_SETTEXTRENDERINGHINT record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.6.8, Microsoft name: EmfPlusSetTextRenderingHint Record, Index 0x1F +*/ +int U_PMR_SETTEXTRENDERINGHINT_print(const char *contents){ + int TRHenum; + int status = U_PMR_SETTEXTRENDERINGHINT_get(contents, NULL, &TRHenum); + if(status){ + printf(" + TRHenum:%d\n",TRHenum); + } + return(status); +} + +/** + \brief Print data from a U_PMR_BEGINCONTAINER record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.7.1, Microsoft name: EmfPlusBeginContainer Record, Index 0x27 +*/ +int U_PMR_BEGINCONTAINER_print(const char *contents){ + int UTenum; + U_PMF_RECTF DstRect, SrcRect; + uint32_t StackID; + int status = U_PMR_BEGINCONTAINER_get(contents, NULL, &UTenum, &DstRect, &SrcRect, &StackID); + if(status){ + printf(" + UTenum:%d",UTenum); + printf(" DstRect:"); (void) U_PMF_RECTF_S_print(&DstRect); + printf(" SrcRect:"); (void) U_PMF_RECTF_S_print(&SrcRect); + printf(" StackID:%u\n", StackID); + } + return(status); +} + +/** + \brief Print data from a U_PMR_BEGINCONTAINERNOPARAMS record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.7.2, Microsoft name: EmfPlusBeginContainerNoParams Record, Index 0x28 +*/ +int U_PMR_BEGINCONTAINERNOPARAMS_print(const char *contents){ + uint32_t StackID; + int status = U_PMR_BEGINCONTAINERNOPARAMS_get(contents, NULL, &StackID); + if(status){ + printf(" + StackID:%u\n", StackID); + } + return(status); +} + +/** + \brief Print data from a U_PMR_ENDCONTAINER record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.7.3, Microsoft name: EmfPlusEndContainer Record, Index 0x29 +*/ +int U_PMR_ENDCONTAINER_print(const char *contents){ + uint32_t StackID; + int status = U_PMR_ENDCONTAINER_get(contents, NULL, &StackID); + if(status){ + printf(" + StackID:%u\n", StackID); + } + return(status); +} + +/** + \brief Print data from a U_PMR_RESTORE record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.7.4, Microsoft name: EmfPlusRestore Record, Index 0x26 +*/ +int U_PMR_RESTORE_print(const char *contents){ + uint32_t StackID; + int status = U_PMR_RESTORE_get(contents, NULL, &StackID); + if(status){ + printf(" + StackID:%u\n", StackID); + } + return(status); +} + +/** + \brief Print data from a U_PMR_SAVE record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.7.5, Microsoft name: EmfPlusSave Record, Index 0x25 +*/ +int U_PMR_SAVE_print(const char *contents){ + uint32_t StackID; + int status = U_PMR_SAVE_get(contents, NULL, &StackID); + if(status){ + printf(" + StackID:%u\n", StackID); + } + return(status); +} + +/** + \brief Print data from a U_PMR_SETTSCLIP record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.8.1, Microsoft name: EmfPlusSetTSClip Record, Index 0x3A +*/ +int U_PMR_SETTSCLIP_print(const char *contents){ + int ctype; + uint32_t Elements; + U_PMF_RECTF *Rects; + int status = U_PMR_SETTSCLIP_get(contents, NULL, &ctype, &Elements, &Rects); + if(status){ + printf(" + ctype:%d Elements:%u",ctype,Elements); + (void) U_PMF_VARRECTF_S_print(Rects, Elements); + free(Rects); + printf("\n"); + } + return(status); +} + +/** + \brief Print data from a U_PMR_SETTSGRAPHICS record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.8.2, Microsoft name: EmfPlusSetTSGraphics Record, Index 0x39 +*/ +int U_PMR_SETTSGRAPHICS_print(const char *contents){ + int vgatype, pptype; + uint8_t AntiAliasMode, TextRenderHint, CompositingMode, CompositingQuality, FilterType, PixelOffset; + int16_t RenderOriginX, RenderOriginY; + uint16_t TextContrast; + U_PMF_TRANSFORMMATRIX WorldToDevice; + const char *Data; + int status = U_PMR_SETTSGRAPHICS_get(contents, NULL, + &vgatype, &pptype, + &AntiAliasMode, &TextRenderHint, &CompositingMode, &CompositingQuality, + &RenderOriginX, &RenderOriginY, &TextContrast, &FilterType, + &PixelOffset, &WorldToDevice, &Data); + if(status){ + printf(" + vgatype:%d pptype:%u",vgatype,pptype); + printf(" AntiAliasMode:%u TextRenderHint:%u CompositingMode:%u CompositingQuality:%u", + AntiAliasMode, TextRenderHint, CompositingMode, CompositingQuality); + printf(" RenderOriginX:%d RenderOriginY:%d",RenderOriginX, RenderOriginY); + printf(" TextContrast:%u",TextContrast); + printf(" WorldToDevice:"); + U_PMF_TRANSFORMMATRIX2_print(&WorldToDevice); + if(pptype){ (void) U_PMF_PALETTE_print(Data); } + printf("\n"); + } + return(status); +} + + +/** + \brief Print data from a U_PMR_MULTIPLYWORLDTRANSFORM record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.9.1, Microsoft name: EmfPlusMultiplyWorldTransform Record, Index 0x2C +*/ +int U_PMR_MULTIPLYWORLDTRANSFORM_print(const char *contents){ + int xmtype; + U_PMF_TRANSFORMMATRIX Matrix; + int status = U_PMR_MULTIPLYWORLDTRANSFORM_get(contents, NULL, &xmtype, &Matrix); + if(status){ + printf(" + xmtype:%d Multiply:%s",xmtype,(xmtype ? "Post" : "Pre")); + U_PMF_TRANSFORMMATRIX2_print(&Matrix); + printf("\n"); + } + return(status); +} + +/** + \brief Print data from a U_PMR_RESETWORLDTRANSFORM record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.9.2, Microsoft name: EmfPlusResetWorldTransform Record, Index 0x2B +*/ +int U_PMR_RESETWORLDTRANSFORM_print(const char *contents){ + return(U_PMR_NODATAREC_print(contents)); +} + +/** + \brief Print data from a U_PMR_ROTATEWORLDTRANSFORM record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.9.3, Microsoft name: EmfPlusRotateWorldTransform Record, Index 0x2F +*/ +int U_PMR_ROTATEWORLDTRANSFORM_print(const char *contents){ + int xmtype; + U_FLOAT Angle; + int status = U_PMR_ROTATEWORLDTRANSFORM_get(contents, NULL, &xmtype, &Angle); + if(status){ + printf(" + xmtype:%d Multiply:%s Angle:%f\n",xmtype,(xmtype ? "Post" : "Pre"), Angle); + } + return(status); +} + +/** + \brief Print data from a U_PMR_SCALEWORLDTRANSFORM record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.9.4, Microsoft name: EmfPlusScaleWorldTransform Record, Index 0x2E +*/ +int U_PMR_SCALEWORLDTRANSFORM_print(const char *contents){ + int xmtype; + U_FLOAT Sx, Sy; + int status = U_PMR_SCALEWORLDTRANSFORM_get(contents, NULL, &xmtype, &Sx, &Sy); + if(status){ + printf(" + xmtype:%d Multiply:%s ScaleX:%f ScaleY:%f\n",xmtype,(xmtype ? "Post" : "Pre"), Sx, Sy); + } + return(status); +} + +/** + \brief Print data from a U_PMR_SETPAGETRANSFORM record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.9.5, Microsoft name: EmfPlusSetPageTransform Record, Index 0x30 +*/ +int U_PMR_SETPAGETRANSFORM_print(const char *contents){ + int UTenum; + U_FLOAT Scale; + int status = U_PMR_SETPAGETRANSFORM_get(contents, NULL, &UTenum, &Scale); + if(status){ + printf(" + UTenum:%d Scale:%f\n",UTenum, Scale); + } + return(status); +} + +/** + \brief Print data from a U_PMR_SETWORLDTRANSFORM record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.9.6, Microsoft name: EmfPlusSetWorldTransform Record, Index 0x2A +*/ +int U_PMR_SETWORLDTRANSFORM_print(const char *contents){ + U_PMF_TRANSFORMMATRIX Matrix; + int status = U_PMR_SETWORLDTRANSFORM_get(contents, NULL, &Matrix); + if(status){ + printf(" + "); + U_PMF_TRANSFORMMATRIX2_print(&Matrix); + printf("\n"); + } + return(status); +} + +/** + \brief Print data from a U_PMR_TRANSLATEWORLDTRANSFORM record + \return size of record in bytes on success, 0 on error + \param contents Record from which to print data + EMF+ manual 2.3.9.7, Microsoft name: EmfPlusTranslateWorldTransform Record, Index 0x2D +*/ +int U_PMR_TRANSLATEWORLDTRANSFORM_print(const char *contents){ + int xmtype; + U_FLOAT Dx, Dy; + int status = U_PMR_TRANSLATEWORLDTRANSFORM_get(contents, NULL, &xmtype, &Dx, &Dy); + if(status){ + printf(" + xmtype:%d Multiply:%s TranslateX:%f TranlateY:%f\n",xmtype,(xmtype ? "Post" : "Pre"), Dx, Dy); + } + return(status); +} + + +/** + \brief Print data from a U_PMR_STROKEFILLPATH record + \return 1 on success, 0 on error + \param contents Record from which to print data +*/ +int U_PMR_STROKEFILLPATH_print(const char *contents){ + return(U_PMR_NODATAREC_print(contents)); +} + +/** + \brief Print data from a U_PMR_MULTIFORMATSTART record + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual mentioned in 2.1.1.1, reserved, not otherwise documented, Microsoft name: EmfPlusMultiFormatStart Record, Index 0x05 +*/ +int U_PMR_MULTIFORMATSTART_print(const char *contents){ + return(U_PMR_NODATAREC_print(contents)); +} + +/** + \brief Print data from a U_PMR_MULTIFORMATSECTION record + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual mentioned in 2.1.1.1, reserved, not otherwise documented, Microsoft name: EmfPlusMultiFormatSection Record, Index 0x06 +*/ +int U_PMR_MULTIFORMATSECTION_print(const char *contents){ + return(U_PMR_NODATAREC_print(contents)); +} + +/** + \brief Print data from a U_PMR_MULTIFORMATEND record + \return 1 on success, 0 on error + \param contents Record from which to print data + EMF+ manual mentioned in 2.1.1.1, reserved, not otherwise documented, Microsoft name: EmfPlusMultiFormatEnd Record, Index 0x06 +*/ +int U_PMR_MULTIFORMATEND_print(const char *contents){ + return(U_PMR_NODATAREC_print(contents)); +} + + + +#ifdef __cplusplus +} +#endif diff --git a/src/libuemf/upmf_print.h b/src/libuemf/upmf_print.h new file mode 100644 index 000000000..3ba6694eb --- /dev/null +++ b/src/libuemf/upmf_print.h @@ -0,0 +1,180 @@ +/** + @file upmf_print.h + + @brief Prototypes for functions for printing records from EMF files. +*/ + +/* +File: upmf_print.h +Version: 0.0.2 +Date: 17-OCT-2013 +Author: David Mathog, Biology Division, Caltech +email: mathog@caltech.edu +Copyright: 2013 David Mathog and California Institute of Technology (Caltech) +*/ + +#ifndef _UPMF_PRINT_ +#define _UPMF_PRINT_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "upmf.h" /* includes uemf.h */ + +/* prototypes for simple types and enums used in PMR records */ +int U_PMF_CMN_HDR_print(U_PMF_CMN_HDR Header, int precnum, int off); +int U_PMF_UINT8_ARRAY_print(const char *Start, const uint8_t *Array, int Elements, char *End); +int U_PMF_BRUSHTYPEENUMERATION_print(int otype); +int U_PMF_HATCHSTYLEENUMERATION_print(int hstype); +int U_PMF_OBJECTTYPEENUMERATION_print(int otype); +int U_PMF_PATHPOINTTYPE_ENUM_print(int Type); +int U_PMF_PX_FMT_ENUM_print(int pfe); +int U_PMF_NODETYPE_print(int Type); + +/* prototypes for objects used in PMR records */ +int U_PMF_BRUSH_print(const char *contents); +int U_PMF_CUSTOMLINECAP_print(const char *contents, const char *Which); +int U_PMF_FONT_print(const char *contents); +int U_PMF_IMAGE_print(const char *contents); +int U_PMF_IMAGEATTRIBUTES_print(const char *contents); +int U_PMF_PATH_print(const char *contents); +int U_PMF_PEN_print(const char *contents); +int U_PMF_REGION_print(const char *contents); +int U_PMF_STRINGFORMAT_print(const char *contents); +int U_PMF_ARGB_print(const char *contents); +int U_PMF_BITMAP_print(const char *contents); +int U_PMF_BITMAPDATA_print(const char *contents); +int U_PMF_BLENDCOLORS_print(const char *contents); +int U_PMF_BLENDFACTORS_print(const char *contents, const char *type); +int U_PMF_BOUNDARYPATHDATA_print(const char *contents); +int U_PMF_BOUNDARYPOINTDATA_print(const char *contents); +int U_PMF_CHARACTERRANGE_print(const char *contents); +int U_PMF_COMPOUNDLINEDATA_print(const char *contents); +int U_PMF_COMPRESSEDIMAGE_print(const char *contents); +int U_PMF_CUSTOMENDCAPDATA_print(const char *contents); +int U_PMF_CUSTOMLINECAPARROWDATA_print(const char *contents); +int U_PMF_CUSTOMLINECAPDATA_print(const char *contents); +int U_PMF_CUSTOMLINECAPOPTIONALDATA_print(const char *contents, uint32_t Flags); +int U_PMF_CUSTOMSTARTCAPDATA_print(const char *contents); +int U_PMF_DASHEDLINEDATA_print(const char *contents); +int U_PMF_FILLPATHOBJ_print(const char *contents); +int U_PMF_FOCUSSCALEDATA_print(const char *contents); +int U_PMF_GRAPHICSVERSION_print(const char *contents); +int U_PMF_HATCHBRUSHDATA_print(const char *contents); +int U_PMF_LANGUAGEIDENTIFIER_print(U_PMF_LANGUAGEIDENTIFIER LId); +int U_PMF_LINEARGRADIENTBRUSHDATA_print(const char *contents); +int U_PMF_LINEARGRADIENTBRUSHOPTIONALDATA_print(const char *contents, int BDFlag); +int U_PMF_LINEPATH_print(const char *contents); +int U_PMF_METAFILE_print(const char *contents); +int U_PMF_PALETTE_print(const char *contents); +int U_PMF_PATHGRADIENTBRUSHDATA_print(const char *contents); +int U_PMF_PATHGRADIENTBRUSHOPTIONALDATA_print(const char *contents, int BDFlag); +int U_PMF_PATHPOINTTYPE_print(const char *contents); +int U_PMF_PATHPOINTTYPERLE_print(const char *contents); +int U_PMF_PENDATA_print(const char *contents); +int U_PMF_PENOPTIONALDATA_print(const char *contents, int Flags); +int U_PMF_POINT_print(const char **contents); +int U_PMF_POINTF_print(const char **contents); +int U_PMF_POINTR_print(const char **contents, U_FLOAT *Xpos, U_FLOAT *Ypos); +int U_PMF_POINT_S_print(U_PMF_POINT *Point); +int U_PMF_POINTF_S_print(U_PMF_POINTF *Point); +int U_PMF_RECT_print(const char **contents); +int U_PMF_RECTF_print(const char **contents); +int U_PMF_RECT_S_print(U_PMF_RECT *Rect); +int U_PMF_RECTF_S_print(U_PMF_RECTF *Rect); +int U_PMF_REGIONNODE_print(const char *contents, int Level); +int U_PMF_REGIONNODECHILDNODES_print(const char *contents, int Level); +int U_PMF_REGIONNODEPATH_print(const char *contents); +int U_PMF_SOLIDBRUSHDATA_print(const char *contents); +int U_PMF_STRINGFORMATDATA_print(const char *contents, uint32_t TabStopCount, uint32_t RangeCount); +int U_PMF_TEXTUREBRUSHDATA_print(const char *contents); +int U_PMF_TEXTUREBRUSHOPTIONALDATA_print(const char *contents, int HasImage); +int U_PMF_TRANSFORMMATRIX_print(const char *contents); +int U_PMF_TRANSFORMMATRIX2_print(U_PMF_TRANSFORMMATRIX *Matrix); +int U_PMF_ROTMATRIX2_print(U_PMF_ROTMATRIX *Matrix); +int U_PMF_IE_BLUR_print(const char *contents); +int U_PMF_IE_BRIGHTNESSCONTRAST_print(const char *contents); +int U_PMF_IE_COLORBALANCE_print(const char *contents); +int U_PMF_IE_COLORCURVE_print(const char *contents); +int U_PMF_IE_COLORLOOKUPTABLE_print(const char *contents); +int U_PMF_IE_COLORMATRIX_print(const char *contents); +int U_PMF_IE_HUESATURATIONLIGHTNESS_print(const char *contents); +int U_PMF_IE_LEVELS_print(const char *contents); +int U_PMF_IE_REDEYECORRECTION_print(const char *contents); +int U_PMF_IE_SHARPEN_print(const char *contents); +int U_PMF_IE_TINT_print(const char *contents); + +/* prototypes for PMR records */ +int U_PMR_OFFSETCLIP_print(const char *contents); +int U_PMR_RESETCLIP_print(const char *contents); +int U_PMR_SETCLIPPATH_print(const char *contents); +int U_PMR_SETCLIPRECT_print(const char *contents); +int U_PMR_SETCLIPREGION_print(const char *contents); +int U_PMR_COMMENT_print(const char *contents); +int U_PMR_ENDOFFILE_print(const char *contents); +int U_PMR_GETDC_print(const char *contents); +int U_PMR_HEADER_print(const char *contents); +int U_PMR_CLEAR_print(const char *contents); +int U_PMR_DRAWARC_print(const char *contents); +int U_PMR_DRAWBEZIERS_print(const char *contents); +int U_PMR_DRAWCLOSEDCURVE_print(const char *contents); +int U_PMR_DRAWCURVE_print(const char *contents); +int U_PMR_DRAWDRIVERSTRING_print(const char *contents); +int U_PMR_DRAWELLIPSE_print(const char *contents); +int U_PMR_DRAWIMAGE_print(const char *contents); +int U_PMR_DRAWIMAGEPOINTS_print(const char *contents); +int U_PMR_DRAWLINES_print(const char *contents); +int U_PMR_DRAWPATH_print(const char *contents); +int U_PMR_DRAWPIE_print(const char *contents); +int U_PMR_DRAWRECTS_print(const char *contents, const char *blimit); +int U_PMR_DRAWSTRING_print(const char *contents); +int U_PMR_FILLCLOSEDCURVE_print(const char *contents); +int U_PMR_FILLELLIPSE_print(const char *contents); +int U_PMR_FILLPATH_print(const char *contents); +int U_PMR_FILLPIE_print(const char *contents); +int U_PMR_FILLPOLYGON_print(const char *contents); +int U_PMR_FILLRECTS_print(const char *contents, const char *blimit); +int U_PMR_FILLREGION_print(const char *contents); +int U_PMR_OBJECT_print(const char *contents, const char *blimit, U_OBJ_ACCUM *ObjCont, int term); +int U_PMR_SERIALIZABLEOBJECT_print(const char *contents); +int U_PMR_SETANTIALIASMODE_print(const char *contents); +int U_PMR_SETCOMPOSITINGMODE_print(const char *contents); +int U_PMR_SETCOMPOSITINGQUALITY_print(const char *contents); +int U_PMR_SETINTERPOLATIONMODE_print(const char *contents); +int U_PMR_SETPIXELOFFSETMODE_print(const char *contents); +int U_PMR_SETRENDERINGORIGIN_print(const char *contents); +int U_PMR_SETTEXTCONTRAST_print(const char *contents); +int U_PMR_SETTEXTRENDERINGHINT_print(const char *contents); +int U_PMR_BEGINCONTAINER_print(const char *contents); +int U_PMR_BEGINCONTAINERNOPARAMS_print(const char *contents); +int U_PMR_ENDCONTAINER_print(const char *contents); +int U_PMR_RESTORE_print(const char *contents); +int U_PMR_SAVE_print(const char *contents); +int U_PMR_SETTSCLIP_print(const char *contents); +int U_PMR_SETTSGRAPHICS_print(const char *contents); +int U_PMR_MULTIPLYWORLDTRANSFORM_print(const char *contents); +int U_PMR_RESETWORLDTRANSFORM_print(const char *contents); +int U_PMR_ROTATEWORLDTRANSFORM_print(const char *contents); +int U_PMR_SCALEWORLDTRANSFORM_print(const char *contents); +int U_PMR_SETPAGETRANSFORM_print(const char *contents); +int U_PMR_SETWORLDTRANSFORM_print(const char *contents); +int U_PMR_TRANSLATEWORLDTRANSFORM_print(const char *contents); +int U_PMR_STROKEFILLPATH_print(const char *contents); /* not documented */ +int U_PMR_MULTIFORMATSTART_print(const char *contents); /* last of reserved but not used */ +int U_PMR_MULTIFORMATSECTION_print(const char *contents); /* last of reserved but not used */ +int U_PMR_MULTIFORMATEND_print(const char *contents); /* last of reserved but not used */ + +int U_pmf_onerec_print(const char *contents, const char *blimit, int recnum, int off); + + + + + + + +#ifdef __cplusplus +} +#endif + +#endif /* _UPMF_PRINT_ */ diff --git a/src/libuemf/uwmf.c b/src/libuemf/uwmf.c index 9d916ecee..a6ac963cb 100644 --- a/src/libuemf/uwmf.c +++ b/src/libuemf/uwmf.c @@ -1,5 +1,7 @@ /** - @file uwmf.c Functions for manipulating WMF files and structures. + @file uwmf.c + + @brief Functions for manipulating WMF files and structures. [U_WMR*]_set all take data and return a pointer to memory holding the constructed record. If something goes wrong a NULL pointer is returned. @@ -17,8 +19,8 @@ /* File: uwmf.c -Version: 0.0.11 -Date: 19-MAR-2013 +Version: 0.0.12 +Date: 25-NOV-2013 Author: David Mathog, Biology Division, Caltech email: mathog@caltech.edu Copyright: 2013 David Mathog and California Institute of Technology (Caltech) @@ -665,17 +667,19 @@ char *U_wmr_escnames(int idx){ return(name); } +//! \cond /* one prototype from uwmf_endian. Put it here because end user should never need to see it, so not in uemf.h or uwmf_endian.h */ void U_swap2(void *ul, unsigned int count); +//! \endcond /** \brief Derive from bounding box and start and end arc, for WMF arc, chord, or pie records, the center, start, and end points, and the bounding rectangle. \return 0 on success, other values on errors. - \param rclBox Bounding box of Arc - \param ArcStart Coordinates for Start of Arc - \param ArcEnd Coordinates for End of Arc + \param rclBox16 Bounding box of Arc + \param ArcStart16 Coordinates for Start of Arc + \param ArcEnd16 Coordinates for End of Arc \param f1 1 if rotation angle >= 180, else 0 \param f2 Rotation direction, 1 if counter clockwise, else 0 \param center Center coordinates @@ -689,10 +693,10 @@ int wmr_arc_points( U_POINT16 ArcEnd16, int *f1, int f2, - PU_PAIRF center, - PU_PAIRF start, - PU_PAIRF end, - PU_PAIRF size + U_PAIRF *center, + U_PAIRF *start, + U_PAIRF *end, + U_PAIRF *size ){ U_RECTL rclBox; U_POINTL ArcStart,ArcEnd; @@ -737,6 +741,7 @@ uint32_t U_wmr_size(const U_METARECORD *record){ return(2*Size16); } +//! \cond should never be called directly #define SET_CB_FROM_PXBMI(A,B,C,D,E,F) /* A=Px, B=Bmi, C=cbImage, D=cbImage4, E=cbBmi, F=cbPx */ \ if(A){\ if(!B)return(NULL); /* size is derived from U_BITMAPINFO, but NOT from its size field, go figure*/ \ @@ -745,7 +750,7 @@ uint32_t U_wmr_size(const U_METARECORD *record){ E = U_SIZE_BITMAPINFOHEADER + 4 * get_real_color_count((char *)&(B->bmiHeader)); /* bmiheader + colortable*/ \ }\ else { C = 0; D = 0; E=0; } - +//! \endcond /** \brief Create and return a U_FONT structure. @@ -765,7 +770,7 @@ uint32_t U_wmr_size(const U_METARECORD *record){ \param PitchAndFamily LF_PitchAndFamily Enumeration \param FaceName Name of font. ANSI Latin1, null terminated. */ -PU_FONT U_FONT_set( +U_FONT *U_FONT_set( int16_t Height, //!< Height in Logical units int16_t Width, //!< Average Width in Logical units int16_t Escapement, //!< Angle in 0.1 degrees betweem escapement vector and X axis @@ -781,10 +786,10 @@ PU_FONT U_FONT_set( uint8_t PitchAndFamily, //!< LF_PitchAndFamily Enumeration char *FaceName //!< Name of font. ANSI Latin1, null terminated. ){ - PU_FONT font; + U_FONT *font; int slen = 1 + strlen(FaceName); /* include terminator */ if(slen & 1)slen++; /* storage length even */ - font = (PU_FONT) calloc(1,slen + U_SIZE_FONT_CORE); /* use calloc to auto fill in terminating '\0'*/ + font = (U_FONT *) calloc(1,slen + U_SIZE_FONT_CORE); /* use calloc to auto fill in terminating '\0'*/ if(font){ font->Height = Height; font->Width = Width; @@ -825,12 +830,12 @@ U_PLTNTRY U_PLTNTRY_set(U_COLORREF Color){ \param NumEntries Number of U_LOGPLTNTRY objects \param PalEntries Pointer to array of PaletteEntry Objects */ -PU_PALETTE U_PLTENTRY_set( +U_PALETTE *U_PLTENTRY_set( uint16_t Start, //!< Either 0x0300 or an offset into the Palette table uint16_t NumEntries, //!< Number of U_LOGPLTNTRY objects - PU_PLTNTRY PalEntries //!< Pointer to array of PaletteEntry Objects + U_PLTNTRY *PalEntries //!< Pointer to array of PaletteEntry Objects ){ - PU_PALETTE Palette = NULL; + U_PALETTE *Palette = NULL; if(NumEntries){ Palette = malloc(4 + 4*NumEntries); if(Palette){ @@ -892,7 +897,7 @@ U_RECT16 U_RECT16_set( \param BitsPixel number of adjacent color bits on each plane (R bits + G bits + B bits ????) \param Bits bitmap pixel data. Bytes contained = (((Width * BitsPixel + 15) >> 4) << 1) * Height */ -PU_BITMAP16 U_BITMAP16_set( +U_BITMAP16 *U_BITMAP16_set( const int16_t Type, const int16_t Width, const int16_t Height, @@ -900,11 +905,11 @@ PU_BITMAP16 U_BITMAP16_set( const uint8_t BitsPixel, const char *Bits ){ - PU_BITMAP16 bm16; - uint32_t irecsize; - int cbBits,iHeight; - int usedbytes; - int16_t WidthBytes; // total bytes per scan line (used and padding). + U_BITMAP16 *bm16; + uint32_t irecsize; + int cbBits,iHeight; + int usedbytes; + int16_t WidthBytes; // total bytes per scan line (used and padding). usedbytes = (Width * BitsPixel + 7)/8; // width of line in fully and partially occupied bytes WidthBytes = (LineN * ((usedbytes + (LineN - 1) ) / LineN)); // Account for padding required by line alignment in the pixel array @@ -913,7 +918,7 @@ PU_BITMAP16 U_BITMAP16_set( cbBits = WidthBytes * iHeight; if(!Bits || cbBits<=0)return(NULL); irecsize = U_SIZE_BITMAP16 + cbBits; - bm16 = (PU_BITMAP16) malloc(irecsize); + bm16 = (U_BITMAP16 *) malloc(irecsize); if(bm16){ bm16->Type = Type; bm16->Width = Width; @@ -934,13 +939,13 @@ PU_BITMAP16 U_BITMAP16_set( \param bottom Y coordinate of the bottom scanline \param ScanLines Array of 16 bit left/right pairs, array has 2*count entries */ -PU_SCAN U_SCAN_set( +U_SCAN *U_SCAN_set( uint16_t count, //!< Number of entries in the ScanLines array uint16_t top, //!< Y coordinate of the top scanline uint16_t bottom, //!< Y coordinate of the bottom scanline uint16_t *ScanLines //!< Array of 16 bit left/right pairs, array has 2*count entries ){ - PU_SCAN scan=NULL; + U_SCAN *scan=NULL; int size = 6 + count*4; scan = malloc(size); if(scan){ @@ -961,19 +966,19 @@ PU_SCAN U_SCAN_set( \param sRect bounding rectangle \param aScans series of U_SCAN objects to append. This is also an array of uint16_t, but should be handled as a bunch of U_SCAN objects tightly packed into the buffer. */ -PU_REGION U_REGION_set( +U_REGION *U_REGION_set( int16_t Size, //!< aScans in bytes + regions size in bytes (size of this header plus all U_SCAN objects?) int16_t sCount, //!< number of scan objects in region (docs say scanlines, but then no way to add sizes) int16_t sMax, //!< largest number of points in any scan U_RECT16 sRect, //!< bounding rectangle uint16_t *aScans //!< series of U_SCAN objects to append. This is also an array of uint16_t, but should be handled as a bunch of U_SCAN objects tightly packed into the buffer. ){ - PU_REGION region=NULL; + U_REGION *region=NULL; char *psc; int scansize,i,off; psc = (char *)aScans; for(scansize=i=0; icount); + off = 6 + 4*(((U_SCAN *)psc)->count); scansize += off; psc += off; } @@ -1021,11 +1026,11 @@ U_WLOGBRUSH U_WLOGBRUSH_set( \param x x value \param y y value */ -PU_PAIRF U_PAIRF_set( +U_PAIRF *U_PAIRF_set( float x, //!< x value float y //!< y value ){ - PU_PAIRF pf=malloc(U_SIZE_PAIRF); + U_PAIRF *pf=malloc(U_SIZE_PAIRF); if(pf){ pf->x = x; pf->y = y; @@ -1496,7 +1501,7 @@ int wmf_finish( // Set the header fields which were unknown up until this point - if(((PU_WMRPLACEABLE) wt->buf)->Key == 0x9AC6CDD7){ off = U_SIZE_WMRPLACEABLE; } + if(((U_WMRPLACEABLE *) wt->buf)->Key == 0x9AC6CDD7){ off = U_SIZE_WMRPLACEABLE; } else { off = 0; } record = (wt->buf + off); @@ -1617,14 +1622,14 @@ int wmf_append( \param freerec If true, free rec after append */ int wmf_header_append( - PU_METARECORD rec, + U_METARECORD *rec, WMFTRACK *wt, int freerec ){ size_t deficit; unsigned int hsize; - hsize = (((PU_WMRPLACEABLE) rec)->Key == 0x9AC6CDD7 ? U_SIZE_WMRHEADER + U_SIZE_WMRPLACEABLE: U_SIZE_WMRHEADER); + hsize = (((U_WMRPLACEABLE *) rec)->Key == 0x9AC6CDD7 ? U_SIZE_WMRHEADER + U_SIZE_WMRPLACEABLE: U_SIZE_WMRHEADER); #ifdef U_VALGRIND printf("\nbefore \n"); @@ -1764,7 +1769,7 @@ These functions create standard structures used in the WMR records. *********************************************************************************************** */ // hide these from Doxygen -//! @cond +//! \cond /* ********************************************************************************************** These functions contain shared code used by various U_WMR*_print functions. These should NEVER be called by end user code and to further that end prototypes are NOT provided and they are hidden from Doxygen. @@ -1789,8 +1794,8 @@ void U_WMRCORE_SETRECHEAD(char *record, uint32_t irecsize, int iType){ uint32_t Size16; Size16 = irecsize/2; memcpy(record,&Size16,4); /*Size16_4 is at offset 0 in the record */ - ((PU_METARECORD) record)->iType = iType; - ((PU_METARECORD) record)->xb = U_WMR_XB_FROM_TYPE(iType); + ((U_METARECORD *) record)->iType = iType; + ((U_METARECORD *) record)->xb = U_WMR_XB_FROM_TYPE(iType); } /* records that have no arguments */ @@ -1832,7 +1837,7 @@ char *U_WMRCORE_1U16_CRF_2U16_set( return(record); } -/* records that have a single uint16_t argument like PU_WMRSETMAPMODE +/* records that have a single uint16_t argument like U_WMRSETMAPMODE May also be used with int16_t with appropriate casts */ char *U_WMRCORE_1U16_set( int iType, @@ -2016,7 +2021,7 @@ char *U_WMRCORE_2U16_N16_set( May also be used with int16_t with appropriate casts */ char *U_WMRCORE_PALETTE_set( int iType, - PU_PALETTE Palette + const U_PALETTE *Palette ){ char *record=NULL; uint32_t irecsize, off, nPE; @@ -2034,7 +2039,7 @@ char *U_WMRCORE_PALETTE_set( return(record); } -//! @endcond +//! \endcond /* ********************************************************************************************** These functions are simpler or more convenient ways to generate the specified types of WMR records. @@ -2141,7 +2146,7 @@ char *wcreatedibpatternbrush_srcdib_set( uint32_t *ihBrush, WMFHANDLES *wht, const uint32_t iUsage, - PU_BITMAPINFO Bmi, + const U_BITMAPINFO *Bmi, const uint32_t cbPx, const char *Px @@ -2164,7 +2169,7 @@ char *wcreatedibpatternbrush_srcbm16_set( uint32_t *ihBrush, WMFHANDLES *wht, const uint32_t iUsage, - PU_BITMAP16 Bm16 + const U_BITMAP16 *Bm16 ){ if(wmf_htable_insert(ihBrush, wht))return(NULL); *ihBrush -= 1; /* 1->N+1 --> 0->N */ @@ -2184,7 +2189,7 @@ char *wcreatedibpatternbrush_srcbm16_set( char *wcreatepatternbrush_set( uint32_t *ihBrush, WMFHANDLES *wht, - PU_BITMAP16 Bm16, + U_BITMAP16 *Bm16, char *Pattern ){ if(wmf_htable_insert(ihBrush, wht))return(NULL); @@ -2199,12 +2204,12 @@ char *wcreatepatternbrush_set( \return pointer to the U_WMRCREATEFONTINDIRECT record, or NULL on error. \param ihFont Font handle, will be created and returned \param wht Pointer to structure holding all WMF handles - \param uf Pointer to Font parameters as PU_FONT + \param uf Pointer to Font parameters as U_FONT * */ char *wcreatefontindirect_set( uint32_t *ihFont, WMFHANDLES *wht, - PU_FONT uf + U_FONT *uf ){ if(wmf_htable_insert(ihFont, wht))return(NULL); *ihFont -= 1; /* 1->N+1 --> 0->N */ @@ -2223,7 +2228,7 @@ char *wcreatefontindirect_set( char *wcreatepalette_set( uint32_t *ihPal, WMFHANDLES *wht, - PU_PALETTE up + U_PALETTE *up ){ if(wmf_htable_insert(ihPal, wht))return(NULL); *ihPal -= 1; /* 1->N+1 --> 0->N */ @@ -2242,7 +2247,7 @@ char *wcreatepalette_set( char *wsetpaletteentries_set( uint32_t *ihPal, WMFHANDLES *wht, - const PU_PALETTE Palettes + const U_PALETTE *Palettes ){ if(wmf_htable_insert(ihPal, wht))return(NULL); *ihPal -= 1; /* 1->N+1 --> 0->N */ @@ -2261,7 +2266,7 @@ char *wsetpaletteentries_set( char *wcreateregion_set( uint32_t *ihReg, WMFHANDLES *wht, - const PU_REGION Region + const U_REGION *Region ){ if(wmf_htable_insert(ihReg, wht))return(NULL); *ihReg -= 1; /* 1->N+1 --> 0->N */ @@ -2349,7 +2354,7 @@ They are listed in order by the corresponding U_WMR_* index number. \param dpi Logical units/inch. If 0 defaults to 1440. */ char *U_WMRHEADER_set( - PU_PAIRF size, + U_PAIRF *size, unsigned int dpi ){ char *record=NULL; @@ -2370,20 +2375,20 @@ char *U_WMRHEADER_set( } xm16 = xmax; ym16 = ymax; - ((PU_WMRPLACEABLE) record)->Key = 0x9AC6CDD7; - ((PU_WMRPLACEABLE) record)->HWmf = 0; /* Manual says number of 16 bit words in record, but all WMF examples had it as 0 */ - ((PU_WMRPLACEABLE) record)->Dst.left = 0; - ((PU_WMRPLACEABLE) record)->Dst.top = 0; - ((PU_WMRPLACEABLE) record)->Dst.right = xm16; - ((PU_WMRPLACEABLE) record)->Dst.bottom = ym16; - ((PU_WMRPLACEABLE) record)->Inch = dpi; - ((PU_WMRPLACEABLE) record)->Reserved = 0; - ((PU_WMRPLACEABLE) record)->Checksum = U_16_checksum((int16_t *)record,10); + ((U_WMRPLACEABLE *) record)->Key = 0x9AC6CDD7; + ((U_WMRPLACEABLE *) record)->HWmf = 0; /* Manual says number of 16 bit words in record, but all WMF examples had it as 0 */ + ((U_WMRPLACEABLE *) record)->Dst.left = 0; + ((U_WMRPLACEABLE *) record)->Dst.top = 0; + ((U_WMRPLACEABLE *) record)->Dst.right = xm16; + ((U_WMRPLACEABLE *) record)->Dst.bottom = ym16; + ((U_WMRPLACEABLE *) record)->Inch = dpi; + ((U_WMRPLACEABLE *) record)->Reserved = 0; + ((U_WMRPLACEABLE *) record)->Checksum = U_16_checksum((int16_t *)record,10); off = U_SIZE_WMRPLACEABLE; } - ((PU_WMRHEADER) (record + off))->iType = 1; - ((PU_WMRHEADER) (record + off))->version = U_METAVERSION300; - ((PU_WMRHEADER) (record + off))->Size16w = U_SIZE_WMRHEADER/2; + ((U_WMRHEADER *) (record + off))->iType = 1; + ((U_WMRHEADER *) (record + off))->version = U_METAVERSION300; + ((U_WMRHEADER *) (record + off))->Size16w = U_SIZE_WMRHEADER/2; } return(record); } @@ -2731,13 +2736,13 @@ char *U_WMRPATBLT_set( ){ char *record=NULL; uint32_t irecsize; - PU_WMRPATBLT pmr; + U_WMRPATBLT *pmr; irecsize = U_SIZE_WMRPATBLT; record = malloc(irecsize); if(record){ U_WMRCORE_SETRECHEAD(record,irecsize,U_WMR_PATBLT); - pmr = (PU_WMRPATBLT) record; + pmr = (U_WMRPATBLT *) record; memcpy(pmr->rop3w, &dwRop3, 4); pmr->Height = cwh.y; pmr->Width = cwh.x; @@ -2755,16 +2760,27 @@ char *U_WMRSAVEDC_set(void){ return U_WMRCORE_NOARGS_set(U_WMR_SAVEDC); } -char *U_WMRSETPIXEL_set(U_COLORREF Color, U_POINT16 coord){ +/** + \brief Allocate and construct a U_WMRSETPIXEL record + \return pointer to the U_WMRSETPIXEL record, or NULL on error. + \param Color U_COLORREF color of the pixel + \param Coord U_POINT16 coordinates of the pixel +*/ +char *U_WMRSETPIXEL_set(U_COLORREF Color, U_POINT16 Coord){ return U_WMRCORE_1U16_CRF_2U16_set( U_WMR_SETPIXEL, NULL, Color, - U_P16(coord.y), - U_P16(coord.x) + U_P16(Coord.y), + U_P16(Coord.x) ); } +/** + \brief Allocate and construct a U_WMROFFSETCLIPRGN record + \return pointer to the U_WMROFFSETCLIPRGN record, or NULL on error. + \param offset U_POINT16 x,y offset to apply to the clipping region. +*/ char *U_WMROFFSETCLIPRGN_set(U_POINT16 offset){ return U_WMRCORE_2U16_set(U_WMR_OFFSETCLIPRGN, U_U16(offset.y), U_U16(offset.x)); } @@ -2815,13 +2831,13 @@ char *U_WMRBITBLT_set( U_POINT16 cwh, U_POINT16 Src, uint32_t dwRop3, - const PU_BITMAP16 Bm16 + const U_BITMAP16 *Bm16 ){ char *record=NULL; uint32_t irecsize; int cbBm16,cbBm164,off; - PU_WMRBITBLT_PX pmr_px; - PU_WMRBITBLT_NOPX pmr_nopx; + U_WMRBITBLT_PX *pmr_px; + U_WMRBITBLT_NOPX *pmr_nopx; if(Bm16){ cbBm16 = U_SIZE_BITMAP16 + (((Bm16->Width * Bm16->BitsPixel + 15) >> 4) << 1) * Bm16->Height; @@ -2830,7 +2846,7 @@ char *U_WMRBITBLT_set( record = malloc(irecsize); if(record){ U_WMRCORE_SETRECHEAD(record,irecsize,U_WMR_BITBLT); - pmr_px = (PU_WMRBITBLT_PX) record; + pmr_px = (U_WMRBITBLT_PX *) record; memcpy(pmr_px->rop3w, &dwRop3, 4); pmr_px->ySrc = Src.y; pmr_px->xSrc = Src.x; @@ -2848,7 +2864,7 @@ char *U_WMRBITBLT_set( record = malloc(irecsize); if(record){ U_WMRCORE_SETRECHEAD(record,irecsize,U_WMR_BITBLT); - pmr_nopx = (PU_WMRBITBLT_NOPX) record; + pmr_nopx = (U_WMRBITBLT_NOPX *) record; memcpy(pmr_nopx->rop3w, &dwRop3, 4); pmr_nopx->ySrc = Src.y; pmr_nopx->xSrc = Src.x; @@ -2878,13 +2894,13 @@ char *U_WMRSTRETCHBLT_set( U_POINT16 Src, U_POINT16 cSrc, uint32_t dwRop3, - const PU_BITMAP16 Bm16 + const U_BITMAP16 *Bm16 ){ char *record=NULL; uint32_t irecsize; int cbBm16,cbBm164,off; - PU_WMRSTRETCHBLT_PX pmr_px; - PU_WMRSTRETCHBLT_NOPX pmr_nopx; + U_WMRSTRETCHBLT_PX *pmr_px; + U_WMRSTRETCHBLT_NOPX *pmr_nopx; if(Bm16){ cbBm16 = U_SIZE_BITMAP16 + (((Bm16->Width * Bm16->BitsPixel + 15) >> 4) << 1) * Bm16->Height; @@ -2893,7 +2909,7 @@ char *U_WMRSTRETCHBLT_set( record = malloc(irecsize); if(record){ U_WMRCORE_SETRECHEAD(record,irecsize,U_WMR_STRETCHBLT); - pmr_px = (PU_WMRSTRETCHBLT_PX) record; + pmr_px = (U_WMRSTRETCHBLT_PX *) record; memcpy(pmr_px->rop3w, &dwRop3, 4); pmr_px->hSrc = cSrc.y; pmr_px->wSrc = cSrc.x; @@ -2913,7 +2929,7 @@ char *U_WMRSTRETCHBLT_set( record = malloc(irecsize); if(record){ U_WMRCORE_SETRECHEAD(record,irecsize,U_WMR_STRETCHBLT); - pmr_nopx = (PU_WMRSTRETCHBLT_NOPX) record; + pmr_nopx = (U_WMRSTRETCHBLT_NOPX *) record; memcpy(pmr_nopx->rop3w, &dwRop3, 4); pmr_nopx->hSrc = cSrc.y; pmr_nopx->wSrc = cSrc.x; @@ -2935,7 +2951,7 @@ char *U_WMRSTRETCHBLT_set( \param Length Number of points in the Polygon \param Data Array of Length points */ -char *U_WMRPOLYGON_set(uint16_t Length, const PU_POINT16 Data){ +char *U_WMRPOLYGON_set(uint16_t Length, const U_POINT16 *Data){ return U_WMRCORE_2U16_N16_set(U_WMR_POLYGON, NULL, &Length, 2*Length, Data); } @@ -2945,7 +2961,7 @@ char *U_WMRPOLYGON_set(uint16_t Length, const PU_POINT16 Data){ \param Length Number of points in the Polyline \param Data Array of Length points */ -char *U_WMRPOLYLINE_set(uint16_t Length, const PU_POINT16 Data){ +char *U_WMRPOLYLINE_set(uint16_t Length, const U_POINT16 *Data){ return U_WMRCORE_2U16_N16_set(U_WMR_POLYLINE, NULL, &Length, 2*Length, Data); } @@ -3042,8 +3058,9 @@ char *U_WMRSETTEXTALIGN_set(uint16_t Mode){ return U_WMRCORE_2U16_set(U_WMR_SETTEXTALIGN, Mode, 0); } -/* in Wine, not in WMF PDF. */ - char *U_WMRDRAWTEXT_set(void){ /* in Wine, not in WMF PDF. */ +/** in GDI and Wine, not in WMF manual.. +*/ + char *U_WMRDRAWTEXT_set(void){ return U_WMRCORENONE_set("U_WMRDRAWTEXT"); } @@ -3155,7 +3172,7 @@ char *U_WMRREALIZEPALETTE_set(void){ \return pointer to the U_WMRSETPALENTRIES record, or NULL on error. \param Palette Redefines a set of RGB values for the current active Palette. */ -char *U_WMRANIMATEPALETTE_set(PU_PALETTE Palette){ +char *U_WMRANIMATEPALETTE_set(U_PALETTE *Palette){ return U_WMRCORE_PALETTE_set(U_WMR_ANIMATEPALETTE, Palette); } @@ -3164,7 +3181,7 @@ char *U_WMRANIMATEPALETTE_set(PU_PALETTE Palette){ \return pointer to the U_WMRSETPALENTRIES record, or NULL on error. \param Palette Defines a set of RGB values for the current active Palette. */ -char *U_WMRSETPALENTRIES_set(PU_PALETTE Palette){ +char *U_WMRSETPALENTRIES_set(const U_PALETTE *Palette){ return U_WMRCORE_PALETTE_set(U_WMR_SETPALENTRIES, Palette); } @@ -3178,7 +3195,7 @@ char *U_WMRSETPALENTRIES_set(PU_PALETTE Palette){ char *U_WMRPOLYPOLYGON_set( const uint16_t nPolys, const uint16_t *aPolyCounts, - const PU_POINT16 Points + const U_POINT16 *Points ){ char *record; uint32_t irecsize; @@ -3210,6 +3227,7 @@ char *U_WMRRESIZEPALETTE_set(uint16_t Palette){ return U_WMRCORE_1U16_set(U_WMR_RESIZEPALETTE, Palette); } +//! \cond char *U_WMR3A_set(void){ return U_WMRCORENONE_set("U_WMR3A"); } @@ -3233,6 +3251,7 @@ char *U_WMR3E_set(void){ char *U_WMR3F_set(void){ return U_WMRCORENONE_set("U_WMR3F"); } +//! \endcond // U_WMRDIBBITBLT_set /** @@ -3251,15 +3270,15 @@ char *U_WMRDIBBITBLT_set( U_POINT16 cwh, U_POINT16 Src, uint32_t dwRop3, - const PU_BITMAPINFO Bmi, + const U_BITMAPINFO *Bmi, uint32_t cbPx, const char *Px ){ char *record=NULL; uint32_t irecsize; int cbImage,cbImage4,cbBmi,off; - PU_WMRDIBBITBLT_PX pmr_px; - PU_WMRDIBBITBLT_NOPX pmr_nopx; + U_WMRDIBBITBLT_PX *pmr_px; + U_WMRDIBBITBLT_NOPX *pmr_nopx; if(Px && Bmi){ @@ -3268,7 +3287,7 @@ char *U_WMRDIBBITBLT_set( record = malloc(irecsize); if(record){ U_WMRCORE_SETRECHEAD(record,irecsize,U_WMR_DIBBITBLT); - pmr_px = (PU_WMRDIBBITBLT_PX) record; + pmr_px = (U_WMRDIBBITBLT_PX *) record; memcpy(pmr_px->rop3w, &dwRop3, 4); pmr_px->ySrc = Src.y; pmr_px->xSrc = Src.x; @@ -3287,7 +3306,7 @@ char *U_WMRDIBBITBLT_set( record = malloc(irecsize); if(record){ U_WMRCORE_SETRECHEAD(record,irecsize,U_WMR_DIBBITBLT); - pmr_nopx = (PU_WMRDIBBITBLT_NOPX) record; + pmr_nopx = (U_WMRDIBBITBLT_NOPX *) record; memcpy(pmr_nopx->rop3w, &dwRop3, 4); pmr_nopx->ySrc = Src.y; pmr_nopx->xSrc = Src.x; @@ -3319,22 +3338,22 @@ char *U_WMRDIBSTRETCHBLT_set( U_POINT16 Src, U_POINT16 cSrc, uint32_t dwRop3, - const PU_BITMAPINFO Bmi, + const U_BITMAPINFO *Bmi, uint32_t cbPx, const char *Px ){ char *record=NULL; uint32_t irecsize; int cbImage,cbImage4,cbBmi,off; - PU_WMRDIBSTRETCHBLT_PX pmr_px; - PU_WMRDIBSTRETCHBLT_NOPX pmr_nopx; + U_WMRDIBSTRETCHBLT_PX *pmr_px; + U_WMRDIBSTRETCHBLT_NOPX *pmr_nopx; if(Px && Bmi){ SET_CB_FROM_PXBMI(Px,Bmi,cbImage,cbImage4,cbBmi,cbPx); irecsize = U_SIZE_WMRDIBSTRETCHBLT_PX + cbBmi + cbImage4; record = malloc(irecsize); if(record){ U_WMRCORE_SETRECHEAD(record,irecsize,U_WMR_DIBSTRETCHBLT); - pmr_px = (PU_WMRDIBSTRETCHBLT_PX) record; + pmr_px = (U_WMRDIBSTRETCHBLT_PX *) record; memcpy(pmr_px->rop3w, &dwRop3, 4); pmr_px->hSrc = cSrc.y; pmr_px->wSrc = cSrc.x; @@ -3355,7 +3374,7 @@ char *U_WMRDIBSTRETCHBLT_set( record = malloc(irecsize); if(record){ U_WMRCORE_SETRECHEAD(record,irecsize,U_WMR_DIBSTRETCHBLT); - pmr_nopx = (PU_WMRDIBSTRETCHBLT_NOPX) record; + pmr_nopx = (U_WMRDIBSTRETCHBLT_NOPX *) record; memcpy(pmr_nopx->rop3w, &dwRop3, 4); pmr_nopx->hSrc = cSrc.y; pmr_nopx->wSrc = cSrc.x; @@ -3385,10 +3404,10 @@ char *U_WMRDIBSTRETCHBLT_set( char *U_WMRDIBCREATEPATTERNBRUSH_set( const uint16_t Style, const uint16_t iUsage, - PU_BITMAPINFO Bmi, + const U_BITMAPINFO *Bmi, const uint32_t cbPx, const char *Px, - PU_BITMAP16 Bm16 + const U_BITMAP16 *Bm16 ){ char *record=NULL; uint32_t irecsize; @@ -3445,14 +3464,14 @@ char *U_WMRSTRETCHDIB_set( U_POINT16 cSrc, uint16_t cUsage, uint32_t dwRop3, - const PU_BITMAPINFO Bmi, + const U_BITMAPINFO *Bmi, uint32_t cbPx, const char *Px ){ char *record; uint32_t irecsize; int cbImage,cbImage4,cbBmi,off; - PU_WMRSTRETCHDIB pmr; + U_WMRSTRETCHDIB *pmr; SET_CB_FROM_PXBMI(Px,Bmi,cbImage,cbImage4,cbBmi,cbPx); @@ -3460,7 +3479,7 @@ char *U_WMRSTRETCHDIB_set( record = malloc(irecsize); if(record){ U_WMRCORE_SETRECHEAD(record,irecsize,U_WMR_STRETCHDIB); - pmr = (PU_WMRSTRETCHDIB) record; + pmr = (U_WMRSTRETCHDIB *) record; memcpy(pmr->rop3w, &dwRop3, 4); pmr->cUsage = cUsage; pmr->hSrc = cSrc.y; @@ -3481,6 +3500,7 @@ char *U_WMRSTRETCHDIB_set( return(record); } +//! \cond char *U_WMR44_set(void){ return U_WMRCORENONE_set("U_WMR44"); } @@ -3496,6 +3516,7 @@ char *U_WMR46_set(void){ char *U_WMR47_set(void){ return U_WMRCORENONE_set("U_WMR47"); } +//! \endcond /** \brief Create and return a U_WMREXTFLOODFILL record @@ -3514,6 +3535,7 @@ char *U_WMREXTFLOODFILL_set(uint16_t Mode, U_COLORREF Color, U_POINT16 coord){ ); } +//! \cond char *U_WMR49_set(void){ return U_WMRCORENONE_set("U_WMR49"); } @@ -4181,6 +4203,7 @@ char *U_WMREE_set(void){ char *U_WMREF_set(void){ return U_WMRCORENONE_set("U_WMREF"); } +//! \endcond /** \brief Create and return a U_WMRDELETEOBJECT record @@ -4191,6 +4214,7 @@ char *U_WMRDELETEOBJECT_set(uint16_t object){ return U_WMRCORE_1U16_set(U_WMR_DELETEOBJECT, object); } +//! \cond char *U_WMRF1_set(void){ return U_WMRCORENONE_set("U_WMRF1"); } @@ -4214,19 +4238,22 @@ char *U_WMRF5_set(void){ char *U_WMRF6_set(void){ return U_WMRCORENONE_set("U_WMRF6"); } +//! \endcond /** \brief Create and return a U_WMRCREATEPALETTE record \return pointer to the U_WMRCREATEPALETTE record, or NULL on error \param Palette Create a Palette object. */ -char *U_WMRCREATEPALETTE_set(PU_PALETTE Palette){ +char *U_WMRCREATEPALETTE_set(U_PALETTE *Palette){ return U_WMRCORE_PALETTE_set(U_WMR_CREATEPALETTE, Palette); } +//! \cond char *U_WMRF8_set(void){ return U_WMRCORENONE_set("U_WMRF8"); } +//! \endcond /** \brief Allocate and construct a U_WMRCREATEPATTERNBRUSH record. @@ -4236,7 +4263,7 @@ char *U_WMRF8_set(void){ \param Pattern byte array pattern, described by Bm16, for brush */ char *U_WMRCREATEPATTERNBRUSH_set( - PU_BITMAP16 Bm16, + U_BITMAP16 *Bm16, char *Pattern ){ char *record; @@ -4271,7 +4298,7 @@ char *U_WMRCREATEPENINDIRECT_set(U_PEN pen){ \return pointer to the U_WMRCREATEFONTINDIRECT record, or NULL on error. \param font Parameters of the font object to create. */ -char *U_WMRCREATEFONTINDIRECT_set(PU_FONT font){ +char *U_WMRCREATEFONTINDIRECT_set(U_FONT *font){ char *record=NULL; uint32_t irecsize,off,flen; flen = 1 + strlen((char *)font->FaceName); /* include the null terminator in the count */ @@ -4295,12 +4322,14 @@ char *U_WMRCREATEBRUSHINDIRECT_set(U_WLOGBRUSH brush){ return U_WMRCORE_2U16_N16_set(U_WMR_CREATEBRUSHINDIRECT, NULL, NULL, U_SIZE_WLOGBRUSH/2, &brush); } - /* in Wine, not in WMF PDF */ - char *U_WMRCREATEBITMAPINDIRECT_set(void){ +/** in GDI and Wine, not in WMF manual. +*/ +char *U_WMRCREATEBITMAPINDIRECT_set(void){ return U_WMRCORENONE_set("U_WMRCREATEBITMAPINDIRECT"); } - /* in Wine, not in WMF PDF */ +/** in GDI and Wine, not in WMF manual. +*/ char *U_WMRCREATEBITMAP_set(void){ return U_WMRCORENONE_set("U_WMRCREATEBITMAP"); } @@ -4310,7 +4339,7 @@ char *U_WMRCREATEBRUSHINDIRECT_set(U_WLOGBRUSH brush){ \return pointer to the U_WMRCREATEREGION record, or NULL on error. \param region Parameters of the region object to create. */ -char *U_WMRCREATEREGION_set(PU_REGION region){ +char *U_WMRCREATEREGION_set(const U_REGION *region){ char *record=NULL; uint32_t irecsize,off; irecsize = U_SIZE_METARECORD + region->Size; @@ -4391,7 +4420,7 @@ These functions create standard structures used in the WMR records. *********************************************************************************************** */ // hide these from Doxygen -//! @cond +//! \cond /* ********************************************************************************************** These functions contain shared code used by various U_WMR*_get functions. These should NEVER be called by end user code and to further that end prototypes are NOT provided and they are hidden from Doxygen. @@ -4424,7 +4453,7 @@ int U_WMRCORE_1U16_CRF_2U16_get( const char *contents, int minsize, uint16_t *arg1, - PU_COLORREF Color, + U_COLORREF *Color, uint16_t *arg2, uint16_t *arg3 ){ @@ -4442,7 +4471,7 @@ int U_WMRCORE_1U16_CRF_2U16_get( return(size); } -/* records that have a single uint16_t argument like PU_WMRSETMAPMODE +/* records that have a single uint16_t argument like U_WMRSETMAPMODE May also be used with int16_t with appropriate casts */ int U_WMRCORE_1U16_get( const char *contents, @@ -4596,7 +4625,7 @@ int U_WMRCORE_2U16_N16_get( int U_WMRCORE_PALETTE_get( const char *contents, int minsize, - PU_PALETTE Palette, + U_PALETTE *Palette, const char **PalEntries ){ int size = U_WMRCORE_RECSAFE_get(contents, minsize); @@ -4608,14 +4637,14 @@ int U_WMRCORE_PALETTE_get( return(size); } -//! @endcond +//! \endcond /** \brief Return parameters from a bitmapcoreheader. All are returned as 32 bit integers, regardless of their internal representation. \param BmiCh char * pointer to a U_BITMAPCOREHEADER. Note, data may not be properly aligned. - \param Size_4 size of the coreheader in bytes + \param Size size of the coreheader in bytes \param Width; Width of pixel array \param Height; Height of pixel array \param BitCount Pixel Format (BitCount Enumeration) @@ -4731,7 +4760,7 @@ int wget_DIB_params( if(bic == U_BI_RGB){ *numCt = get_real_color_count(dib); if(*numCt){ - *ct = (PU_RGBQUAD) (dib + U_SIZE_BITMAPINFOHEADER); + *ct = (U_RGBQUAD *) (dib + U_SIZE_BITMAPINFOHEADER); *px += U_SIZE_COLORREF * (*numCt); } else { *ct = NULL; } @@ -4767,8 +4796,8 @@ They are listed in order by the corresponding U_WMR_* index number. int wmfheader_get( const char *contents, const char *blimit, - PU_WMRPLACEABLE Placeable, - PU_WMRHEADER Header + U_WMRPLACEABLE *Placeable, + U_WMRHEADER *Header ){ uint32_t Key; int size=0; @@ -4810,7 +4839,7 @@ int U_WMREOF_get( */ int U_WMRSETBKCOLOR_get( const char *contents, - PU_COLORREF Color + U_COLORREF *Color ){ int size = U_WMRCORE_RECSAFE_get(contents, (U_SIZE_WMRSETBKCOLOR)); if(!size)return(0); @@ -4915,7 +4944,7 @@ int U_WMRSETTEXTCHAREXTRA_get( */ int U_WMRSETTEXTCOLOR_get( const char *contents, - PU_COLORREF Color + U_COLORREF *Color ){ int size = U_WMRCORE_RECSAFE_get(contents, (U_SIZE_WMRSETTEXTCOLOR)); if(!size)return(0); @@ -4946,7 +4975,7 @@ int U_WMRSETTEXTJUSTIFICATION_get( */ int U_WMRSETWINDOWORG_get( const char *contents, - PU_POINT16 coord + U_POINT16 * coord ){ return(U_WMRCORE_2U16_get(contents, (U_SIZE_WMRSETWINDOWORG), U_P16(coord->y), U_P16(coord->x))); } @@ -4959,7 +4988,7 @@ int U_WMRSETWINDOWORG_get( */ int U_WMRSETWINDOWEXT_get( const char *contents, - PU_POINT16 extent + U_POINT16 * extent ){ return(U_WMRCORE_2U16_get(contents, (U_SIZE_WMRSETWINDOWEXT), U_P16(extent->y), U_P16(extent->x))); } @@ -4972,7 +5001,7 @@ int U_WMRSETWINDOWEXT_get( */ int U_WMRSETVIEWPORTORG_get( const char *contents, - PU_POINT16 coord + U_POINT16 * coord ){ return(U_WMRCORE_2U16_get(contents, (U_SIZE_WMRSETVIEWPORTORG), U_P16(coord->y), U_P16(coord->x))); @@ -4986,7 +5015,7 @@ int U_WMRSETVIEWPORTORG_get( */ int U_WMRSETVIEWPORTEXT_get( const char *contents, - PU_POINT16 extent + U_POINT16 * extent ){ return(U_WMRCORE_2U16_get(contents, (U_SIZE_WMRSETVIEWPORTEXT), U_P16(extent->y), U_P16(extent->x))); } @@ -4999,7 +5028,7 @@ int U_WMRSETVIEWPORTEXT_get( */ int U_WMROFFSETWINDOWORG_get( const char *contents, - PU_POINT16 offset + U_POINT16 * offset ){ return(U_WMRCORE_2U16_get(contents, (U_SIZE_WMROFFSETWINDOWORG), U_P16(offset->y), U_P16(offset->x))); } @@ -5013,8 +5042,8 @@ int U_WMROFFSETWINDOWORG_get( */ int U_WMRSCALEWINDOWEXT_get( const char *contents, - PU_POINT16 Denom, - PU_POINT16 Num + U_POINT16 * Denom, + U_POINT16 * Num ){ return(U_WMRCORE_4U16_get(contents, (U_SIZE_WMRSCALEWINDOWEXT), U_P16(Denom->y), U_P16(Denom->x), U_P16(Num->y), U_P16(Num->x))); } @@ -5027,7 +5056,7 @@ int U_WMRSCALEWINDOWEXT_get( */ int U_WMROFFSETVIEWPORTORG_get( const char *contents, - PU_POINT16 offset + U_POINT16 * offset ){ return(U_WMRCORE_2U16_get(contents, (U_SIZE_WMROFFSETVIEWPORTORG), U_P16(offset->y), U_P16(offset->x))); } @@ -5041,8 +5070,8 @@ int U_WMROFFSETVIEWPORTORG_get( */ int U_WMRSCALEVIEWPORTEXT_get( const char *contents, - PU_POINT16 Denom, - PU_POINT16 Num + U_POINT16 * Denom, + U_POINT16 * Num ){ return(U_WMRCORE_4U16_get(contents, (U_SIZE_WMRSCALEVIEWPORTEXT), U_P16(Denom->y), U_P16(Denom->x), U_P16(Num->y), U_P16(Num->x))); } @@ -5055,7 +5084,7 @@ int U_WMRSCALEVIEWPORTEXT_get( */ int U_WMRLINETO_get( const char *contents, - PU_POINT16 coord + U_POINT16 * coord ){ return(U_WMRCORE_2U16_get(contents, (U_SIZE_WMRLINETO), U_P16(coord->y), U_P16(coord->x))); } @@ -5068,7 +5097,7 @@ int U_WMRLINETO_get( */ int U_WMRMOVETO_get( const char *contents, - PU_POINT16 coord + U_POINT16 * coord ){ return(U_WMRCORE_2U16_get(contents, (U_SIZE_WMRMOVETO), U_P16(coord->y), U_P16(coord->x))); } @@ -5081,7 +5110,7 @@ int U_WMRMOVETO_get( */ int U_WMREXCLUDECLIPRECT_get( const char *contents, - PU_RECT16 rect + U_RECT16 *rect ){ return(U_WMRCORE_4U16_get(contents, (U_SIZE_WMREXCLUDECLIPRECT), U_P16(rect->bottom), U_P16(rect->right), U_P16(rect->top), U_P16(rect->left))); } @@ -5094,7 +5123,7 @@ int U_WMREXCLUDECLIPRECT_get( */ int U_WMRINTERSECTCLIPRECT_get( const char *contents, - PU_RECT16 rect + U_RECT16 *rect ){ return(U_WMRCORE_4U16_get(contents, (U_SIZE_WMRINTERSECTCLIPRECT), U_P16(rect->bottom), U_P16(rect->right), U_P16(rect->top), U_P16(rect->left))); } @@ -5109,9 +5138,9 @@ int U_WMRINTERSECTCLIPRECT_get( */ int U_WMRARC_get( const char *contents, - PU_POINT16 StartArc, - PU_POINT16 EndArc, - PU_RECT16 rect + U_POINT16 *StartArc, + U_POINT16 *EndArc, + U_RECT16 *rect ){ return U_WMRCORE_8U16_get( contents, @@ -5135,7 +5164,7 @@ int U_WMRARC_get( */ int U_WMRELLIPSE_get( const char *contents, - PU_RECT16 rect + U_RECT16 *rect ){ return U_WMRCORE_4U16_get( contents, @@ -5158,8 +5187,8 @@ int U_WMRELLIPSE_get( int U_WMRFLOODFILL_get( const char *contents, uint16_t *Mode, - PU_COLORREF Color, - PU_POINT16 coord + U_COLORREF *Color, + U_POINT16 *coord ){ return U_WMRCORE_1U16_CRF_2U16_get( contents, @@ -5181,9 +5210,9 @@ int U_WMRFLOODFILL_get( */ int U_WMRPIE_get( const char *contents, - PU_POINT16 Radial1, - PU_POINT16 Radial2, - PU_RECT16 rect + U_POINT16 *Radial1, + U_POINT16 *Radial2, + U_RECT16 *rect ){ return U_WMRCORE_8U16_get( contents, @@ -5207,7 +5236,7 @@ int U_WMRPIE_get( */ int U_WMRRECTANGLE_get( const char *contents, - PU_RECT16 rect + U_RECT16 *rect ){ return U_WMRCORE_4U16_get( contents, @@ -5231,7 +5260,7 @@ int U_WMRROUNDRECT_get( const char *contents, int16_t *Width, int16_t *Height, - PU_RECT16 rect + U_RECT16 *rect ){ return U_WMRCORE_6U16_get( contents, @@ -5255,8 +5284,8 @@ int U_WMRROUNDRECT_get( */ int U_WMRPATBLT_get( const char *contents, - PU_POINT16 Dst, - PU_POINT16 cwh, + U_POINT16 * Dst, + U_POINT16 * cwh, uint32_t *dwRop3 ){ int size = U_WMRCORE_RECSAFE_get(contents, (U_SIZE_WMRPATBLT)); @@ -5280,23 +5309,36 @@ int U_WMRSAVEDC_get( return(U_WMRCORE_RECSAFE_get(contents, (U_SIZE_WMRSAVEDC))); } +/** + \brief Get data from a U_WMRSETPIXEL record + \return length of the U_WMRSETPIXEL record in bytes, or 0 on error + \param contents record to extract data from + \param Color pointer to a U_COLORREF variable where the color will be stored. + \param Coord pointer to a U_POINT16 variable where the coordinates will be stored. +*/ int U_WMRSETPIXEL_get( const char *contents, - PU_COLORREF Color, - PU_POINT16 coord){ + U_COLORREF *Color, + U_POINT16 *Coord){ return U_WMRCORE_1U16_CRF_2U16_get( contents, (U_SIZE_WMRSETPIXEL), NULL, Color, - U_P16(coord->y), - U_P16(coord->x) + U_P16(Coord->y), + U_P16(Coord->x) ); } +/** + \brief Get data from a U_WMROFFSETCLIPRGN record + \return length of the U_WMROFFSETCLIPRGN record in bytes, or 0 on error + \param contents record to extract data from + \param offset pointer to a U_POINT16 variable where the x,y offsets will be stored. +*/ int U_WMROFFSETCLIPRGN_get( const char *contents, - PU_POINT16 offset + U_POINT16 *offset ){ return U_WMRCORE_2U16_get(contents, (U_SIZE_WMROFFSETCLIPRGN), U_P16(offset->y), U_P16(offset->x)); } @@ -5311,7 +5353,7 @@ int U_WMROFFSETCLIPRGN_get( */ int U_WMRTEXTOUT_get( const char *contents, - PU_POINT16 Dst, + U_POINT16 * Dst, int16_t *Length, const char **string ){ @@ -5344,11 +5386,11 @@ int U_WMRTEXTOUT_get( */ int U_WMRBITBLT_get( const char *contents, - PU_POINT16 Dst, - PU_POINT16 cwh, - PU_POINT16 Src, + U_POINT16 * Dst, + U_POINT16 * cwh, + U_POINT16 * Src, uint32_t *dwRop3, - PU_BITMAP16 Bm16, + U_BITMAP16 *Bm16, const char **px ){ uint8_t xb; @@ -5394,12 +5436,12 @@ int U_WMRBITBLT_get( */ int U_WMRSTRETCHBLT_get( const char *contents, - PU_POINT16 Dst, - PU_POINT16 cDst, - PU_POINT16 Src, - PU_POINT16 cSrc, + U_POINT16 * Dst, + U_POINT16 * cDst, + U_POINT16 * Src, + U_POINT16 * cSrc, uint32_t *dwRop3, - PU_BITMAP16 Bm16, + U_BITMAP16 *Bm16, const char **px ){ uint8_t xb; @@ -5601,7 +5643,8 @@ int U_WMRSETTEXTALIGN_get( return U_WMRCORE_1U16_get(contents, (U_SIZE_WMRSETTEXTALIGN), Mode); } -/* in Wine, not in WMF PDF. */ +/** in GDI and Wine, not in WMF manual. +*/ int U_WMRDRAWTEXT_get(void){ /* in Wine, not in WMF PDF. */ return U_WMRCORENONE_get("U_WMRDRAWTEXT"); } @@ -5616,9 +5659,9 @@ int U_WMRDRAWTEXT_get(void){ /* in Wine, not in WMF PDF. */ */ int U_WMRCHORD_get( const char *contents, - PU_POINT16 Radial1, - PU_POINT16 Radial2, - PU_RECT16 rect + U_POINT16 *Radial1, + U_POINT16 *Radial2, + U_RECT16 *rect ){ return U_WMRCORE_8U16_get( contents, @@ -5663,12 +5706,12 @@ int U_WMRSETMAPPERFLAGS_get( */ int U_WMREXTTEXTOUT_get( const char *contents, - PU_POINT16 Dst, + U_POINT16 * Dst, int16_t *Length, uint16_t *Opts, const char **string, const int16_t **dx, - PU_RECT16 rect + U_RECT16 *rect ){ int size = U_WMRCORE_RECSAFE_get(contents, (U_SIZE_WMREXTTEXTOUT)); int off = U_SIZE_METARECORD; @@ -5701,9 +5744,9 @@ int U_WMREXTTEXTOUT_get( */ int U_WMRSETDIBTODEV_get( const char *contents, - PU_POINT16 Dst, - PU_POINT16 cwh, - PU_POINT16 Src, + U_POINT16 * Dst, + U_POINT16 * cwh, + U_POINT16 * Src, uint16_t *cUsage, uint16_t *ScanCount, uint16_t *StartScan, @@ -5757,7 +5800,7 @@ int U_WMRREALIZEPALETTE_get( */ int U_WMRANIMATEPALETTE_get( const char *contents, - PU_PALETTE Palette, + U_PALETTE *Palette, const char **PalEntries ){ return U_WMRCORE_PALETTE_get(contents, (U_SIZE_WMRANIMATEPALETTE), Palette, PalEntries); @@ -5772,7 +5815,7 @@ int U_WMRANIMATEPALETTE_get( */ int U_WMRSETPALENTRIES_get( const char *contents, - PU_PALETTE Palette, + U_PALETTE *Palette, const char **PalEntries ){ return U_WMRCORE_PALETTE_get(contents, (U_SIZE_WMRSETPALENTRIES), Palette, PalEntries); @@ -5814,6 +5857,7 @@ int U_WMRRESIZEPALETTE_get( return U_WMRCORE_1U16_get(contents, (U_SIZE_WMRRESIZEPALETTE), Palette); } +//! \cond int U_WMR3A_get(void){ return U_WMRCORENONE_get("U_WMR3A"); } @@ -5837,6 +5881,7 @@ int U_WMR3E_get(void){ int U_WMR3F_get(void){ return U_WMRCORENONE_get("U_WMR3F"); } +//! \endcond // U_WMRDIBBITBLT_get /** @@ -5851,9 +5896,9 @@ int U_WMR3F_get(void){ */ int U_WMRDIBBITBLT_get( const char *contents, - PU_POINT16 Dst, - PU_POINT16 cwh, - PU_POINT16 Src, + U_POINT16 * Dst, + U_POINT16 * cwh, + U_POINT16 * Src, uint32_t *dwRop3, const char **dib ){ @@ -5897,10 +5942,10 @@ int U_WMRDIBBITBLT_get( */ int U_WMRDIBSTRETCHBLT_get( const char *contents, - PU_POINT16 Dst, - PU_POINT16 cDst, - PU_POINT16 Src, - PU_POINT16 cSrc, + U_POINT16 * Dst, + U_POINT16 * cDst, + U_POINT16 * Src, + U_POINT16 * cSrc, uint32_t *dwRop3, const char **dib ){ @@ -5993,10 +6038,10 @@ int U_WMRDIBCREATEPATTERNBRUSH_get( */ int U_WMRSTRETCHDIB_get( const char *contents, - PU_POINT16 Dst, - PU_POINT16 cDst, - PU_POINT16 Src, - PU_POINT16 cSrc, + U_POINT16 * Dst, + U_POINT16 * cDst, + U_POINT16 * Src, + U_POINT16 * cSrc, uint16_t *cUsage, uint32_t *dwRop3, const char **dib @@ -6018,6 +6063,7 @@ int U_WMRSTRETCHDIB_get( return(size); } +//! \cond int U_WMR44_get(void){ return U_WMRCORENONE_get("U_WMR44"); } @@ -6033,6 +6079,7 @@ int U_WMR46_get(void){ int U_WMR47_get(void){ return U_WMRCORENONE_get("U_WMR47"); } +//! \endcond /** \brief Retrieve values from a U_WMREXTFLOODFILL record @@ -6045,8 +6092,8 @@ int U_WMR47_get(void){ int U_WMREXTFLOODFILL_get( const char *contents, uint16_t *Mode, - PU_COLORREF Color, - PU_POINT16 coord + U_COLORREF *Color, + U_POINT16 * coord ){ return U_WMRCORE_1U16_CRF_2U16_get( contents, @@ -6058,6 +6105,7 @@ int U_WMREXTFLOODFILL_get( ); } +//! \cond int U_WMR49_get(void){ return U_WMRCORENONE_get("U_WMR49"); } @@ -6725,6 +6773,7 @@ int U_WMREE_get(void){ int U_WMREF_get(void){ return U_WMRCORENONE_get("U_WMREF"); } +//! \endcond /** \brief Get data from a U_WMRDELETEOBJECT record. @@ -6739,6 +6788,7 @@ int U_WMRDELETEOBJECT_get( return U_WMRCORE_1U16_get(contents, (U_SIZE_WMRDELETEOBJECT), Object); } +//! \cond int U_WMRF1_get(void){ return U_WMRCORENONE_get("U_WMRF1"); } @@ -6762,6 +6812,7 @@ int U_WMRF5_get(void){ int U_WMRF6_get(void){ return U_WMRCORENONE_get("U_WMRF6"); } +//! \endcond /** \brief Retrieve values from a U_WMRCREATEPALETTE record @@ -6772,15 +6823,17 @@ int U_WMRF6_get(void){ */ int U_WMRCREATEPALETTE_get( const char *contents, - PU_PALETTE Palette, + U_PALETTE *Palette, const char **PalEntries ){ return U_WMRCORE_PALETTE_get(contents, (U_SIZE_WMRCREATEPALETTE), Palette, PalEntries); } +//! \cond int U_WMRF8_get(void){ return U_WMRCORENONE_get("U_WMRF8"); } +//! \endcond /** \brief Get data from a U_WMRCREATEPATTERNBRUSH record. @@ -6793,7 +6846,7 @@ int U_WMRF8_get(void){ */ int U_WMRCREATEPATTERNBRUSH_get( const char *contents, - PU_BITMAP16 Bm16, + U_BITMAP16 *Bm16, int *pasize, const char **Pattern ){ @@ -6816,7 +6869,7 @@ int U_WMRCREATEPATTERNBRUSH_get( */ int U_WMRCREATEPENINDIRECT_get( const char *contents, - PU_PEN pen + U_PEN *pen ){ int size = U_WMRCORE_RECSAFE_get(contents, (U_SIZE_WMRCREATEPENINDIRECT)); if(!size)return(0); @@ -6850,12 +6903,14 @@ int U_WMRCREATEBRUSHINDIRECT_get( return U_WMRCORE_2U16_N16_get(contents, (U_SIZE_WMRCREATEBRUSHINDIRECT), NULL, NULL, brush); } - /* in Wine, not in WMF PDF */ +/** in GDI and Wine, not in WMF manual. +*/ int U_WMRCREATEBITMAPINDIRECT_get(void){ return U_WMRCORENONE_get("U_WMRCREATEBITMAPINDIRECT"); } - /* in Wine, not in WMF PDF */ +/** in GDI and Wine, not in WMF manual. +*/ int U_WMRCREATEBITMAP_get(void){ return U_WMRCORENONE_get("U_WMRCREATEBITMAP"); } diff --git a/src/libuemf/uwmf.h b/src/libuemf/uwmf.h index a97648eb1..65424cad1 100644 --- a/src/libuemf/uwmf.h +++ b/src/libuemf/uwmf.h @@ -1,10 +1,12 @@ /** - @file uwmf.h Structures and functions prototypes for WMF files. + @file uwmf.h + + @brief Structures, definitions, and function prototypes for WMF files. WMF file Record structure information has been derived from Mingw and Wine header files, and from Microsoft's WMF Information pdf, release date July 5,2012, link from here: - http://msdn2.microsoft.com/en-us/library/250370.aspx + http://msdn2.microsoft.com/en-us/library/cc250370.aspx If the direct link fails the document may be found by searching for: "[MS-WMF]: Windows Metafile Format" @@ -62,11 +64,11 @@ extern "C" { // *********************************************************************************** -// Value enumerations and other predefined constants, alphabetical order by group +// Value Enumerations and other predefined constants, alphabetical order by group -/** RecordType Enumeration WMF PDF 2.1.1.1 - \defgroup U_WMR_RecordTypes WMR Record types - @{ +/* RecordType Enumeration WMF manual 2.1.1.1 */ +/** WMF manual 2.1.1.1 + \brief WMR Record types */ enum U_WMR_TYPES{ U_WMR_EOF, //!< 0x0000 U_WMREOF record @@ -326,20 +328,19 @@ enum U_WMR_TYPES{ U_WMR_CREATEBITMAP, //!< 0x06FE U_WMRCREATEBITMAP record U_WMR_CREATEREGION, //!< 0x06FF U_WMRCREATEREGION record }; -/** @} */ #define U_WMR_MIN 0 //!< Minimum U_WMR_ value. #define U_WMR_MAX 255 //!< Maximum U_WMR_ value. #define U_WMR_MASK 0xFF //!< Mask for enumerator (lower) byte -#define U_WMR_INVALID 0xFFFFFFFF //!< Not any valid U_EMF_ valuee +#define U_WMR_INVALID 0xFFFFFFFF //!< Indicates "Not a valid U_WMR_* value" -/** BinaryRasterOperation Enumeration WMF PDF 2.1.1.2 +/** BinaryRasterOperation Enumeration WMF manual 2.1.1.2 - Same as U_EMRSETROP2 in uemf.h + Same as U_EMF_EMRSETROP2 in uemf.h */ -/** BitCount Enumeration WMF PDF 2.1.1.3 - \defgroup AltBitCount_Qualifiers Alternate names for the values under U_BITMAPINFOHEADER_biBitCount_Qualifiers in uemf.h +/** BitCount Enumeration WMF manual 2.1.1.3 + \defgroup U_WMF_AltBitCount_Qualifiers WMF Alternate names for the values under EMF Bitcount Enumeration in uemf.h @{ */ #define BI_BITCOUNT_0 U_BCBM_EXPLICIT //!< Derived from JPG or PNG compressed image or ? @@ -351,26 +352,27 @@ enum U_WMR_TYPES{ #define BI_BITCOUNT_6 U_BCBM_COLOR32 //!< 2^32 colors. bmiColors is not used. Pixels are U_RGBQUAD. /** @} */ -/** BrushStyle Enumeration WMF PDF 2.1.1.4 - Same as "LB_Style Enumeration" in uemf.h +/* BrushStyle Enumeration WMF manual 2.1.1.4 + Same as "EMF LB_Style Enumeration" in uemf.h */ -/** CharacterSet Enumeration WMF PDF 2.1.1.5 - Same as "LF_CharSet Enumeration" in uemf.h +/* CharacterSet Enumeration WMF manual 2.1.1.5 + Same as "EMF LF_CharSet Enumeration" in uemf.h */ -/** ColorUsage Enumeration WMF PDF 2.1.1.6 - Same as "DIBColors Enumeration" in uemf.h, with one addition - \defgroup Extra_iUsageSrc_Qualifiers Extra DIBColors Enumeration +/** ColorUsage Enumeration WMF manual 2.1.1.6 For cUsage fields in various DIB related records. + \defgroup U_WMF_Extra_iUsageSrc_Qualifiers WMF Extra DIBColors Enumeration + WMF is the same as "EMF DIBColors Enumeration" in uemf.h, except it also supports + this one extra value. @{ */ #define U_DIB_PAL_INDICES 2 //!< No color table, pixels are logical palette indices. /** @} */ -/** Compression Enumeration WMF PDF 2.1.1.7 - Same as "BI_Compression Enumeration" in uemf.h with these additions - \defgroup ExtraU_BITMAPINFOHEADER_biCompression_Qualifiers Extra BI_Compression Enumeration, none are implemented +/** Compression Enumeration WMF manual 2.1.1.7 + Same as "EMF BI_Compression Enumeration" in uemf.h with these additions + \defgroup U_WMF_EXTRA_BITMAPINFOHEADER_biCompression_Qualifiers WMF Extra BI_Compression Enumerations, none are implemented @{ */ #define U_BI_CMYK 0x000B //!< CMYK uncompressed @@ -378,49 +380,51 @@ enum U_WMR_TYPES{ #define U_BI_CMYKRLE4 = 0x000D //!< CMYK RLE4 compression /** @} */ -/** FamilyFont enumeration WMF PDF 2.1.1.8 +/* FamilyFont Enumeration WMF manual 2.1.1.8 Only used in a PitchAndFamily object, defined there */ -/** Floodfill enumeration WMF PDF 2.1.1.9 - Same as "FloodFill Enumeration" in uemf.h +/* FloodFill Enumeration WMF manual 2.1.1.9 + Same as "EMF FloodFill Enumeration" in uemf.h */ -/** FontQuality enumeration WMF PDF 2.1.1.10 - Same as "LF_Quality Enumeration" in uemf.h +/* FontQuality Enumeration WMF manual 2.1.1.10 + Same as "EMF LF_Quality Enumeration" in uemf.h */ -/** GamutMappingIntent enumeration WMF PDF 2.1.1.11 - Same as "LCS_Intent Enumeration" in uemf.h +/* GamutMappingIntent Enumeration WMF manual 2.1.1.11 + Same as "EMF LCS_Intent Enumeration" in uemf.h */ -/** HatchStyle enumeration WMF PDF 2.1.1.12 - Same as "HatchStyle Enumeration" in uemf.h +/* HatchStyle Enumeration WMF manual 2.1.1.12 + Same as "EMF HatchStyle Enumeration" in uemf.h */ -/** Layout enumeration WMF PDF 2.1.1.13 - Same as "Mirroring Enumeration" in uemf.h +/* Layout Enumeration WMF manual 2.1.1.13 + Same as "EMF Mirroring Enumeration" in uemf.h */ -/** LogicalColorSpace Enumeration WMF PDF 2.1.1.14 +/** LogicalColorSpace Enumeration WMF manual 2.1.1.14 Not used presently, applies in BitmapV4Header @{ */ -//!< #define U_LCS_CALIBRATED_RGB 0x00000000 calibrated RGB -#define U_LCS_sRGB 0x73524742 //!< ASCII for "sRGB" -#define U_LCS_WINDOWS_COLOR_SPACE 0x57696E20 //!< ASCII for "Win " +/* U_LCS_CALIBRATED_RGB is defined in uemf.h under LCS_CSType Enumeration, WMF manual also defines it, but do not replicate define. +#define U_LCS_CALIBRATED_RGB 0x00000000 //!< calibrated RGB +*/ +#define U_LCS_sRGB 0x73524742 //!< ASCII for "sRGB" +#define U_LCS_WINDOWS_COLOR_SPACE 0x57696E20 //!< ASCII for "Win " /** @} */ -/** LogicalColorSpaceV5 Enumeration WMF PDF 2.1.1.15 - Same as "Profile Enumeration" in uemf.h +/* LogicalColorSpaceV5 Enumeration WMF manual 2.1.1.15 + Same as "EMF Profile Enumeration" in uemf.h */ -/** MapMode Enumeration WMF PDF 2.1.1.16 - Same as "MapMode Enumeration" in uemf.h +/* MapMode Enumeration WMF manual 2.1.1.16 + Same as "EMF MapMode Enumeration" in uemf.h */ -/** MetaFilesEscape Enumeration WMF PDF 2.1.1.17 - \defgroup MFEscape_Qualifiers Metafile Escape record types +/** MetaFilesEscape Enumeration WMF manual 2.1.1.17 + \defgroup U_WMF_MFEscape_Qualifiers WMF Metafile Escape record types For U_WMRESCAPE eFunc field @{ */ @@ -486,14 +490,14 @@ enum U_WMR_TYPES{ #define U_MFE_SPCLPASSTHROUGH2 0x11D8 //!< SPCLPASSTHROUGH2 escape type /** @} */ -/** MetafileType Enumeration WMF PDF 2.1.1.18 +/** MetafileType Enumeration WMF manual 2.1.1.18 @{ */ #define U_MEMORYMETAFILE 0x0001 //!< memory metafile (never used by libUWMF) #define U_DISKMETAFILE 0x0002 //!< disk metafile (always used by libUWMF) /** @} */ -/** MetafileVersion Enumeration WMF PDF 2.1.1.19 +/** MetafileVersion Enumeration WMF manual 2.1.1.19 @{ */ @@ -501,15 +505,15 @@ enum U_WMR_TYPES{ #define U_METAVERSION300 0x0300 //!< DIBs allowed /** @} */ -/** MixMode Enumeration WMF PDF 2.1.1.20 - Same as "BackgroundMode Enumeration" in uemf.h +/* MixMode Enumeration WMF manual 2.1.1.20 + Same as "EMF BackgroundMode Enumeration" in uemf.h */ -/** OutPrecision Enumeration WMF PDF 2.1.1.21 - Same as "LF_OutPrecision Enumeration" in uemf.h +/* OutPrecision Enumeration WMF manual 2.1.1.21 + Same as "EMF LF_OutPrecision Enumeration" in uemf.h */ -/** PaletteEntryFlag Enumeration WMF PDF 2.1.1.22 +/** PaletteEntryFlag Enumeration WMF manual 2.1.1.22 @{ */ #define U_PC_RESERVED 0x01 //!< used for animation @@ -517,8 +521,8 @@ enum U_WMR_TYPES{ #define U_PC_NOCOLLAPSE 0x04 //!< store as new color in palette, do not match to existing color /** @} */ -/** PenStyle Enumeration WMF PDF 2.1.1.23 - Same as "PenStyle Enumeration" in uemf.h +/** PenStyle Enumeration WMF manual 2.1.1.23 + Same as "EMF PenStyle Enumeration" in uemf.h, EXCEPT no values >0xFFFF are used, in particular there is no U_PS_GEOMETRIC (ie, all are U_PS_COSMETIC). Apparently because there is no U_PS_GEOMETRIC, U_PS_JOIN* and U_PS_ENDCAP* are also ignored by XP SP3 Preview (which defaults to a rounded cap) and PowerPoint 2003 (which defaults to square cap). The behavior @@ -526,16 +530,16 @@ enum U_WMR_TYPES{ to be very hit and miss from application to application. */ -/** PitchFont Enumeration WMF PDF 2.1.1.24 +/* PitchFont Enumeration WMF manual 2.1.1.24 These are only used in PitchAndFamily object, defined there. */ -/** PolyFillMode Enumeration WMF PDF 2.1.1.25 - These are the first twp emtries in "PolygonFillMode Enumeration" in uemf.h +/* PolyFillMode Enumeration WMF manual 2.1.1.25 + These are the first two emtries in "EMF PolygonFillMode Enumeration" in uemf.h */ -/** PostScriptCap Enumeration WMF PDF 2.1.1.26 +/** PostScriptCap Enumeration WMF manual 2.1.1.26 These are used in Escape Cap @{ */ @@ -545,13 +549,13 @@ enum U_WMR_TYPES{ #define U_WPS_CAP_SQUARE 2 /** @} */ -/** PostScriptClipping Enumeration WMF PDF 2.1.1.27 - PostFeatureSetting Enumeration WMF PDF 2.1.1.28 +/* PostScriptClipping Enumeration WMF manual 2.1.1.27 + PostFeatureSetting Enumeration WMF manual 2.1.1.28 These are used by postscript drivers, not supported by libUWEMF. */ -/** PostScrioptJoin Enumeration WMF PDF 2.1.1.29 +/** PostScrioptJoin Enumeration WMF manual 2.1.1.29 These are used in Escape Cap @{ */ @@ -561,170 +565,182 @@ enum U_WMR_TYPES{ #define U_WPS_JOIN_BEVEL 2 /** @} */ -/** StretchMode Enumeration WMF PDF 2.1.1.30 - Same as "StretchMode Enumeration" in uemf.h +/* StretchMode Enumeration WMF manual 2.1.1.30 + Same as "EMF StretchMode Enumeration" in uemf.h */ -/** TernaryRasterOperation Enumeration WMF PDF 2.1.1.31 - Same as "Ternary Raster Operation Enumeration" in uemf.h +/* TernaryRasterOperation Enumeration WMF manual 2.1.1.31 + Same as "EMF Ternary Raster Operation Enumeration" in uemf.h Only partially supported in libUWMF.h */ -/** ClipPrecision Flags WMF PDF 2.1.2.1 - Same as "LF_ClipPrecision Enumeration" in uemf.h +/* ClipPrecision Flags WMF manual 2.1.2.1 + Same as "EMF LF_ClipPrecision Enumeration" in uemf.h */ -/** ExtTextOutOptions Flags WMF PDF 2.1.2.2 - These are a subset of "ExtTextOutOptions Enumeration" in uemf.h +/* ExtTextOutOptions Flags WMF manual 2.1.2.2 + These are a subset of "EMF ExtTextOutOptions Enumeration" in uemf.h + Not defined for WMF: U_ETO_NONE, U_ETO_GRAYED, U_ETO_NORECT, U_ETO_SMALL_CHARS,U_ETO_IGNORELANGUAGE,U_ETO_REVERSE_INDEX_MAP + Defined for WMF: U_ETO_OPAQUE, U_ETO_CLIPPED, U_ETO_GLYPH_INDEX, U_ETO_RTLREADING,_ETO_NUMERICSLOCAL,U_ETO_NUMERICSLATIN, U_ETO_PDY */ -/** TextAlignment Enumeration WMF PDF 2.1.2.3 - VertialTextAlignment Enumeration WMF PDF 2.1.2.4 - These are both in "TextAlignment Enumeration" in uemf.h +/* TextAlignment Enumeration WMF manual 2.1.2.3 + VertialTextAlignment Enumeration WMF manual 2.1.2.4 + These are both in "EMF TextAlignment Enumeration" in uemf.h */ // *************************************************************************** // Miscellaneous Values -/** TextAlignmentMode Flags WMF PDF 2.1.2.3 - VerticalTextAlignmentMode Flags WMF PDF 2.1.2.4 - Same as "TextAlignment Enumeration" in uemf.h +/* TextAlignmentMode Flags WMF manual 2.1.2.3 + VerticalTextAlignmentMode Flags WMF manual 2.1.2.4 + Same as "EMF TextAlignment Enumeration" in uemf.h */ -/** \defgroup MinimumRecord_sizes Size in bytes of core record of each type. - These are USUALLY not the same - as the corresponding struct, so in general it is unsafe to use sizeof() with this code. +/** \defgroup U_WMF_MinimumRecord_sizes WMF Size in bytes of core record types. + + The size of the object/record is USUALLY not the same + as the sizeof() of the corresponding struct, so in general it is unsafe to use sizeof() with this code. + Always use the U_SIZE_x instead!!!! - Note that some records may actually be much, much longer than their minimum as they include strings, + + Note that some records may actually be much, much longer than their minimum size as they include strings, bitmaps, and such. + + Documentation for each value is: + + = same as struct size + or + X = different from struct size + followed by + Number (sizeof(struct) == size of the struct in bytes.) + @{ */ -/* Record sizeof (+ same, X differs) */ -#define U_SIZE_PAIRF 8 /* + 8 this might be different on 64 bit platform */ -#define U_SIZE_COLORREF 4 /* + 4 */ -#define U_SIZE_BRUSH 8 /* + 8 */ -#define U_SIZE_FONT 19 /* + 20 */ -#define U_SIZE_FONT_CORE 18 /* Minus the FaceName part */ -#define U_SIZE_PLTNTRY 4 /* + 4 */ -#define U_SIZE_PALETTE 8 /* + 8 */ -#define U_SIZE_PEN 10 /* + 10 */ -#define U_SIZE_POINT16 4 /* + 4 */ -#define U_SIZE_RECT16 8 /* + 8 */ -#define U_SIZE_REGION 20 /* X 22 20 is minums the variable part */ -#define U_SIZE_BITMAP16 10 /* + 10 */ -#define U_SIZE_BITMAPCOREHEADER 12 /* + 12 */ -#define U_SIZE_BITMAPINFOHEADER 40 /* + 40 */ -#define U_SIZE_BITMAPV4HEADER 108 /* ? 108 not tested */ -#define U_SIZE_BITMAPV5HEADER 124 /* ? 124 not tested */ -#define U_SIZE_WLOGBRUSH 8 /* + 8 */ -#define U_SIZE_POLYPOLYGON 4 /* + 4 */ -#define U_SIZE_SCAN 8 /* + 8 */ -#define U_SIZE_METARECORD 6 /* X 8 */ -#define U_SIZE_WMRPLACEABLE 22 /* X 24 */ -#define U_SIZE_WMRHEADER 18 /* X 20 */ -#define U_SIZE_WMREOF 6 /* X 8 */ -#define U_SIZE_WMRSETRELABS 6 /* X 8 */ -#define U_SIZE_WMRSAVEDC 6 /* X 8 */ -#define U_SIZE_WMRRESTOREDC 8 /* * 8 */ -#define U_SIZE_WMRREALIZEPALETTE 6 /* X 8 */ -#define U_SIZE_WMRSETBKCOLOR 10 /* X 12 */ -#define U_SIZE_WMRSETTEXTCOLOR 10 /* X 12 */ -#define U_SIZE_WMRSETBKMODE 8 /* X 12 last 2 bytes are optional */ -#define U_SIZE_WMRSETROP2 8 /* X 12 last 2 bytes are optional */ -#define U_SIZE_WMRSETPOLYFILLMODE 8 /* X 12 last 2 bytes are optional */ -#define U_SIZE_WMRSETSTRETCHBLTMODE 8 /* X 12 last 2 bytes are optional */ -#define U_SIZE_WMRSETTEXTALIGN 8 /* X 12 last 2 bytes are optional */ -#define U_SIZE_WMRSETMAPMODE 8 /* + 8 */ -#define U_SIZE_WMRSETTEXTCHAREXTRA 8 /* + 8 */ -#define U_SIZE_WMRSETTEXTJUSTIFICATION 10 /* X 12 */ -#define U_SIZE_WMRSETWINDOWORG 10 /* X 12 */ -#define U_SIZE_WMRSETWINDOWEXT 10 /* X 12 */ -#define U_SIZE_WMRSETVIEWPORTORG 10 /* X 12 */ -#define U_SIZE_WMRSETVIEWPORTEXT 10 /* X 12 */ -#define U_SIZE_WMROFFSETWINDOWORG 10 /* X 12 */ -#define U_SIZE_WMROFFSETVIEWPORTORG 10 /* X 12 */ -#define U_SIZE_WMRLINETO 10 /* X 12 */ -#define U_SIZE_WMRMOVETO 10 /* X 12 */ -#define U_SIZE_WMROFFSETCLIPRGN 10 /* X 12 */ -#define U_SIZE_WMRSCALEWINDOWEXT 14 /* X 16 */ -#define U_SIZE_WMRSCALEVIEWPORTEXT 14 /* X 16 */ -#define U_SIZE_WMREXCLUDECLIPRECT 14 /* X 16 */ -#define U_SIZE_WMRINTERSECTCLIPRECT 14 /* X 16 */ -#define U_SIZE_WMRARC 22 /* X 24 */ -#define U_SIZE_WMRELLIPSE 14 /* X 16 */ -#define U_SIZE_WMRRECTANGLE 14 /* X 16 */ -#define U_SIZE_WMRFLOODFILL 16 /* + 16 */ -#define U_SIZE_WMREXTFLOODFILL 16 /* + 16 */ -#define U_SIZE_WMRSETPIXEL 14 /* X 16 */ -#define U_SIZE_WMRPIE 22 /* X 24 */ -#define U_SIZE_WMRCHORD 22 /* X 24 */ -#define U_SIZE_WMRROUNDRECT 18 /* X 20 */ -#define U_SIZE_WMRPATBLT 18 /* X 20 */ -#define U_SIZE_WMRTEXTOUT 8 /* X 12 (not including String,y,x) */ -#define U_SIZE_WMRBITBLT_NOPX 24 /* + 24 */ -#define U_SIZE_WMRBITBLT_PX 22 /* X 32 */ -#define U_SIZE_WMRSTRETCHBLT_NOPX 28 /* + 28 */ -#define U_SIZE_WMRSTRETCHBLT_PX 26 /* X 36 */ -#define U_SIZE_WMRPOLYGON 10 /* X 12 */ -#define U_SIZE_WMRPOLYLINE 10 /* X 12 */ -#define U_SIZE_WMRESCAPE 10 /* X 12 Data field could be completely absent */ -#define U_SIZE_WMRFILLREGION 10 /* X 12 */ -#define U_SIZE_WMRFRAMEREGION 14 /* X 16 */ -#define U_SIZE_WMRINVERTREGION 8 /* + 8 */ -#define U_SIZE_WMRPAINTREGION 8 /* + 8 */ -#define U_SIZE_WMRSELECTCLIPREGION 8 /* + 8 */ -#define U_SIZE_WMRSELECTOBJECT 8 /* + 8 */ -#define U_SIZE_WMRSELECTPALETTE 8 /* + 8 */ -#define U_SIZE_WMRRESIZEPALETTE 8 /* + 8 */ -#define U_SIZE_WMRDELETEOBJECT 8 /* + 8 */ -#define U_SIZE_WMRDRAWTEXT 6 /* X 8 */ -#define U_SIZE_WMRCREATEBITMAPINDIRECT 6 /* X 8 */ -#define U_SIZE_WMRCREATEBITMAP 6 /* X 8 */ -#define U_SIZE_WMRSETMAPPERFLAGS 10 /* X 12 */ -#define U_SIZE_WMREXTTEXTOUT 14 /* X 16 */ -#define U_SIZE_WMRSETDIBTODEV 22 /* X 28 */ -#define U_SIZE_WMRANIMATEPALETTE 14 /* X 16 */ -#define U_SIZE_WMRSETPALENTRIES 14 /* X 16 */ -#define U_SIZE_WMRCREATEPALETTE 14 /* X 16 */ -#define U_SIZE_WMRPOLYPOLYGON 10 /* X 12 */ -#define U_SIZE_WMRDIBBITBLT_NOPX 24 /* + 24 */ -#define U_SIZE_WMRDIBBITBLT_PX 22 /* X 24 */ -#define U_SIZE_WMRDIBSTRETCHBLT_NOPX 28 /* + 28 */ -#define U_SIZE_WMRDIBSTRETCHBLT_PX 26 /* X 28 */ -#define U_SIZE_WMRDIBCREATEPATTERNBRUSH 10 /* X 12 */ -#define U_SIZE_WMRSTRETCHDIB 28 /* X 32 */ -#define U_SIZE_WMRCREATEPATTERNBRUSH 6 /* X 8 */ -#define U_SIZE_WMRCREATEPENINDIRECT 16 /* + 16 */ -#define U_SIZE_WMRCREATEFONTINDIRECT 26 /* X 28 */ -#define U_SIZE_WMRCREATEBRUSHINDIRECT 14 /* X 16 */ -#define U_SIZE_WMRCREATEREGION 26 /* X 28 */ +#define U_SIZE_PAIRF 8 /**< + 8 this might be different on 64 bit platform */ +#define U_SIZE_COLORREF 4 /**< + 4 */ +#define U_SIZE_BRUSH 8 /**< + 8 */ +#define U_SIZE_FONT 19 /**< X 20 */ +#define U_SIZE_FONT_CORE 18 /**< X 20 Like U_FONT, but minus the FaceName part */ +#define U_SIZE_PLTNTRY 4 /**< + 4 */ +#define U_SIZE_PALETTE 8 /**< + 8 */ +#define U_SIZE_PEN 10 /**< + 10 */ +#define U_SIZE_POINT16 4 /**< + 4 */ +#define U_SIZE_RECT16 8 /**< + 8 */ +#define U_SIZE_REGION 20 /**< X 22 20 is minums the variable part */ +#define U_SIZE_BITMAP16 10 /**< + 10 */ +#define U_SIZE_BITMAPCOREHEADER 12 /**< + 12 */ +#define U_SIZE_BITMAPINFOHEADER 40 /**< + 40 */ +#define U_SIZE_BITMAPV4HEADER 108 /**< ? 108 not tested */ +#define U_SIZE_BITMAPV5HEADER 124 /**< ? 124 not tested */ +#define U_SIZE_WLOGBRUSH 8 /**< + 8 */ +#define U_SIZE_POLYPOLYGON 4 /**< + 4 */ +#define U_SIZE_SCAN 8 /**< + 8 */ +#define U_SIZE_METARECORD 6 /**< X 8 */ +#define U_SIZE_WMRPLACEABLE 22 /**< X 24 */ +#define U_SIZE_WMRHEADER 18 /**< X 20 */ +#define U_SIZE_WMREOF 6 /**< X 8 */ +#define U_SIZE_WMRSETRELABS 6 /**< X 8 */ +#define U_SIZE_WMRSAVEDC 6 /**< X 8 */ +#define U_SIZE_WMRRESTOREDC 8 /**< * 8 */ +#define U_SIZE_WMRREALIZEPALETTE 6 /**< X 8 */ +#define U_SIZE_WMRSETBKCOLOR 10 /**< X 12 */ +#define U_SIZE_WMRSETTEXTCOLOR 10 /**< X 12 */ +#define U_SIZE_WMRSETBKMODE 8 /**< X 12 last 2 bytes are optional */ +#define U_SIZE_WMRSETROP2 8 /**< X 12 last 2 bytes are optional */ +#define U_SIZE_WMRSETPOLYFILLMODE 8 /**< X 12 last 2 bytes are optional */ +#define U_SIZE_WMRSETSTRETCHBLTMODE 8 /**< X 12 last 2 bytes are optional */ +#define U_SIZE_WMRSETTEXTALIGN 8 /**< X 12 last 2 bytes are optional */ +#define U_SIZE_WMRSETMAPMODE 8 /**< + 8 */ +#define U_SIZE_WMRSETTEXTCHAREXTRA 8 /**< + 8 */ +#define U_SIZE_WMRSETTEXTJUSTIFICATION 10 /**< X 12 */ +#define U_SIZE_WMRSETWINDOWORG 10 /**< X 12 */ +#define U_SIZE_WMRSETWINDOWEXT 10 /**< X 12 */ +#define U_SIZE_WMRSETVIEWPORTORG 10 /**< X 12 */ +#define U_SIZE_WMRSETVIEWPORTEXT 10 /**< X 12 */ +#define U_SIZE_WMROFFSETWINDOWORG 10 /**< X 12 */ +#define U_SIZE_WMROFFSETVIEWPORTORG 10 /**< X 12 */ +#define U_SIZE_WMRLINETO 10 /**< X 12 */ +#define U_SIZE_WMRMOVETO 10 /**< X 12 */ +#define U_SIZE_WMROFFSETCLIPRGN 10 /**< X 12 */ +#define U_SIZE_WMRSCALEWINDOWEXT 14 /**< X 16 */ +#define U_SIZE_WMRSCALEVIEWPORTEXT 14 /**< X 16 */ +#define U_SIZE_WMREXCLUDECLIPRECT 14 /**< X 16 */ +#define U_SIZE_WMRINTERSECTCLIPRECT 14 /**< X 16 */ +#define U_SIZE_WMRARC 22 /**< X 24 */ +#define U_SIZE_WMRELLIPSE 14 /**< X 16 */ +#define U_SIZE_WMRRECTANGLE 14 /**< X 16 */ +#define U_SIZE_WMRFLOODFILL 16 /**< + 16 */ +#define U_SIZE_WMREXTFLOODFILL 16 /**< + 16 */ +#define U_SIZE_WMRSETPIXEL 14 /**< X 16 */ +#define U_SIZE_WMRPIE 22 /**< X 24 */ +#define U_SIZE_WMRCHORD 22 /**< X 24 */ +#define U_SIZE_WMRROUNDRECT 18 /**< X 20 */ +#define U_SIZE_WMRPATBLT 18 /**< X 20 */ +#define U_SIZE_WMRTEXTOUT 8 /**< X 12 (not including String,y,x) */ +#define U_SIZE_WMRBITBLT_NOPX 24 /**< + 24 */ +#define U_SIZE_WMRBITBLT_PX 22 /**< X 32 */ +#define U_SIZE_WMRSTRETCHBLT_NOPX 28 /**< + 28 */ +#define U_SIZE_WMRSTRETCHBLT_PX 26 /**< X 36 */ +#define U_SIZE_WMRPOLYGON 10 /**< X 12 */ +#define U_SIZE_WMRPOLYLINE 10 /**< X 12 */ +#define U_SIZE_WMRESCAPE 10 /**< X 12 Data field could be completely absent */ +#define U_SIZE_WMRFILLREGION 10 /**< X 12 */ +#define U_SIZE_WMRFRAMEREGION 14 /**< X 16 */ +#define U_SIZE_WMRINVERTREGION 8 /**< + 8 */ +#define U_SIZE_WMRPAINTREGION 8 /**< + 8 */ +#define U_SIZE_WMRSELECTCLIPREGION 8 /**< + 8 */ +#define U_SIZE_WMRSELECTOBJECT 8 /**< + 8 */ +#define U_SIZE_WMRSELECTPALETTE 8 /**< + 8 */ +#define U_SIZE_WMRRESIZEPALETTE 8 /**< + 8 */ +#define U_SIZE_WMRDELETEOBJECT 8 /**< + 8 */ +#define U_SIZE_WMRDRAWTEXT 6 /**< X 8 */ +#define U_SIZE_WMRCREATEBITMAPINDIRECT 6 /**< X 8 */ +#define U_SIZE_WMRCREATEBITMAP 6 /**< X 8 */ +#define U_SIZE_WMRSETMAPPERFLAGS 10 /**< X 12 */ +#define U_SIZE_WMREXTTEXTOUT 14 /**< X 16 */ +#define U_SIZE_WMRSETDIBTODEV 22 /**< X 28 */ +#define U_SIZE_WMRANIMATEPALETTE 14 /**< X 16 */ +#define U_SIZE_WMRSETPALENTRIES 14 /**< X 16 */ +#define U_SIZE_WMRCREATEPALETTE 14 /**< X 16 */ +#define U_SIZE_WMRPOLYPOLYGON 10 /**< X 12 */ +#define U_SIZE_WMRDIBBITBLT_NOPX 24 /**< + 24 */ +#define U_SIZE_WMRDIBBITBLT_PX 22 /**< X 24 */ +#define U_SIZE_WMRDIBSTRETCHBLT_NOPX 28 /**< + 28 */ +#define U_SIZE_WMRDIBSTRETCHBLT_PX 26 /**< X 28 */ +#define U_SIZE_WMRDIBCREATEPATTERNBRUSH 10 /**< X 12 */ +#define U_SIZE_WMRSTRETCHDIB 28 /**< X 32 */ +#define U_SIZE_WMRCREATEPATTERNBRUSH 6 /**< X 8 */ +#define U_SIZE_WMRCREATEPENINDIRECT 16 /**< + 16 */ +#define U_SIZE_WMRCREATEFONTINDIRECT 26 /**< X 28 */ +#define U_SIZE_WMRCREATEBRUSHINDIRECT 14 /**< X 16 */ +#define U_SIZE_WMRCREATEREGION 26 /**< X 28 */ /** @} */ // *************************************************************************** // Macros -/** \defgroup Common_macros Common Macros +/** \defgroup U_WMF_Common_macros WMF Common Macros +Because Size16_4 may not be aligned no tests should dereference it directly from a pointer. +in NOPX tests cast causes uint8_t to promote to uint32_t, without it c++ compiler complains about +comparison of int with unsigned int @{ */ -/* Because Size16_4 may not be aligned no tests should dereference it directly from a pointer. -in NOPX tests cast causes uint8_t to promote to uint32_t, without it c++ compiler complains about -comparison of int with unsigned int */ -#define U_TEST_NOPX2(A,B) (A == (uint32_t) (B + 3)) /* A is Size16_4 (extracted and aligned), B = xb true if no bitmap associated with the structure, used with some BLT records*/ -#define U_TEST_NOPXB(A,B) (A/2 == (uint32_t) (B + 3)) /* A is Size16_4(extracted and aligned)*2, B - xb, true if no bitmap associated with the structure, used with some BLT records*/ -#define U_WMRTYPE(A) (((PU_METARECORD)A)->iType) //!< Get iType from U_WMR* record -#define U_WMRXB(A) (((PU_METARECORD)A)->xb) //!< Get xb from U_WMR* record -#define U_WMR_XB_FROM_TYPE(A) ((uint8_t) (U_wmr_values(A)>>8)) //!< Get xb from type value -#define U_U16(A) (*(uint16_t *)&A) /* interpret a 16 bit type as uint16_t */ -#define U_P16(A) ( (uint16_t *)&A) /* pass any 16 bit type as a pointer to a uint16_t */ -#define U_PP16(A) ( (uint16_t *) A) /* pass any pointer to a 16 bit type as a pointer to a uint16_t */ +#define U_TEST_NOPX2(A,B) (A == (uint32_t) (B + 3)) //!< A is Size16_4 (extracted and aligned), B = xb true if no bitmap associated with the structure, used with some BLT records. +#define U_TEST_NOPXB(A,B) (A/2 == (uint32_t) (B + 3)) //!< A is Size16_4 (extracted and aligned)*2, B = xb, true if no bitmap associated with the structure, used with some BLT records. +#define U_WMRTYPE(A) (((U_METARECORD *)A)->iType) //!< Get iType from U_WMR* record. +#define U_WMRXB(A) (((U_METARECORD *)A)->xb) //!< Get xb from U_WMR* record. +#define U_WMR_XB_FROM_TYPE(A) ((uint8_t) (U_wmr_values(A)>>8)) //!< Get xb from type value. +#define U_U16(A) (*(uint16_t *)&A) //!< interpret a 16 bit type as uint16_t. +#define U_P16(A) ( (uint16_t *)&A) //!< pass any 16 bit type as a pointer to a uint16_t. +#define U_PP16(A) ( (uint16_t *) A) //!< pass any pointer to a 16 bit type as a pointer to a uint16_t. /** @} */ @@ -732,28 +748,27 @@ comparison of int with unsigned int */ WMF structures OTHER than those corresponding to complete U_WMR_* records ************************************************************ */ -/** Brush Object WMF PDF 2.2.1.1 +/** Brush Object WMF manual 2.2.1.1 Documentation is muddy, bColor and bHatch fields have different meanings depending on the value of bStyle. Unclear if bHatch bytes are present in some cases from the documentation. - style Color Data - U_BS_SOLID ColorRef Object Not used (bytes present???) - U_BS_NULL ignored ignored (bytes present???). - U_BS_PATTERN ignored Bitmap16 object holding patern - U_BS_DIBPATTERNPT ColorUsage Enum DIB object - U_BS_HATCHED ColorRef Object HatchStyle Enumeration + style Color Data + U_BS_SOLID ColorRef Object Not used (bytes present???) + U_BS_NULL ignored ignored (bytes present???). + U_BS_PATTERN ignored Bitmap16 object holding patern + U_BS_DIBPATTERNPT ColorUsage Enum DIB object + U_BS_HATCHED ColorRef Object HatchStyle Enumeration */ - typedef struct { - uint16_t Style; //!< BrushStyle enumeration + uint16_t Style; //!< BrushStyle Enumeration U_COLORREF Color; //!< Brush Color value, 32 bit value is not aligned. uint8_t Data[1]; //!< Brush pattern information, variable size and format -} U_BRUSH, *PU_BRUSH; +} U_BRUSH; -/** Font Object WMF PDF 2.2.1.2 +/** Font Object WMF manual 2.2.1.2 Warning, only pass by pointer, passing by value will will truncate in Facename! */ typedef struct { @@ -771,9 +786,9 @@ typedef struct { uint8_t Quality; //!< LF_Quality Enumeration uint8_t PitchAndFamily; //!< LF_PitchAndFamily Enumeration uint8_t FaceName[1]; //!< Name of font. ANSI Latin1, null terminated. -} U_FONT, *PU_FONT; +} U_FONT; -/** PaletteEntry Object WMF PDF 2.2.2.13 +/** PaletteEntry Object WMF manual 2.2.2.13 Note, NOT compatiable with U_LOGPLTNTRY Out of PDF order because needed for next struture. */ @@ -782,10 +797,10 @@ typedef struct { uint8_t Blue; //!< Palette entry Blue Intensity uint8_t Green; //!< Palette entry Green Intensity uint8_t Red; //!< Palette entry Red Intensity -} U_PLTNTRY, *PU_PLTNTRY; +} U_PLTNTRY; -/** Palette Object WMF PDF 2.2.1.3 - NOT same as "LogPalette Object" in uemf.h because Palette Entries have reversed colors. +/** Palette Object WMF manual 2.2.1.3 + NOT Same as "EMF LogPalette Object" in uemf.h because Palette Entries have reversed colors. Values for palVersion are expanded Start must be 0x0300 (as for EMF) with U_WMRCREATEPALETTE but is an offset @@ -795,17 +810,17 @@ typedef struct { uint16_t Start; //!< Either 0x0300 or an offset into the Palette table uint16_t NumEntries; //!< Number of U_LOGPLTNTRY objects U_PLTNTRY PalEntries[1]; //!< Array of PaletteEntry Objects -} U_PALETTE, *PU_PALETTE; +} U_PALETTE; -/** Pen Object WMF PDF 2.2.1.4 +/** Pen Object WMF manual 2.2.1.4 */ typedef struct { uint16_t Style; //!< PenStyle Enumeration uint16_t Widthw[2]; //!< reassemble/store the Pen Width in object dimensions using Widthw, the 32 bit value is not aligned U_COLORREF Color; //!< Pen Color, the 32 bit value is not aligned. -} U_PEN, *PU_PEN; +} U_PEN; -/** Rect Object WMF PDF 2.2.2.18 +/** Rect Object WMF manual 2.2.2.18 \brief Coordinates of the upper left, lower right corner. Note that the coordinate system is 0,0 in the upper left corner of the screen an N,M in the lower right corner. @@ -818,11 +833,11 @@ typedef struct { int16_t top; //!< top coordinate int16_t right; //!< right coordinate int16_t bottom; //!< bottom coordinate -} U_RECT16, *PU_RECT16; +} U_RECT16; #define U_RCL16_DEF (U_RECT16){0,0,-1,-1} //!< Use this when no bounds are needed. -/** Region Object WMF PDF 2.2.1.5 +/** Region Object WMF manual 2.2.1.5 */ typedef struct { uint16_t ignore1; //!< unused value @@ -833,13 +848,13 @@ typedef struct { int16_t sMax; //!< largest number of points in any scan U_RECT16 sRect; //!< bounding rectangle uint16_t aScans[1]; //!< series of appended U_SCAN objects -} U_REGION, *PU_REGION; +} U_REGION; -/** Bitmap16 Object WMF PDF 2.2.2.1 +/** Bitmap16 Object WMF manual 2.2.2.1 - The U_BITMAP16 core is always followed by - uint8_t Bits[1]; //!< bitmap pixel data. Bytes contained = (((Width * BitsPixel + 15) >> 4) << 1) * Height - Note that in U_WMRCREATEPATTERNBRUSH Bits is always [4]. + The U_BITMAP16 core is always followed by + uint8_t Bits[1]; //!< bitmap pixel data. Bytes contained = (((Width * BitsPixel + 15) >> 4) << 1) * Height + Note that in U_WMRCREATEPATTERNBRUSH Bits is always [4]. */ typedef struct { @@ -849,9 +864,9 @@ typedef struct { int16_t WidthBytes; //!< bytes per scan line. uint8_t Planes; //!< must be 1. uint8_t BitsPixel; //!< number of adjacent color bits on each plane (R bits + G bits + B bits ????) -} U_BITMAP16, *PU_BITMAP16; +} U_BITMAP16; -/** BitmapCoreHeader Object WMF PDF 2.2.2.2 +/** BitmapCoreHeader Object WMF manual 2.2.2.2 */ typedef struct { uint16_t Size_4[2]; //!< size of U_BITMAPCOREHEADER in bytes. @@ -859,15 +874,16 @@ typedef struct { uint16_t Height; //!< DIB height in pixels. uint16_t Planes; //!< must be 1 uint16_t BitCount; //!< Pixel Format (BitCount Enumeration) -} U_BITMAPCOREHEADER, *PU_BITMAPCOREHEADER; +} U_BITMAPCOREHEADER; -/** BitmapInfoHeader Object WMF PDF 2.2.2.3 - same as "BITMAPINFOHEADER Object" in uemf.h +/** BitmapInfoHeader Object WMF manual 2.2.2.3 + Same as "EMF BITMAPINFOHEADER Object" in uemf.h use U_BITMAPINFOHEADER */ -/** BitmapV4Header Object WMF PDF 2.2.2.4 +//! \cond +/** BitmapV4Header Object WMF manual 2.2.2.4 */ typedef struct { uint32_t bV4Size; @@ -890,10 +906,10 @@ typedef struct { uint32_t bV4GammaRed; uint32_t bV4GammaGreen; uint32_t bV4GammaBlue; -} U_BITMAPV4HEADER, *PU_BITMAPV4HEADER; //!< For ? +} U_BITMAPV4HEADER; //!< For ? -/** BitmapV5Header Object WMF PDF 2.2.2.5 +/** BitmapV5Header Object WMF manual 2.2.2.5 */ typedef struct { uint32_t bV5Size; @@ -920,129 +936,138 @@ typedef struct { uint32_t bV5ProfileData; uint32_t bV5ProfileSize; uint32_t bV5Reserved; -} U_BITMAPV5HEADER, *PU_BITMAPV5HEADER; //!< For ? +} U_BITMAPV5HEADER; //!< For ? +//! \endcond -/** CIEXYZ Object WMF PDF 2.2.2.6 - Same as "CIEXYZ Object" in uemf.h +/** CIEXYZ Object WMF manual 2.2.2.6 + Same as "EMF CIEXYZ Object" in uemf.h */ -/** CIEXYZTriple Object WMF PDF 2.2.2.7 - Same as "CIEXYZTRIPLE Object" in uemf.h +/** CIEXYZTriple Object WMF manual 2.2.2.7 + Same as "EMF CIEXYZTRIPLE Object" in uemf.h */ -/** ColorRef Object WMF PDF 2.2.2.8 - Same as "COLORREF Object" in uemf.h +/** ColorRef Object WMF manual 2.2.2.8 + Same as "EMF COLORREF Object" in uemf.h */ -/** DeviceIndependentBitmap Object WMF PDF 2.2.2.9 +/** DeviceIndependentBitmap Object WMF manual 2.2.2.9 This "object" has an organization, but not one that can be easily expressed with a C struct. It consists of three parts, all of which have variable size: - DIBHeaderInfo BitmapCoreHeader or BitmapInfoHeader Object - Colors Array of RGBQuad Objects or uint16_t that make a color table, as determined from the DIBHeaderInfo field. - BitMapBuffer Array of bytes containing the image. + DIBHeaderInfo BitmapCoreHeader or BitmapInfoHeader Object + Colors Array of RGBQuad Objects or uint16_t that make a color table, as determined from the DIBHeaderInfo field. + BitMapBuffer Array of bytes containing the image. */ -/** WLogBrush Object WMF PDF 2.2.2.10 +/** WLogBrush Object WMF manual 2.2.2.10 Not compatible with EMF LogBrush object! - style Color Hatch - U_BS_SOLID ColorRef Object Not used (bytes present???) - U_BS_NULL ignored ignored (bytes present???). - U_BS_PATTERN ignored not used (Action is not strictly defined) - U_BS_DIBPATTERN ignored not used (Action is not strictly defined) - U_BS_DIBPATTERNPT ignored not used (Action is not strictly defined) - U_BS_HATCHED ColorRef Object HatchStyle Enumeration + style Color Hatch + U_BS_SOLID ColorRef Object Not used (bytes present???) + U_BS_NULL ignored ignored (bytes present???). + U_BS_PATTERN ignored not used (Action is not strictly defined) + U_BS_DIBPATTERN ignored not used (Action is not strictly defined) + U_BS_DIBPATTERNPT ignored not used (Action is not strictly defined) + U_BS_HATCHED ColorRef Object HatchStyle Enumeration */ typedef struct { uint16_t Style; //!< BrushStyle Enumeration U_COLORREF Color; //!< Brush Color value, 32 bit value is not aligned. uint16_t Hatch; //!< HatchStyle Enumeration -} U_WLOGBRUSH, *PU_WLOGBRUSH; +} U_WLOGBRUSH; -/** LogColorSpace Object WMF PDF 2.2.2.11 - Same as "LOGCOLORSPACEA Object" in uemf.h +/* LogColorSpace Object WMF manual 2.2.2.11 + Same as "EMF LOGCOLORSPACEA Object" in uemf.h use U_LOGCOLORSPACEA */ -/** LogColorSpaceW Object WMF PDF 2.2.2.12 - Same as "LOGCOLORSPACEW Object" in uemf.h +/* LogColorSpaceW Object WMF manual 2.2.2.12 + Same as "EMF LOGCOLORSPACEW Object" in uemf.h use U_LOGCOLORSPACEW */ -/** PaletteEntry Object WMF PDF 2.2.2.13 +/* PaletteEntry Object WMF manual 2.2.2.13 moved up before Palette Object */ -/** PitchAndFamily Enumerations WMF PDF 2.2.2.14 - Same as "LF_PitchAndFamily Enumeration" in uemf.h +/* PitchAndFamily Enumerations WMF manual 2.2.2.14 + Same as "EMF LF_PitchAndFamily Enumeration" in uemf.h */ -/** PointL Object WMF PDF 2.2.2.15 - Same as "Point Object" in uemf.h +/* PointL Object WMF manual 2.2.2.15 + Same as "EMF Point Object" in uemf.h */ -/** PointS Object WMF PDF 2.2.2.16 - Same as "POINTS Object" in uemf.h +/* PointS Object WMF manual 2.2.2.16 + Same as "EMF POINTS Object" in uemf.h */ -/** PolyPolygon Object WMF PDF 2.2.2.17 +/* PolyPolygon Object WMF manual 2.2.2.17 */ +/** WMF manual 2.2.2.17 + There is an array "aPoints" of uint16_t after aPolyCounts that holds the coordinates. + Presumably it is in order [x1,y1],[x2,y2],etc. The documentation does not say, it might have y then x. + aPoints starts at aPolyCounts[nPolys] */ typedef struct { uint16_t nPolys; //!< Number of polygons uint16_t aPolyCounts[1]; //!< Number of points in each polygon (sequential) -} U_POLYPOLYGON, *PU_POLYPOLYGON; +} U_POLYPOLYGON; -/** Rect Object WMF PDF 2.2.2.18 +/* Rect Object WMF manual 2.2.2.18 This one is out of order, had to be created much earlier than this */ -/** RectL Object WMF PDF 2.2.2.19 - Same as "RECT Object" in uemf.h +/* RectL Object WMF manual 2.2.2.19 + Same as "EMF RECT Object" in uemf.h */ -/** RGBQuad Object WMF PDF 2.2.2.20 - Same as "RGBQUAD Object" in uemf.h +/* RGBQuad Object WMF manual 2.2.2.20 + Same as "EMF RGBQUAD Object" in uemf.h */ -/** Scan Object WMF PDF 2.2.2.21 - Field "count2" must follow ScanLines, but it cannot be placed into the struct. It is - an uint16_t value which must be the same as count. +/** Scan Object WMF manual 2.2.2.21 */ +/** WMF manual 2.2.2.21 + + Mandatory field "count2" must follow ScanLines, but it cannot be placed into the struct because + ScanLines has variable size. "count2" is + an uint16_t value which must have the same value as count. */ typedef struct { uint16_t count; //!< Number of entries in the ScanLines array uint16_t top; //!< Y coordinate of the top scanline uint16_t bottom; //!< Y coordinate of the bottom scanline uint16_t ScanLines[1]; //!< Array of 16 bit left/right pairs -} U_SCAN, *PU_SCAN; +} U_SCAN; -/** SizeL Object WMF PDF 2.2.2.22 - Same as "SIZEL Object" in uemf.h +/** SizeL Object WMF manual 2.2.2.22 + Same as "EMF SIZEL Object" in uemf.h */ /** First three fields of MOST WMF records (not WMR_HEADER and WMR_PLACEABLE!) - Should only used for accessing size and type fields. - NOT used as a prefix like U_EMR in uemf.h because it may cause alignment issues. + + This Sshould only used for accessing size and type fields. + It is NOT used as a prefix like U_EMR in uemf.h because it may cause alignment issues. Microsoft name: WMF Object */ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type -} U_METARECORD, *PU_METARECORD; +} U_METARECORD; -/** WMF PDF 2.3.2.3 META_PLACEABLE - If present this must immediately precede the header. - It is not enumerated as an WMR record type. - This only ever occurs at the start of a WMF file, so the two uint32_t values will always be aligned. +/** WMF manual 2.3.2.3 META_PLACEABLE + If present this must immediately precede the header. + It is not enumerated as an WMR record type. + This only ever occurs at the start of a WMF file, so the two uint32_t values will always be aligned. */ typedef struct { uint32_t Key; //!< MUST be 0x9AC6CDD7 @@ -1051,146 +1076,172 @@ typedef struct { uint16_t Inch; //!< Logical units/inch (convention if not specified: 1440 logical units/inch) uint32_t Reserved; //!< must be 0 uint16_t Checksum; //!< Checksum of preceding 10 16 bit values -} U_WMRPLACEABLE, *PU_WMRPLACEABLE; +} U_WMRPLACEABLE; -/** WMF PDF 2.3.2.2 META_HEADER +/** WMF manual 2.3.2.2 META_HEADER */ typedef struct { - uint8_t iType; //!< RecordType enumeration, must be 1 + uint8_t iType; //!< RecordType Enumeration, must be 1 uint8_t xb; //!< Extra high order byte associated with record type uint16_t Size16w; //!< Total number of 16bit words in record - uint16_t version; //!< Metafile version enumeration + uint16_t version; //!< Metafile version Enumeration uint16_t Sizew[2]; //!< reassemble/store the Size (16 bit words in entire file) using Sizew, the 32 bit value is not aligned uint16_t nObjects; //!< Total number of brushes, pens, and other graphics objects defined in this file uint32_t maxSize; //!< Largest record in file, in number of 16bit words (This uint32_t is aligned) uint16_t nMembers; //!< Unused, should be 0 -} U_WMRHEADER, *PU_WMRHEADER; +} U_WMRHEADER; // *********************************************************************************** // The following structures correspond to U_WMR_# records -/* Index 00 U_WMREOF WMF PDF 2.3.2.1 META_EOF */ +/* Index 00 U_WMREOF WMF manual 2.3.2.1 META_EOF */ +/** WMF manual 2.3.2.1 META_EOF +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type -} U_WMREOF, *PU_WMREOF, - U_WMRSETRELABS, *PU_WMRSETRELABS, - U_WMRSAVEDC, *PU_WMRSAVEDC, - U_WMRREALIZEPALETTE, *PU_WMRREALIZEPALETTE; +} U_WMREOF, + U_WMRSETRELABS, //!< WMF manual 2.3.5.21 + U_WMRSAVEDC, //!< WMF manual 2.3.5.11 + U_WMRREALIZEPALETTE; //!< WMF manual 2.3.5.8 -/* Index 01 U_WMRSETBKCOLOR WMF PDF 2.3.5.14 */ +/* Index 01 U_WMRSETBKCOLOR WMF manual 2.3.5.14 */ +/** WMF manual 2.3.5.14 +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type U_COLORREF Color; //!< Color value, the 32 bit value is not aligned. -} U_WMRSETBKCOLOR, *PU_WMRSETBKCOLOR, - U_WMRSETTEXTCOLOR, *PU_WMRSETTEXTCOLOR; +} U_WMRSETBKCOLOR, + U_WMRSETTEXTCOLOR; //!< WMF manual 2.3.5.26 -/* Index 02 U_WMRSETBKMODE WMF PDF 2.3.5.15 */ +/* Index 02 U_WMRSETBKMODE WMF manual 2.3.5.15 */ +/** WMF manual 2.3.5.15 +mode = MixMode Enumeration. +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type uint16_t Mode; //!< Various Enumeraton. uint16_t Reserved; //!< Ignore (ALSO OPTIONAL - FIELD MAY NOT BE PRESENT!!!!) -} U_WMRSETBKMODE, *PU_WMRSETBKMODE, //!< MixMode Enumeration. - U_WMRSETROP2, *PU_WMRSETROP2, //!< Binary Raster Operation Enumeration. - U_WMRSETPOLYFILLMODE, *PU_WMRSETPOLYFILLMODE, //!< PolyFillMode Enumeration. - U_WMRSETSTRETCHBLTMODE, *PU_WMRSETSTRETCHBLTMODE, //!< StretchMode Enumeration - U_WMRSETTEXTALIGN, *PU_WMRSETTEXTALIGN; //!< TextAlignment Enumeration. +} U_WMRSETBKMODE, + U_WMRSETPOLYFILLMODE, //!< WMF manual 2.3.5.20 Mode = PolyFillMode Enumeration. + U_WMRSETROP2, //!< WMF manual 2.3.5.22 Binary Raster Operation Enumeration. + U_WMRSETSTRETCHBLTMODE, //!< WMF manual 2.3.5.23 Mode = StretchMode Enumeration + U_WMRSETTEXTALIGN; //!< WMF manual 2.3.5.24 Mode = TextAlignment Enumeration. -/* Index 03 U_WMRSETMAPMODE WMF PDF 2.3.5.17 */ +/* Index 03 U_WMRSETMAPMODE WMF manual 2.3.5.17 */ +/** WMF manual 2.3.5.17 +Mode = MapMode Enumeration. +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type uint16_t Mode; //!< Various Enumeraton and other -} U_WMRSETMAPMODE, *PU_WMRSETMAPMODE, //!< MapMode Enumeration. - U_WMRSETTEXTCHAREXTRA, *PU_WMRSETTEXTCHAREXTRA; //!< Extra space in logical units to add to each character +} U_WMRSETMAPMODE, + U_WMRSETTEXTCHAREXTRA; //!< WMF manual 2.3.5.25, Mode = Extra space in logical units to add to each character -/* Index 04 U_WMRSETROP2 WMF PDF 2.3.5.22 See Index 02 */ +/* Index 04 U_WMRSETROP2 WMF manual 2.3.5.22 See Index 02 */ -/* Index 05 U_WMRSETRELABS WMF PDF 2.3.5.21 See Index 00*/ +/* Index 05 U_WMRSETRELABS WMF manual 2.3.5.21 See Index 00*/ -/* Index 06 U_WMRSETPOLYFILLMODE WMF PDF 2.3.5.20 See Index 02 - Index 07 U_WMRSETSTRETCHBLTMODE WMF PDF 2.3.5.23 */ +/* Index 06 U_WMRSETPOLYFILLMODE WMF manual 2.3.5.20 See Index 02 + Index 07 U_WMRSETSTRETCHBLTMODE WMF manual 2.3.5.23 */ -/* Index 08 U_WMRSETTEXTCHAREXTRA WMF PDF 2.3.5.25 See Index 03*/ +/* Index 08 U_WMRSETTEXTCHAREXTRA WMF manual 2.3.5.25 See Index 03*/ -/* Index 09 U_WMRSETTEXTCOLOR WMF PDF 2.3.5.26 see Index 01 */ +/* Index 09 U_WMRSETTEXTCOLOR WMF manual 2.3.5.26 see Index 01 */ -/* Index 0A U_WMRSETTEXTJUSTIFICATION WMF PDF 2.3.5.27 */ +/* Index 0A U_WMRSETTEXTJUSTIFICATION WMF manual 2.3.5.27 */ +/** WMF manual 2.3.5.27 +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type uint16_t Count; //!< Number of space characters in the line uint16_t Extra; //!< Number of extra space characters to add to the line -} U_WMRSETTEXTJUSTIFICATION, *PU_WMRSETTEXTJUSTIFICATION; +} U_WMRSETTEXTJUSTIFICATION; -/* Index 0B U_WMRSETWINDOWORG WMF PDF 2.3.5.31 - Index 0C U_WMRSETWINDOWEXT WMF PDF 2.3.5.30 - Index 0D U_WMRSETVIEWPORTORG WMF PDF 2.3.5.29 - Index 0E U_WMRSETVIEWPORTEXT WMF PDF 2.3.5.28 - Index 0F U_WMROFFSETWINDOWORG WMF PDF 2.3.5.7 - Index 13 U_WMRLINETO WMF PDF 2.3.3.10 - Index 14 U_WMRMOVETO WMF PDF 2.3.3.4 +/* Index 0B U_WMRSETWINDOWORG WMF manual 2.3.5.31 + Index 0C U_WMRSETWINDOWEXT WMF manual 2.3.5.30 + Index 0D U_WMRSETVIEWPORTORG WMF manual 2.3.5.29 + Index 0E U_WMRSETVIEWPORTEXT WMF manual 2.3.5.28 + Index 0F U_WMROFFSETWINDOWORG WMF manual 2.3.5.7 + Index 0F U_WMROFFSETVIEWPORTORG WMF manual 2.3.5.6 + Index 13 U_WMRLINETO WMF manual 2.3.3.10 + Index 14 U_WMRMOVETO WMF manual 2.3.3.4 + Index 20 U_WMROFFSETCLIPRGN WMF manual 2.3.5.5 +*/ +/** WMF manual 2.3.5.31 +Window X,Y origin */ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type int16_t y; //!< Y value (note order!) int16_t x; //!< X value -} U_WMRSETWINDOWORG, *PU_WMRSETWINDOWORG, //!< Window X,Y origin - U_WMRSETWINDOWEXT, *PU_WMRSETWINDOWEXT, //!< Window X,Y extent - U_WMRSETVIEWPORTORG, *PU_WMRSETVIEWPORTORG, //!< Viewport X,Y origin - U_WMRSETVIEWPORTEXT, *PU_WMRSETVIEWPORTEXT, //!< Viewport X,Y extent - U_WMROFFSETWINDOWORG, *PU_WMROFFSETWINDOWORG, //!< Window X,Y offset in device units - U_WMROFFSETVIEWPORTORG, *PU_WMROFFSETVIEWPORTORG, //!< Viewport X,Y offset in device units - U_WMRLINETO, *PU_WMRLINETO, //!< Endpoint X,Y in logical units - U_WMRMOVETO, *PU_WMRMOVETO, //!< Destination X,Y in logical units - U_WMROFFSETCLIPRGN, *PU_WMROFFSETCLIPRGN; //!< ClipRegion X,Y offset in logical units - -/* Index 10 U_WMRSCALEWINDOWEXT WMF PDF 2.3.5.13 */ +} U_WMRSETWINDOWORG, + U_WMRSETWINDOWEXT, //!< WMF manual 2.3.5.30, Window X,Y extent + U_WMRSETVIEWPORTORG, //!< WMF manual 2.3.5.29, Viewport X,Y origin + U_WMRSETVIEWPORTEXT, //!< WMF manual 2.3.5.28, Viewport X,Y extent + U_WMROFFSETWINDOWORG, //!< WMF manual 2.3.5.7, Window X,Y offset in device units + U_WMROFFSETVIEWPORTORG, //!< WMF manual 2.3.5.6, Viewport X,Y offset in device units + U_WMRLINETO, //!< WMF manual 2.3.3.10, Endpoint X,Y in logical units + U_WMRMOVETO, //!< WMF manual 2.3.3.4, Destination X,Y in logical units + U_WMROFFSETCLIPRGN; //!< WMF manual 2.3.5.5, Y offset in logical units + +/* Index 10 U_WMRSCALEWINDOWEXT WMF manual 2.3.5.13 + Index 12 U_WMRSCALEVIEWPORTEXT WMF manual 2.3.5.12 +*/ +/** WMF manual 2.3.5.13 +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type int16_t yDenom; //!< Y denominator int16_t yNum; //!< Y numerator int16_t xDenom; //!< X denominator int16_t xNum; //!< X numerator -} U_WMRSCALEWINDOWEXT, *PU_WMRSCALEWINDOWEXT, - U_WMRSCALEVIEWPORTEXT, *PU_WMRSCALEVIEWPORTEXT; +} U_WMRSCALEWINDOWEXT, + U_WMRSCALEVIEWPORTEXT; //!< WMF manual 2.3.5.12 -/* Index 11 U_WMROFFSETVIEWPORTORG WMF PDF 2.3.5.6 see Index 0B */ +/* Index 11 U_WMROFFSETVIEWPORTORG WMF manual 2.3.5.6 see Index 0B */ -/* Index 12 U_WMRSCALEVIEWPORTEXT WMF PDF 2.3.5.12 see Index 10 */ +/* Index 12 U_WMRSCALEVIEWPORTEXT WMF manual 2.3.5.12 see Index 10 */ -/* Index 13 U_WMRLINETO WMF PDF 2.3.3.10 see index 0B - Index 14 U_WMRMOVETO WMF PDF 2.3.5.4 */ +/* Index 13 U_WMRLINETO WMF manual 2.3.3.10 see index 0B + Index 14 U_WMRMOVETO WMF manual 2.3.5.4 */ -/* Index 15 U_WMREXCLUDECLIPRECT WMF PDF 2.3.5.2 - Index 16 U_WMRINTERSECTCLIPRECT WMF PDF 2.3.5.3 */ +/* Index 15 U_WMREXCLUDECLIPRECT WMF manual 2.3.5.2 + Index 16 U_WMRINTERSECTCLIPRECT WMF manual 2.3.5.3 +*/ +/** WMF manual 2.3.5.2 +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type int16_t Bottom; //!< Coordinates in logical units int16_t Right; //!< Coordinates in logical units int16_t Top; //!< Coordinates in logical units int16_t Left; //!< Coordinates in logical units -} U_WMREXCLUDECLIPRECT, *PU_WMREXCLUDECLIPRECT, - U_WMRINTERSECTCLIPRECT, *PU_WMRINTERSECTCLIPRECT; +} U_WMREXCLUDECLIPRECT, + U_WMRINTERSECTCLIPRECT; //!< WMF manual 2.3.5.3 -/* Index 17 U_WMRARC WMF PDF 2.3.3.1 */ +/* Index 17 U_WMRARC WMF manual 2.3.3.1 */ +/** WMF manual 2.3.3.1 +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type int16_t yEndArc; //!< Coordinates in logical units int16_t xEndArc; //!< Coordinates in logical units @@ -1200,36 +1251,48 @@ typedef struct { int16_t Right; //!< Coordinates in logical units int16_t Top; //!< Coordinates in logical units int16_t Left; //!< Coordinates in logical units -} U_WMRARC, *PU_WMRARC; +} U_WMRARC; -/* Index 18 U_WMRELLIPSE WMF PDF 2.3.3.3 */ +/* Index 18 U_WMRELLIPSE WMF manual 2.3.3.3 + Index 1B U_WMRRECTANGLE WMF manual 2.3.3.17 +*/ +/** WMF manual 2.3.3.3 +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type int16_t Bottom; //!< Coordinates in logical units int16_t Right; //!< Coordinates in logical units int16_t Top; //!< Coordinates in logical units int16_t Left; //!< Coordinates in logical units -} U_WMRELLIPSE, *PU_WMRELLIPSE, - U_WMRRECTANGLE, *PU_WMRRECTANGLE; +} U_WMRELLIPSE, + U_WMRRECTANGLE; //!< WMF manual 2.3.3.17 -/* Index 19 U_WMRFLOODFILL WMF PDF 2.3.3.7 */ +/* Index 19 U_WMRFLOODFILL WMF manual 2.3.3.7 + Index 48 U_WMREXTFLOODFILL WMF manual 2.3.3.4 +*/ +/** WMF manual 2.3.3.7 +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type int16_t Mode; //!< FloodFill Enumeration U_COLORREF Color; //!< Color int16_t y; //!< Y int16_t x; //!< X -} U_WMRFLOODFILL, *PU_WMRFLOODFILL, - U_WMREXTFLOODFILL, *PU_WMREXTFLOODFILL; +} U_WMRFLOODFILL, + U_WMREXTFLOODFILL; //!< WMF manual 2.3.3.7 -/* Index 1A U_WMRPIE WMF PDF 2.3.3.13 */ +/* Index 1A U_WMRPIE WMF manual 2.3.3.13 + Index 30 U_WMRCHORD WMF manual 2.3.3.2 +*/ +/** WMF manual 2.3.3.13 +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type int16_t yRadial2; //!< in logical units int16_t xRadial2; //!< in logical units @@ -1239,15 +1302,17 @@ typedef struct { int16_t Right; //!< in logical units int16_t Top; //!< in logical units int16_t Left; //!< in logical units -} U_WMRPIE, *PU_WMRPIE, - U_WMRCHORD, *PU_WMRCHORD; +} U_WMRPIE, + U_WMRCHORD; //!< WMF manual 2.3.3.2 -/* Index 1B U_WMRRECTANGLE WMF PDF 2.3.3.17 See Index 18 */ +/* Index 1B U_WMRRECTANGLE WMF manual 2.3.3.17 See Index 18 */ -/* Index 1C U_WMRROUNDRECT WMF PDF 2.3.3.18 */ +/* Index 1C U_WMRROUNDRECT WMF manual 2.3.3.18 */ +/** WMF manual 2.3.3.18 +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type int16_t Height; //!< in logical units (rounded corner) int16_t Width; //!< in logical units (rounded corner) @@ -1255,50 +1320,61 @@ typedef struct { int16_t Right; //!< in logical units int16_t Top; //!< in logical units int16_t Left; //!< in logical units -} U_WMRROUNDRECT, *PU_WMRROUNDRECT; +} U_WMRROUNDRECT; -/* Index 1D U_WMRPATBLT WMF PDF 2.3.3.12 +/* Index 1D U_WMRPATBLT WMF manual 2.3.3.12 +*/ +/** WMF manual 2.3.3.12 */ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type uint16_t rop3w[2]; //!< reassemble/store the rop3 Ternary raster operation using rop3w, as the 32 bit value is not aligned int16_t Height; //!< in logical units (of Rect to Fill) int16_t Width; //!< in logical units (of Rect to Fill) int16_t yDst; //!< in logical units (UL corner to fill) int16_t xDst; //!< in logical units (UL corner to fill) -} U_WMRPATBLT, *PU_WMRPATBLT; +} U_WMRPATBLT; -/* Index 1E U_WMRSAVEDC WMF PDF 2.3.5.11 See Index 00*/ +/* Index 1E U_WMRSAVEDC WMF manual 2.3.5.11 See Index 00*/ -/* Index 1F U_WMRSETPIXEL WMF PDF 2.3.3.19 */ +/* Index 1F U_WMRSETPIXEL WMF manual 2.3.3.19 */ +/** WMF manual 2.3.3.19 +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type U_COLORREF Color; //!< Color int16_t y; //!< Y int16_t x; //!< X -} U_WMRSETPIXEL, *PU_WMRSETPIXEL; +} U_WMRSETPIXEL; -/* Index 20 U_WMROFFSETCLIPRGN WMF PDF 2.3.5.5 See Index 0B*/ +/* Index 20 U_WMROFFSETCLIPRGN WMF manual 2.3.5.5 See Index 0B*/ -/* Index 21 U_WMRTEXTOUT WMF PDF 2.3.3.20 - Also part of the record, but at variable positions - int16_t y; start position - int16_t x; start position +/* Index 21 U_WMRTEXTOUT WMF manual 2.3.3.20 +*/ +/** WMF manual 2.3.3.20 +Also part of the record, following String, and so at variable positions: + +int16_t y; start position + +int16_t x; start position */ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type int16_t Length; //!< Stringlength in bytes uint8_t String; //!< String to write, storage area must be 2n bytes. -} U_WMRTEXTOUT, *PU_WMRTEXTOUT; +} U_WMRTEXTOUT; + +/* Index 22 U_WMRBITBLT WMF manual 2.3.1.1 +*/ +/** WMF manual 2.3.1.1 -/* Index 22 U_WMRBITBLT WMF PDF 2.3.1.1 - This is a variable structure the core, invariant part extends to xSrc. + This is a variable structure the core/invariant part extends to xSrc. if RecordSize == ((xb) + 3) then there is no bitmap and use the _NOPX form, otherwise use the _PX form Use Macro U_TEST_NOPX2 @@ -1306,7 +1382,7 @@ typedef struct { */ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type uint16_t rop3w[2]; //!< reassemble/store the Ternary raster operation rop3 value using rop3w, the 32 bit value is not aligned. int16_t ySrc; //!< in logical units (UL corner of Src rect) @@ -1316,11 +1392,19 @@ typedef struct { int16_t Width; //!< in logical units (of Src and Dst rects) int16_t yDst; //!< in logical units (UL corner of Dst rect) int16_t xDst; //!< in logical units (UL corner of Dst rect) -} U_WMRBITBLT_NOPX, *PU_WMRBITBLT_NOPX; +} U_WMRBITBLT_NOPX; + +/** WMF manual 2.3.1.1 + This is a variable structure the core/invariant part extends to xSrc. + + if RecordSize == ((xb) + 3) then there is no bitmap and use the _NOPX form, otherwise use the _PX form + Use Macro U_TEST_NOPX2 + +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type uint16_t rop3w[2]; //!< reassemble/store the Ternary raster operation rop3 value using rop3w, the 32 bit value is not aligned. int16_t ySrc; //!< in logical units (UL corner of Src rect) @@ -1330,18 +1414,21 @@ typedef struct { int16_t yDst; //!< in logical units (UL corner of Dst rect) int16_t xDst; //!< in logical units (UL corner of Dst rect) U_BITMAP16 bitmap; //!< Src bitmap -} U_WMRBITBLT_PX, *PU_WMRBITBLT_PX; +} U_WMRBITBLT_PX; + +/* Index 23 U_WMRSTRETCHBLT WMF manual 2.3.1.5 */ +/** WMF manual 2.3.1.5 -/* Index 23 U_WMRSTRETCHBLT WMF PDF 2.3.1.5 - This is a variable structure the core, invariant part extends to xSrc. + This is a variable structure the core/invariant part extends to xSrc. if RecordSize == ((xb) + 3) then there is no bitmap and use the _NOPX form, otherwise use the _PX form Use Macro U_TEST_NOPX2. */ + typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type uint16_t rop3w[2]; //!< reassemble/store the Ternary raster operation rop3 value using rop3w, the 32 bit value is not aligned. int16_t hSrc; //!< Height in logical units of Src rect @@ -1353,11 +1440,20 @@ typedef struct { int16_t wDst; //!< Wdith in logical units of Dst rect int16_t yDst; //!< in logical units (UL corner of Dst rect) int16_t xDst; //!< in logical units (UL corner of Dst rect) -} U_WMRSTRETCHBLT_NOPX, *PU_WMRSTRETCHBLT_NOPX; +} U_WMRSTRETCHBLT_NOPX; + + +/* Index 23 U_WMRSTRETCHBLT WMF manual 2.3.1.5 */ +/** WMF manual 2.3.1.5 + This is a variable structure the core/invariant part extends to xSrc. + + if RecordSize == ((xb) + 3) then there is no bitmap and use the _NOPX form, otherwise use the _PX form + Use Macro U_TEST_NOPX2. +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type uint16_t rop3w[2]; //!< reassemble/store the Ternary raster operation rop3 value using rop3w, the 32 bit value is not aligned. int16_t hSrc; //!< Height in logical units of Src rect @@ -1369,124 +1465,153 @@ typedef struct { int16_t yDst; //!< in logical units (UL corner of Dst rect) int16_t xDst; //!< in logical units (UL corner of Dst rect) U_BITMAP16 bitmap; //!< Src bitmap -} U_WMRSTRETCHBLT_PX, *PU_WMRSTRETCHBLT_PX; +} U_WMRSTRETCHBLT_PX; -/* Index 24 U_WMRPOLYGON WMF PDF 2.3.3.15 - Index 25 U_WMRPOLYLINE WMF PDF 2.3.3.14 */ +/* Index 24 U_WMRPOLYGON WMF manual 2.3.3.15 + Index 25 U_WMRPOLYLINE WMF manual 2.3.3.14 +*/ +/** WMF manual 2.3.3.15 +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type int16_t nPoints; //!< Number of points in aPoints U_POINT16 aPoints[1]; //!< Array of points -} U_WMRPOLYGON, *PU_WMRPOLYGON, - U_WMRPOLYLINE, *PU_WMRPOLYLINE; +} U_WMRPOLYGON, + U_WMRPOLYLINE; //!< WMF manual 2.3.3.14 -/* Index 26 U_WMRESCAPE WMF PDF 2.3.6.1 */ +/* Index 26 U_WMRESCAPE WMF manual 2.3.6.1 */ +/** WMF manual 2.3.6.1 +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type uint16_t eFunc; //!< Escape function uint16_t nBytes; //!< bytes in the data array uint8_t Data[1]; //!< data array -} U_WMRESCAPE, *PU_WMRESCAPE; +} U_WMRESCAPE; -/* Index 27 U_WMRRESTOREDC WMF PDF 2.3.5.10*/ +/* Index 27 U_WMRRESTOREDC WMF manual 2.3.5.10 */ +/** WMF manual 2.3.5.10 +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type int16_t DC; //!< DC to restore (negative is relative to current, positive is absolute) -} U_WMRRESTOREDC, *PU_WMRRESTOREDC; +} U_WMRRESTOREDC; -/* Index 28 U_WMRFILLREGION WMF PDF 2.3.3.6 */ +/* Index 28 U_WMRFILLREGION WMF manual 2.3.3.6 */ +/** WMF manual 2.3.3.6 +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type uint16_t Region; //!< Index of region to fill in object table uint16_t Brush; //!< Index of brush to use in object table -} U_WMRFILLREGION, *PU_WMRFILLREGION; +} U_WMRFILLREGION; -/* Index 29 U_WMRFRAMEREGION WMF PDF 2.3.3.8 */ +/* Index 29 U_WMRFRAMEREGION WMF manual 2.3.3.8 */ +/** WMF manual 2.3.3.8 +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type uint16_t Region; //!< Index of region to frame in object table uint16_t Brush; //!< Index of brush to use in frame in object table int16_t Height; //!< in logical units (of frame) int16_t Width; //!< in logical units (of frame) -} U_WMRFRAMEREGION, *PU_WMRFRAMEREGION; +} U_WMRFRAMEREGION; -/* Index 2A U_WMRINVERTREGION WMF PDF 2.3.3.9 - Index 2B U_WMRPAINTREGION WMF PDF 2.3.3.11 - Index 2C U_WMRSELECTCLIPREGION WMF PDF 2.3.4.9 - Index 2D U_WMRSELECTOBJECT WMF PDF 2.3.4.10 */ +/* Index 2A U_WMRINVERTREGION WMF manual 2.3.3.9 + Index 2B U_WMRPAINTREGION WMF manual 2.3.3.11 + Index 2C U_WMRSELECTCLIPREGION WMF manual 2.3.4.9 + Index 2D U_WMRSELECTOBJECT WMF manual 2.3.4.10 + Index 34 U_WMRSELECTPALETTE WMF manual 2.3.4.11 + Index 39 U_WMRRESIZEPALETTE WMF manual 2.3.5.9 + Index F0 U_WMRDELETEOBJECT WMF manual 2.3.4.7 +*/ +/** WMF manual 2.3.3.9 +invert region +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type uint16_t index; //!< (usually) index of region/object in object table -} U_WMRINVERTREGION, *PU_WMRINVERTREGION, //!< invert region - U_WMRPAINTREGION, *PU_WMRPAINTREGION, //!< paint region - U_WMRSELECTCLIPREGION, *PU_WMRSELECTCLIPREGION, //!< select as clip region - U_WMRSELECTOBJECT, *PU_WMRSELECTOBJECT, //!< select object - U_WMRSELECTPALETTE, *PU_WMRSELECTPALETTE, //!< select palette object - U_WMRRESIZEPALETTE, *PU_WMRRESIZEPALETTE, //!< resize the system palette to "index" - U_WMRDELETEOBJECT, *PU_WMRDELETEOBJECT; //!< delete object - -/* Index 2E U_WMRSETTEXTALIGN WMF PDF 2.3.5.24 See Index 02 */ - -/* Index 2F U_WMRDRAWTEXT in Wine, not in WMF PDF. - no documentation found, this part must be correct */ +} U_WMRINVERTREGION, + U_WMRPAINTREGION, //!< WMF manual 2.3.3.11, paint region + U_WMRSELECTCLIPREGION, //!< WMF manual 2.3.4.9, select as clip region + U_WMRSELECTOBJECT, //!< WMF manual 2.3.4.10, select object + U_WMRSELECTPALETTE, //!< WMF manual 2.3.4.11, select palette object + U_WMRRESIZEPALETTE, //!< WMF manual 2.3.5.9, resize the system palette to "index" + U_WMRDELETEOBJECT; //!< WMF manual 2.3.4.7, delete object + +/* Index 2E U_WMRSETTEXTALIGN WMF manual 2.3.5.24 See Index 02 */ + +/* Index 2F U_WMRDRAWTEXT in GDI and Wine, not documented in WMF manual. + Index FE U_WMRCREATEBITMAP in GDI and Wine, not documented in WMF manual. + Index FD U_WMRCREATEBITMAPINDIRECT in GDI and Wine, not documented in WMF manual. + + no documentation found, this part of these records, at least, must be correct */ +/** in GDI and Wine, not documented in WMF manual. +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type -} U_WMRDRAWTEXT, *PU_WMRDRAWTEXT, - U_WMRCREATEBITMAPINDIRECT, *PU_WMRCREATEBITMAPINDIRECT, - U_WMRCREATEBITMAP, *PU_WMRCREATEBITMAP; +} U_WMRDRAWTEXT, + U_WMRCREATEBITMAPINDIRECT, //!< in GDI and Wine, not documented in WMF manual. + U_WMRCREATEBITMAP; //!< in GDI and Wine, not documented in WMF manual. -/* Index 30 U_WMRCHORD WMF PDF 2.3.3.2 See Index 1A */ +/* Index 30 U_WMRCHORD WMF manual 2.3.3.2 See Index 1A */ -/* Index 31 U_WMRSETMAPPERFLAGS WMF PDF 2.3.5.18 */ +/* Index 31 U_WMRSETMAPPERFLAGS WMF manual 2.3.5.18 */ +/** WMF manual 2.3.5.18 +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type uint16_t valuew[2]; //!< if 1 bit set font mapper selects only matching aspect fonts. reassemble/store the value using valuew, the 32 bit value is not aligned. -} U_WMRSETMAPPERFLAGS, *PU_WMRSETMAPPERFLAGS; +} U_WMRSETMAPPERFLAGS; -/* Index 32 U_WMREXTTEXTOUT WMF PDF 2.3.3.5 - Variable size structure. Common part is shown. +/* Index 32 U_WMREXTTEXTOUT WMF manual 2.3.3.5 +*/ +/** WMF manual 2.3.3.5 + + Variable size record. Optional fields which follow the struct fields are: - U_RECT16 Rect; Only present when U_ETO_OPAQUE or U_ETO_CLIPPED bits are set in Opts - uint8_t String; String to write, storage area must be 2n bytes. - int16_t Dx; Kerning information. Must have same number of entries as Length. - Dx is present when - 2*Size16_4[2] -14 - 2*((Length + 1)/2)) - 8*(Opts & (U_ETO_OPAQUE | U_ETO_CLIPPED)) == 2*Length + U_RECT16 Rect; Only present when U_ETO_OPAQUE or U_ETO_CLIPPED bits are set in Opts + uint8_t String; String to write, storage area must be 2n bytes. + int16_t Dx; Kerning information. Must have same number of entries as Length. + Dx is present when + 2*Size16_4[2] -14 - 2*((Length + 1)/2)) - 8*(Opts & (U_ETO_OPAQUE | U_ETO_CLIPPED)) == 2*Length */ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type int16_t y; //!< in logical units (draw point) int16_t x; //!< in logical units (draw point) int16_t Length; //!< Stringlength in bytes uint16_t Opts; //!< ExtTextOutOptions Flags -} U_WMREXTTEXTOUT, *PU_WMREXTTEXTOUT; +} U_WMREXTTEXTOUT; + +/* Index 33 U_WMRSETDIBTODEV WMF manual 2.3.1.4 */ +/** WMF manual 2.3.1.4 -/* Index 33 U_WMRSETDIBTODEV WMF PDF 2.3.1.4 - Constant part of record is showon. It is followed by a - DeviceIndependentBitmap Object + Constant part of record is shown. It is followed by a DeviceIndependentBitmap Object */ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type - uint16_t cUsage; //!< ColorUsage enumeration + uint16_t cUsage; //!< ColorUsage Enumeration uint16_t ScanCount; //!< Number of scan lines in Src uint16_t StartScan; //!< First Scan line in Src int16_t ySrc; //!< in logical units (UL corner of Src rect) @@ -1496,35 +1621,44 @@ typedef struct { int16_t yDst; //!< in logical units (UL corner of Dst rect) int16_t xDst; //!< in logical units (UL corner of Dst rect) uint8_t dib[1]; //!< DeviceIndependentBitmap object -} U_WMRSETDIBTODEV, *PU_WMRSETDIBTODEV; +} U_WMRSETDIBTODEV; -/* Index 34 U_WMRSELECTPALETTE WMF PDF 2.3.4.11 See Index 2A */ +/* Index 34 U_WMRSELECTPALETTE WMF manual 2.3.4.11 See Index 2A */ -/* Index 35 U_WMRREALIZEPALETTE WMF PDF 2.3.5.8 See Index 00 */ +/* Index 35 U_WMRREALIZEPALETTE WMF manual 2.3.5.8 See Index 00 */ -/* Index 36 U_WMRANIMATEPALETTE WMF PDF 2.3.5.1 - Index 37 U_WMRSETPALENTRIES WMF PDF 2.3.5.19 */ +/* Index 36 U_WMRANIMATEPALETTE WMF manual 2.3.5.1 + Index 37 U_WMRSETPALENTRIES WMF manual 2.3.5.19 + Index F7 U_WMRCREATEPALETTE WMF manual 2.3.4.3 +*/ +/** WMF manual 2.3.5.1 +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type U_PALETTE Palette; //!< Palette object -} U_WMRANIMATEPALETTE, *PU_WMRANIMATEPALETTE, - U_WMRSETPALENTRIES, *PU_WMRSETPALENTRIES, - U_WMRCREATEPALETTE, *PU_WMRCREATEPALETTE; +} U_WMRANIMATEPALETTE, + U_WMRSETPALENTRIES, //!< WMF manual 2.3.5.19 + U_WMRCREATEPALETTE; //!< WMF manual 2.3.4.3 -/* Index 38 U_WMRPOLYPOLYGON WMF PDF 2.3.3.16 */ +/* Index 38 U_WMRPOLYPOLYGON WMF manual 2.3.3.16 */ +/** WMF manual 2.3.3.16 +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type U_POLYPOLYGON PPolygon; //!< PolyPolygon object (size is variable!) -} U_WMRPOLYPOLYGON, *PU_WMRPOLYPOLYGON; +} U_WMRPOLYPOLYGON; -/* Index 39 U_WMRRESIZEPALETTE WMF PDF 2.3.5.9 See Index 2A */ +/* Index 39 U_WMRRESIZEPALETTE WMF manual 2.3.5.9 See Index 2A */ -/* Index 40 U_WMRDIBBITBLT WMF PDF 2.3.1.2 - The PX form is a variable structure the core, invariant part extends to xDst, and that is +/* Index 40 U_WMRDIBBITBLT WMF manual 2.3.1.2 +*/ +/** WMF manual 2.3.1.2 + + The PX form is a variable structure the core/invariant part extends to xDst, and that is followed by a DeviceInvariantBitmap object which starts at "dib". The NOPX form is a constant structure. @@ -1533,7 +1667,7 @@ typedef struct { */ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type uint16_t rop3w[2]; //!< reassemble/store the Ternary raster operation rop3 value using rop3w, the 32 bit value is not aligned. int16_t ySrc; //!< in logical units (UL corner of Src rect) @@ -1543,11 +1677,20 @@ typedef struct { int16_t Width; //!< in logical units (of Src and Dst) int16_t yDst; //!< in logical units (UL corner of Dst rect) int16_t xDst; //!< in logical units (UL corner of Dst rect) -} U_WMRDIBBITBLT_NOPX, *PU_WMRDIBBITBLT_NOPX; +} U_WMRDIBBITBLT_NOPX; + +/** WMF manual 2.3.1.2 + The PX form is a variable structure the core/invariant part extends to xDst, and that is + followed by a DeviceInvariantBitmap object which starts at "dib". + The NOPX form is a constant structure. + + if RecordSize == ((xb) + 3) then there is no bitmap and use the _NOPX form, otherwise use the _PX form + Use Macro U_TEST_NOPX2. +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type uint16_t rop3w[2]; //!< reassemble/store the Ternary raster operation rop3 value using rop3w, the 32 bit value is not aligned. int16_t ySrc; //!< in logical units (UL corner of Src rect) @@ -1557,10 +1700,12 @@ typedef struct { int16_t yDst; //!< in logical units (UL corner of Dst rect) int16_t xDst; //!< in logical units (UL corner of Dst rect) uint8_t dib[1]; //!< DeviceIndependentBitmap object -} U_WMRDIBBITBLT_PX, *PU_WMRDIBBITBLT_PX; +} U_WMRDIBBITBLT_PX; + +/* Index 41 U_WMRDIBSTRETCHBLT WMF manual 2.3.1.3 */ +/** WMF manual 2.3.1.3 -/* Index 41 U_WMRDIBSTRETCHBLT WMF PDF 2.3.1.3 - The PX form is a variable structure the core, invariant part extends to xDst, and that is + The PX form is a variable structure the core/invariant part extends to xDst, and that is followed by a DeviceInvariantBitmap object which starts at "dib". The NOPX form is a constant structure. @@ -1569,7 +1714,7 @@ typedef struct { */ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type uint16_t rop3w[2]; //!< reassemble/store the Ternary raster operation rop3 value using rop3w, the 32 bit value is not aligned. int16_t hSrc; //!< in logical units (of Src) @@ -1581,11 +1726,20 @@ typedef struct { int16_t wDst; //!< in logical units (of Dst) int16_t yDst; //!< in logical units (UL corner of Dst rect) int16_t xDst; //!< in logical units (UL corner of Dst rect) -} U_WMRDIBSTRETCHBLT_NOPX, *PU_WMRDIBSTRETCHBLT_NOPX; +} U_WMRDIBSTRETCHBLT_NOPX; +/** WMF manual 2.3.1.3 + + The PX form is a variable structure the core/invariant part extends to xDst, and that is + followed by a DeviceInvariantBitmap object which starts at "dib". + The NOPX form is a constant structure. + + if RecordSize == ((xb) + 3) then there is no bitmap and use the _NOPX form, otherwise use the _PX form + Use Macro U_TEST_NOPX2. +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type uint16_t rop3w[2]; //!< reassemble/store the Ternary raster operation rop3 value using rop3w, the 32 bit value is not aligned. int16_t hSrc; //!< in logical units (of Src) @@ -1597,34 +1751,38 @@ typedef struct { int16_t yDst; //!< in logical units (UL corner of Dst rect) int16_t xDst; //!< in logical units (UL corner of Dst rect) uint8_t dib[1]; //!< DeviceIndependentBitmap object -} U_WMRDIBSTRETCHBLT_PX, *PU_WMRDIBSTRETCHBLT_PX; +} U_WMRDIBSTRETCHBLT_PX; -/* Index 42 U_WMRDIBCREATEPATTERNBRUSH WMF PDF 2.3.4.8 +/* Index 42 U_WMRDIBCREATEPATTERNBRUSH WMF manual 2.3.4.8 +*/ +/** WMF manual 2.3.4.8 - style cUsage Brush created - U_BS_SOLID like U_BS_DIBPATTERNPT - U_BS_NULL like U_BS_DIBPATTERNPT - U_BS_HATCHED like U_BS_DIBPATTERNPT - U_BS_DIBPATTERNPT ColorUsage enumer. U_BS_DIBPATTERNPT brush from DIB in Src - U_BS_PATTERN ColorUsage enumer. U_BS_PATTERN brush from Bitmap16 object in Src + style cUsage Brush created + U_BS_SOLID like U_BS_DIBPATTERNPT + U_BS_NULL like U_BS_DIBPATTERNPT + U_BS_HATCHED like U_BS_DIBPATTERNPT + U_BS_DIBPATTERNPT ColorUsage enumer. U_BS_DIBPATTERNPT brush from DIB in Src + U_BS_PATTERN ColorUsage enumer. U_BS_PATTERN brush from Bitmap16 object in Src */ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type uint16_t Style; //!< BrushStyle Enumeration uint16_t cUsage; //!< See table above uint8_t Src[1]; //!< DeviceIndependentBitmap or Bitmap16 object -} U_WMRDIBCREATEPATTERNBRUSH, *PU_WMRDIBCREATEPATTERNBRUSH; +} U_WMRDIBCREATEPATTERNBRUSH; -/* Index 43 U_WMRSTRETCHDIB WMF PDF 2.3.1.6 */ +/* Index 43 U_WMRSTRETCHDIB WMF manual 2.3.1.6 */ +/** WMF manual 2.3.1.6 +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type uint16_t rop3w[2]; //!< reassemble/store the Ternary raster operation rop3 value using rop3w, the 32 bit value is not aligned. - uint16_t cUsage; //!< ColorUsage enumeration + uint16_t cUsage; //!< ColorUsage Enumeration int16_t hSrc; //!< in logical units (of Src) int16_t wSrc; //!< in logical units (of Src) int16_t ySrc; //!< in logical units (UL corner of Src rect) @@ -1634,9 +1792,9 @@ typedef struct { int16_t yDst; //!< in logical units (UL corner of Dst rect) int16_t xDst; //!< in logical units (UL corner of Dst rect) uint8_t dib[1]; //!< DeviceIndependentBitmap object -} U_WMRSTRETCHDIB, *PU_WMRSTRETCHDIB; +} U_WMRSTRETCHDIB; -/* Index 48 U_WMREXTFLOODFILL WMF PDF 2.3.3.4 See Index 19*/ +/* Index 48 U_WMREXTFLOODFILL WMF manual 2.3.3.4 See Index 19*/ /* Index 4C U_WMR4C */ /* Index 4D U_WMR4D */ /* Index 4F U_WMR4F */ @@ -1788,78 +1946,90 @@ typedef struct { /* Index ED U_WMRED */ /* Index EE U_WMREE */ /* Index EF U_WMREF */ -/* Index F0 U_WMRDELETEOBJECT WMF PDF 2.3.4.7 See Index 2A */ +/* Index F0 U_WMRDELETEOBJECT WMF manual 2.3.4.7 See Index 2A */ /* Index F1 U_WMRF1 */ /* Index F2 U_WMRF2 */ /* Index F3 U_WMRF3 */ /* Index F4 U_WMRF4 */ /* Index F5 U_WMRF5 */ -/* Index F7 U_WMRCREATEPALETTE WMF PDF 2.3.4.3 See Index 36*/ +/* Index F7 U_WMRCREATEPALETTE WMF manual 2.3.4.3 See Index 36*/ /* Index F8 U_WMRF8 */ -/* Index F9 U_WMRCREATEPATTERNBRUSH WMF PDF 2.3.4.4 +/* Index F9 U_WMRCREATEPATTERNBRUSH WMF manual 2.3.4.4 */ +/** WMF manual 2.3.4.4 - This one is peculiar... + This record is peculiar... After the core structure there is: - 1. A truncated U_BITMAP16. Only the first 14 bytes are present, and the last 4 bytes (bits section) are ignored.\ - 2. 18 zero bytes (reserved) - 3. A pattern. The pattern is a byte array whose size is set by the fields in the U_BITMAP16 structure as follows: + A truncated U_BITMAP16. Only the first 14 bytes are present, and the last 4 bytes (bits section) are ignored. + 18 zero bytes (reserved) + A pattern. The pattern is a byte array whose size is set by the fields in the U_BITMAP16 structure as follows: - (((Width * BitsPixel + 15) >> 4) << 1) * Height - - brush created is BS_PATTERN + (((Width * BitsPixel + 15) >> 4) << 1) * Height + + brush created has style U_BS_PATTERN. -*/ +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type -} U_WMRCREATEPATTERNBRUSH, *PU_WMRCREATEPATTERNBRUSH; +} U_WMRCREATEPATTERNBRUSH; -/* Index FA U_WMRCREATEPENINDIRECT WMF PDF 2.3.4.5 */ +/* Index FA U_WMRCREATEPENINDIRECT WMF manual 2.3.4.5 */ +/** WMF manual 2.3.4.5 +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type U_PEN pen; //!< Pen Object -} U_WMRCREATEPENINDIRECT, *PU_WMRCREATEPENINDIRECT; +} U_WMRCREATEPENINDIRECT; -/* Index FB U_WMRCREATEFONTINDIRECT WMF PDF 2.3.4.2 */ +/* Index FB U_WMRCREATEFONTINDIRECT WMF manual 2.3.4.2 */ +/** WMF manual 2.3.4.2 +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type U_FONT font; //!< Font Object -} U_WMRCREATEFONTINDIRECT, *PU_WMRCREATEFONTINDIRECT; +} U_WMRCREATEFONTINDIRECT; -/* Index FC U_WMRCREATEBRUSHINDIRECT WMF PDF 2.3.4.1 */ +/* Index FC U_WMRCREATEBRUSHINDIRECT WMF manual 2.3.4.1 */ +/** WMF manual 2.3.4.1 +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type U_WLOGBRUSH brush; //!< WLogBrush Object -} U_WMRCREATEBRUSHINDIRECT, *PU_WMRCREATEBRUSHINDIRECT; +} U_WMRCREATEBRUSHINDIRECT; -/* Index FD U_WMRCREATEBITMAPINDIRECT in Wine, not in WMF PDF see index 2F */ +/* Index FD U_WMRCREATEBITMAPINDIRECT in GDI and Wine, not in WMF manual, see index 2F */ -/* Index FE U_WMRCREATEBITMAP in Wine, not in WMF PDF see index 2F */ +/* Index FE U_WMRCREATEBITMAP in GDI and Wine, not in WMF manual, see index 2F */ -/* Index FF U_WMRCREATEREGION WMF PDF 2.3.4.6 */ +/* Index FF U_WMRCREATEREGION WMF manual 2.3.4.6 */ +/** WMF manual 2.3.4.6 +*/ typedef struct { uint16_t Size16_4[2]; //!< Total number of 16bit words in record - uint8_t iType; //!< RecordType enumeration + uint8_t iType; //!< RecordType Enumeration uint8_t xb; //!< Extra high order byte associated with record type U_REGION region; //!< Region Object -} U_WMRCREATEREGION, *PU_WMRCREATEREGION; +} U_WMRCREATEREGION; // ************************************************************************************************ // Utility function structures +/** + Storage for keeping track of properties of the growing WMF file as records are added. +*/ typedef struct { FILE *fp; //!< Open file size_t allocated; //!< Size of the buffer @@ -1891,14 +2061,15 @@ typedef struct { uint32_t peak; //!< Highest table slot occupied (ever) } WMFHANDLES; +//! \cond // ************************************************************************************************ // Prototypes (_set first, then _get) char *wmr_dup(const char *wmr); int wmf_start(const char *name, uint32_t initsize, uint32_t chunksize, WMFTRACK **wt); int wmf_free(WMFTRACK **wt); int wmf_finish(WMFTRACK *wt); -int wmf_append(PU_METARECORD rec, WMFTRACK *wt, int freerec); -int wmf_header_append(PU_METARECORD rec,WMFTRACK *et, int freerec); +int wmf_append(U_METARECORD *rec, WMFTRACK *wt, int freerec); +int wmf_header_append(U_METARECORD *rec,WMFTRACK *et, int freerec); int wmf_readdata(const char *filename, char **contents, size_t*length); #define wmf_fopen emf_fopen int wmf_htable_create(uint32_t initsize, uint32_t chunksize, WMFHANDLES **wht); @@ -1917,34 +2088,34 @@ char *U_wmr_escnames(int idx); void U_sanerect16(U_RECT16 rc, double *left, double *top, double *right, double *bottom); -PU_FONT U_FONT_set(int16_t Height, int16_t Width, int16_t Escapement, int16_t Orientation, +U_FONT *U_FONT_set(int16_t Height, int16_t Width, int16_t Escapement, int16_t Orientation, int16_t Weight, uint8_t Italic, uint8_t Underline, uint8_t StrikeOut, uint8_t CharSet, uint8_t OutPrecision, uint8_t ClipPrecision, uint8_t Quality, uint8_t PitchAndFamily, char *FaceName); U_PLTNTRY U_PLTNTRY_set(U_COLORREF Color); -PU_PALETTE U_PLTENTRY_set(uint16_t Start, uint16_t NumEntries, PU_PLTNTRY Entries); +U_PALETTE *U_PLTENTRY_set(uint16_t Start, uint16_t NumEntries, U_PLTNTRY *Entries); U_PEN U_PEN_set(uint16_t Style, uint16_t Width, U_COLORREF Color); U_RECT16 U_RECT16_set(U_POINT16 ul,U_POINT16 lr); -PU_BITMAP16 U_BITMAP16_set(const int16_t Type, const int16_t Width, const int16_t Height, +U_BITMAP16 *U_BITMAP16_set(const int16_t Type, const int16_t Width, const int16_t Height, const int16_t LineN, const uint8_t BitsPixel, const char *Bits); -PU_SCAN U_SCAN_set(uint16_t count, uint16_t top, uint16_t bottom, uint16_t *ScanLines); -PU_REGION U_REGION_set(int16_t Size, int16_t sCount, int16_t sMax, U_RECT16 sRect, uint16_t *aScans); +U_SCAN *U_SCAN_set(uint16_t count, uint16_t top, uint16_t bottom, uint16_t *ScanLines); +U_REGION *U_REGION_set(int16_t Size, int16_t sCount, int16_t sMax, U_RECT16 sRect, uint16_t *aScans); U_WLOGBRUSH U_WLOGBRUSH_set(uint16_t Style, U_COLORREF Color, uint16_t Hatch); -PU_PAIRF U_PAIRF_set(float x, float y); +U_PAIRF *U_PAIRF_set(float x, float y); char *wdeleteobject_set(uint32_t *ihObject, WMFHANDLES *wht); char *wselectobject_set(uint32_t ihObject, WMFHANDLES *wht ); char *wcreatepenindirect_set(uint32_t *ihPen, WMFHANDLES *wht, U_PEN pen); char *wcreatebrushindirect_set(uint32_t *ihBrush, WMFHANDLES *wht, U_WLOGBRUSH lb); char *wcreatedibpatternbrush_srcdib_set(uint32_t *ihBrush, WMFHANDLES *wht, - uint32_t iUsage, const PU_BITMAPINFO Bmi, uint32_t cbPx, const char *Px); + uint32_t iUsage, const U_BITMAPINFO *Bmi, uint32_t cbPx, const char *Px); char *wcreatedibpatternbrush_srcbm16_set(uint32_t *ihBrush, WMFHANDLES *wht, - uint32_t iUsage, const PU_BITMAP16 Bm16); -char *wcreatepatternbrush_set(uint32_t *ihBrush, WMFHANDLES *wht, PU_BITMAP16 Bm16, char *Pattern); -char *wcreatefontindirect_set(uint32_t *ihFont, WMFHANDLES *wht, PU_FONT uf); -char *wcreatepalette_set(uint32_t *ihPal, WMFHANDLES *wht, PU_PALETTE up); -char *wsetpaletteentries_set(uint32_t *ihPal, WMFHANDLES *wht, const PU_PALETTE Palletes); -char *wcreateregion_set(uint32_t *ihReg, WMFHANDLES *wht, const PU_REGION Region); + uint32_t iUsage, const U_BITMAP16 *Bm16); +char *wcreatepatternbrush_set(uint32_t *ihBrush, WMFHANDLES *wht, U_BITMAP16 *Bm16, char *Pattern); +char *wcreatefontindirect_set(uint32_t *ihFont, WMFHANDLES *wht, U_FONT *uf); +char *wcreatepalette_set(uint32_t *ihPal, WMFHANDLES *wht, U_PALETTE *up); +char *wsetpaletteentries_set(uint32_t *ihPal, WMFHANDLES *wht, const U_PALETTE *Palletes); +char *wcreateregion_set(uint32_t *ihReg, WMFHANDLES *wht, const U_REGION *Region); char *wbegin_path_set(void); char *wend_path_set(void); char *wlinecap_set(int32_t Type); @@ -1952,7 +2123,7 @@ char *wlinejoin_set(int32_t Type); char *wmiterlimit_set(int32_t limit); -char *U_WMRHEADER_set(PU_PAIRF size,unsigned int dpi); +char *U_WMRHEADER_set(U_PAIRF *size,unsigned int dpi); char *U_WMREOF_set(void); char *U_WMRSETBKCOLOR_set(U_COLORREF Color); char *U_WMRSETBKMODE_set(uint16_t Mode); @@ -1988,11 +2159,11 @@ char *U_WMRSETPIXEL_set(U_COLORREF Color, U_POINT16 coord); char *U_WMROFFSETCLIPRGN_set(U_POINT16 offset); char *U_WMRTEXTOUT_set(U_POINT16 Dst, char *string); char *U_WMRBITBLT_set(U_POINT16 Dst, U_POINT16 cwh, U_POINT16 Src, - uint32_t dwRop3, const PU_BITMAP16 Bm16); + uint32_t dwRop3, const U_BITMAP16 *Bm16); char *U_WMRSTRETCHBLT_set(U_POINT16 Dst, U_POINT16 cDst, U_POINT16 Src, - U_POINT16 cSrc, uint32_t dwRop3, const PU_BITMAP16 Bm16); -char *U_WMRPOLYGON_set(uint16_t Length, const PU_POINT16 Data); -char *U_WMRPOLYLINE_set(uint16_t Length, const PU_POINT16 Data); + U_POINT16 cSrc, uint32_t dwRop3, const U_BITMAP16 *Bm16); +char *U_WMRPOLYGON_set(uint16_t Length, const U_POINT16 * Data); +char *U_WMRPOLYLINE_set(uint16_t Length, const U_POINT16 * Data); char *U_WMRESCAPE_set(uint16_t Escape, uint16_t Length, const void *Data); char *U_WMRRESTOREDC_set(int16_t DC); char *U_WMRFILLREGION_set(uint16_t Region, uint16_t Brush); @@ -2002,16 +2173,16 @@ char *U_WMRPAINTREGION_set(uint16_t Region); char *U_WMRSELECTCLIPREGION_set(uint16_t Region); char *U_WMRSELECTOBJECT_set(uint16_t object); char *U_WMRSETTEXTALIGN_set(uint16_t Mode); -char *U_WMRDRAWTEXT_set(void); /* in Wine, not in WMF PDF. */ +char *U_WMRDRAWTEXT_set(void); /* in GDI and Wine, not in WMF manual. */ char *U_WMRCHORD_set(U_POINT16 Radial1, U_POINT16 Radial2, U_RECT16 rect); char *U_WMRSETMAPPERFLAGS_set(uint32_t Mode); char *U_WMREXTTEXTOUT_set(U_POINT16 Dst, int16_t Length, uint16_t Opts, const char *string, int16_t *dx, U_RECT16 rect); char *U_WMRSETDIBTODEV_set(void); char *U_WMRSELECTPALETTE_set(uint16_t Palette); char *U_WMRREALIZEPALETTE_set(void); -char *U_WMRANIMATEPALETTE_set(PU_PALETTE Palette); -char *U_WMRSETPALENTRIES_set(PU_PALETTE Palette); -char *U_WMRPOLYPOLYGON_set(const uint16_t, const uint16_t *aPolyCounts, const PU_POINT16 points); +char *U_WMRANIMATEPALETTE_set(U_PALETTE *Palette); +char *U_WMRSETPALENTRIES_set(const U_PALETTE *Palette); +char *U_WMRPOLYPOLYGON_set(const uint16_t, const uint16_t *aPolyCounts, const U_POINT16 * points); char *U_WMRRESIZEPALETTE_set(uint16_t Palette); char *U_WMR3A_set(void); char *U_WMR3B_set(void); @@ -2020,13 +2191,13 @@ char *U_WMR3D_set(void); char *U_WMR3E_set(void); char *U_WMR3F_set(void); char *U_WMRDIBBITBLT_set(U_POINT16 Dst, U_POINT16 cwh, U_POINT16 Src, - uint32_t dwRop3, const PU_BITMAPINFO Bmi, uint32_t cbPx, const char *Px); + uint32_t dwRop3, const U_BITMAPINFO * Bmi, uint32_t cbPx, const char *Px); char *U_WMRDIBSTRETCHBLT_set(U_POINT16 Dst, U_POINT16 cDst, U_POINT16 Src, - U_POINT16 cSrc, uint32_t dwRop3, const PU_BITMAPINFO Bmi, uint32_t cbPx, const char *Px); + U_POINT16 cSrc, uint32_t dwRop3, const U_BITMAPINFO *Bmi, uint32_t cbPx, const char *Px); char *U_WMRDIBCREATEPATTERNBRUSH_set(const uint16_t Style, const uint16_t iUsage, - PU_BITMAPINFO Bmi, uint32_t cbPx, const char *Px, PU_BITMAP16 Bm16); + const U_BITMAPINFO *Bmi, uint32_t cbPx, const char *Px, const U_BITMAP16 *Bm16); char *U_WMRSTRETCHDIB_set(U_POINT16 Dest, U_POINT16 cDest, U_POINT16 Src, U_POINT16 cSrc, - const uint16_t cUsage, uint32_t dwRop3, const PU_BITMAPINFO Bmi, uint32_t cbPx, const char *Px); + const uint16_t cUsage, uint32_t dwRop3, const U_BITMAPINFO *Bmi, uint32_t cbPx, const char *Px); char *U_WMR44_set(void); char *U_WMR45_set(void); char *U_WMR46_set(void); @@ -2206,21 +2377,21 @@ char *U_WMRF3_set(void); char *U_WMRF4_set(void); char *U_WMRF5_set(void); char *U_WMRF6_set(void); -char *U_WMRCREATEPALETTE_set(PU_PALETTE Palette); +char *U_WMRCREATEPALETTE_set(U_PALETTE *Palette); char *U_WMRF8_set(void); -char *U_WMRCREATEPATTERNBRUSH_set(PU_BITMAP16 Bm16, char *Pattern); +char *U_WMRCREATEPATTERNBRUSH_set(U_BITMAP16 *Bm16, char *Pattern); char *U_WMRCREATEPENINDIRECT_set(U_PEN pen); -char *U_WMRCREATEFONTINDIRECT_set(PU_FONT font); +char *U_WMRCREATEFONTINDIRECT_set(U_FONT *font); char *U_WMRCREATEBRUSHINDIRECT_set(U_WLOGBRUSH brush); -char *U_WMRCREATEBITMAPINDIRECT_set(void); /* in Wine, not in WMF PDF*/ -char *U_WMRCREATEBITMAP_set(void); /* in Wine, not in WMF PDF */ -char *U_WMRCREATEREGION_set(PU_REGION region); +char *U_WMRCREATEBITMAPINDIRECT_set(void); /* in GDI and Wine, not in WMF manual. */ +char *U_WMRCREATEBITMAP_set(void); /* in GDI and Wine, not in WMF manual. */ +char *U_WMRCREATEREGION_set(const U_REGION *region); int16_t *dx16_get( int32_t height, uint32_t weight, uint32_t members); size_t U_WMRRECSAFE_get(const char *contents, const char *blimit); -int wmfheader_get(const char *contents, const char *blimit, PU_WMRPLACEABLE Placeable, PU_WMRHEADER Header); +int wmfheader_get(const char *contents, const char *blimit, U_WMRPLACEABLE *Placeable, U_WMRHEADER *Header); int wmr_arc_points(U_RECT16 rclBox, U_POINT16 ArcStart, U_POINT16 ArcEnd, - int *f1, int f2, PU_PAIRF center, PU_PAIRF start, PU_PAIRF end, PU_PAIRF size ); + int *f1, int f2, U_PAIRF *center, U_PAIRF *start, U_PAIRF *end, U_PAIRF *size ); void U_BITMAPINFOHEADER_get(const char *Bmih, uint32_t *Size, int32_t *Width, int32_t *Height, uint32_t *Planes, uint32_t *BitCount, uint32_t *Compression, uint32_t *SizeImage, int32_t *XPelsPerMeter, int32_t *YPelsPerMeter, uint32_t *ClrUsed, uint32_t *ClrImportant); @@ -2228,7 +2399,7 @@ void U_BITMAPCOREHEADER_get(const char *BmiCh, int32_t *Size, int32_t *W int wget_DIB_params(const char *dib, const char **px, const U_RGBQUAD **ct, int32_t *numCt, int32_t *width, int32_t *height, int32_t *colortype, int32_t *invert); int U_WMREOF_get(const char *contents); -int U_WMRSETBKCOLOR_get(const char *contents, PU_COLORREF Color); +int U_WMRSETBKCOLOR_get(const char *contents, U_COLORREF *Color); int U_WMRSETBKMODE_get(const char *contents, uint16_t *Mode); int U_WMRSETMAPMODE_get(const char *contents, uint16_t *Mode); int U_WMRSETROP2_get(const char *contents, uint16_t *Mode); @@ -2236,33 +2407,33 @@ int U_WMRSETRELABS_get(const char *contents); int U_WMRSETPOLYFILLMODE_get(const char *contents, uint16_t *Mode); int U_WMRSETSTRETCHBLTMODE_get(const char *contents, uint16_t *Mode); int U_WMRSETTEXTCHAREXTRA_get(const char *contents, uint16_t *Mode); -int U_WMRSETTEXTCOLOR_get(const char *contents, PU_COLORREF Color); +int U_WMRSETTEXTCOLOR_get(const char *contents, U_COLORREF *Color); int U_WMRSETTEXTJUSTIFICATION_get(const char *contents, uint16_t *Count, uint16_t *Extra); -int U_WMRSETWINDOWORG_get(const char *contents, PU_POINT16 coord); -int U_WMRSETWINDOWEXT_get(const char *contents, PU_POINT16 extent); -int U_WMRSETVIEWPORTORG_get(const char *contents, PU_POINT16 coord); -int U_WMRSETVIEWPORTEXT_get(const char *contents, PU_POINT16 extent); -int U_WMROFFSETWINDOWORG_get(const char *contents, PU_POINT16 offset); -int U_WMRSCALEWINDOWEXT_get(const char *contents, PU_POINT16 Denom, PU_POINT16 Num); -int U_WMROFFSETVIEWPORTORG_get(const char *contents, PU_POINT16 offset); -int U_WMRSCALEVIEWPORTEXT_get(const char *contents, PU_POINT16 Denom, PU_POINT16 Num); -int U_WMRLINETO_get(const char *contents, PU_POINT16 coord); -int U_WMRMOVETO_get(const char *contents, PU_POINT16 coord); -int U_WMREXCLUDECLIPRECT_get(const char *contents, PU_RECT16 rect); -int U_WMRINTERSECTCLIPRECT_get(const char *contents, PU_RECT16 rect); -int U_WMRARC_get(const char *contents, PU_POINT16 StartArc, PU_POINT16 EndArc, PU_RECT16 rect); -int U_WMRELLIPSE_get(const char *contents, PU_RECT16 rect); -int U_WMRFLOODFILL_get(const char *contents, uint16_t *Mode, PU_COLORREF Color, PU_POINT16 coord); -int U_WMRPIE_get(const char *contents, PU_POINT16 Radial1, PU_POINT16 Radial2, PU_RECT16 rect); -int U_WMRRECTANGLE_get(const char *contents, PU_RECT16 rect); -int U_WMRROUNDRECT_get(const char *contents, int16_t *Width, int16_t *Height, PU_RECT16 rect); -int U_WMRPATBLT_get(const char *contents, PU_POINT16 Dst, PU_POINT16 cwh, uint32_t *dwRop3); +int U_WMRSETWINDOWORG_get(const char *contents, U_POINT16 * coord); +int U_WMRSETWINDOWEXT_get(const char *contents, U_POINT16 * extent); +int U_WMRSETVIEWPORTORG_get(const char *contents, U_POINT16 * coord); +int U_WMRSETVIEWPORTEXT_get(const char *contents, U_POINT16 * extent); +int U_WMROFFSETWINDOWORG_get(const char *contents, U_POINT16 * offset); +int U_WMRSCALEWINDOWEXT_get(const char *contents, U_POINT16 * Denom, U_POINT16 * Num); +int U_WMROFFSETVIEWPORTORG_get(const char *contents, U_POINT16 * offset); +int U_WMRSCALEVIEWPORTEXT_get(const char *contents, U_POINT16 * Denom, U_POINT16 * Num); +int U_WMRLINETO_get(const char *contents, U_POINT16 * coord); +int U_WMRMOVETO_get(const char *contents, U_POINT16 * coord); +int U_WMREXCLUDECLIPRECT_get(const char *contents, U_RECT16 * rect); +int U_WMRINTERSECTCLIPRECT_get(const char *contents, U_RECT16 * rect); +int U_WMRARC_get(const char *contents, U_POINT16 * StartArc, U_POINT16 * EndArc, U_RECT16 * rect); +int U_WMRELLIPSE_get(const char *contents, U_RECT16 * rect); +int U_WMRFLOODFILL_get(const char *contents, uint16_t *Mode, U_COLORREF *Color, U_POINT16 * coord); +int U_WMRPIE_get(const char *contents, U_POINT16 * Radial1, U_POINT16 * Radial2, U_RECT16 * rect); +int U_WMRRECTANGLE_get(const char *contents, U_RECT16 * rect); +int U_WMRROUNDRECT_get(const char *contents, int16_t *Width, int16_t *Height, U_RECT16 * rect); +int U_WMRPATBLT_get(const char *contents, U_POINT16 * Dst, U_POINT16 * cwh, uint32_t *dwRop3); int U_WMRSAVEDC_get(const char *contents); -int U_WMRSETPIXEL_get(const char *contents, PU_COLORREF Color, PU_POINT16 coord); -int U_WMROFFSETCLIPRGN_get(const char *contents, PU_POINT16 offset); -int U_WMRTEXTOUT_get(const char *contents, PU_POINT16 Dst, int16_t *Length, const char **string); -int U_WMRBITBLT_get(const char *contents, PU_POINT16 Dst, PU_POINT16 cwh, PU_POINT16 Src, uint32_t *dwRop3, PU_BITMAP16 Bm16, const char **px); -int U_WMRSTRETCHBLT_get(const char *contents, PU_POINT16 Dst, PU_POINT16 cDst, PU_POINT16 Src, PU_POINT16 cSrc, uint32_t *dwRop3, PU_BITMAP16 Bm16, const char **px); +int U_WMRSETPIXEL_get(const char *contents, U_COLORREF *Color, U_POINT16 * coord); +int U_WMROFFSETCLIPRGN_get(const char *contents, U_POINT16 * offset); +int U_WMRTEXTOUT_get(const char *contents, U_POINT16 * Dst, int16_t *Length, const char **string); +int U_WMRBITBLT_get(const char *contents, U_POINT16 * Dst, U_POINT16 * cwh, U_POINT16 * Src, uint32_t *dwRop3, U_BITMAP16 *Bm16, const char **px); +int U_WMRSTRETCHBLT_get(const char *contents, U_POINT16 * Dst, U_POINT16 * cDst, U_POINT16 * Src, U_POINT16 * cSrc, uint32_t *dwRop3, U_BITMAP16 *Bm16, const char **px); int U_WMRPOLYGON_get(const char *contents, uint16_t *Length, const char **Data); int U_WMRPOLYLINE_get(const char *contents, uint16_t *Length, const char **Data); int U_WMRESCAPE_get(const char *contents, uint16_t *Escape, uint16_t *Length, const char **Data); @@ -2274,15 +2445,15 @@ int U_WMRPAINTREGION_get(const char *contents, uint16_t *Region); int U_WMRSELECTCLIPREGION_get(const char *contents, uint16_t *Region); int U_WMRSELECTOBJECT_get(const char *contents, uint16_t *Object); int U_WMRSETTEXTALIGN_get(const char *contents, uint16_t *Mode); -int U_WMRDRAWTEXT_get(void); /* in Wine, not in WMF PDF. */ -int U_WMRCHORD_get(const char *contents, PU_POINT16 Radial1, PU_POINT16 Radial2, PU_RECT16 rect); +int U_WMRDRAWTEXT_get(void); /* in GDI and Wine, not in WMF manual. */ +int U_WMRCHORD_get(const char *contents, U_POINT16 * Radial1, U_POINT16 * Radial2, U_RECT16 * rect); int U_WMRSETMAPPERFLAGS_get(const char *contents, uint32_t *Mode); -int U_WMREXTTEXTOUT_get(const char *contents, PU_POINT16 Dst, int16_t *Length, uint16_t *Opts, const char **string, const int16_t **dx, PU_RECT16 rect); -int U_WMRSETDIBTODEV_get(const char *contents, PU_POINT16 Dst, PU_POINT16 cwh, PU_POINT16 Src, uint16_t *cUsage, uint16_t *ScanCount, uint16_t *StartScan, const char **dib); +int U_WMREXTTEXTOUT_get(const char *contents, U_POINT16 * Dst, int16_t *Length, uint16_t *Opts, const char **string, const int16_t **dx, U_RECT16 * rect); +int U_WMRSETDIBTODEV_get(const char *contents, U_POINT16 * Dst, U_POINT16 * cwh, U_POINT16 * Src, uint16_t *cUsage, uint16_t *ScanCount, uint16_t *StartScan, const char **dib); int U_WMRSELECTPALETTE_get(const char *contents, uint16_t *Palette); int U_WMRREALIZEPALETTE_get(const char *contents); -int U_WMRANIMATEPALETTE_get(const char *contents, PU_PALETTE Palette, const char **PalEntries); -int U_WMRSETPALENTRIES_get(const char *contents, PU_PALETTE Palette, const char **PalEntries); +int U_WMRANIMATEPALETTE_get(const char *contents, U_PALETTE *Palette, const char **PalEntries); +int U_WMRSETPALENTRIES_get(const char *contents, U_PALETTE *Palette, const char **PalEntries); int U_WMRPOLYPOLYGON_get(const char *contents, uint16_t *nPolys, const uint16_t **aPolyCounts, const char **Points); int U_WMRRESIZEPALETTE_get(const char *contents, uint16_t *Palette); int U_WMR3A_get(void); @@ -2291,15 +2462,15 @@ int U_WMR3C_get(void); int U_WMR3D_get(void); int U_WMR3E_get(void); int U_WMR3F_get(void); -int U_WMRDIBBITBLT_get(const char *contents, PU_POINT16 Dst, PU_POINT16 cwh, PU_POINT16 Src, uint32_t *dwRop3, const char **dib); -int U_WMRDIBSTRETCHBLT_get(const char *contents, PU_POINT16 Dst, PU_POINT16 cDst, PU_POINT16 Src, PU_POINT16 cSrc, uint32_t *dwRop3, const char **dib); +int U_WMRDIBBITBLT_get(const char *contents, U_POINT16 * Dst, U_POINT16 * cwh, U_POINT16 * Src, uint32_t *dwRop3, const char **dib); +int U_WMRDIBSTRETCHBLT_get(const char *contents, U_POINT16 * Dst, U_POINT16 * cDst, U_POINT16 * Src, U_POINT16 * cSrc, uint32_t *dwRop3, const char **dib); int U_WMRDIBCREATEPATTERNBRUSH_get(const char *contents, uint16_t *Style, uint16_t *cUsage, const char **Bm16, const char **dib); -int U_WMRSTRETCHDIB_get(const char *contents, PU_POINT16 Dst, PU_POINT16 cDst, PU_POINT16 Src, PU_POINT16 cSrc, uint16_t *cUsage, uint32_t *dwRop3, const char **dib); +int U_WMRSTRETCHDIB_get(const char *contents, U_POINT16 * Dst, U_POINT16 * cDst, U_POINT16 * Src, U_POINT16 * cSrc, uint16_t *cUsage, uint32_t *dwRop3, const char **dib); int U_WMR44_get(void); int U_WMR45_get(void); int U_WMR46_get(void); int U_WMR47_get(void); -int U_WMREXTFLOODFILL_get(const char *contents, uint16_t *Mode, PU_COLORREF Color, PU_POINT16 coord); +int U_WMREXTFLOODFILL_get(const char *contents, uint16_t *Mode, U_COLORREF *Color, U_POINT16 * coord); int U_WMR49_get(void); int U_WMR4A_get(void); int U_WMR4B_get(void); @@ -2474,15 +2645,16 @@ int U_WMRF3_get(void); int U_WMRF4_get(void); int U_WMRF5_get(void); int U_WMRF6_get(void); -int U_WMRCREATEPALETTE_get(const char *contents, PU_PALETTE Palette, const char **PalEntries); +int U_WMRCREATEPALETTE_get(const char *contents, U_PALETTE *Palette, const char **PalEntries); int U_WMRF8_get(void); -int U_WMRCREATEPATTERNBRUSH_get(const char *contents, PU_BITMAP16 Bm16, int *pasize, const char **Pattern); -int U_WMRCREATEPENINDIRECT_get(const char *contents, PU_PEN pen); +int U_WMRCREATEPATTERNBRUSH_get(const char *contents, U_BITMAP16 *Bm16, int *pasize, const char **Pattern); +int U_WMRCREATEPENINDIRECT_get(const char *contents, U_PEN *pen); int U_WMRCREATEFONTINDIRECT_get(const char *contents, const char **font); int U_WMRCREATEBRUSHINDIRECT_get(const char *contents, const char **brush); int U_WMRCREATEBITMAPINDIRECT_get(void); int U_WMRCREATEBITMAP_get(void); int U_WMRCREATEREGION_get(const char *contents, const char **Region); +//! \endcond #ifdef __cplusplus diff --git a/src/libuemf/uwmf_endian.c b/src/libuemf/uwmf_endian.c index e14c7aa77..6caa24d8f 100644 --- a/src/libuemf/uwmf_endian.c +++ b/src/libuemf/uwmf_endian.c @@ -1,5 +1,7 @@ /** - @file uwmf_endian.c Functions for Swaping WMF records + @file uwmf_endian.c + + @brief Functions for converting WMF records between Big Endian and Little Endian byte orders. */ /* @@ -23,7 +25,7 @@ extern "C" { #include "uwmf_endian.h" // hide almost everything in this file from Doxygen -//! @cond +//! \cond /* Prototypes for functions used here and defined in uemf_endian.c, but which are not supposed to be used in end user code. */ @@ -273,8 +275,6 @@ int wmfheader_swap( -// hide these from Doxygen -//! @cond /* ********************************************************************************************** These functions contain shared code used by various U_WMR*_Swap functions. These should NEVER be called by end user code and to further that end prototypes are NOT provided and they are hidden from Doxygen. @@ -327,9 +327,6 @@ void U_WMRCORE_U16_CR_2U16_swap(char *record, int torev){ U_swap2(record+off, 2); } - -//! @endcond - /* ********************************************************************************************** These are the core WMR functions, each creates a particular type of record. All return these records via a char* pointer, which is NULL if the call failed. @@ -1465,7 +1462,7 @@ void U_WMRCREATEREGION_swap(char *record, int torev){ U_WMRCORE_SIZE16_swap(record, torev); region_swap(record + offsetof(U_WMRCREATEREGION,region), torev); } -//! @endcond +//! \endcond /** \brief Convert an entire WMF in memory from Big Endian to Little Endian (or vice versa). diff --git a/src/libuemf/uwmf_endian.h b/src/libuemf/uwmf_endian.h index dc01c0d07..57fd4ae44 100644 --- a/src/libuemf/uwmf_endian.h +++ b/src/libuemf/uwmf_endian.h @@ -1,11 +1,13 @@ /** - @file uemf_endian.h Prototype for function for converting EMF records between Big Endian and Little Endian + @file uwmf_endian.h + + @brief Prototypes for functions for converting WMF records between Big Endian and Little Endian */ /* File: uwmf_endian.h -Version: 0.0.1 -Date: 10-JAN-2013 +Version: 0.0.2 +Date: 26-NOV-2013 Author: David Mathog, Biology Division, Caltech email: mathog@caltech.edu Copyright: 2013 David Mathog and California Institute of Technology (Caltech) @@ -20,17 +22,10 @@ extern "C" { #include "uemf_endian.h" -/* There is no way for the preprocessor, in general, to figure out endianness. So the command line must define - WORDS_BIGENDIAN for a big endian machine. Otherwise we assume is is little endian. If it is something - else this code won't work in any case. */ -#ifdef WORDS_BIGENDIAN -#define U_BYTE_SWAP 1 -#else -#define U_BYTE_SWAP 0 -#endif - +//! \cond // prototypes int U_wmf_endian(char *contents, size_t length, int torev); +//! \endcond #ifdef __cplusplus } diff --git a/src/libuemf/uwmf_print.c b/src/libuemf/uwmf_print.c index d044cf9b6..d120a2da0 100644 --- a/src/libuemf/uwmf_print.c +++ b/src/libuemf/uwmf_print.c @@ -1,11 +1,13 @@ /** - @file uwmf_print.c Functions for printing WMF records + @file uwmf_print.c + + @brief Functions for printing WMF records */ /* File: uwmf_print.c -Version: 0.0.2 -Date: 18-FEB-2013 +Version: 0.0.3 +Date: 17-OCT-2013 Author: David Mathog, Biology Division, Caltech email: mathog@caltech.edu Copyright: 2012 David Mathog and California Institute of Technology (Caltech) @@ -21,6 +23,10 @@ extern "C" { #include #include "uwmf_print.h" +//! \cond + +#define UNUSED(x) (void)(x) + /* ********************************************************************************************** These functions print standard objects used in the WMR records. The low level ones do not append EOL. @@ -112,7 +118,7 @@ void pltntry_print( \param PalEntries Array of Palette Entries */ void palette_print( - const PU_PALETTE p, + const U_PALETTE *p, const char *PalEntries ){ int i; @@ -374,8 +380,6 @@ int wmfheader_print( -// hide these from Doxygen -//! @cond /* ********************************************************************************************** These functions contain shared code used by various U_WMR*_print functions. These should NEVER be called by end user code and to further that end prototypes are NOT provided and they are hidden from Doxygen. @@ -395,8 +399,6 @@ void wcore_points_print(uint16_t nPoints, const char *aPoints){ -//! @endcond - /* ********************************************************************************************** These are the core WMR functions, each creates a particular type of record. All return these records via a char* pointer, which is NULL if the call failed. @@ -408,12 +410,12 @@ They are listed in order by the corresponding U_WMR_* index number. \param contents pointer to a buffer holding a WMR record */ void U_WMRNOTIMPLEMENTED_print(const char *contents){ - (void) contents; + UNUSED(contents); printf(" Not Implemented!\n"); } void U_WMREOF_print(const char *contents){ - (void) contents; + UNUSED(contents); } void U_WMRSETBKCOLOR_print(const char *contents){ @@ -449,7 +451,7 @@ void U_WMRSETROP2_print(const char *contents){ } void U_WMRSETRELABS_print(const char *contents){ - (void) contents; + UNUSED(contents); /* This record type has only the common 6 bytes, so nothing (else) to print */ } @@ -685,7 +687,7 @@ void U_WMRPATBLT_print(const char *contents){ } void U_WMRSAVEDC_print(const char *contents){ - (void) contents; + UNUSED(contents); /* This record type has only the common 6 bytes, so nothing (else) to print */ } @@ -790,7 +792,7 @@ void U_WMRESCAPE_print(const char *contents){ } void U_WMRRESTOREDC_print(const char *contents){ - (void) contents; + UNUSED(contents); /* This record type has only the common 6 bytes, so nothing (else) to print */ } @@ -933,7 +935,7 @@ void U_WMRSELECTPALETTE_print(const char *contents){ } void U_WMRREALIZEPALETTE_print(const char *contents){ - (void) contents; + UNUSED(contents); /* This record type has only the common 6 bytes, so nothing (else) to print */ } @@ -1324,6 +1326,8 @@ void U_WMRCREATEREGION_print(const char *contents){ } } +//! \endcond + /** \brief Print any record in a wmf \returns record length for a normal record, 0 for WMREOF, -1 for a bad record @@ -1347,11 +1351,11 @@ int U_wmf_onerec_print(const char *contents, const char *blimit, int recnum, siz iType = *(uint8_t *)(contents + offsetof(U_METARECORD, iType ) ); -#if 1 /* show record checksums, this is NOT portable, result changes with endian type, useful for debugging */ - printf("%-30srecord:%5d type:%3u offset:%8d size:%8u\n", +#if 1 + printf("%-30srecord:%5d type:%-4u offset:%8d rsize:%8u\n", U_wmr_names(iType), recnum, iType, (int) off, (int) size); -#else - printf("%-30srecord:%5d type:%3u offset:%8d size:%8u recchecksum:%u\n", +#else /* show record checksums, this is NOT portable, result changes with endian type, useful for debugging */ + printf("%-30srecord:%5d type:%-4u offset:%8d size:%8u recchecksum:%u\n", U_wmr_names(iType), recnum, iType, (int) off, (int) size, U_16_checksum((int16_t *)contents, size)); #endif diff --git a/src/libuemf/uwmf_print.h b/src/libuemf/uwmf_print.h index 31a8df5dc..8daee0feb 100644 --- a/src/libuemf/uwmf_print.h +++ b/src/libuemf/uwmf_print.h @@ -1,5 +1,7 @@ /** - @file uwmf_print.h Functions for printing records from WMF files. + @file uwmf_print.h + + @brief Prototypes for functions for printing records from WMF files. */ /* @@ -20,11 +22,12 @@ extern "C" { #include "uwmf.h" #include "uemf_print.h" +//! \cond /* prototypes for objects used in WMR records (other than those defined in uemf_print.h) */ void brush_print(U_BRUSH b); void font_print(const char *font); void pltntry_print(U_PLTNTRY pny); -void palette_print(const PU_PALETTE p, const char *PalEntries); +void palette_print(const U_PALETTE *p, const char *PalEntries); void pen_print(U_PEN p); void rect16_ltrb_print(U_RECT16 rect); void rect16_brtl_print(U_RECT16 rect); @@ -40,6 +43,7 @@ void dibheader_print(const void *dh); int wmfheader_print(const char *contents, const char *blimit); void U_WMRNOTIMPLEMENTED_print(const char *contents); int U_wmf_onerec_print(const char *contents, const char *blimit, int recnum, size_t off); +//! \endcond #ifdef __cplusplus } -- cgit v1.2.3 From 8ce1d4c9f4cad86fb0b1f63c6b25838c8c6d640d Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Fri, 17 Jan 2014 23:51:59 -0500 Subject: Fix missing embeded image condition, kindly caught by suv in bug #1270334 Fixed bugs: - https://launchpad.net/bugs/1270334 (bzr r12954) --- src/sp-image.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/sp-image.cpp b/src/sp-image.cpp index f4995ce31..b08d6f9b0 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -340,13 +340,18 @@ void SPImage::update(SPCtx *ctx, unsigned int flags) { this->getRepr()->attribute("sodipodi:absref"), doc->getBase()); - if(filename && g_str_has_suffix(filename, ".svg")) { + Inkscape::Pixbuf::create_from_data_uri(filename); + if (strncmp (filename,"data:", 5) == 0) { + filename += 5; + pixbuf = Inkscape::Pixbuf::create_from_data_uri(filename); + } else if(filename && g_str_has_suffix(filename, ".svg")) { // TODO: We want to deal with svg images properly. This // space allows us to do so later. g_warning("Including svg images tags is not yet supported."); } else if (filename) { pixbuf = Inkscape::Pixbuf::create_from_file(filename); - } else { + } + if(!pixbuf) { /* Nope: We do not find any valid pixmap file :-( */ pixbuf = new Inkscape::Pixbuf( gdk_pixbuf_new_from_xpm_data((const gchar **) brokenimage_xpm)); @@ -671,7 +676,7 @@ gchar const *sp_image_repr_read_filename(gchar const *href, gchar const *absref, filename = g_filename_from_uri(filename, NULL, NULL); } else if (strncmp (filename,"data:",5) == 0) { /* data URI - embedded image */ - filename += 5; + return filename; } else if (!g_path_is_absolute (filename)) { /* try to load from relative pos combined with document base*/ const gchar *docbase = base; -- cgit v1.2.3 From eac3c11251e65774a2f4f610f2799592978487d8 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Sun, 19 Jan 2014 00:38:09 -0500 Subject: Try another fix for the undo when dragging bug #168695 Fixed bugs: - https://launchpad.net/bugs/168695 (bzr r12955) --- src/document-undo.cpp | 2 +- src/ui/tools/tool-base.cpp | 14 +++++++++++--- src/ui/tools/tool-base.h | 1 + 3 files changed, 13 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/document-undo.cpp b/src/document-undo.cpp index 312ccb7f8..bad4d6c81 100644 --- a/src/document-undo.cpp +++ b/src/document-undo.cpp @@ -242,7 +242,7 @@ gboolean Inkscape::DocumentUndo::undo(SPDocument *doc) g_assert (doc != NULL); g_assert (doc->priv != NULL); - g_assert (doc->priv->sensitive); + g_return_val_if_fail (doc->priv->sensitive, FALSE); doc->priv->sensitive = FALSE; doc->priv->seeking = true; diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp index 6c7867633..f8868ec0e 100644 --- a/src/ui/tools/tool-base.cpp +++ b/src/ui/tools/tool-base.cpp @@ -57,6 +57,7 @@ #include "shape-editor.h" #include "sp-guide.h" #include "color.h" +#include "document-undo.h" // globals for temporary switching to selector by space static bool selector_toggled = FALSE; @@ -977,9 +978,16 @@ gint sp_event_context_root_handler(ToolBase * event_context, gint sp_event_context_virtual_root_handler(ToolBase * event_context, GdkEvent * event) { gint ret = false; - if (event_context) { // If no event-context is available then do nothing, otherwise Inkscape would crash - // (see the comment in SPDesktop::set_event_context, and bug LP #622350) - //ret = (SP_EVENT_CONTEXT_CLASS(G_OBJECT_GET_CLASS(event_context)))->root_handler(event_context, event); + if (event_context) { + // We want to disable undo while we drag anything + SPDocument *document = sp_desktop_document(event_context->desktop); + if (event->type == GDK_BUTTON_PRESS) { + event_context->undo_sensitive = DocumentUndo::getUndoSensitive(document); + DocumentUndo::setUndoSensitive(document, false); + } else if (event->type == GDK_BUTTON_RELEASE) { + DocumentUndo::setUndoSensitive(document, event_context->undo_sensitive); + } + ret = event_context->root_handler(event); set_event_location(event_context->desktop, event); diff --git a/src/ui/tools/tool-base.h b/src/ui/tools/tool-base.h index 7ed5875b1..068bc6402 100644 --- a/src/ui/tools/tool-base.h +++ b/src/ui/tools/tool-base.h @@ -119,6 +119,7 @@ public: gint xp, yp; ///< where drag started gint tolerance; bool within_tolerance; ///< are we still within tolerance of origin + bool undo_sensitive; /// Was undo previously sensitive before drag SPItem *item_to_select; ///< the item where mouse_press occurred, to ///< be selected if this is a click not drag -- cgit v1.2.3 From e5feb4b17ce16b17ee7ff19188072c25c736bf90 Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Sun, 19 Jan 2014 07:43:14 -0500 Subject: fix scaling crash caused by negative stroke (Bug 1270464) Fixed bugs: - https://launchpad.net/bugs/1270464 (bzr r12956) --- src/sp-item-transform.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/sp-item-transform.cpp b/src/sp-item-transform.cpp index 9dbe412d7..854fb9cd7 100644 --- a/src/sp-item-transform.cpp +++ b/src/sp-item-transform.cpp @@ -110,6 +110,9 @@ Geom::Affine get_scale_transform_for_uniform_stroke(Geom::Rect const &bbox_visua // -> The width and height of the geometric bounding box will therefore be (w0 - 2*0.5*r0) and (h0 - 2*0.5*r0) // 4) If preserve transforms is true, then stroke_x != stroke_y, since these are the apparent stroke widths, after transforming + if ((stroke_x == Geom::infinity()) || (fabs(stroke_x) < 1e-6)) stroke_x = 0; + if ((stroke_y == Geom::infinity()) || (fabs(stroke_y) < 1e-6)) stroke_y = 0; + gdouble w0 = bbox_visual.width(); // will return a value >= 0, as required further down the road gdouble h0 = bbox_visual.height(); gdouble r0 = sqrt(stroke_x*stroke_y); // r0 is redundant, used only for those cases where stroke_x = stroke_y -- cgit v1.2.3 From 5b1689d145435a515d0affcd3b6f3b3ae0e18111 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Sun, 19 Jan 2014 16:25:49 +0100 Subject: LPE strings consistency fix. (bzr r12957) --- src/live_effects/lpe-angle_bisector.cpp | 2 +- src/live_effects/lpe-perp_bisector.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-angle_bisector.cpp b/src/live_effects/lpe-angle_bisector.cpp index 2f57b710b..1acf9605f 100644 --- a/src/live_effects/lpe-angle_bisector.cpp +++ b/src/live_effects/lpe-angle_bisector.cpp @@ -89,7 +89,7 @@ LPEAngleBisector::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *deskt { KnotHolderEntity *e = new AB::KnotHolderEntityRightEnd(this); e->create( desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, - _("Adjust the \"right\" of the bisector") ); + _("Adjust the \"right\" end of the bisector") ); knotholder->add(e); } }; diff --git a/src/live_effects/lpe-perp_bisector.cpp b/src/live_effects/lpe-perp_bisector.cpp index c2a25a187..feed55b26 100644 --- a/src/live_effects/lpe-perp_bisector.cpp +++ b/src/live_effects/lpe-perp_bisector.cpp @@ -156,13 +156,13 @@ LPEPerpBisector::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *deskto { KnotHolderEntity *e = new PB::KnotHolderEntityLeftEnd(this); e->create( desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, - _("Adjust the bisector's \"left\" end") ); + _("Adjust the \"left\" end of the bisector") ); knotholder->add(e); } { KnotHolderEntity *e = new PB::KnotHolderEntityRightEnd(this); e->create( desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, - _("Adjust the bisector's \"right\" end") ); + _("Adjust the \"right\" end of the bisector") ); knotholder->add(e); } }; -- cgit v1.2.3 From 367d97e047f3b1e1fe544efb7f15061d1e83fbf0 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Sun, 19 Jan 2014 16:48:47 +0100 Subject: i18n. No need to translate strings with one single space. (bzr r12958) --- src/ui/dialog/template-widget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp index d1697244e..d8e6f9b4f 100644 --- a/src/ui/dialog/template-widget.cpp +++ b/src/ui/dialog/template-widget.cpp @@ -34,7 +34,7 @@ namespace UI { TemplateWidget::TemplateWidget() : _more_info_button(_("More info")) - , _short_description_label(_(" ")) + , _short_description_label(" ") , _template_name_label(_("no template selected")) , _effect_prefs(NULL) { -- cgit v1.2.3 From 9f50a2b092e521634ceec0a9b06369d6a04708b2 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Sun, 19 Jan 2014 16:18:27 -0500 Subject: Allow undo methods to survive a non-sensitive call. (bzr r12959) --- src/document-undo.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/document-undo.cpp b/src/document-undo.cpp index bad4d6c81..4a4156a70 100644 --- a/src/document-undo.cpp +++ b/src/document-undo.cpp @@ -155,7 +155,7 @@ void Inkscape::DocumentUndo::maybeDone(SPDocument *doc, const gchar *key, const { g_assert (doc != NULL); g_assert (doc->priv != NULL); - g_assert (doc->priv->sensitive); + g_return_if_fail(doc->priv->sensitive); if ( key && !*key ) { g_warning("Blank undo key specified."); } @@ -204,7 +204,7 @@ void Inkscape::DocumentUndo::cancel(SPDocument *doc) { g_assert (doc != NULL); g_assert (doc->priv != NULL); - g_assert (doc->priv->sensitive); + g_return_if_fail(doc->priv->sensitive); sp_repr_rollback (doc->rdoc); @@ -287,7 +287,7 @@ gboolean Inkscape::DocumentUndo::redo(SPDocument *doc) g_assert (doc != NULL); g_assert (doc->priv != NULL); - g_assert (doc->priv->sensitive); + g_return_val_if_fail(doc->priv->sensitive, FALSE); doc->priv->sensitive = FALSE; doc->priv->seeking = true; -- cgit v1.2.3 From cca2c219973a60fb6535836559aa42ec2b9cb630 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Sun, 19 Jan 2014 20:30:15 -0500 Subject: Revert changes from r12959 and r12955, impliment new stratedgy to fix bug #168695 Fixed bugs: - https://launchpad.net/bugs/168695 (bzr r12960) --- src/document-undo.cpp | 8 ++++---- src/selection-chemistry.cpp | 6 ++++++ src/ui/tools/tool-base.cpp | 16 ++++++---------- src/ui/tools/tool-base.h | 3 ++- 4 files changed, 18 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/document-undo.cpp b/src/document-undo.cpp index 4a4156a70..39c8a04a0 100644 --- a/src/document-undo.cpp +++ b/src/document-undo.cpp @@ -155,7 +155,7 @@ void Inkscape::DocumentUndo::maybeDone(SPDocument *doc, const gchar *key, const { g_assert (doc != NULL); g_assert (doc->priv != NULL); - g_return_if_fail(doc->priv->sensitive); + g_assert (doc->priv->sensitive); if ( key && !*key ) { g_warning("Blank undo key specified."); } @@ -204,7 +204,7 @@ void Inkscape::DocumentUndo::cancel(SPDocument *doc) { g_assert (doc != NULL); g_assert (doc->priv != NULL); - g_return_if_fail(doc->priv->sensitive); + g_assert (doc->priv->sensitive); sp_repr_rollback (doc->rdoc); @@ -242,7 +242,7 @@ gboolean Inkscape::DocumentUndo::undo(SPDocument *doc) g_assert (doc != NULL); g_assert (doc->priv != NULL); - g_return_val_if_fail (doc->priv->sensitive, FALSE); + g_assert (doc->priv->sensitive); doc->priv->sensitive = FALSE; doc->priv->seeking = true; @@ -287,7 +287,7 @@ gboolean Inkscape::DocumentUndo::redo(SPDocument *doc) g_assert (doc != NULL); g_assert (doc->priv != NULL); - g_return_val_if_fail(doc->priv->sensitive, FALSE); + g_assert (doc->priv->sensitive); doc->priv->sensitive = FALSE; doc->priv->seeking = true; diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index f9649d62f..1957b9297 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -1083,6 +1083,9 @@ void sp_selection_lower_to_bottom(Inkscape::Selection *selection, SPDesktop *des void sp_undo(SPDesktop *desktop, SPDocument *) { + // No re/undo while dragging, too dangerous. + if(desktop->getEventContext()->is_dragging) return; + if (!DocumentUndo::undo(sp_desktop_document(desktop))) { desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Nothing to undo.")); } @@ -1091,6 +1094,9 @@ sp_undo(SPDesktop *desktop, SPDocument *) void sp_redo(SPDesktop *desktop, SPDocument *) { + // No re/undo while dragging, too dangerous. + if(desktop->getEventContext()->is_dragging) return; + if (!DocumentUndo::redo(sp_desktop_document(desktop))) { desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Nothing to redo.")); } diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp index f8868ec0e..3b51147e0 100644 --- a/src/ui/tools/tool-base.cpp +++ b/src/ui/tools/tool-base.cpp @@ -57,7 +57,6 @@ #include "shape-editor.h" #include "sp-guide.h" #include "color.h" -#include "document-undo.h" // globals for temporary switching to selector by space static bool selector_toggled = FALSE; @@ -99,6 +98,7 @@ ToolBase::ToolBase() { this->hot_x = 0; this->yp = 0; this->within_tolerance = false; + this->is_dragging = false; this->tolerance = 0; //this->key = 0; this->item_to_select = 0; @@ -979,18 +979,14 @@ gint sp_event_context_root_handler(ToolBase * event_context, gint sp_event_context_virtual_root_handler(ToolBase * event_context, GdkEvent * event) { gint ret = false; if (event_context) { - // We want to disable undo while we drag anything - SPDocument *document = sp_desktop_document(event_context->desktop); - if (event->type == GDK_BUTTON_PRESS) { - event_context->undo_sensitive = DocumentUndo::getUndoSensitive(document); - DocumentUndo::setUndoSensitive(document, false); - } else if (event->type == GDK_BUTTON_RELEASE) { - DocumentUndo::setUndoSensitive(document, event_context->undo_sensitive); - } + if(event->type == GDK_BUTTON_PRESS) + event_context->is_dragging = true; ret = event_context->root_handler(event); - set_event_location(event_context->desktop, event); + + if(event->type == GDK_BUTTON_RELEASE) + event_context->is_dragging = false; } return ret; } diff --git a/src/ui/tools/tool-base.h b/src/ui/tools/tool-base.h index 068bc6402..ab8bd8caa 100644 --- a/src/ui/tools/tool-base.h +++ b/src/ui/tools/tool-base.h @@ -118,8 +118,9 @@ public: gint xp, yp; ///< where drag started gint tolerance; + bool is_dragging; // Is a tool currently dragging something + bool within_tolerance; ///< are we still within tolerance of origin - bool undo_sensitive; /// Was undo previously sensitive before drag SPItem *item_to_select; ///< the item where mouse_press occurred, to ///< be selected if this is a click not drag -- cgit v1.2.3 From 73317394a0079e3602e6c596f8d2a249d5b4a114 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Mon, 20 Jan 2014 19:06:46 +0100 Subject: Fix for bug #1270287 (The toolbox buttons toggle between being pressed and released). Fixed bugs: - https://launchpad.net/bugs/1270287 (bzr r12961) --- src/desktop.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/desktop.cpp b/src/desktop.cpp index bf3b70d43..364b5e930 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -668,6 +668,7 @@ void SPDesktop::set_event_context2(const std::string& toolName) old_tool->finish(); delete old_tool; } else { + _event_context_changed_signal.emit(this, event_context); return; } } -- cgit v1.2.3 From 1534dc84087db1b26f1e86e79436eb63f3dffd3f Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Mon, 20 Jan 2014 20:56:38 +0100 Subject: cppcheck stuff (bzr r12963) --- src/line-geometry.cpp | 16 +++++++++------- src/ui/dialog/template-load-tab.cpp | 7 ++----- src/ui/tools/text-tool.cpp | 4 ++-- src/widgets/icon.cpp | 4 ++-- 4 files changed, 15 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/line-geometry.cpp b/src/line-geometry.cpp index e9f07f96f..982762a12 100644 --- a/src/line-geometry.cpp +++ b/src/line-geometry.cpp @@ -28,8 +28,9 @@ namespace Box3D { * of the segment. Otherwise interpret it as the direction of the line. * FIXME: Think of a better way to distinguish between the two constructors of lines. */ -Line::Line(Geom::Point const &start, Geom::Point const &vec, bool is_endpoint) { - pt = start; +Line::Line(Geom::Point const &start, Geom::Point const &vec, bool is_endpoint): + pt(start) +{ if (is_endpoint) v_dir = vec - start; else @@ -38,11 +39,12 @@ Line::Line(Geom::Point const &start, Geom::Point const &vec, bool is_endpoint) { d0 = Geom::dot(normal, pt); } -Line::Line(Line const &line) { - pt = line.pt; - v_dir = line.v_dir; - normal = line.normal; - d0 = line.d0; +Line::Line(Line const &line): + pt(line.pt), + v_dir(line.v_dir), + normal(line.normal), + d0(line.d0) +{ } Line &Line::operator=(Line const &line) { diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index 4f2d51ef7..6b1f4542f 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -220,12 +220,9 @@ TemplateLoadTab::TemplateData TemplateLoadTab::_processTemplateFile(const std::s n = result.display_name.rfind(".svg"); result.display_name.replace(n, 4, 1, ' '); - Inkscape::XML::Document *rdoc; - rdoc = sp_repr_read_file(path.data(), SP_SVG_NS_URI); - Inkscape::XML::Node *myRoot; - + Inkscape::XML::Document *rdoc = sp_repr_read_file(path.data(), SP_SVG_NS_URI); if (rdoc){ - myRoot = rdoc->root(); + Inkscape::XML::Node *myRoot = rdoc->root(); if (strcmp(myRoot->name(), "svg:svg") != 0){ // Wrong file format return result; } diff --git a/src/ui/tools/text-tool.cpp b/src/ui/tools/text-tool.cpp index c73164c09..9b5ab1016 100644 --- a/src/ui/tools/text-tool.cpp +++ b/src/ui/tools/text-tool.cpp @@ -1335,7 +1335,7 @@ bool sp_text_paste_inline(ToolBase *ec) paste_string_uchar == 0x00000009 || paste_string_uchar == 0x0000000A || paste_string_uchar == 0x0000000D) { - itr++; + ++itr; } else { itr = text.erase(itr); } @@ -1637,7 +1637,7 @@ static void sp_text_context_update_text_selection(TextTool *tc) // the selection update (can't do both atomically, alas) if (!tc->desktop) return; - for (std::vector::iterator it = tc->text_selection_quads.begin() ; it != tc->text_selection_quads.end() ; it++) { + for (std::vector::iterator it = tc->text_selection_quads.begin() ; it != tc->text_selection_quads.end() ; ++it) { sp_canvas_item_hide(*it); sp_canvas_item_destroy(*it); } diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index 768a835c9..a9c30ee8f 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -1310,11 +1310,11 @@ guchar *IconImpl::load_svg_pixels(std::list const &names, } static void addToIconSet(GdkPixbuf* pb, gchar const* name, GtkIconSize lsize, unsigned psize) { - static bool dump = Inkscape::Preferences::get()->getBool("/debug/icons/dumpGtk"); Glib::RefPtr icon_theme = Gtk::IconTheme::get_default(); bool icon_found = icon_theme->has_icon(name); if ( !icon_found ) { Gtk::IconTheme::add_builtin_icon( name, psize, Glib::wrap(pb) ); + static bool dump = Inkscape::Preferences::get()->getBool("/debug/icons/dumpGtk"); if (dump) { g_message(" set in a builtin for %s:%d:%d", name, lsize, psize); } @@ -1354,7 +1354,6 @@ static std::string getDestDir( unsigned psize ) bool IconImpl::prerenderIcon(gchar const *name, GtkIconSize lsize, unsigned psize) { bool loadNeeded = false; - static bool dump = Inkscape::Preferences::get()->getBool("/debug/icons/dumpGtk"); static bool useCache = Inkscape::Preferences::get()->getBool("/debug/icons/useCache", true); static bool cacheValidated = false; if (!cacheValidated) { @@ -1366,6 +1365,7 @@ bool IconImpl::prerenderIcon(gchar const *name, GtkIconSize lsize, unsigned psiz Glib::ustring key = icon_cache_key(name, psize); if ( !get_cached_pixbuf(key) ) { + static bool dump = Inkscape::Preferences::get()->getBool("/debug/icons/dumpGtk"); if ((internalNames.find(name) != internalNames.end()) || (!gtk_icon_theme_has_icon(gtk_icon_theme_get_default(), name))) { if (dump) { -- cgit v1.2.3 From 0e330f5f1fc975666d7a934e3d2efe594ac0b876 Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Mon, 20 Jan 2014 17:06:21 -0500 Subject: 1. make scaling of stroke of horizontal line the same as nearly horizontal line. 2. remove vertical offset when using Transform dialog to attempt to vertically scale horizontal line. (bzr r12964) --- src/sp-item-transform.cpp | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/sp-item-transform.cpp b/src/sp-item-transform.cpp index 854fb9cd7..7fa591fee 100644 --- a/src/sp-item-transform.cpp +++ b/src/sp-item-transform.cpp @@ -144,13 +144,11 @@ Geom::Affine get_scale_transform_for_uniform_stroke(Geom::Rect const &bbox_visua gdouble r1 = r0; if ((fabs(w0 - stroke_x) < 1e-6) || w1 == 0) { // We have a vertical line at hand - r1 = transform_stroke ? r0 * sqrt(h1/h0) : r0; - scale_x = 1; - scale_y = preserve ? h1/h0 : (h1 - r1)/(h0 - r0); + scale_y = h1/h0; + scale_x = transform_stroke ? 1 : scale_y; } else if ((fabs(h0 - stroke_y) < 1e-6) || h1 == 0) { // We have a horizontal line at hand - r1 = transform_stroke ? r0 * sqrt(w1/w0) : r0; - scale_x = preserve ? w1/w0 : (w1 - r1)/(w0 - r0); - scale_y = 1; + scale_x = w1/w0; + scale_y = transform_stroke ? 1 : scale_x; } else { // We have a true 2D object at hand if (transform_stroke && !preserve) { /* Initial area of the geometric bounding box: A0 = (w0-r0)*(h0-r0) @@ -297,13 +295,13 @@ Geom::Affine get_scale_transform_for_variable_stroke(Geom::Rect const &bbox_visu gdouble r1w = r0w; if ((fabs(w0 - r0w) < 1e-6) || w1 == 0) { // We have a vertical line at hand - r1h = transform_stroke ? r0h * sqrt(h1/h0) : r0h; - scale_x = 1; - scale_y = preserve ? h1/h0 : (h1 - r1h)/(h0 - r0h); + scale_y = h1/h0; + scale_x = transform_stroke ? 1 : scale_y; + unbudge *= Geom::Translate (flip_x * 0.5 * (w1 - w0), 0); // compensate for the fact that this operation cannot be performed } else if ((fabs(h0 - r0h) < 1e-6) || h1 == 0) { // We have a horizontal line at hand - r1w = transform_stroke ? r0w * sqrt(w1/w0) : r0w; - scale_x = preserve ? w1/w0 : (w1 - r1w)/(w0 - r0w); - scale_y = 1; + scale_x = w1/w0; + scale_y = transform_stroke ? 1 : scale_x; + unbudge *= Geom::Translate (0, flip_y * 0.5 * (h1 - h0)); // compensate for the fact that this operation cannot be performed } else { // We have a true 2D object at hand if (transform_stroke && !preserve) { /* Initial area of the geometric bounding box: A0 = (w0-r0w)*(h0-r0h) -- cgit v1.2.3 From 77c9748e54f9170aac7c8b292377951f73da487f Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Mon, 20 Jan 2014 20:11:09 -0500 Subject: Fix imprecise viewBox dimensions on page size change (bug #1235279). Fixed bugs: - https://launchpad.net/bugs/1235279 (bzr r12965) --- src/document.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/document.cpp b/src/document.cpp index e56adee68..8b956d5e7 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -585,6 +585,7 @@ Inkscape::Util::Quantity SPDocument::getWidth() const void SPDocument::setWidth(const Inkscape::Util::Quantity &width) { gdouble old_computed = root->width.computed; + gdouble old_value = root->width.value; root->width.computed = width.value("px"); /* SVG does not support meters as a unit, so we must translate meters to * cm when writing */ @@ -596,8 +597,14 @@ void SPDocument::setWidth(const Inkscape::Util::Quantity &width) root->width.unit = (SVGLength::Unit) width.unit->svgUnit(); } - if (root->viewBox_set) - root->viewBox.setMax(Geom::Point(root->viewBox.left() + (root->width.computed / old_computed) * root->viewBox.width(), root->viewBox.bottom())); + if (root->viewBox_set) { + if (abs(old_value - root->viewBox.width()) < 0.00001) { + root->viewBox.setMax(Geom::Point(root->viewBox.left() + root->width.value, root->viewBox.bottom())); + } + else { + root->viewBox.setMax(Geom::Point(root->viewBox.left() + (root->width.computed / old_computed) * root->viewBox.width(), root->viewBox.bottom())); + } + } root->updateRepr(); } @@ -622,6 +629,7 @@ Inkscape::Util::Quantity SPDocument::getHeight() const void SPDocument::setHeight(const Inkscape::Util::Quantity &height) { gdouble old_computed = root->height.computed; + gdouble old_value = root->height.value; root->height.computed = height.value("px"); /* SVG does not support meters as a unit, so we must translate meters to * cm when writing */ @@ -633,8 +641,14 @@ void SPDocument::setHeight(const Inkscape::Util::Quantity &height) root->height.unit = (SVGLength::Unit) height.unit->svgUnit(); } - if (root->viewBox_set) - root->viewBox.setMax(Geom::Point(root->viewBox.right(), root->viewBox.top() + (root->height.computed / old_computed) * root->viewBox.height())); + if (root->viewBox_set) { + if (abs(old_value - root->viewBox.height()) < 0.00001) { + root->viewBox.setMax(Geom::Point(root->viewBox.right(), root->viewBox.top() + root->height.value)); + } + else { + root->viewBox.setMax(Geom::Point(root->viewBox.right(), root->viewBox.top() + (root->height.computed / old_computed) * root->viewBox.height())); + } + } root->updateRepr(); } -- cgit v1.2.3 From d94a93e813b9e4a30f82925670b30de93fc63d38 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Mon, 20 Jan 2014 20:36:09 -0500 Subject: Revert last commit (breaks changing document units). (bzr r12966) --- src/document.cpp | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/document.cpp b/src/document.cpp index 8b956d5e7..e56adee68 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -585,7 +585,6 @@ Inkscape::Util::Quantity SPDocument::getWidth() const void SPDocument::setWidth(const Inkscape::Util::Quantity &width) { gdouble old_computed = root->width.computed; - gdouble old_value = root->width.value; root->width.computed = width.value("px"); /* SVG does not support meters as a unit, so we must translate meters to * cm when writing */ @@ -597,14 +596,8 @@ void SPDocument::setWidth(const Inkscape::Util::Quantity &width) root->width.unit = (SVGLength::Unit) width.unit->svgUnit(); } - if (root->viewBox_set) { - if (abs(old_value - root->viewBox.width()) < 0.00001) { - root->viewBox.setMax(Geom::Point(root->viewBox.left() + root->width.value, root->viewBox.bottom())); - } - else { - root->viewBox.setMax(Geom::Point(root->viewBox.left() + (root->width.computed / old_computed) * root->viewBox.width(), root->viewBox.bottom())); - } - } + if (root->viewBox_set) + root->viewBox.setMax(Geom::Point(root->viewBox.left() + (root->width.computed / old_computed) * root->viewBox.width(), root->viewBox.bottom())); root->updateRepr(); } @@ -629,7 +622,6 @@ Inkscape::Util::Quantity SPDocument::getHeight() const void SPDocument::setHeight(const Inkscape::Util::Quantity &height) { gdouble old_computed = root->height.computed; - gdouble old_value = root->height.value; root->height.computed = height.value("px"); /* SVG does not support meters as a unit, so we must translate meters to * cm when writing */ @@ -641,14 +633,8 @@ void SPDocument::setHeight(const Inkscape::Util::Quantity &height) root->height.unit = (SVGLength::Unit) height.unit->svgUnit(); } - if (root->viewBox_set) { - if (abs(old_value - root->viewBox.height()) < 0.00001) { - root->viewBox.setMax(Geom::Point(root->viewBox.right(), root->viewBox.top() + root->height.value)); - } - else { - root->viewBox.setMax(Geom::Point(root->viewBox.right(), root->viewBox.top() + (root->height.computed / old_computed) * root->viewBox.height())); - } - } + if (root->viewBox_set) + root->viewBox.setMax(Geom::Point(root->viewBox.right(), root->viewBox.top() + (root->height.computed / old_computed) * root->viewBox.height())); root->updateRepr(); } -- cgit v1.2.3 From 29e005620b05165ffd5ad21c2a9751adac89d34a Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Tue, 21 Jan 2014 10:21:10 -0500 Subject: Move dragging undo block from tools-base to canvas. Regarding bug #168695 (bzr r12967) --- src/display/sp-canvas.cpp | 5 +++++ src/display/sp-canvas.h | 1 + src/selection-chemistry.cpp | 5 +++-- src/ui/tools/tool-base.cpp | 7 ------- src/ui/tools/tool-base.h | 1 - 5 files changed, 9 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 455f628bc..ff58cf453 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1545,6 +1545,11 @@ int SPCanvasImpl::emitEvent(SPCanvas *canvas, GdkEvent *event) default: break; } + // Block Undo and Redo while we drag /anything/ + if(event->type == GDK_BUTTON_PRESS) + canvas->is_dragging = true; + else if(event->type == GDK_BUTTON_RELEASE) + canvas->is_dragging = false; // Choose where we send the event diff --git a/src/display/sp-canvas.h b/src/display/sp-canvas.h index b570b739e..72ae4b6bc 100644 --- a/src/display/sp-canvas.h +++ b/src/display/sp-canvas.h @@ -124,6 +124,7 @@ struct SPCanvas { SPCanvasItem *root; + bool is_dragging; double dx0; double dy0; int x0; diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 1957b9297..3082a2fe4 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -56,6 +56,7 @@ SPCycleType SP_CYCLING = SP_CYCLE_FOCUS; #include "sp-polyline.h" #include "sp-line.h" #include "text-editing.h" +#include "display/sp-canvas.h" #include "ui/tools/text-tool.h" #include "ui/tools/connector-tool.h" #include "sp-path.h" @@ -1084,7 +1085,7 @@ void sp_undo(SPDesktop *desktop, SPDocument *) { // No re/undo while dragging, too dangerous. - if(desktop->getEventContext()->is_dragging) return; + if(desktop->getCanvas()->is_dragging) return; if (!DocumentUndo::undo(sp_desktop_document(desktop))) { desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Nothing to undo.")); @@ -1095,7 +1096,7 @@ void sp_redo(SPDesktop *desktop, SPDocument *) { // No re/undo while dragging, too dangerous. - if(desktop->getEventContext()->is_dragging) return; + if(desktop->getCanvas()->is_dragging) return; if (!DocumentUndo::redo(sp_desktop_document(desktop))) { desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Nothing to redo.")); diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp index 3b51147e0..cc028724a 100644 --- a/src/ui/tools/tool-base.cpp +++ b/src/ui/tools/tool-base.cpp @@ -98,7 +98,6 @@ ToolBase::ToolBase() { this->hot_x = 0; this->yp = 0; this->within_tolerance = false; - this->is_dragging = false; this->tolerance = 0; //this->key = 0; this->item_to_select = 0; @@ -979,14 +978,8 @@ gint sp_event_context_root_handler(ToolBase * event_context, gint sp_event_context_virtual_root_handler(ToolBase * event_context, GdkEvent * event) { gint ret = false; if (event_context) { - if(event->type == GDK_BUTTON_PRESS) - event_context->is_dragging = true; - ret = event_context->root_handler(event); set_event_location(event_context->desktop, event); - - if(event->type == GDK_BUTTON_RELEASE) - event_context->is_dragging = false; } return ret; } diff --git a/src/ui/tools/tool-base.h b/src/ui/tools/tool-base.h index ab8bd8caa..43edc4bd7 100644 --- a/src/ui/tools/tool-base.h +++ b/src/ui/tools/tool-base.h @@ -118,7 +118,6 @@ public: gint xp, yp; ///< where drag started gint tolerance; - bool is_dragging; // Is a tool currently dragging something bool within_tolerance; ///< are we still within tolerance of origin -- cgit v1.2.3 From 61737a54a16f2434f26b1ccfa5e1e082464d65c0 Mon Sep 17 00:00:00 2001 From: David Mathog Date: Wed, 22 Jan 2014 00:44:34 +0100 Subject: EMF export: fix handling of transformed rectangular gradients (bug #1263242) Fixed bugs: - https://launchpad.net/bugs/1263242 (bzr r12968) --- src/extension/internal/emf-print.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/extension/internal/emf-print.cpp b/src/extension/internal/emf-print.cpp index 3c27ac1b8..2680718cf 100644 --- a/src/extension/internal/emf-print.cpp +++ b/src/extension/internal/emf-print.cpp @@ -814,10 +814,10 @@ Geom::Path PrintEmf::pathv_to_simple_polygon(Geom::PathVector const &pathv, int return(bad); } P1_lead = cit->finalPoint(); - if(Geom::are_near(P1_lead,P1))continue; // duplicate points at the same coordinate + if(Geom::are_near(P1_lead, P1, 1e-5))continue; // duplicate points at the same coordinate v1 = unit_vector(P1 - P1_trail); v2 = unit_vector(P1_lead - P1 ); - if(Geom::are_near(dot(v1,v2),1.0)){ // P1 is within a straight line + if(Geom::are_near(dot(v1,v2), 1.0, 1e-5)){ // P1 is within a straight line P1 = P1_lead; continue; } @@ -867,7 +867,7 @@ Geom::Path PrintEmf::pathv_to_rect(Geom::PathVector const &pathv, bool *is_rect, P1_lead = cit->finalPoint(); v1 = unit_vector(P1 - P1_trail); v2 = unit_vector(P1_lead - P1 ); - if(!Geom::are_near(dot(v1,v2),0.0))break; // P1 is center of a turn that is not 90 degrees + if(!Geom::are_near(dot(v1,v2), 0.0, 1e-5))break; // P1 is center of a turn that is not 90 degrees P1_trail = P1; P1 = P1_lead; vertex_count++; @@ -891,12 +891,12 @@ int PrintEmf::vector_rect_alignment(double angle, Geom::Point vtest){ int stat = 0; Geom::Point v1 = Geom::unit_vector(vtest); // unit vector to test alignment Geom::Point v2 = Geom::Point(1,0) * Geom::Rotate(-angle); // unit horizontal side (sign change because Y increases DOWN) - if( Geom::are_near(dot(v1,v2), 1.0)){ stat = 1; } - else if(Geom::are_near(dot(v1,v2),-1.0)){ stat = 2; } + if( Geom::are_near(dot(v1,v2), 1.0, 1e-5)){ stat = 1; } + else if(Geom::are_near(dot(v1,v2),-1.0, 1e-5)){ stat = 2; } if(!stat){ v2 = Geom::Point(0,1) * Geom::Rotate(-angle); // unit vertical side - if( Geom::are_near(dot(v1,v2), 1.0)){ stat = 3; } - else if(Geom::are_near(dot(v1,v2),-1.0)){ stat = 4; } + if( Geom::are_near(dot(v1,v2), 1.0, 1e-5)){ stat = 3; } + else if(Geom::are_near(dot(v1,v2),-1.0, 1e-5)){ stat = 4; } } return(stat); } @@ -1091,7 +1091,6 @@ unsigned int PrintEmf::fill( U_TRIVERTEX ut[2]; U_GRADIENT4 ug4; U_RECTL rcb; - Geom::Affine tf2; U_XFORM tmpTransform; double wRect, hRect; @@ -1107,7 +1106,8 @@ unsigned int PrintEmf::fill( Actual gradientfill records are either this entire rectangle or slices of it as defined by the stops. */ - tf2 = Geom::Rotate(-angle); + Geom::Affine tf2 = Geom::Rotate(-angle); // the rectangle may be drawn skewed to the coordinate system + tf2 *= tf; // the coordinate system of the rectangular path may be rotated tmpTransform.eM11 = tf2[0]; tmpTransform.eM12 = tf2[1]; tmpTransform.eM21 = tf2[2]; -- cgit v1.2.3 From e01eb5907b04fdc194551741be6c6dbf5ee6f7e5 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Tue, 21 Jan 2014 22:20:23 -0500 Subject: Improve use tag logic by recording the loaded documents in a list. (bzr r12969) --- src/document.cpp | 1 + src/document.h | 5 +++++ src/uri-references.cpp | 39 +++++++++++++++++++++++++++++---------- 3 files changed, 35 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/document.cpp b/src/document.cpp index e56adee68..32a025e87 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -106,6 +106,7 @@ SPDocument::SPDocument() : profileManager(0), // deferred until after other initialization router(new Avoid::Router(Avoid::PolyLineRouting|Avoid::OrthogonalRouting)), _collection_queue(0), + parent_document(NULL), oldSignalsConnected(false), current_persp3d(NULL), current_persp3d_impl(NULL) diff --git a/src/document.h b/src/document.h index cc565e3aa..e804a4980 100644 --- a/src/document.h +++ b/src/document.h @@ -25,6 +25,7 @@ #include "gc-finalized.h" #include "gc-anchored.h" #include +#include #include namespace Avoid { @@ -120,6 +121,10 @@ public: GSList *_collection_queue; + // A list of svg documents being used or shown within this document + boost::ptr_list child_documents; + SPDocument *parent_document; + bool oldSignalsConnected; /** Returns our SPRoot */ diff --git a/src/uri-references.cpp b/src/uri-references.cpp index 718b2d451..adf948c7b 100644 --- a/src/uri-references.cpp +++ b/src/uri-references.cpp @@ -58,17 +58,36 @@ void URIReference::attach(const URI &uri) throw(BadURIException) // The path contains references to seperate document files to load. const char *path = uri.getPath(); - if(path) { - if(document != NULL) { - // Calculate the absolute path from an available document - std::string basePath = std::string( document->getBase() ); - std::string absPath = Glib::build_filename(basePath, std::string( path ) ); - path = absPath.c_str(); + if(path && document != NULL) { + // Calculate the absolute path from an available document + std::string basePath = std::string( document->getBase() ); + std::string absPath = Glib::build_filename(basePath, std::string( path ) ); + path = absPath.c_str(); + + // We look at existing children and parents + SPDocument *parent = document; + SPDocument *original = document; + document = NULL; + + while(parent != NULL) { + boost::ptr_list::iterator iter; + for (iter = parent->child_documents.begin(); + iter != parent->child_documents.end(); ++iter) { + if(strcmp(iter->getURI(), path)==0) + document = &*iter; + } + parent = parent->parent_document; + } + // Load a fresh document from the svg source. + if(!document) { + document = SPDocument::createNewDoc(path, FALSE); + if(document) { + document->parent_document = original; + original->child_documents.push_back(document); + } else { + g_warning("Could not load svg file: %s", path); + } } - // TODO: This is inefficient because it will load the same svg file - // many times if it's used many times. A global list of documents would - // be useful for tracking linked items. - document = SPDocument::createNewDoc(path, FALSE); } g_return_if_fail(document != NULL); -- cgit v1.2.3 From 9a0c54cb8bc9b0bfc0c6af95f4b156fd717179a8 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Wed, 22 Jan 2014 14:58:15 -0500 Subject: Protect against infinate looping of new included hrefs (bzr r12970) --- src/document.cpp | 10 ++++++---- src/document.h | 8 +++++--- src/extension/implementation/xslt.cpp | 2 +- src/uri-references.cpp | 17 ++++++++++++----- 4 files changed, 24 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/document.cpp b/src/document.cpp index 32a025e87..90f35307d 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -315,7 +315,8 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, gchar const *uri, gchar const *base, gchar const *name, - unsigned int keepalive) + unsigned int keepalive, + SPDocument *parent) { SPDocument *document = new SPDocument(); @@ -326,6 +327,7 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, document->rdoc = rdoc; document->rroot = rroot; + document->parent_document = parent; if (document->uri){ g_free(document->uri); @@ -474,7 +476,7 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, * Fetches document from URI, or creates new, if NULL; public document * appears in document list. */ -SPDocument *SPDocument::createNewDoc(gchar const *uri, unsigned int keepalive, bool make_new) +SPDocument *SPDocument::createNewDoc(gchar const *uri, unsigned int keepalive, bool make_new, SPDocument *parent) { SPDocument *doc; Inkscape::XML::Document *rdoc; @@ -519,7 +521,7 @@ SPDocument *SPDocument::createNewDoc(gchar const *uri, unsigned int keepalive, b //# These should be set by now g_assert(name); - doc = createDoc(rdoc, uri, base, name, keepalive); + doc = createDoc(rdoc, uri, base, name, keepalive, parent); g_free(base); g_free(name); @@ -540,7 +542,7 @@ SPDocument *SPDocument::createNewDocFromMem(gchar const *buffer, gint length, un // TODO fixme: destroy document } else { Glib::ustring name = Glib::ustring::compose( _("Memory document %1"), ++doc_mem_count ); - doc = createDoc(rdoc, NULL, NULL, name.c_str(), keepalive); + doc = createDoc(rdoc, NULL, NULL, name.c_str(), keepalive, NULL); } } diff --git a/src/document.h b/src/document.h index e804a4980..06b2b5f6e 100644 --- a/src/document.h +++ b/src/document.h @@ -221,7 +221,8 @@ public: sigc::connection connectResourcesChanged(const gchar *key, SPDocument::ResourcesChangedSignal::slot_type slot); void fitToRect(Geom::Rect const &rect, bool with_margins = false); - static SPDocument *createNewDoc(const gchar *uri, unsigned int keepalive, bool make_new = false); + static SPDocument *createNewDoc(const gchar *uri, unsigned int keepalive, + bool make_new = false, SPDocument *parent=NULL ); static SPDocument *createNewDocFromMem(const gchar *buffer, gint length, unsigned int keepalive); /** @@ -229,8 +230,9 @@ public: */ static SPItem *getItemFromListAtPointBottom(unsigned int dkey, SPGroup *group, const GSList *list, Geom::Point const &p, bool take_insensitive = false); - // ToDo - Merge createDoc with createNewDoc - static SPDocument *createDoc(Inkscape::XML::Document *rdoc, gchar const *uri, gchar const *base, gchar const *name, unsigned int keepalive); + static SPDocument *createDoc(Inkscape::XML::Document *rdoc, gchar const *uri, + gchar const *base, gchar const *name, unsigned int keepalive, + SPDocument *parent); SPDocument *doRef(); SPDocument *doUnref(); diff --git a/src/extension/implementation/xslt.cpp b/src/extension/implementation/xslt.cpp index 9dd9c83ee..bcea06cb5 100644 --- a/src/extension/implementation/xslt.cpp +++ b/src/extension/implementation/xslt.cpp @@ -177,7 +177,7 @@ XSLT::open(Inkscape::Extension::Input */*module*/, gchar const *filename) } g_free(s); - SPDocument * doc = SPDocument::createDoc(rdoc, filename, base, name, true); + SPDocument * doc = SPDocument::createDoc(rdoc, filename, base, name, true, NULL); g_free(base); g_free(name); diff --git a/src/uri-references.cpp b/src/uri-references.cpp index adf948c7b..30e832c04 100644 --- a/src/uri-references.cpp +++ b/src/uri-references.cpp @@ -64,25 +64,32 @@ void URIReference::attach(const URI &uri) throw(BadURIException) std::string absPath = Glib::build_filename(basePath, std::string( path ) ); path = absPath.c_str(); - // We look at existing children and parents SPDocument *parent = document; SPDocument *original = document; document = NULL; - while(parent != NULL) { + while(parent != NULL && document == NULL) { + // Check myself and any parents int he chain + if(strcmp(parent->getURI(), path)==0) { + document = parent; + break; + } + // Then check children of those. boost::ptr_list::iterator iter; for (iter = parent->child_documents.begin(); iter != parent->child_documents.end(); ++iter) { - if(strcmp(iter->getURI(), path)==0) + if(strcmp(iter->getURI(), path)==0) { document = &*iter; + break; + } } parent = parent->parent_document; } + // Load a fresh document from the svg source. if(!document) { - document = SPDocument::createNewDoc(path, FALSE); + document = SPDocument::createNewDoc(path, false, false, original); if(document) { - document->parent_document = original; original->child_documents.push_back(document); } else { g_warning("Could not load svg file: %s", path); -- cgit v1.2.3 From 423ea7c0373e77a83c8a9ef62df9a786b4feb7ac Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Wed, 22 Jan 2014 17:58:40 -0500 Subject: Move sub-document reference creation code from uri-reference to document.cpp as createChildDoc(path) (bzr r12971) --- src/document.cpp | 47 ++++++++++++++++++++++++++++++++++++++++++++--- src/document.h | 10 ++++++---- src/uri-references.cpp | 37 +------------------------------------ 3 files changed, 51 insertions(+), 43 deletions(-) (limited to 'src') diff --git a/src/document.cpp b/src/document.cpp index 90f35307d..f5c799575 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -106,10 +106,10 @@ SPDocument::SPDocument() : profileManager(0), // deferred until after other initialization router(new Avoid::Router(Avoid::PolyLineRouting|Avoid::OrthogonalRouting)), _collection_queue(0), - parent_document(NULL), oldSignalsConnected(false), current_persp3d(NULL), - current_persp3d_impl(NULL) + current_persp3d_impl(NULL), + _parent_document(NULL) { // Penalise libavoid for choosing paths with needless extra segments. // This results in much better looking orthogonal connector paths. @@ -327,7 +327,10 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, document->rdoc = rdoc; document->rroot = rroot; - document->parent_document = parent; + if (parent) { + document->_parent_document = parent; + parent->_child_documents.push_back(document); + } if (document->uri){ g_free(document->uri); @@ -472,6 +475,43 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, return document; } +/** + * Fetches a document and attaches it to the current document as a child href + */ +SPDocument *SPDocument::createChildDoc(gchar const *uri) { + + // Calculate the absolute path from an available document + std::string basePath = std::string( this->getBase() ); + std::string absPath = Glib::build_filename(basePath, std::string( uri ) ); + const char *path = absPath.c_str(); + + SPDocument *parent = this; + SPDocument *document = NULL; + + while(parent != NULL && document == NULL) { + // Check myself and any parents int he chain + if(strcmp(parent->getURI(), path)==0) { + document = parent; + break; + } + // Then check children of those. + boost::ptr_list::iterator iter; + for (iter = parent->_child_documents.begin(); + iter != parent->_child_documents.end(); ++iter) { + if(strcmp(iter->getURI(), path)==0) { + document = &*iter; + break; + } + } + parent = parent->_parent_document; + } + + // Load a fresh document from the svg source. + if(!document) { + document = createNewDoc(path, false, false, this); + } + return document; +} /** * Fetches document from URI, or creates new, if NULL; public document * appears in document list. @@ -605,6 +645,7 @@ void SPDocument::setWidth(const Inkscape::Util::Quantity &width) root->updateRepr(); } + Inkscape::Util::Quantity SPDocument::getHeight() const { g_return_val_if_fail(this->priv != NULL, Inkscape::Util::Quantity(0.0, unit_table.getUnit(""))); diff --git a/src/document.h b/src/document.h index 06b2b5f6e..79381e0c2 100644 --- a/src/document.h +++ b/src/document.h @@ -121,10 +121,6 @@ public: GSList *_collection_queue; - // A list of svg documents being used or shown within this document - boost::ptr_list child_documents; - SPDocument *parent_document; - bool oldSignalsConnected; /** Returns our SPRoot */ @@ -207,6 +203,11 @@ private: Persp3D *current_persp3d; /**< Currently 'active' perspective (to which, e.g., newly created boxes are attached) */ Persp3DImpl *current_persp3d_impl; + // A list of svg documents being used or shown within this document + boost::ptr_list _child_documents; + // Conversely this is a parent document because this is a child. + SPDocument *_parent_document; + public: sigc::connection connectReconstructionStart(ReconstructionStart::slot_type slot); sigc::connection connectReconstructionFinish(ReconstructionFinish::slot_type slot); @@ -224,6 +225,7 @@ public: static SPDocument *createNewDoc(const gchar *uri, unsigned int keepalive, bool make_new = false, SPDocument *parent=NULL ); static SPDocument *createNewDocFromMem(const gchar *buffer, gint length, unsigned int keepalive); + SPDocument *createChildDoc(gchar const *uri); /** * Returns the bottommost item from the list which is at the point, or NULL if none. diff --git a/src/uri-references.cpp b/src/uri-references.cpp index 30e832c04..1684c6ade 100644 --- a/src/uri-references.cpp +++ b/src/uri-references.cpp @@ -59,42 +59,7 @@ void URIReference::attach(const URI &uri) throw(BadURIException) // The path contains references to seperate document files to load. const char *path = uri.getPath(); if(path && document != NULL) { - // Calculate the absolute path from an available document - std::string basePath = std::string( document->getBase() ); - std::string absPath = Glib::build_filename(basePath, std::string( path ) ); - path = absPath.c_str(); - - SPDocument *parent = document; - SPDocument *original = document; - document = NULL; - - while(parent != NULL && document == NULL) { - // Check myself and any parents int he chain - if(strcmp(parent->getURI(), path)==0) { - document = parent; - break; - } - // Then check children of those. - boost::ptr_list::iterator iter; - for (iter = parent->child_documents.begin(); - iter != parent->child_documents.end(); ++iter) { - if(strcmp(iter->getURI(), path)==0) { - document = &*iter; - break; - } - } - parent = parent->parent_document; - } - - // Load a fresh document from the svg source. - if(!document) { - document = SPDocument::createNewDoc(path, false, false, original); - if(document) { - original->child_documents.push_back(document); - } else { - g_warning("Could not load svg file: %s", path); - } - } + document = document->createChildDoc(path); } g_return_if_fail(document != NULL); -- cgit v1.2.3 From ae7f7f7449a2da248ff13119e802a104de297c3d Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Wed, 22 Jan 2014 18:06:39 -0500 Subject: Improve warnings for missing files. Don't just assert bolocks to the user. (bzr r12972) --- src/uri-references.cpp | 5 ++++- src/xml/repr-io.cpp | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/uri-references.cpp b/src/uri-references.cpp index 1684c6ade..f2df55213 100644 --- a/src/uri-references.cpp +++ b/src/uri-references.cpp @@ -61,7 +61,10 @@ void URIReference::attach(const URI &uri) throw(BadURIException) if(path && document != NULL) { document = document->createChildDoc(path); } - g_return_if_fail(document != NULL); + if(!document) { + g_warning("Can't get document for referenced URI: %s", uri.toString()); + return; + } gchar const *fragment = uri.getFragment(); if ( !uri.isRelative() || uri.getQuery() || !fragment ) { diff --git a/src/xml/repr-io.cpp b/src/xml/repr-io.cpp index 54eff00bc..0319bb5e3 100644 --- a/src/xml/repr-io.cpp +++ b/src/xml/repr-io.cpp @@ -334,7 +334,10 @@ Document *sp_repr_read_file (const gchar * filename, const gchar *default_ns) xmlSubstituteEntitiesDefault(1); g_return_val_if_fail (filename != NULL, NULL); - g_return_val_if_fail (Inkscape::IO::file_test( filename, G_FILE_TEST_EXISTS ), NULL); + if (!Inkscape::IO::file_test( filename, G_FILE_TEST_EXISTS )) { + g_warning("Can't open file: %s (doesn't exist)", filename); + return NULL; + } /* fixme: A file can disappear at any time, including between now and when we actually try to * open it. Get rid of the above test once we're sure that we correctly handle * non-existence. */ -- cgit v1.2.3 From f30005bef81c2e1c5e04fe583935269c5b209749 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Wed, 22 Jan 2014 21:17:48 -0500 Subject: Don't throw away an existing full path. (bzr r12973) --- src/document.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/document.cpp b/src/document.cpp index f5c799575..499601259 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -481,16 +481,19 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, SPDocument *SPDocument::createChildDoc(gchar const *uri) { // Calculate the absolute path from an available document - std::string basePath = std::string( this->getBase() ); - std::string absPath = Glib::build_filename(basePath, std::string( uri ) ); - const char *path = absPath.c_str(); + if(strncmp(uri, "/", 1)!=0) { + std::string basePath = std::string( this->getBase() ); + std::string absPath = Glib::build_filename(basePath, std::string( uri ) ); + // free uri first? + uri = absPath.c_str(); + } SPDocument *parent = this; SPDocument *document = NULL; while(parent != NULL && document == NULL) { // Check myself and any parents int he chain - if(strcmp(parent->getURI(), path)==0) { + if(strcmp(parent->getURI(), uri)==0) { document = parent; break; } @@ -498,7 +501,7 @@ SPDocument *SPDocument::createChildDoc(gchar const *uri) { boost::ptr_list::iterator iter; for (iter = parent->_child_documents.begin(); iter != parent->_child_documents.end(); ++iter) { - if(strcmp(iter->getURI(), path)==0) { + if(strcmp(iter->getURI(), uri)==0) { document = &*iter; break; } @@ -508,7 +511,7 @@ SPDocument *SPDocument::createChildDoc(gchar const *uri) { // Load a fresh document from the svg source. if(!document) { - document = createNewDoc(path, false, false, this); + document = createNewDoc(uri, false, false, this); } return document; } -- cgit v1.2.3 From 11ae816a74c061c219a4d833b58e6f940a53fff5 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Wed, 22 Jan 2014 22:21:57 -0500 Subject: Make sure we're not interfering with right or middle click with undo prevention bug #168695 (bzr r12974) --- src/display/sp-canvas.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index ff58cf453..d9640f763 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1546,7 +1546,7 @@ int SPCanvasImpl::emitEvent(SPCanvas *canvas, GdkEvent *event) break; } // Block Undo and Redo while we drag /anything/ - if(event->type == GDK_BUTTON_PRESS) + if(event->type == GDK_BUTTON_PRESS && event->button.button == 1) canvas->is_dragging = true; else if(event->type == GDK_BUTTON_RELEASE) canvas->is_dragging = false; -- cgit v1.2.3 From d9fbd1a23235bc8725574f61e156e0992ecc83bf Mon Sep 17 00:00:00 2001 From: su_v Date: Thu, 23 Jan 2014 22:12:22 +0100 Subject: Fix GTK3 build failure (follow-up to r12971) Fixed bugs: - https://launchpad.net/bugs/1271802 (bzr r12975) --- src/document.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/document.cpp b/src/document.cpp index 499601259..b7f5cb097 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -67,6 +67,8 @@ #include "xml/rebase-hrefs.h" #include "libcroco/cr-cascade.h" +#include + using Inkscape::DocumentUndo; using Inkscape::Util::unit_table; -- cgit v1.2.3 From ddb8af8009f151c7107daf0c2127f0ba2d882649 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Fri, 24 Jan 2014 20:05:26 -0500 Subject: Move absolute path generator to URI and use std::strings (bzr r12977) --- src/document.cpp | 21 ++++++--------------- src/document.h | 2 +- src/uri-references.cpp | 8 +++++--- src/uri.cpp | 13 +++++++++++++ src/uri.h | 3 +++ 5 files changed, 28 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/document.cpp b/src/document.cpp index b7f5cb097..e456f2b81 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -67,8 +67,6 @@ #include "xml/rebase-hrefs.h" #include "libcroco/cr-cascade.h" -#include - using Inkscape::DocumentUndo; using Inkscape::Util::unit_table; @@ -480,22 +478,14 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, /** * Fetches a document and attaches it to the current document as a child href */ -SPDocument *SPDocument::createChildDoc(gchar const *uri) { - - // Calculate the absolute path from an available document - if(strncmp(uri, "/", 1)!=0) { - std::string basePath = std::string( this->getBase() ); - std::string absPath = Glib::build_filename(basePath, std::string( uri ) ); - // free uri first? - uri = absPath.c_str(); - } - +SPDocument *SPDocument::createChildDoc(std::string const uri) +{ SPDocument *parent = this; SPDocument *document = NULL; while(parent != NULL && document == NULL) { // Check myself and any parents int he chain - if(strcmp(parent->getURI(), uri)==0) { + if(uri.compare(parent->getURI())==0) { document = parent; break; } @@ -503,7 +493,7 @@ SPDocument *SPDocument::createChildDoc(gchar const *uri) { boost::ptr_list::iterator iter; for (iter = parent->_child_documents.begin(); iter != parent->_child_documents.end(); ++iter) { - if(strcmp(iter->getURI(), uri)==0) { + if(uri.compare(iter->getURI())==0) { document = &*iter; break; } @@ -513,7 +503,8 @@ SPDocument *SPDocument::createChildDoc(gchar const *uri) { // Load a fresh document from the svg source. if(!document) { - document = createNewDoc(uri, false, false, this); + const char *path = g_strdup(uri.c_str()); + document = createNewDoc(path, false, false, this); } return document; } diff --git a/src/document.h b/src/document.h index 79381e0c2..110db11c6 100644 --- a/src/document.h +++ b/src/document.h @@ -225,7 +225,7 @@ public: static SPDocument *createNewDoc(const gchar *uri, unsigned int keepalive, bool make_new = false, SPDocument *parent=NULL ); static SPDocument *createNewDocFromMem(const gchar *buffer, gint length, unsigned int keepalive); - SPDocument *createChildDoc(gchar const *uri); + SPDocument *createChildDoc(std::string const uri); /** * Returns the bottommost item from the list which is at the point, or NULL if none. diff --git a/src/uri-references.cpp b/src/uri-references.cpp index f2df55213..dc0101024 100644 --- a/src/uri-references.cpp +++ b/src/uri-references.cpp @@ -57,9 +57,11 @@ void URIReference::attach(const URI &uri) throw(BadURIException) } // The path contains references to seperate document files to load. - const char *path = uri.getPath(); - if(path && document != NULL) { - document = document->createChildDoc(path); + if(document && uri.getPath()) { + std::string base = std::string(g_strdup(document->getBase())); + std::string path = uri.getFullPath(base); + if(!path.empty()) + document = document->createChildDoc(path); } if(!document) { g_warning("Can't get document for referenced URI: %s", uri.toString()); diff --git a/src/uri.cpp b/src/uri.cpp index de6a454ec..8d0e49139 100644 --- a/src/uri.cpp +++ b/src/uri.cpp @@ -10,7 +10,9 @@ #include #include "uri.h" +#include #include +#include namespace Inkscape { @@ -134,6 +136,17 @@ gchar *URI::to_native_filename(gchar const* uri) throw(BadURIException) return filename; } +const std::string URI::getFullPath(std::string const base) const { + std::string path = std::string(_impl->getPath()); + // Calculate the absolute path from an available base + if(!path.empty() && !base.empty() && path.compare(0, 1, "/") != 0) { + path = Glib::build_filename(base, path); + } + // TODO: Check existance of file here + return path; +} + + /* TODO !!! proper error handling */ gchar *URI::toNativeFilename() const throw(BadURIException) { gchar *uriString = toString(); diff --git a/src/uri.h b/src/uri.h index adcc76d6b..74820cb29 100644 --- a/src/uri.h +++ b/src/uri.h @@ -15,6 +15,7 @@ #include #include #include "bad-uri-exception.h" +#include namespace Inkscape { @@ -101,6 +102,8 @@ public: static gchar *to_native_filename(gchar const* uri) throw(BadURIException); + const std::string getFullPath(std::string const base) const; + gchar *toNativeFilename() const throw(BadURIException); /** -- cgit v1.2.3 From 24b5b970fd4e6fadce881db84aa9f40bf81183d8 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Fri, 24 Jan 2014 20:05:47 -0500 Subject: A partial refactor of sp-image.cpp, expect more. (bzr r12978) --- src/sp-image.cpp | 89 +++++++++++++++++++++----------------------------------- src/sp-image.h | 5 ++++ 2 files changed, 38 insertions(+), 56 deletions(-) (limited to 'src') diff --git a/src/sp-image.cpp b/src/sp-image.cpp index b08d6f9b0..f1ea737ff 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -76,7 +76,6 @@ static void sp_image_set_curve(SPImage *image); -gchar const *sp_image_repr_read_filename(gchar const *href, gchar const *absref, gchar const *base ); static void sp_image_update_arenaitem (SPImage *img, Inkscape::DrawingImage *ai); static void sp_image_update_canvas_image (SPImage *image); @@ -170,8 +169,7 @@ void SPImage::release() { this->href = NULL; } - delete this->pixbuf; - this->pixbuf = NULL; + this->clear_image(); #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) if (this->color_profile) { @@ -329,29 +327,31 @@ void SPImage::update(SPCtx *ctx, unsigned int flags) { SPItem::update(ctx, flags); if (flags & SP_IMAGE_HREF_MODIFIED_FLAG) { - delete this->pixbuf; - this->pixbuf = NULL; + this->clear_image(); if (this->href) { Inkscape::Pixbuf *pixbuf = NULL; + gchar const* uri = this->getRepr()->attribute("xlink:href"); + + if(!uri) { + g_warning("Image tag has no valid href: %s", this->getId()); - gchar const* filename = sp_image_repr_read_filename ( - this->getRepr()->attribute("xlink:href"), - this->getRepr()->attribute("sodipodi:absref"), - doc->getBase()); - - Inkscape::Pixbuf::create_from_data_uri(filename); - if (strncmp (filename,"data:", 5) == 0) { - filename += 5; - pixbuf = Inkscape::Pixbuf::create_from_data_uri(filename); - } else if(filename && g_str_has_suffix(filename, ".svg")) { - // TODO: We want to deal with svg images properly. This - // space allows us to do so later. - g_warning("Including svg images tags is not yet supported."); - } else if (filename) { - pixbuf = Inkscape::Pixbuf::create_from_file(filename); + } else if (strncmp (uri, "data:", 5) == 0) { + uri += 5; + pixbuf = Inkscape::Pixbuf::create_from_data_uri(uri); + + } else if(g_str_has_suffix(uri, ".svg")) { + SPDocument *doc = this->document->createChildDoc(uri); + if(doc) { + this->child = SP_ITEM(doc); + g_warning("Loaded document: %s", uri); + } else { + g_warning("Could not load svg for image tag: %s",this->getId()); + } + } else { + pixbuf = Inkscape::Pixbuf::create_from_file(uri); } - if(!pixbuf) { + if(!pixbuf && !this->child) { /* Nope: We do not find any valid pixmap file :-( */ pixbuf = new Inkscape::Pixbuf( gdk_pixbuf_new_from_xpm_data((const gchar **) brokenimage_xpm)); @@ -527,6 +527,18 @@ void SPImage::update(SPCtx *ctx, unsigned int flags) { sp_image_update_canvas_image ((SPImage *) this); } +// Remove references to image or child objects. +void SPImage::clear_image() { + if(this->pixbuf) { + delete this->pixbuf; + this->pixbuf = NULL; + } + if(this->child) { + this->detach(this->child); + this->child = NULL; + } +} + void SPImage::modified(unsigned int flags) { // SPItem::onModified(flags); @@ -667,41 +679,6 @@ Inkscape::DrawingItem* SPImage::show(Inkscape::Drawing &drawing, unsigned int /* return ai; } -gchar const *sp_image_repr_read_filename(gchar const *href, gchar const *absref, gchar const *base) -{ - gchar const *filename = href; - - if (filename != NULL) { - if (strncmp (filename,"file:",5) == 0) { - filename = g_filename_from_uri(filename, NULL, NULL); - } else if (strncmp (filename,"data:",5) == 0) { - /* data URI - embedded image */ - return filename; - } else if (!g_path_is_absolute (filename)) { - /* try to load from relative pos combined with document base*/ - const gchar *docbase = base; - if (!docbase) docbase = "."; - filename = g_build_filename(docbase, filename, NULL); - } - } - - if (filename && g_file_test(filename, G_FILE_TEST_EXISTS) ) { - return filename; - } - - /* at last try to load from sp absolute path name */ - if (absref != NULL && g_file_test(absref, G_FILE_TEST_EXISTS)) { - // using absref is outside of SVG rules, so we must at least warn the user - if ( base != NULL && href != NULL ) { - g_warning (" did not resolve to a valid image file (base dir is %s), now trying sodipodi:absref=\"%s\"", href, base, absref); - } else { - g_warning ("xlink:href did not resolve to a valid image file, now trying sodipodi:absref=\"%s\"", absref); - } - return absref; - } - return NULL; -} - /* We assert that realpixbuf is either NULL or identical size to pixbuf */ static void sp_image_update_arenaitem (SPImage *image, Inkscape::DrawingImage *ai) diff --git a/src/sp-image.h b/src/sp-image.h index 3b7208487..ad4fd4d54 100644 --- a/src/sp-image.h +++ b/src/sp-image.h @@ -53,7 +53,10 @@ public: gchar *color_profile; #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) + // When image is a raster image, we use pixbuf Inkscape::Pixbuf *pixbuf; + // When it's an svg file, we use an SPItem similar to sp-use + SPItem *child; virtual void build(SPDocument *document, Inkscape::XML::Node *repr); virtual void release(); @@ -69,6 +72,8 @@ public: virtual Inkscape::DrawingItem* show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags); virtual void snappoints(std::vector &p, Inkscape::SnapPreferences const *snapprefs) const; virtual Geom::Affine set_transform(Geom::Affine const &transform); +private: + void clear_image(); }; /* Return duplicate of curve or NULL */ -- cgit v1.2.3 From 7455f1a259ce28ee56866b5cde06e79be4cfaf97 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Sun, 26 Jan 2014 12:19:47 -0500 Subject: Check file existance and clean up memory issues thanks to KK and Johan (bzr r12979) --- src/document.cpp | 10 +++++----- src/document.h | 2 +- src/uri-references.cpp | 4 +++- src/uri.cpp | 17 ++++++++++++++--- 4 files changed, 23 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/document.cpp b/src/document.cpp index e456f2b81..634462001 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -478,22 +478,22 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, /** * Fetches a document and attaches it to the current document as a child href */ -SPDocument *SPDocument::createChildDoc(std::string const uri) +SPDocument *SPDocument::createChildDoc(std::string const &uri) { SPDocument *parent = this; SPDocument *document = NULL; while(parent != NULL && document == NULL) { // Check myself and any parents int he chain - if(uri.compare(parent->getURI())==0) { + if(uri == parent->getURI()) { document = parent; break; } // Then check children of those. boost::ptr_list::iterator iter; for (iter = parent->_child_documents.begin(); - iter != parent->_child_documents.end(); ++iter) { - if(uri.compare(iter->getURI())==0) { + iter != parent->_child_documents.end(); ++iter) { + if(uri == iter->getURI()) { document = &*iter; break; } @@ -503,7 +503,7 @@ SPDocument *SPDocument::createChildDoc(std::string const uri) // Load a fresh document from the svg source. if(!document) { - const char *path = g_strdup(uri.c_str()); + const char *path = uri.c_str(); document = createNewDoc(path, false, false, this); } return document; diff --git a/src/document.h b/src/document.h index 110db11c6..e5567d3b6 100644 --- a/src/document.h +++ b/src/document.h @@ -225,7 +225,7 @@ public: static SPDocument *createNewDoc(const gchar *uri, unsigned int keepalive, bool make_new = false, SPDocument *parent=NULL ); static SPDocument *createNewDocFromMem(const gchar *buffer, gint length, unsigned int keepalive); - SPDocument *createChildDoc(std::string const uri); + SPDocument *createChildDoc(std::string const &uri); /** * Returns the bottommost item from the list which is at the point, or NULL if none. diff --git a/src/uri-references.cpp b/src/uri-references.cpp index dc0101024..abe16ec9d 100644 --- a/src/uri-references.cpp +++ b/src/uri-references.cpp @@ -58,10 +58,12 @@ void URIReference::attach(const URI &uri) throw(BadURIException) // The path contains references to seperate document files to load. if(document && uri.getPath()) { - std::string base = std::string(g_strdup(document->getBase())); + std::string base = std::string(document->getBase()); std::string path = uri.getFullPath(base); if(!path.empty()) document = document->createChildDoc(path); + else + document = NULL; } if(!document) { g_warning("Can't get document for referenced URI: %s", uri.toString()); diff --git a/src/uri.cpp b/src/uri.cpp index 8d0e49139..89f6f33e4 100644 --- a/src/uri.cpp +++ b/src/uri.cpp @@ -135,14 +135,25 @@ gchar *URI::to_native_filename(gchar const* uri) throw(BadURIException) filename = tmp.toNativeFilename(); return filename; } - +/* + * Returns the absolute path to an existing file referenced in this URI, + * if the uri is data, the path is empty or the file doesn't exist, then + * an empty string is returned. + * + * Does not check if the returned path is the local document's path (local) + * and thus redundent. Caller is expected to check against the document's path. + */ const std::string URI::getFullPath(std::string const base) const { std::string path = std::string(_impl->getPath()); // Calculate the absolute path from an available base - if(!path.empty() && !base.empty() && path.compare(0, 1, "/") != 0) { + if(!base.empty() && !path.empty() && path[0] != '/') { path = Glib::build_filename(base, path); } - // TODO: Check existance of file here + // Check the existance of the file + if(! g_file_test(path.c_str(), G_FILE_TEST_EXISTS) + || g_file_test(path.c_str(), G_FILE_TEST_IS_DIR) ) { + path.clear(); + } return path; } -- cgit v1.2.3 From 99a8b0ae7da4f776f7ec85862ab52c29a4abb164 Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Sun, 26 Jan 2014 15:09:05 -0500 Subject: sbasis-to-bezier : add support for case where Bezier control arm length is zero (Bug 1272119) Fixed bugs: - https://launchpad.net/bugs/1272119 (bzr r12980) --- src/2geom/sbasis-to-bezier.cpp | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/2geom/sbasis-to-bezier.cpp b/src/2geom/sbasis-to-bezier.cpp index bd88f93c0..0525be04b 100644 --- a/src/2geom/sbasis-to-bezier.cpp +++ b/src/2geom/sbasis-to-bezier.cpp @@ -242,24 +242,38 @@ void sbasis_to_cubic_bezier (std::vector & bz, D2 const& sb) // calculate Bezier control arms - if (std::abs(xprime[1]*yprime[0] - yprime[1]*xprime[0]) > 1.e-5) { // general case : fit mid fxn value + if ((std::abs(xprime[0]) < EPSILON) && (std::abs(yprime[0]) < EPSILON) + && ((std::abs(xprime[1]) > EPSILON) || (std::abs(yprime[1]) > EPSILON))) { // degenerate handle at 0 : use distance of closest approach + numer = midx*xprime[1] + midy*yprime[1]; + denom = 3.0*(xprime[1]*xprime[1] + yprime[1]*yprime[1]); + delx[0] = 0; + dely[0] = 0; + delx[1] = -xprime[1]*numer/denom; + dely[1] = -yprime[1]*numer/denom; + } else if ((std::abs(xprime[1]) < EPSILON) && (std::abs(yprime[1]) < EPSILON) + && ((std::abs(xprime[0]) > EPSILON) || (std::abs(yprime[0]) > EPSILON))) { // degenerate handle at 1 : ditto + numer = midx*xprime[0] + midy*yprime[0]; + denom = 3.0*(xprime[0]*xprime[0] + yprime[0]*yprime[0]); + delx[0] = xprime[0]*numer/denom; + dely[0] = yprime[0]*numer/denom; + delx[1] = 0; + dely[1] = 0; + } else if (std::abs(xprime[1]*yprime[0] - yprime[1]*xprime[0]) > EPSILON) { // general case : fit mid fxn value denom = xprime[1]*yprime[0] - yprime[1]*xprime[0]; for (int i = 0; i < 2; ++i) { numer = xprime[1 - i]*midy - yprime[1 - i]*midx; delx[i] = xprime[i]*numer/denom/3; dely[i] = yprime[i]*numer/denom/3; } - } - else if ((xprime[0]*xprime[1] < 0) || (yprime[0]*yprime[1] < 0)) { // symmetric case : use distance of closest approach + } else if ((xprime[0]*xprime[1] < 0) || (yprime[0]*yprime[1] < 0)) { // symmetric case : use distance of closest approach numer = midx*xprime[0] + midy*yprime[0]; denom = 6.0*(xprime[0]*xprime[0] + yprime[0]*yprime[0]); delx[0] = xprime[0]*numer/denom; dely[0] = yprime[0]*numer/denom; delx[1] = -delx[0]; dely[1] = -dely[0]; - } - else { // anti-symmetric case : fit mid slope - // calculate slope at t = 0.5 + } else { // anti-symmetric case : fit mid slope + // calculate slope at t = 0.5 midx = 0; div = 1; for (size_t i = 0; i < sb[X].size(); ++i) { @@ -279,8 +293,7 @@ void sbasis_to_cubic_bezier (std::vector & bz, D2 const& sb) delx[i] = xprime[0]*numer/denom; dely[i] = yprime[0]*numer/denom; } - } - else { // linear case + } else { // linear case for (int i = 0; i < 2; ++i) { delx[i] = (bz[3][X] - bz[0][X])/3; dely[i] = (bz[3][Y] - bz[0][Y])/3; -- cgit v1.2.3 From 8da52916bd86c3c19749b3062dcdbda63de3b554 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Mon, 27 Jan 2014 08:11:24 -0500 Subject: Protect export options from blank filenames, png, pdf, emf and wmf. This should fix Bug #941103 Fixed bugs: - https://launchpad.net/bugs/941103 (bzr r12981) --- src/main.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index 079944af6..868f389a8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1515,7 +1515,7 @@ static int sp_do_export_png(SPDocument *doc) // set filename and dpi from options, if not yet set from the hints if (filename.empty()) { - if (!sp_export_png) { + if (!sp_export_png || sp_export_png[0] == '\0') { g_warning ("No export filename given and no filename hint. Nothing exported."); return 1; } @@ -1771,6 +1771,11 @@ static int do_export_ps_pdf(SPDocument* doc, gchar const* uri, char const* mime) } } + if(!uri || uri[0] == '\0') { + g_warning ("No export filename given. Nothing exported."); + return 0; + } + //check if specified directory exists if (!Inkscape::IO::file_directory_exists(uri)) { g_warning("File path \"%s\" includes directory that doesn't exist.\n", uri); @@ -1837,6 +1842,10 @@ static int do_export_win_metafile_common(SPDocument* doc, gchar const* uri, char static int do_export_emf(SPDocument* doc, gchar const* uri, char const* mime) { + if(!uri || uri[0] == '\0') { + g_warning("No filename provided for emf export."); + return 0; + } return do_export_win_metafile_common(doc, uri, mime); } @@ -1850,6 +1859,10 @@ static int do_export_emf(SPDocument* doc, gchar const* uri, char const* mime) static int do_export_wmf(SPDocument* doc, gchar const* uri, char const* mime) { + if(!uri || uri[0] == '\0') { + g_warning("No filename provided for wmf export."); + return 0; + } return do_export_win_metafile_common(doc, uri, mime); } -- cgit v1.2.3 From fd1ceb05805f20402606fd9fae1a048e0bca8e78 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Mon, 27 Jan 2014 13:19:30 -0500 Subject: Protect pdf and png exports from failure and output reasonalbe warnings. (bzr r12982) --- src/helper/png-write.cpp | 2 +- src/main.cpp | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/helper/png-write.cpp b/src/helper/png-write.cpp index b8b815b4c..a16fe8e12 100644 --- a/src/helper/png-write.cpp +++ b/src/helper/png-write.cpp @@ -142,7 +142,7 @@ sp_png_write_rgba_striped(SPDocument *doc, Inkscape::IO::dump_fopen_call(filename, "M"); fp = Inkscape::IO::fopen_utf8name(filename, "wb"); - g_return_val_if_fail(fp != NULL, false); + if(fp == NULL) return false; /* Create and initialize the png_struct with the desired error handler * functions. If you want to use the default stderr and longjump method, diff --git a/src/main.cpp b/src/main.cpp index 868f389a8..25f813c2b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1632,10 +1632,13 @@ static int sp_do_export_png(SPDocument *doc) g_print("Area %g:%g:%g:%g exported to %lu x %lu pixels (%g dpi)\n", area[Geom::X][0], area[Geom::Y][0], area[Geom::X][1], area[Geom::Y][1], width, height, dpi); - g_print("Bitmap saved as: %s\n", filename.c_str()); - if ((width >= 1) && (height >= 1) && (width <= PNG_UINT_31_MAX) && (height <= PNG_UINT_31_MAX)) { - sp_export_png_file(doc, path.c_str(), area, width, height, dpi, dpi, bgcolor, NULL, NULL, true, sp_export_id_only ? items : NULL); + if( sp_export_png_file(doc, path.c_str(), area, width, height, dpi, + dpi, bgcolor, NULL, NULL, true, sp_export_id_only ? items : NULL) == 1 ) { + g_print("Bitmap saved as: %s\n", filename.c_str()); + } else { + g_warning("Bitmap failed to save to: %s", filename.c_str()); + } } else { g_warning("Calculated bitmap dimensions %lu %lu are out of range (1 - %lu). Nothing exported.", width, height, (unsigned long int)PNG_UINT_31_MAX); } @@ -1794,7 +1797,11 @@ static int do_export_ps_pdf(SPDocument* doc, gchar const* uri, char const* mime) ? "PostScript level 3" : "PostScript level 2"); } - (*i)->save(doc, uri); + try { + (*i)->save(doc, uri); + } catch(...) { + g_warning("Failed to save pdf to: %s", uri); + } return 0; } -- cgit v1.2.3 From a9e16718924f28cf5e55706946720b2cc44a409d Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Wed, 29 Jan 2014 16:55:32 -0500 Subject: Revert sp-image until the refactoring takes. (bzr r12984) --- src/sp-image.cpp | 135 +++++++++++++++++++++++++++++++++++++------------------ src/sp-image.h | 5 --- 2 files changed, 92 insertions(+), 48 deletions(-) (limited to 'src') diff --git a/src/sp-image.cpp b/src/sp-image.cpp index f1ea737ff..8f7a60ca6 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -24,7 +24,6 @@ #include <2geom/rect.h> #include <2geom/transforms.h> #include -#include #include "display/drawing-image.h" #include "display/cairo-utils.h" @@ -76,6 +75,7 @@ static void sp_image_set_curve(SPImage *image); +static Inkscape::Pixbuf *sp_image_repr_read_image(gchar const *href, gchar const *absref, gchar const *base ); static void sp_image_update_arenaitem (SPImage *img, Inkscape::DrawingImage *ai); static void sp_image_update_canvas_image (SPImage *image); @@ -169,7 +169,8 @@ void SPImage::release() { this->href = NULL; } - this->clear_image(); + delete this->pixbuf; + this->pixbuf = NULL; #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) if (this->color_profile) { @@ -327,38 +328,16 @@ void SPImage::update(SPCtx *ctx, unsigned int flags) { SPItem::update(ctx, flags); if (flags & SP_IMAGE_HREF_MODIFIED_FLAG) { - this->clear_image(); + delete this->pixbuf; + this->pixbuf = NULL; if (this->href) { Inkscape::Pixbuf *pixbuf = NULL; - gchar const* uri = this->getRepr()->attribute("xlink:href"); - - if(!uri) { - g_warning("Image tag has no valid href: %s", this->getId()); - - } else if (strncmp (uri, "data:", 5) == 0) { - uri += 5; - pixbuf = Inkscape::Pixbuf::create_from_data_uri(uri); - - } else if(g_str_has_suffix(uri, ".svg")) { - SPDocument *doc = this->document->createChildDoc(uri); - if(doc) { - this->child = SP_ITEM(doc); - g_warning("Loaded document: %s", uri); - } else { - g_warning("Could not load svg for image tag: %s",this->getId()); - } - } else { - pixbuf = Inkscape::Pixbuf::create_from_file(uri); - } - if(!pixbuf && !this->child) { - /* Nope: We do not find any valid pixmap file :-( */ - pixbuf = new Inkscape::Pixbuf( - gdk_pixbuf_new_from_xpm_data((const gchar **) brokenimage_xpm)); - - /* If the xpm doesn't load, our libraries are broken */ - g_assert (pixbuf != NULL); - } + pixbuf = sp_image_repr_read_image ( + this->getRepr()->attribute("xlink:href"), + this->getRepr()->attribute("sodipodi:absref"), + doc->getBase()); + if (pixbuf) { // BLIP #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) @@ -527,18 +506,6 @@ void SPImage::update(SPCtx *ctx, unsigned int flags) { sp_image_update_canvas_image ((SPImage *) this); } -// Remove references to image or child objects. -void SPImage::clear_image() { - if(this->pixbuf) { - delete this->pixbuf; - this->pixbuf = NULL; - } - if(this->child) { - this->detach(this->child); - this->child = NULL; - } -} - void SPImage::modified(unsigned int flags) { // SPItem::onModified(flags); @@ -679,6 +646,88 @@ Inkscape::DrawingItem* SPImage::show(Inkscape::Drawing &drawing, unsigned int /* return ai; } +Inkscape::Pixbuf *sp_image_repr_read_image(gchar const *href, gchar const *absref, gchar const *base) +{ + Inkscape::Pixbuf *inkpb = 0; + + gchar const *filename = href; + + if (filename != NULL) { + if (strncmp (filename,"file:",5) == 0) { + gchar *fullname = g_filename_from_uri(filename, NULL, NULL); + if (fullname) { + inkpb = Inkscape::Pixbuf::create_from_file(fullname); + g_free(fullname); + if (inkpb != NULL) { + return inkpb; + } + } + } else if (strncmp (filename,"data:",5) == 0) { + /* data URI - embedded image */ + filename += 5; + inkpb = Inkscape::Pixbuf::create_from_data_uri(filename); + if (inkpb != NULL) { + return inkpb; + } + } else { + + if (!g_path_is_absolute (filename)) { + /* try to load from relative pos combined with document base*/ + const gchar *docbase = base; + if (!docbase) { + docbase = "."; + } + gchar *fullname = g_build_filename(docbase, filename, NULL); + + // document base can be wrong (on the temporary doc when importing bitmap from a + // different dir) or unset (when doc is not saved yet), so we check for base+href existence first, + // and if it fails, we also try to use bare href regardless of its g_path_is_absolute + if (g_file_test (fullname, G_FILE_TEST_EXISTS) && !g_file_test (fullname, G_FILE_TEST_IS_DIR)) { + inkpb = Inkscape::Pixbuf::create_from_file(fullname); + if (inkpb != NULL) { + g_free (fullname); + return inkpb; + } + } + g_free (fullname); + } + + /* try filename as absolute */ + if (g_file_test (filename, G_FILE_TEST_EXISTS) && !g_file_test (filename, G_FILE_TEST_IS_DIR)) { + inkpb = Inkscape::Pixbuf::create_from_file(filename); + if (inkpb != NULL) { + return inkpb; + } + } + } + } + + /* at last try to load from sp absolute path name */ + filename = absref; + if (filename != NULL) { + // using absref is outside of SVG rules, so we must at least warn the user + if ( base != NULL && href != NULL ) { + g_warning (" did not resolve to a valid image file (base dir is %s), now trying sodipodi:absref=\"%s\"", href, base, absref); + } else { + g_warning ("xlink:href did not resolve to a valid image file, now trying sodipodi:absref=\"%s\"", absref); + } + + inkpb = Inkscape::Pixbuf::create_from_file(filename); + if (inkpb != NULL) { + return inkpb; + } + } + /* Nope: We do not find any valid pixmap file :-( */ + GdkPixbuf *pixbuf = gdk_pixbuf_new_from_xpm_data((const gchar **) brokenimage_xpm); + inkpb = new Inkscape::Pixbuf(pixbuf); + + /* It should be included xpm, so if it still does not does load, */ + /* our libraries are broken */ + g_assert (inkpb != NULL); + + return inkpb; +} + /* We assert that realpixbuf is either NULL or identical size to pixbuf */ static void sp_image_update_arenaitem (SPImage *image, Inkscape::DrawingImage *ai) diff --git a/src/sp-image.h b/src/sp-image.h index ad4fd4d54..3b7208487 100644 --- a/src/sp-image.h +++ b/src/sp-image.h @@ -53,10 +53,7 @@ public: gchar *color_profile; #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - // When image is a raster image, we use pixbuf Inkscape::Pixbuf *pixbuf; - // When it's an svg file, we use an SPItem similar to sp-use - SPItem *child; virtual void build(SPDocument *document, Inkscape::XML::Node *repr); virtual void release(); @@ -72,8 +69,6 @@ public: virtual Inkscape::DrawingItem* show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags); virtual void snappoints(std::vector &p, Inkscape::SnapPreferences const *snapprefs) const; virtual Geom::Affine set_transform(Geom::Affine const &transform); -private: - void clear_image(); }; /* Return duplicate of curve or NULL */ -- cgit v1.2.3 From 0605b3e5559d3124a89c1270ae9b453388c838c7 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Thu, 30 Jan 2014 11:22:46 +0100 Subject: Prevent crash if a symbols file does not have a title. (bzr r12985) --- src/ui/dialog/symbols.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index c33920117..7079ca001 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -562,10 +562,18 @@ void SymbolsDialog::get_symbols() { symbol_doc = SPDocument::createNewDoc( fullname, FALSE ); if( symbol_doc ) { - const gchar *title = g_dpgettext2(NULL, "Symbol", symbol_doc->getRoot()->title()); + + const gchar *title = symbol_doc->getRoot()->title(); + + // A user provided file may not have a title + if( title != NULL ) { + title = g_dpgettext2(NULL, "Symbol", title); // Translate + } + if( title == NULL ) { title = _("Unnamed Symbols"); } + symbolSets[Glib::ustring(title)] = symbol_doc; symbolSet->append(title); } -- cgit v1.2.3 From a4ce97ec6835fb6ea8dfd3dbee11abe103b064e4 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Thu, 30 Jan 2014 14:18:11 +0100 Subject: Correct positioning of custom markers. Fixes #230491. (bzr r12986) --- src/marker.cpp | 6 ++++-- src/marker.h | 2 +- src/selection-chemistry.cpp | 29 +++++++++++++++-------------- 3 files changed, 20 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/marker.cpp b/src/marker.cpp index d145aadaf..b9464186d 100644 --- a/src/marker.cpp +++ b/src/marker.cpp @@ -654,7 +654,7 @@ sp_marker_view_remove (SPMarker *marker, SPMarkerView *view, unsigned int destro delete view; } -const gchar *generate_marker(GSList *reprs, Geom::Rect bounds, SPDocument *document, Geom::Affine /*transform*/, Geom::Affine move) +const gchar *generate_marker(GSList *reprs, Geom::Rect bounds, SPDocument *document, Geom::Point center, Geom::Affine move) { Inkscape::XML::Document *xml_doc = document->getReprDoc(); Inkscape::XML::Node *defsrepr = document->getDefs()->getRepr(); @@ -668,6 +668,8 @@ const gchar *generate_marker(GSList *reprs, Geom::Rect bounds, SPDocument *docum sp_repr_set_svg_double(repr, "markerWidth", bounds.dimensions()[Geom::X]); sp_repr_set_svg_double(repr, "markerHeight", bounds.dimensions()[Geom::Y]); + sp_repr_set_svg_double(repr, "refX", center[Geom::X]); + sp_repr_set_svg_double(repr, "refY", center[Geom::Y]); repr->setAttribute("orient", "auto"); @@ -676,7 +678,7 @@ const gchar *generate_marker(GSList *reprs, Geom::Rect bounds, SPDocument *docum SPObject *mark_object = document->getObjectById(mark_id); for (GSList *i = reprs; i != NULL; i = i->next) { - Inkscape::XML::Node *node = (Inkscape::XML::Node *)(i->data); + Inkscape::XML::Node *node = (Inkscape::XML::Node *)(i->data); SPItem *copy = SP_ITEM(mark_object->appendChildRepr(node)); Geom::Affine dup_transform; diff --git a/src/marker.h b/src/marker.h index 831b298ac..b780950de 100644 --- a/src/marker.h +++ b/src/marker.h @@ -97,7 +97,7 @@ Inkscape::DrawingItem *sp_marker_show_instance (SPMarker *marker, Inkscape::Draw unsigned int key, unsigned int pos, Geom::Affine const &base, float linewidth); void sp_marker_hide (SPMarker *marker, unsigned int key); -const gchar *generate_marker (GSList *reprs, Geom::Rect bounds, SPDocument *document, Geom::Affine transform, Geom::Affine move); +const gchar *generate_marker (GSList *reprs, Geom::Rect bounds, SPDocument *document, Geom::Point center, Geom::Affine move); SPObject *sp_marker_fork_if_necessary(SPObject *marker); #endif diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 3082a2fe4..3f54ef8b9 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -2804,6 +2804,7 @@ void sp_selection_clone_original_path_lpe(SPDesktop *desktop) void sp_selection_to_marker(SPDesktop *desktop, bool apply) { + // sp_selection_tile has similar code if (desktop == NULL) { return; } @@ -2826,25 +2827,28 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply) return; } + // FIXME: Inverted Y coodinate + Geom::Point doc_height( 0, doc->getHeight().value("px")); + // calculate the transform to be applied to objects to move them to 0,0 - Geom::Point move_p = Geom::Point(0, doc->getHeight().value("px")) - *c; + Geom::Point corner( r->min()[Geom::X], r->max()[Geom::Y] ); // FIXME: Inverted Y coodinate + Geom::Point move_p = doc_height - corner; move_p[Geom::Y] = -move_p[Geom::Y]; Geom::Affine move = Geom::Affine(Geom::Translate(move_p)); + Geom::Point center( *c - corner ); // As defined by rotation center + center[Geom::Y] = -center[Geom::Y]; + GSList *items = g_slist_copy(const_cast(selection->itemList())); - items = g_slist_sort(items, (GCompareFunc) sp_object_compare_position); + items = g_slist_sort(items, (GCompareFunc) sp_object_compare_position); // Why needed? // bottommost object, after sorting SPObject *parent = SP_OBJECT(items->data)->parent; Geom::Affine parent_transform(SP_ITEM(parent)->i2doc_affine()); - // remember the position of the first item - gint pos = SP_OBJECT(items->data)->getRepr()->position(); - (void)pos; // TODO check why this was remembered - - // create a list of duplicates + // Create a list of duplicates, to be pasted inside marker element. GSList *repr_copies = NULL; for (GSList *i = items; i != NULL; i = i->next) { Inkscape::XML::Node *dup = SP_OBJECT(i->data)->getRepr()->duplicate(xml_doc); @@ -2854,7 +2858,8 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply) Geom::Rect bbox(desktop->dt2doc(r->min()), desktop->dt2doc(r->max())); if (apply) { - // delete objects so that their clones don't get alerted; this object will be restored shortly + // Delete objects so that their clones don't get alerted; + // the objects will be restored inside the marker element. for (GSList *i = items; i != NULL; i = i->next) { SPObject *item = reinterpret_cast(i->data); item->deleteObject(false); @@ -2868,12 +2873,7 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply) int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); - gchar const *mark_id = generate_marker(repr_copies, bbox, doc, - ( Geom::Affine(Geom::Translate(desktop->dt2doc( - Geom::Point(r->min()[Geom::X], - r->max()[Geom::Y])))) - * parent_transform.inverse() ), - parent_transform * move); + gchar const *mark_id = generate_marker(repr_copies, bbox, doc, center, parent_transform * move); (void)mark_id; // restore compensation setting @@ -3099,6 +3099,7 @@ void sp_selection_unsymbol(SPDesktop *desktop) void sp_selection_tile(SPDesktop *desktop, bool apply) { + // sp_selection_to_marker has similar code if (desktop == NULL) { return; } -- cgit v1.2.3 From 5072fa495b429536218ce602162098582df1707b Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Thu, 30 Jan 2014 16:38:53 +0100 Subject: Don't reverse object order when creating a marker. (bzr r12987) --- src/selection-chemistry.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 3f54ef8b9..ecf814f60 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -2841,7 +2841,7 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply) GSList *items = g_slist_copy(const_cast(selection->itemList())); - items = g_slist_sort(items, (GCompareFunc) sp_object_compare_position); // Why needed? + //items = g_slist_sort(items, (GCompareFunc) sp_object_compare_position); // Why needed? // bottommost object, after sorting SPObject *parent = SP_OBJECT(items->data)->parent; -- cgit v1.2.3 From 77e7d632cbfdd00b7c6d61c952608ed6f26872f6 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Fri, 31 Jan 2014 14:36:53 -0500 Subject: Fix spacing/remove tabs and eliminate extra conditional. (bzr r12989) --- src/ui/dialog/symbols.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index 7079ca001..b3efb58f7 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -563,16 +563,14 @@ void SymbolsDialog::get_symbols() { symbol_doc = SPDocument::createNewDoc( fullname, FALSE ); if( symbol_doc ) { - const gchar *title = symbol_doc->getRoot()->title(); - - // A user provided file may not have a title - if( title != NULL ) { - title = g_dpgettext2(NULL, "Symbol", title); // Translate - } - - if( title == NULL ) { - title = _("Unnamed Symbols"); - } + const gchar *title = symbol_doc->getRoot()->title(); + + // A user provided file may not have a title + if( title != NULL ) { + title = g_dpgettext2(NULL, "Symbol", title); // Translate + } else { + title = _("Unnamed Symbols"); + } symbolSets[Glib::ustring(title)] = symbol_doc; symbolSet->append(title); -- cgit v1.2.3 From a666cb5212b82f743913c5e45c11ac759077ec43 Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Fri, 31 Jan 2014 16:54:37 -0500 Subject: simplify equations in get_scale_transform_for_variable_stroke() for the case of 'scaled stroke'/'optimized transforms' (bzr r12990) --- src/sp-item-transform.cpp | 47 ++++++++++++++++------------------------------- 1 file changed, 16 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/sp-item-transform.cpp b/src/sp-item-transform.cpp index 7fa591fee..05390c910 100644 --- a/src/sp-item-transform.cpp +++ b/src/sp-item-transform.cpp @@ -246,7 +246,7 @@ Geom::Affine get_scale_transform_for_variable_stroke(Geom::Rect const &bbox_visu // 1) We start with a visual bounding box (w0, h0) which we want to transfer into another visual bounding box (w1, h1) // 2) We will also know the geometric bounding box, which can be used to calculate the strokewidth. The strokewidth will however - // be different for each of the four sides (left/right/top/bottom: r0l, r0r, r0t, r0b) + // be different for each of the four sides (left/right/top/bottom: r0l, r0r, r0t, r0b) gdouble w0 = bbox_visual.width(); // will return a value >= 0, as required further down the road gdouble h0 = bbox_visual.height(); @@ -258,8 +258,10 @@ Geom::Affine get_scale_transform_for_variable_stroke(Geom::Rect const &bbox_visu // We will now try to calculate the affine transformation required to transform the first visual bounding box into // the second one, while accounting for strokewidth - gdouble r0w = w0 - bbox_geom.width(); // r0w is the average strokewidth of the left and right edges, i.e. 0.5*(r0l + r0r) + gdouble r0w = w0 - bbox_geom.width(); // r0w is the average strokewidth of the left and right edges, i.e. 0.5*(r0l + r0r) gdouble r0h = h0 - bbox_geom.height(); // r0h is the average strokewidth of the top and bottom edges, i.e. 0.5*(r0t + r0b) + if ((r0w == Geom::infinity()) || (fabs(r0w) < 1e-6)) r0w = 0; + if ((r0h == Geom::infinity()) || (fabs(r0h) < 1e-6)) r0h = 0; int flip_x = (w1 > 0) ? 1 : -1; int flip_y = (h1 > 0) ? 1 : -1; @@ -308,38 +310,21 @@ Geom::Affine get_scale_transform_for_variable_stroke(Geom::Rect const &bbox_visu * Desired area of the geometric bounding box: A1 = (w1-r1w)*(h1-r1h) * This is how the stroke should scale: r1w^2 = A1/A0 * r0w^2, AND * r1h^2 = A1/A0 * r0h^2 - * Now we have to solve this set of two equations and find r1w and r1h; this too complicated to do by hand, - * so I used wxMaxima for that (http://wxmaxima.sourceforge.net/). These lines can be copied into Maxima - * - * A1: (w1-r1w)*(h1-r1h); - * s: A1/A0; - * expr1a: r1w^2 = s*r0w^2; - * expr1b: r1h^2 = s*r0h^2; - * sol: solve([expr1a, expr1b], [r1h, r1w]); - * sol[1][1]; sol[2][1]; sol[3][1]; sol[4][1]; - * sol[1][2]; sol[2][2]; sol[3][2]; sol[4][2]; - * - * PS1: The last two lines are only needed for readability of the output, and can be omitted if desired - * PS2: A0 is known beforehand and assumed to be constant, instead of using A0 = (w0-r0w)*(h0-r0h). This reduces the - * length of the results significantly - * PS3: You'll get 8 solutions, 4 for each of the strokewidths r1w and r1h. Some experiments quickly showed which of the solutions - * lead to meaningful strokewidths + * These can be re-expressed as : r1w/r0w = r1h/r0h + * and : r1w*r1w*(w0 - r0w)*(h0 - r0h) = r0w*r0w*(w1 - r1w)*(h1 - r1h) + * This leads to a quadratic equation in r1w, solved as follows: * */ - gdouble r0h2 = r0h*r0h; - gdouble r0h3 = r0h2*r0h; - gdouble r0w2 = r0w*r0w; - gdouble w12 = w1*w1; - gdouble h12 = h1*h1; - gdouble A0 = bbox_geom.area(); - gdouble A02 = A0*A0; - - gdouble operant = 4*h1*w1*A0+r0h2*w12-2*h1*r0h*r0w*w1+h12*r0w2; - if (operant < 0) { + + gdouble A = w0*h0 - r0h*w0 - r0w*h0; + gdouble B = r0h*w1 + r0w*h1; + gdouble C = -w1*h1; + + if (B*B - 4*A*C < 0) { g_message("variable stroke scaling error : %d, %d, %f, %f, %f, %f, %f, %f", transform_stroke, preserve, r0w, r0h, w0, h0, w1, h1); } else { - // Of the eight roots, I verified experimentally that these are the two we need - r1h = fabs((r0h*sqrt(operant)-r0h2*w1-h1*r0h*r0w)/(2*A0-2*r0h*r0w)); - r1w = fabs(-((h1*r0w*A0+r0h2*r0w*w1)*sqrt(operant)+(-3*h1*r0h*r0w*w1-h12*r0w2)*A0-r0h3*r0w*w12+h1*r0h2*r0w2*w1)/((r0h*A0-r0h2*r0w)*sqrt(operant)-2*h1*A02+(3*h1*r0h*r0w-r0h2*w1)*A0+r0h3*r0w*w1-h1*r0h2*r0w2)); + gdouble det = (-B + sqrt(B*B - 4*A*C))/(2*A); + r1w = r0w*det; + r1h = r0h*det; // If w1 < 0 then the scale will be wrong if we just assume that scale_x = (w1 - r1)/(w0 - r0); // Therefore we here need the absolute values of w0, w1, h0, h1, and r0, as taken care of earlier scale_x = (w1 - r1w)/(w0 - r0w); -- cgit v1.2.3 From 54f21698664f3b4ae65a4ece376dc404212a2639 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Fri, 31 Jan 2014 22:56:58 +0100 Subject: Do not throw TypeNotRegistered exceptions for now, since they interfere with debugging via 'catch throw'. (bzr r12991) --- src/factory.h | 4 +++- src/sp-object.cpp | 34 ++++++++++++++++------------------ 2 files changed, 19 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/factory.h b/src/factory.h index a1df55277..d7f4cb2b9 100644 --- a/src/factory.h +++ b/src/factory.h @@ -63,7 +63,9 @@ public: typename std::map::const_iterator it = this->_object_map.find(id); if (it == this->_object_map.end()) { - throw FactoryExceptions::TypeNotRegistered(id); + //throw FactoryExceptions::TypeNotRegistered(id); + g_warning("unknown type: %s", id.c_str()); + return NULL; } return it->second(); diff --git a/src/sp-object.cpp b/src/sp-object.cpp index 0e6eef6ae..764b5f260 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -585,23 +585,22 @@ SPObject *SPObject::get_child_by_repr(Inkscape::XML::Node *repr) void SPObject::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) { SPObject* object = this; - try { - const std::string typeString = NodeTraits::get_type_string(*child); + const std::string type_string = NodeTraits::get_type_string(*child); - SPObject* ochild = SPFactory::instance().createObject(typeString); - - SPObject *prev = ref ? object->get_child_by_repr(ref) : NULL; - object->attach(ochild, prev); - sp_object_unref(ochild, NULL); - - ochild->invoke_build(object->document, child, object->cloned); - } catch (const FactoryExceptions::TypeNotRegistered& e) { + SPObject* ochild = SPFactory::instance().createObject(type_string); + if (ochild == NULL) { // Currenty, there are many node types that do not have // corresponding classes in the SPObject tree. // (rdf:RDF, inkscape:clipboard, ...) // Thus, simply ignore this case for now. return; } + + SPObject *prev = ref ? object->get_child_by_repr(ref) : NULL; + object->attach(ochild, prev); + sp_object_unref(ochild, NULL); + + ochild->invoke_build(object->document, child, object->cloned); } void SPObject::release() { @@ -645,21 +644,20 @@ void SPObject::build(SPDocument *document, Inkscape::XML::Node *repr) { object->readAttr("inkscape:collect"); for (Inkscape::XML::Node *rchild = repr->firstChild() ; rchild != NULL; rchild = rchild->next()) { - try { - const std::string typeString = NodeTraits::get_type_string(*rchild); - - SPObject* child = SPFactory::instance().createObject(typeString); + const std::string typeString = NodeTraits::get_type_string(*rchild); - object->attach(child, object->lastChild()); - sp_object_unref(child, NULL); - child->invoke_build(document, rchild, object->cloned); - } catch (const FactoryExceptions::TypeNotRegistered& e) { + SPObject* child = SPFactory::instance().createObject(typeString); + if (child == NULL) { // Currenty, there are many node types that do not have // corresponding classes in the SPObject tree. // (rdf:RDF, inkscape:clipboard, ...) // Thus, simply ignore this case for now. continue; } + + object->attach(child, object->lastChild()); + sp_object_unref(child, NULL); + child->invoke_build(document, rchild, object->cloned); } } -- cgit v1.2.3 From 69b758c9769ae3e38fea2e1ff04a6ed7450e75d9 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Sat, 1 Feb 2014 12:14:58 +0100 Subject: Fix some formatting problems and add formatting info at end of file. (bzr r12992) --- src/ui/dialog/symbols.cpp | 134 +++++++++++++++++++++++++--------------------- 1 file changed, 74 insertions(+), 60 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index b3efb58f7..98754fb4f 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -76,7 +76,7 @@ namespace UI { namespace Dialog { - // See: http://developer.gnome.org/gtkmm/stable/classGtk_1_1TreeModelColumnRecord.html +// See: http://developer.gnome.org/gtkmm/stable/classGtk_1_1TreeModelColumnRecord.html class SymbolColumns : public Gtk::TreeModel::ColumnRecord { public: @@ -399,11 +399,13 @@ SPDocument* SymbolsDialog::selectedSymbols() { } Glib::ustring SymbolsDialog::selectedSymbolId() { - #if WITH_GTKMM_3_0 - std::vector iconArray = iconView->get_selected_items(); - #else - Gtk::IconView::ArrayHandle_TreePaths iconArray = iconView->get_selected_items(); - #endif + +#if WITH_GTKMM_3_0 + std::vector iconArray = iconView->get_selected_items(); +#else + Gtk::IconView::ArrayHandle_TreePaths iconArray = iconView->get_selected_items(); +#endif + if( !iconArray.empty() ) { Gtk::TreeModel::Path const & path = *iconArray.begin(); Gtk::ListStore::iterator row = store->get_iter(path); @@ -428,12 +430,12 @@ void SymbolsDialog::iconChanged() { // First look for default style stored in gchar const* style = symbol->getAttribute("inkscape:symbol-style"); if( !style ) { - // If no default style in , look in documents. - if( symbolDocument == currentDocument ) { - style = style_from_use( symbol_id.c_str(), currentDocument ); - } else { - style = symbolDocument->getReprRoot()->attribute("style"); - } + // If no default style in , look in documents. + if( symbolDocument == currentDocument ) { + style = style_from_use( symbol_id.c_str(), currentDocument ); + } else { + style = symbolDocument->getReprRoot()->attribute("style"); + } } ClipboardManager *cm = ClipboardManager::get(); @@ -497,8 +499,8 @@ SPDocument* read_vss( gchar* fullname, gchar* filename ) { while( std::getline( iss, line ) ) { // std::cout << line << std::endl; if( line.find( "svg:svg" ) == std::string::npos ) { - tmpSVGOutput += line; - tmpSVGOutput += "\n"; + tmpSVGOutput += line; + tmpSVGOutput += "\n"; } } @@ -519,11 +521,11 @@ void SymbolsDialog::get_symbols() { std::list directories; if( Inkscape::IO::file_test( INKSCAPE_SYMBOLSDIR, G_FILE_TEST_EXISTS ) && - Inkscape::IO::file_test( INKSCAPE_SYMBOLSDIR, G_FILE_TEST_IS_DIR ) ) { + Inkscape::IO::file_test( INKSCAPE_SYMBOLSDIR, G_FILE_TEST_IS_DIR ) ) { directories.push_back( INKSCAPE_SYMBOLSDIR ); } if( Inkscape::IO::file_test( profile_path("symbols"), G_FILE_TEST_EXISTS ) && - Inkscape::IO::file_test( profile_path("symbols"), G_FILE_TEST_IS_DIR ) ) { + Inkscape::IO::file_test( profile_path("symbols"), G_FILE_TEST_IS_DIR ) ) { directories.push_back( profile_path("symbols") ); } @@ -534,53 +536,53 @@ void SymbolsDialog::get_symbols() { GDir *dir = g_dir_open( (*it).c_str(), 0, &err ); if( dir ) { - gchar *filename = 0; - while( (filename = (gchar *)g_dir_read_name( dir ) ) != NULL) { + gchar *filename = 0; + while( (filename = (gchar *)g_dir_read_name( dir ) ) != NULL) { - gchar *fullname = g_build_filename((*it).c_str(), filename, NULL); + gchar *fullname = g_build_filename((*it).c_str(), filename, NULL); - if ( !Inkscape::IO::file_test( fullname, G_FILE_TEST_IS_DIR ) - && ( Glib::str_has_suffix(fullname, ".svg") || Glib::str_has_suffix(fullname, ".vss") ) ) { + if ( !Inkscape::IO::file_test( fullname, G_FILE_TEST_IS_DIR ) + && ( Glib::str_has_suffix(fullname, ".svg") || Glib::str_has_suffix(fullname, ".vss") ) ) { - Glib::ustring fn( filename ); - Glib::ustring tag = fn.substr( fn.find_last_of(".") + 1 ); + Glib::ustring fn( filename ); + Glib::ustring tag = fn.substr( fn.find_last_of(".") + 1 ); - SPDocument* symbol_doc = NULL; + SPDocument* symbol_doc = NULL; #ifdef WITH_LIBVISIO - if( tag.compare( "vss" ) == 0 ) { + if( tag.compare( "vss" ) == 0 ) { - symbol_doc = read_vss( fullname, filename ); - if( symbol_doc ) { - symbolSets[Glib::ustring(filename)]= symbol_doc; - symbolSet->append(filename); - } - } + symbol_doc = read_vss( fullname, filename ); + if( symbol_doc ) { + symbolSets[Glib::ustring(filename)]= symbol_doc; + symbolSet->append(filename); + } + } #endif - // Try to read all remaining files as SVG - if( !symbol_doc ) { + // Try to read all remaining files as SVG + if( !symbol_doc ) { + + symbol_doc = SPDocument::createNewDoc( fullname, FALSE ); + if( symbol_doc ) { - symbol_doc = SPDocument::createNewDoc( fullname, FALSE ); - if( symbol_doc ) { + const gchar *title = symbol_doc->getRoot()->title(); - const gchar *title = symbol_doc->getRoot()->title(); + // A user provided file may not have a title + if( title != NULL ) { + title = g_dpgettext2(NULL, "Symbol", title); // Translate + } else { + title = _("Unnamed Symbols"); + } - // A user provided file may not have a title - if( title != NULL ) { - title = g_dpgettext2(NULL, "Symbol", title); // Translate - } else { - title = _("Unnamed Symbols"); + symbolSets[Glib::ustring(title)] = symbol_doc; + symbolSet->append(title); + } } - symbolSets[Glib::ustring(title)] = symbol_doc; - symbolSet->append(title); } + g_free( fullname ); } - - } - g_free( fullname ); - } - g_dir_close( dir ); + g_dir_close( dir ); } } } @@ -642,16 +644,16 @@ gchar const* SymbolsDialog::style_from_use( gchar const* id, SPDocument* documen for( ; l != NULL; l = l->next ) { SPObject* use = SP_OBJECT(l->data); if( SP_IS_USE( use ) ) { - gchar const *href = use->getRepr()->attribute("xlink:href"); - if( href ) { - Glib::ustring href2(href); - Glib::ustring id2(id); - id2 = "#" + id2; - if( !href2.compare(id2) ) { - style = use->getRepr()->attribute("style"); - break; - } - } + gchar const *href = use->getRepr()->attribute("xlink:href"); + if( href ) { + Glib::ustring href2(href); + Glib::ustring id2(id); + id2 = "#" + id2; + if( !href2.compare(id2) ) { + style = use->getRepr()->attribute("style"); + break; + } + } } } return style; @@ -808,8 +810,8 @@ void SymbolsDialog::setTargetDesktop(SPDesktop *desktop) if (this->currentDesktop != desktop) { this->currentDesktop = desktop; if( !symbolSets[symbolSet->get_active_text()] ) { - // Symbol set is from Current document, update - rebuild(); + // Symbol set is from Current document, update + rebuild(); } } } @@ -817,3 +819,15 @@ void SymbolsDialog::setTargetDesktop(SPDesktop *desktop) } //namespace Dialogs } //namespace UI } //namespace Inkscape + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-basic-offset:2 + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=2:tabstop=8:softtabstop=2:fileencoding=utf-8:textwidth=99 : -- cgit v1.2.3 From 4212daecf6d6315290ae74f7a3c1c0fda87fc738 Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Sat, 1 Feb 2014 15:38:03 -0500 Subject: remove vertical offset when stretching a horizontal line (Bug 1275077) Fixed bugs: - https://launchpad.net/bugs/1275077 (bzr r12993) --- src/sp-item-transform.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/sp-item-transform.cpp b/src/sp-item-transform.cpp index 05390c910..1ab8edd51 100644 --- a/src/sp-item-transform.cpp +++ b/src/sp-item-transform.cpp @@ -146,9 +146,13 @@ Geom::Affine get_scale_transform_for_uniform_stroke(Geom::Rect const &bbox_visua if ((fabs(w0 - stroke_x) < 1e-6) || w1 == 0) { // We have a vertical line at hand scale_y = h1/h0; scale_x = transform_stroke ? 1 : scale_y; + unbudge *= Geom::Translate (-flip_x * 0.5 * (scale_x - 1.0) * w0, 0); + unbudge *= Geom::Translate ( flip_x * 0.5 * (w1 - w0), 0); // compensate for the fact that this operation cannot be performed } else if ((fabs(h0 - stroke_y) < 1e-6) || h1 == 0) { // We have a horizontal line at hand scale_x = w1/w0; scale_y = transform_stroke ? 1 : scale_x; + unbudge *= Geom::Translate (0, -flip_y * 0.5 * (scale_y - 1.0) * h0); + unbudge *= Geom::Translate (0, flip_y * 0.5 * (h1 - h0)); // compensate for the fact that this operation cannot be performed } else { // We have a true 2D object at hand if (transform_stroke && !preserve) { /* Initial area of the geometric bounding box: A0 = (w0-r0)*(h0-r0) @@ -299,11 +303,13 @@ Geom::Affine get_scale_transform_for_variable_stroke(Geom::Rect const &bbox_visu if ((fabs(w0 - r0w) < 1e-6) || w1 == 0) { // We have a vertical line at hand scale_y = h1/h0; scale_x = transform_stroke ? 1 : scale_y; - unbudge *= Geom::Translate (flip_x * 0.5 * (w1 - w0), 0); // compensate for the fact that this operation cannot be performed + unbudge *= Geom::Translate (-flip_x * 0.5 * (scale_x - 1.0) * w0, 0); + unbudge *= Geom::Translate ( flip_x * 0.5 * (w1 - w0), 0); // compensate for the fact that this operation cannot be performed } else if ((fabs(h0 - r0h) < 1e-6) || h1 == 0) { // We have a horizontal line at hand scale_x = w1/w0; scale_y = transform_stroke ? 1 : scale_x; - unbudge *= Geom::Translate (0, flip_y * 0.5 * (h1 - h0)); // compensate for the fact that this operation cannot be performed + unbudge *= Geom::Translate (0, -flip_y * 0.5 * (scale_y - 1.0) * h0); + unbudge *= Geom::Translate (0, flip_y * 0.5 * (h1 - h0)); // compensate for the fact that this operation cannot be performed } else { // We have a true 2D object at hand if (transform_stroke && !preserve) { /* Initial area of the geometric bounding box: A0 = (w0-r0w)*(h0-r0h) -- cgit v1.2.3 From 157187379f241da2bb559f17e47b7d35b1684616 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Tue, 4 Feb 2014 07:49:51 +0100 Subject: Fix for Bug #1275146 (numerous messages of type unknown type: rdf:RDF). Fixed bugs: - https://launchpad.net/bugs/1275146 (bzr r12995) --- src/factory.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/factory.h b/src/factory.h index d7f4cb2b9..7e466f95a 100644 --- a/src/factory.h +++ b/src/factory.h @@ -64,7 +64,12 @@ public: if (it == this->_object_map.end()) { //throw FactoryExceptions::TypeNotRegistered(id); - g_warning("unknown type: %s", id.c_str()); + if (!(id.empty() // comments, usually + or id == "rdf:RDF" // no SP node yet + or id == "inkscape:clipboard" // SP node not necessary + or id == "inkscape:_templateinfo")) { + g_warning("unknown type: %s", id.c_str()); + } return NULL; } -- cgit v1.2.3 From 28faf1002334ac22523e7a0cf78f170de9e91f9a Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Tue, 4 Feb 2014 14:58:12 +0100 Subject: Workaround for Bug #1273510 (crash in in cc_generic_knot_handler() after tool-switch). (bzr r12996) --- src/ui/tools/connector-tool.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/tools/connector-tool.cpp b/src/ui/tools/connector-tool.cpp index 62d52f6af..50cb00360 100644 --- a/src/ui/tools/connector-tool.cpp +++ b/src/ui/tools/connector-tool.cpp @@ -1080,7 +1080,12 @@ cc_generic_knot_handler(SPCanvasItem *, GdkEvent *event, SPKnot *knot) case GDK_LEAVE_NOTIFY: sp_knot_set_flag(knot, SP_KNOT_MOUSEOVER, FALSE); - cc->active_handle = NULL; + /* FIXME: the following test is a workaround for LP Bug #1273510. + * It seems that a signal is not correctly disconnected, maybe + * something missing in cc_clear_active_conn()? */ + if (cc) { + cc->active_handle = NULL; + } if (knot_tip) { knot->desktop->event_context->defaultMessageContext()->clear(); -- cgit v1.2.3 From c7731033ef400fccb6a49d830ded86068fcd3432 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Wed, 5 Feb 2014 12:29:11 +0100 Subject: Fix for Bug #1250685 (Unnecessary gender-specific terms in code). Fixed bugs: - https://launchpad.net/bugs/1250685 (bzr r12997) --- src/libnrtype/FontFactory.cpp | 4 +- src/libnrtype/FontInstance.cpp | 40 +-- src/libnrtype/TextWrapper.cpp | 2 +- src/libnrtype/font-instance.h | 2 +- src/livarot/AVL.cpp | 652 ++++++++++++++++++++--------------------- src/livarot/AVL.h | 6 +- src/livarot/PathCutting.cpp | 12 +- src/livarot/ShapeMisc.cpp | 12 +- src/livarot/sweep-event.cpp | 32 +- src/livarot/sweep-tree.cpp | 16 +- src/splivarot.cpp | 10 +- src/ui/tools/spray-tool.cpp | 56 ++-- 12 files changed, 422 insertions(+), 422 deletions(-) (limited to 'src') diff --git a/src/libnrtype/FontFactory.cpp b/src/libnrtype/FontFactory.cpp index 9fc553efd..f05b75aaa 100644 --- a/src/libnrtype/FontFactory.cpp +++ b/src/libnrtype/FontFactory.cpp @@ -973,12 +973,12 @@ font_instance *font_factory::Face(PangoFontDescription *descr, bool canFail) // point) whether loadedFaces[that_descr] is free or not (and overwriting // an entry will bring deallocation problems) res->descr = pango_font_description_copy(descr); - res->daddy = this; + res->parent = this; res->InstallFace(nFace); if ( res->pFont == NULL ) { // failed to install face -> bitmap font // printf("face failed\n"); - res->daddy = NULL; + res->parent = NULL; delete res; res = NULL; if ( canFail ) { diff --git a/src/libnrtype/FontInstance.cpp b/src/libnrtype/FontInstance.cpp index 434f3ee47..a5b782344 100644 --- a/src/libnrtype/FontInstance.cpp +++ b/src/libnrtype/FontInstance.cpp @@ -174,7 +174,7 @@ font_instance::font_instance(void) : pFont(0), descr(0), refCount(0), - daddy(0), + parent(0), nbGlyph(0), maxGlyph(0), glyphs(0), @@ -185,9 +185,9 @@ font_instance::font_instance(void) : font_instance::~font_instance(void) { - if ( daddy ) { - daddy->UnrefFace(this); - daddy = 0; + if ( parent ) { + parent->UnrefFace(this); + parent = 0; } //printf("font instance death\n"); @@ -389,13 +389,13 @@ void font_instance::InitTheFace() if ( !theFace ) { LOGFONT *lf=pango_win32_font_logfont(pFont); g_assert(lf != NULL); - theFace=pango_win32_font_cache_load(daddy->pangoFontCache,lf); + theFace=pango_win32_font_cache_load(parent->pangoFontCache,lf); g_free(lf); } XFORM identity = {1.0, 0.0, 0.0, 1.0, 0.0, 0.0}; - SetWorldTransform(daddy->hScreenDC, &identity); - SetGraphicsMode(daddy->hScreenDC, GM_COMPATIBLE); - SelectObject(daddy->hScreenDC,theFace); + SetWorldTransform(parent->hScreenDC, &identity); + SetGraphicsMode(parent->hScreenDC, GM_COMPATIBLE); + SelectObject(parent->hScreenDC,theFace); #else theFace=pango_fc_font_lock_face(PANGO_FC_FONT(pFont)); if ( theFace ) { @@ -408,8 +408,8 @@ void font_instance::InitTheFace() void font_instance::FreeTheFace() { #ifdef USE_PANGO_WIN32 - SelectObject(daddy->hScreenDC,GetStockObject(SYSTEM_FONT)); - pango_win32_font_cache_unload(daddy->pangoFontCache,theFace); + SelectObject(parent->hScreenDC,GetStockObject(SYSTEM_FONT)); + pango_win32_font_cache_unload(parent->pangoFontCache,theFace); #else pango_fc_font_unlock_face(PANGO_FC_FONT(pFont)); #endif @@ -443,7 +443,7 @@ bool font_instance::IsOutlineFont(void) InitTheFace(); #ifdef USE_PANGO_WIN32 TEXTMETRIC tm; - return GetTextMetrics(daddy->hScreenDC,&tm) && tm.tmPitchAndFamily&(TMPF_TRUETYPE|TMPF_DEVICE); + return GetTextMetrics(parent->hScreenDC,&tm) && tm.tmPitchAndFamily&(TMPF_TRUETYPE|TMPF_DEVICE); #else return FT_IS_SCALABLE(theFace); #endif @@ -513,10 +513,10 @@ void font_instance::LoadGlyph(int glyph_id) MAT2 identity = {{0,1},{0,0},{0,0},{0,1}}; OUTLINETEXTMETRIC otm; - GetOutlineTextMetrics(daddy->hScreenDC, sizeof(otm), &otm); + GetOutlineTextMetrics(parent->hScreenDC, sizeof(otm), &otm); GLYPHMETRICS metrics; - DWORD bufferSize=GetGlyphOutline (daddy->hScreenDC, glyph_id, GGO_GLYPH_INDEX | GGO_NATIVE | GGO_UNHINTED, &metrics, 0, NULL, &identity); - double scale=1.0/daddy->fontSize; + DWORD bufferSize=GetGlyphOutline (parent->hScreenDC, glyph_id, GGO_GLYPH_INDEX | GGO_NATIVE | GGO_UNHINTED, &metrics, 0, NULL, &identity); + double scale=1.0/parent->fontSize; n_g.h_advance=metrics.gmCellIncX*scale; n_g.v_advance=otm.otmTextMetrics.tmHeight*scale; n_g.h_width=metrics.gmBlackBoxX*scale; @@ -528,7 +528,7 @@ void font_instance::LoadGlyph(int glyph_id) doAdd=true; } else { char *buffer = new char[bufferSize]; - if ( GetGlyphOutline (daddy->hScreenDC, glyph_id, GGO_GLYPH_INDEX | GGO_NATIVE | GGO_UNHINTED, &metrics, bufferSize, buffer, &identity) <= 0 ) { + if ( GetGlyphOutline (parent->hScreenDC, glyph_id, GGO_GLYPH_INDEX | GGO_NATIVE | GGO_UNHINTED, &metrics, bufferSize, buffer, &identity) <= 0 ) { // shit happened } else { // Platform SDK is rubbish, read KB87115 instead @@ -655,10 +655,10 @@ bool font_instance::FontMetrics(double &ascent,double &descent,double &leading) } #ifdef USE_PANGO_WIN32 OUTLINETEXTMETRIC otm; - if ( !GetOutlineTextMetrics(daddy->hScreenDC,sizeof(otm),&otm) ) { + if ( !GetOutlineTextMetrics(parent->hScreenDC,sizeof(otm),&otm) ) { return false; } - double scale=1.0/daddy->fontSize; + double scale=1.0/parent->fontSize; ascent=fabs(otm.otmAscent*scale); descent=fabs(otm.otmDescent*scale); leading=fabs(otm.otmLineGap*scale); @@ -688,10 +688,10 @@ bool font_instance::FontDecoration( } #ifdef USE_PANGO_WIN32 OUTLINETEXTMETRIC otm; - if ( !GetOutlineTextMetrics(daddy->hScreenDC,sizeof(otm),&otm) ) { + if ( !GetOutlineTextMetrics(parent->hScreenDC,sizeof(otm),&otm) ) { return false; } - double scale=1.0/daddy->fontSize; + double scale=1.0/parent->fontSize; underline_position = fabs(otm.otmUnderscorePosition *scale); underline_thickness = fabs(otm.otmUnderscoreSize *scale); linethrough_position = fabs(otm.otmStrikeoutPosition *scale); @@ -725,7 +725,7 @@ bool font_instance::FontSlope(double &run, double &rise) #ifdef USE_PANGO_WIN32 OUTLINETEXTMETRIC otm; - if ( !GetOutlineTextMetrics(daddy->hScreenDC,sizeof(otm),&otm) ) return false; + if ( !GetOutlineTextMetrics(parent->hScreenDC,sizeof(otm),&otm) ) return false; run=otm.otmsCharSlopeRun; rise=otm.otmsCharSlopeRise; #else diff --git a/src/libnrtype/TextWrapper.cpp b/src/libnrtype/TextWrapper.cpp index 32877e275..380e9ba3f 100644 --- a/src/libnrtype/TextWrapper.cpp +++ b/src/libnrtype/TextWrapper.cpp @@ -327,7 +327,7 @@ void text_wrapper::DoLayout(void) for (int i = 0; i < glyph_length; i++) { glyph_text[i].uni_st = uni32_codepoint[glyph_text[i].uni_st]; glyph_text[i].uni_en = uni32_codepoint[glyph_text[i].uni_en]; - glyph_text[i].x /= 512; // why is this not default_font->daddy->fontsize? + glyph_text[i].x /= 512; // why is this not default_font->parent->fontsize? glyph_text[i].y /= 512; } if ( glyph_length > 0 ) { diff --git a/src/libnrtype/font-instance.h b/src/libnrtype/font-instance.h index ef10a04d0..75106617b 100644 --- a/src/libnrtype/font-instance.h +++ b/src/libnrtype/font-instance.h @@ -29,7 +29,7 @@ public: // refcount int refCount; // font_factory owning this font_instance - font_factory* daddy; + font_factory* parent; // common glyph definitions for all the rasterfonts std::map id_to_no; diff --git a/src/livarot/AVL.cpp b/src/livarot/AVL.cpp index e8ece7f8c..17af5ee66 100644 --- a/src/livarot/AVL.cpp +++ b/src/livarot/AVL.cpp @@ -28,10 +28,10 @@ void AVLTree::MakeNew() for (int i = 0; i < 2; i++) { elem[i] = NULL; - son[i] = NULL; + child[i] = NULL; } - dad = NULL; + parent = NULL; balance = 0; } @@ -47,32 +47,32 @@ void AVLTree::MakeDelete() AVLTree *AVLTree::Leftmost() { - return leafFromDad(NULL, LEFT); + return leafFromParent(NULL, LEFT); } AVLTree *AVLTree::leaf(AVLTree *from, Side s) { - if (from == son[1 - s]) { - if (son[s]) { - return son[s]->leafFromDad(this, s); + if (from == child[1 - s]) { + if (child[s]) { + return child[s]->leafFromParent(this, s); } - else if (dad) { - return dad->leaf(this, s); + else if (parent) { + return parent->leaf(this, s); } } - else if (from == son[s]) { - if (dad) { - return dad->leaf(this, s); + else if (from == child[s]) { + if (parent) { + return parent->leaf(this, s); } } return NULL; } -AVLTree *AVLTree::leafFromDad(AVLTree */*from*/, Side s) +AVLTree *AVLTree::leafFromParent(AVLTree */*from*/, Side s) { - if (son[s]) { - return son[s]->leafFromDad(this, s); + if (child[s]) { + return child[s]->leafFromParent(this, s); } return this; @@ -83,60 +83,60 @@ AVLTree::RestoreBalances (AVLTree * from, AVLTree * &racine) { if (from == NULL) { - if (dad) - return dad->RestoreBalances (this, racine); + if (parent) + return parent->RestoreBalances (this, racine); } else { if (balance == 0) { - if (from == son[LEFT]) + if (from == child[LEFT]) balance = 1; - if (from == son[RIGHT]) + if (from == child[RIGHT]) balance = -1; - if (dad) - return dad->RestoreBalances (this, racine); + if (parent) + return parent->RestoreBalances (this, racine); return avl_no_err; } else if (balance > 0) { - if (from == son[RIGHT]) + if (from == child[RIGHT]) { balance = 0; return avl_no_err; } - if (son[LEFT] == NULL) + if (child[LEFT] == NULL) { // cout << "mierda\n"; return avl_bal_err; } AVLTree *a = this; - AVLTree *b = son[LEFT]; - AVLTree *e = son[RIGHT]; - AVLTree *c = son[LEFT]->son[LEFT]; - AVLTree *d = son[LEFT]->son[RIGHT]; - if (son[LEFT]->balance > 0) + AVLTree *b = child[LEFT]; + AVLTree *e = child[RIGHT]; + AVLTree *c = child[LEFT]->child[LEFT]; + AVLTree *d = child[LEFT]->child[RIGHT]; + if (child[LEFT]->balance > 0) { - AVLTree *r = dad; + AVLTree *r = parent; - a->dad = b; - b->son[RIGHT] = a; - a->son[RIGHT] = e; + a->parent = b; + b->child[RIGHT] = a; + a->child[RIGHT] = e; if (e) - e->dad = a; - a->son[LEFT] = d; + e->parent = a; + a->child[LEFT] = d; if (d) - d->dad = a; - b->son[LEFT] = c; + d->parent = a; + b->child[LEFT] = c; if (c) - c->dad = b; - b->dad = r; + c->parent = b; + b->parent = r; if (r) { - if (r->son[LEFT] == a) - r->son[LEFT] = b; - if (r->son[RIGHT] == a) - r->son[RIGHT] = b; + if (r->child[LEFT] == a) + r->child[LEFT] = b; + if (r->child[RIGHT] == a) + r->child[RIGHT] = b; } if (racine == a) racine = b; @@ -147,39 +147,39 @@ AVLTree::RestoreBalances (AVLTree * from, AVLTree * &racine) } else { - if (son[LEFT]->son[RIGHT] == NULL) + if (child[LEFT]->child[RIGHT] == NULL) { // cout << "mierda\n"; return avl_bal_err; } - AVLTree *f = son[LEFT]->son[RIGHT]->son[LEFT]; - AVLTree *g = son[LEFT]->son[RIGHT]->son[RIGHT]; - AVLTree *r = dad; - - a->dad = d; - d->son[RIGHT] = a; - b->dad = d; - d->son[LEFT] = b; - a->son[LEFT] = g; + AVLTree *f = child[LEFT]->child[RIGHT]->child[LEFT]; + AVLTree *g = child[LEFT]->child[RIGHT]->child[RIGHT]; + AVLTree *r = parent; + + a->parent = d; + d->child[RIGHT] = a; + b->parent = d; + d->child[LEFT] = b; + a->child[LEFT] = g; if (g) - g->dad = a; - a->son[RIGHT] = e; + g->parent = a; + a->child[RIGHT] = e; if (e) - e->dad = a; - b->son[LEFT] = c; + e->parent = a; + b->child[LEFT] = c; if (c) - c->dad = b; - b->son[RIGHT] = f; + c->parent = b; + b->child[RIGHT] = f; if (f) - f->dad = b; + f->parent = b; - d->dad = r; + d->parent = r; if (r) { - if (r->son[LEFT] == a) - r->son[LEFT] = d; - if (r->son[RIGHT] == a) - r->son[RIGHT] = d; + if (r->child[LEFT] == a) + r->child[LEFT] = d; + if (r->child[RIGHT] == a) + r->child[RIGHT] = d; } if (racine == a) racine = d; @@ -206,43 +206,43 @@ AVLTree::RestoreBalances (AVLTree * from, AVLTree * &racine) } else if (balance < 0) { - if (from == son[LEFT]) + if (from == child[LEFT]) { balance = 0; return avl_no_err; } - if (son[RIGHT] == NULL) + if (child[RIGHT] == NULL) { // cout << "mierda\n"; return avl_bal_err; } AVLTree *a = this; - AVLTree *b = son[RIGHT]; - AVLTree *e = son[LEFT]; - AVLTree *c = son[RIGHT]->son[RIGHT]; - AVLTree *d = son[RIGHT]->son[LEFT]; - AVLTree *r = dad; - if (son[RIGHT]->balance < 0) + AVLTree *b = child[RIGHT]; + AVLTree *e = child[LEFT]; + AVLTree *c = child[RIGHT]->child[RIGHT]; + AVLTree *d = child[RIGHT]->child[LEFT]; + AVLTree *r = parent; + if (child[RIGHT]->balance < 0) { - a->dad = b; - b->son[LEFT] = a; - a->son[LEFT] = e; + a->parent = b; + b->child[LEFT] = a; + a->child[LEFT] = e; if (e) - e->dad = a; - a->son[RIGHT] = d; + e->parent = a; + a->child[RIGHT] = d; if (d) - d->dad = a; - b->son[RIGHT] = c; + d->parent = a; + b->child[RIGHT] = c; if (c) - c->dad = b; - b->dad = r; + c->parent = b; + b->parent = r; if (r) { - if (r->son[LEFT] == a) - r->son[LEFT] = b; - if (r->son[RIGHT] == a) - r->son[RIGHT] = b; + if (r->child[LEFT] == a) + r->child[LEFT] = b; + if (r->child[RIGHT] == a) + r->child[RIGHT] = b; } if (racine == a) racine = b; @@ -252,38 +252,38 @@ AVLTree::RestoreBalances (AVLTree * from, AVLTree * &racine) } else { - if (son[RIGHT]->son[LEFT] == NULL) + if (child[RIGHT]->child[LEFT] == NULL) { // cout << "mierda\n"; return avl_bal_err; } - AVLTree *f = son[RIGHT]->son[LEFT]->son[RIGHT]; - AVLTree *g = son[RIGHT]->son[LEFT]->son[LEFT]; - - a->dad = d; - d->son[LEFT] = a; - b->dad = d; - d->son[RIGHT] = b; - a->son[RIGHT] = g; + AVLTree *f = child[RIGHT]->child[LEFT]->child[RIGHT]; + AVLTree *g = child[RIGHT]->child[LEFT]->child[LEFT]; + + a->parent = d; + d->child[LEFT] = a; + b->parent = d; + d->child[RIGHT] = b; + a->child[RIGHT] = g; if (g) - g->dad = a; - a->son[LEFT] = e; + g->parent = a; + a->child[LEFT] = e; if (e) - e->dad = a; - b->son[RIGHT] = c; + e->parent = a; + b->child[RIGHT] = c; if (c) - c->dad = b; - b->son[LEFT] = f; + c->parent = b; + b->child[LEFT] = f; if (f) - f->dad = b; + f->parent = b; - d->dad = r; + d->parent = r; if (r) { - if (r->son[LEFT] == a) - r->son[LEFT] = d; - if (r->son[RIGHT] == a) - r->son[RIGHT] = d; + if (r->child[LEFT] == a) + r->child[LEFT] = d; + if (r->child[RIGHT] == a) + r->child[RIGHT] = d; } if (racine == a) racine = d; @@ -319,12 +319,12 @@ AVLTree::RestoreBalances (int diff, AVLTree * &racine) if (diff < 0) { balance = 0; - if (dad) + if (parent) { - if (this == dad->son[RIGHT]) - return dad->RestoreBalances (1, racine); - if (this == dad->son[LEFT]) - return dad->RestoreBalances (-1, racine); + if (this == parent->child[RIGHT]) + return parent->RestoreBalances (1, racine); + if (this == parent->child[LEFT]) + return parent->RestoreBalances (-1, racine); } return avl_no_err; } @@ -333,38 +333,38 @@ AVLTree::RestoreBalances (int diff, AVLTree * &racine) } else if (diff > 0) { - if (son[LEFT] == NULL) + if (child[LEFT] == NULL) { // cout << "un probleme\n"; return avl_bal_err; } - AVLTree *r = dad; + AVLTree *r = parent; AVLTree *a = this; - AVLTree *b = son[RIGHT]; - AVLTree *e = son[LEFT]; - AVLTree *f = e->son[RIGHT]; - AVLTree *g = e->son[LEFT]; + AVLTree *b = child[RIGHT]; + AVLTree *e = child[LEFT]; + AVLTree *f = e->child[RIGHT]; + AVLTree *g = e->child[LEFT]; if (e->balance > 0) { - e->son[RIGHT] = a; - e->son[LEFT] = g; - a->son[RIGHT] = b; - a->son[LEFT] = f; + e->child[RIGHT] = a; + e->child[LEFT] = g; + a->child[RIGHT] = b; + a->child[LEFT] = f; if (a) - a->dad = e; + a->parent = e; if (g) - g->dad = e; + g->parent = e; if (b) - b->dad = a; + b->parent = a; if (f) - f->dad = a; - e->dad = r; + f->parent = a; + e->parent = r; if (r) { - if (r->son[LEFT] == a) - r->son[LEFT] = e; - if (r->son[RIGHT] == a) - r->son[RIGHT] = e; + if (r->child[LEFT] == a) + r->child[LEFT] = e; + if (r->child[RIGHT] == a) + r->child[RIGHT] = e; } if (racine == this) racine = e; @@ -372,34 +372,34 @@ AVLTree::RestoreBalances (int diff, AVLTree * &racine) a->balance = 0; if (r) { - if (e == r->son[RIGHT]) + if (e == r->child[RIGHT]) return r->RestoreBalances (1, racine); - if (e == r->son[LEFT]) + if (e == r->child[LEFT]) return r->RestoreBalances (-1, racine); } return avl_no_err; } else if (e->balance == 0) { - e->son[RIGHT] = a; - e->son[LEFT] = g; - a->son[RIGHT] = b; - a->son[LEFT] = f; + e->child[RIGHT] = a; + e->child[LEFT] = g; + a->child[RIGHT] = b; + a->child[LEFT] = f; if (a) - a->dad = e; + a->parent = e; if (g) - g->dad = e; + g->parent = e; if (b) - b->dad = a; + b->parent = a; if (f) - f->dad = a; - e->dad = r; + f->parent = a; + e->parent = r; if (r) { - if (r->son[LEFT] == a) - r->son[LEFT] = e; - if (r->son[RIGHT] == a) - r->son[RIGHT] = e; + if (r->child[LEFT] == a) + r->child[LEFT] = e; + if (r->child[RIGHT] == a) + r->child[RIGHT] = e; } if (racine == this) racine = e; @@ -409,39 +409,39 @@ AVLTree::RestoreBalances (int diff, AVLTree * &racine) } else if (e->balance < 0) { - if (son[LEFT]->son[RIGHT] == NULL) + if (child[LEFT]->child[RIGHT] == NULL) { // cout << "un probleme\n"; return avl_bal_err; } - AVLTree *i = son[LEFT]->son[RIGHT]->son[RIGHT]; - AVLTree *j = son[LEFT]->son[RIGHT]->son[LEFT]; - - f->son[RIGHT] = a; - f->son[LEFT] = e; - a->son[RIGHT] = b; - a->son[LEFT] = i; - e->son[RIGHT] = j; - e->son[LEFT] = g; + AVLTree *i = child[LEFT]->child[RIGHT]->child[RIGHT]; + AVLTree *j = child[LEFT]->child[RIGHT]->child[LEFT]; + + f->child[RIGHT] = a; + f->child[LEFT] = e; + a->child[RIGHT] = b; + a->child[LEFT] = i; + e->child[RIGHT] = j; + e->child[LEFT] = g; if (b) - b->dad = a; + b->parent = a; if (i) - i->dad = a; + i->parent = a; if (g) - g->dad = e; + g->parent = e; if (j) - j->dad = e; + j->parent = e; if (a) - a->dad = f; + a->parent = f; if (e) - e->dad = f; - f->dad = r; + e->parent = f; + f->parent = r; if (r) { - if (r->son[LEFT] == a) - r->son[LEFT] = f; - if (r->son[RIGHT] == a) - r->son[RIGHT] = f; + if (r->child[LEFT] == a) + r->child[LEFT] = f; + if (r->child[RIGHT] == a) + r->child[RIGHT] = f; } if (racine == this) racine = f; @@ -464,9 +464,9 @@ AVLTree::RestoreBalances (int diff, AVLTree * &racine) } if (r) { - if (f == r->son[RIGHT]) + if (f == r->child[RIGHT]) return r->RestoreBalances (1, racine); - if (f == r->son[LEFT]) + if (f == r->child[LEFT]) return r->RestoreBalances (-1, racine); } return avl_no_err; @@ -492,38 +492,38 @@ AVLTree::RestoreBalances (int diff, AVLTree * &racine) { if (diff < 0) { - if (son[RIGHT] == NULL) + if (child[RIGHT] == NULL) { // cout << "un probleme\n"; return avl_bal_err; } - AVLTree *r = dad; + AVLTree *r = parent; AVLTree *a = this; - AVLTree *b = son[LEFT]; - AVLTree *e = son[RIGHT]; - AVLTree *f = e->son[LEFT]; - AVLTree *g = e->son[RIGHT]; + AVLTree *b = child[LEFT]; + AVLTree *e = child[RIGHT]; + AVLTree *f = e->child[LEFT]; + AVLTree *g = e->child[RIGHT]; if (e->balance < 0) { - e->son[LEFT] = a; - e->son[RIGHT] = g; - a->son[LEFT] = b; - a->son[RIGHT] = f; + e->child[LEFT] = a; + e->child[RIGHT] = g; + a->child[LEFT] = b; + a->child[RIGHT] = f; if (a) - a->dad = e; + a->parent = e; if (g) - g->dad = e; + g->parent = e; if (b) - b->dad = a; + b->parent = a; if (f) - f->dad = a; - e->dad = r; + f->parent = a; + e->parent = r; if (r) { - if (r->son[LEFT] == a) - r->son[LEFT] = e; - if (r->son[RIGHT] == a) - r->son[RIGHT] = e; + if (r->child[LEFT] == a) + r->child[LEFT] = e; + if (r->child[RIGHT] == a) + r->child[RIGHT] = e; } if (racine == this) racine = e; @@ -531,34 +531,34 @@ AVLTree::RestoreBalances (int diff, AVLTree * &racine) a->balance = 0; if (r) { - if (e == r->son[RIGHT]) + if (e == r->child[RIGHT]) return r->RestoreBalances (1, racine); - if (e == r->son[LEFT]) + if (e == r->child[LEFT]) return r->RestoreBalances (-1, racine); } return avl_no_err; } else if (e->balance == 0) { - e->son[LEFT] = a; - e->son[RIGHT] = g; - a->son[LEFT] = b; - a->son[RIGHT] = f; + e->child[LEFT] = a; + e->child[RIGHT] = g; + a->child[LEFT] = b; + a->child[RIGHT] = f; if (a) - a->dad = e; + a->parent = e; if (g) - g->dad = e; + g->parent = e; if (b) - b->dad = a; + b->parent = a; if (f) - f->dad = a; - e->dad = r; + f->parent = a; + e->parent = r; if (r) { - if (r->son[LEFT] == a) - r->son[LEFT] = e; - if (r->son[RIGHT] == a) - r->son[RIGHT] = e; + if (r->child[LEFT] == a) + r->child[LEFT] = e; + if (r->child[RIGHT] == a) + r->child[RIGHT] = e; } if (racine == this) racine = e; @@ -568,39 +568,39 @@ AVLTree::RestoreBalances (int diff, AVLTree * &racine) } else if (e->balance > 0) { - if (son[RIGHT]->son[LEFT] == NULL) + if (child[RIGHT]->child[LEFT] == NULL) { // cout << "un probleme\n"; return avl_bal_err; } - AVLTree *i = son[RIGHT]->son[LEFT]->son[LEFT]; - AVLTree *j = son[RIGHT]->son[LEFT]->son[RIGHT]; - - f->son[LEFT] = a; - f->son[RIGHT] = e; - a->son[LEFT] = b; - a->son[RIGHT] = i; - e->son[LEFT] = j; - e->son[RIGHT] = g; + AVLTree *i = child[RIGHT]->child[LEFT]->child[LEFT]; + AVLTree *j = child[RIGHT]->child[LEFT]->child[RIGHT]; + + f->child[LEFT] = a; + f->child[RIGHT] = e; + a->child[LEFT] = b; + a->child[RIGHT] = i; + e->child[LEFT] = j; + e->child[RIGHT] = g; if (b) - b->dad = a; + b->parent = a; if (i) - i->dad = a; + i->parent = a; if (g) - g->dad = e; + g->parent = e; if (j) - j->dad = e; + j->parent = e; if (a) - a->dad = f; + a->parent = f; if (e) - e->dad = f; - f->dad = r; + e->parent = f; + f->parent = r; if (r) { - if (r->son[LEFT] == a) - r->son[LEFT] = f; - if (r->son[RIGHT] == a) - r->son[RIGHT] = f; + if (r->child[LEFT] == a) + r->child[LEFT] = f; + if (r->child[RIGHT] == a) + r->child[RIGHT] = f; } if (racine == this) racine = f; @@ -623,9 +623,9 @@ AVLTree::RestoreBalances (int diff, AVLTree * &racine) } if (r) { - if (f == r->son[RIGHT]) + if (f == r->child[RIGHT]) return r->RestoreBalances (1, racine); - if (f == r->son[LEFT]) + if (f == r->child[LEFT]) return r->RestoreBalances (-1, racine); } return avl_no_err; @@ -637,12 +637,12 @@ AVLTree::RestoreBalances (int diff, AVLTree * &racine) else if (diff > 0) { balance = 0; - if (dad) + if (parent) { - if (this == dad->son[RIGHT]) - return dad->RestoreBalances (1, racine); - if (this == dad->son[LEFT]) - return dad->RestoreBalances (-1, racine); + if (this == parent->child[RIGHT]) + return parent->RestoreBalances (1, racine); + if (this == parent->child[LEFT]) + return parent->RestoreBalances (-1, racine); } return avl_no_err; } @@ -673,126 +673,126 @@ AVLTree::Remove (AVLTree * &racine, AVLTree * &startNode, int &diff) elem[RIGHT]->elem[LEFT] = elem[LEFT]; elem[LEFT] = elem[RIGHT] = NULL; - if (son[LEFT] && son[RIGHT]) + if (child[LEFT] && child[RIGHT]) { - AVLTree *newMe = son[LEFT]->leafFromDad(this, RIGHT); - if (newMe == NULL || newMe->son[RIGHT]) + AVLTree *newMe = child[LEFT]->leafFromParent(this, RIGHT); + if (newMe == NULL || newMe->child[RIGHT]) { // cout << "pas normal\n"; return avl_rm_err; } - if (newMe == son[LEFT]) + if (newMe == child[LEFT]) { startNode = newMe; diff = -1; - newMe->son[RIGHT] = son[RIGHT]; - son[RIGHT]->dad = newMe; - newMe->dad = dad; - if (dad) + newMe->child[RIGHT] = child[RIGHT]; + child[RIGHT]->parent = newMe; + newMe->parent = parent; + if (parent) { - if (dad->son[LEFT] == this) - dad->son[LEFT] = newMe; - if (dad->son[RIGHT] == this) - dad->son[RIGHT] = newMe; + if (parent->child[LEFT] == this) + parent->child[LEFT] = newMe; + if (parent->child[RIGHT] == this) + parent->child[RIGHT] = newMe; } } else { - AVLTree *oDad = newMe->dad; - startNode = oDad; + AVLTree *oParent = newMe->parent; + startNode = oParent; diff = 1; - oDad->son[RIGHT] = newMe->son[LEFT]; - if (newMe->son[LEFT]) - newMe->son[LEFT]->dad = oDad; + oParent->child[RIGHT] = newMe->child[LEFT]; + if (newMe->child[LEFT]) + newMe->child[LEFT]->parent = oParent; - newMe->dad = dad; - newMe->son[LEFT] = son[LEFT]; - newMe->son[RIGHT] = son[RIGHT]; - if (dad) + newMe->parent = parent; + newMe->child[LEFT] = child[LEFT]; + newMe->child[RIGHT] = child[RIGHT]; + if (parent) { - if (dad->son[LEFT] == this) - dad->son[LEFT] = newMe; - if (dad->son[RIGHT] == this) - dad->son[RIGHT] = newMe; + if (parent->child[LEFT] == this) + parent->child[LEFT] = newMe; + if (parent->child[RIGHT] == this) + parent->child[RIGHT] = newMe; } - if (son[LEFT]) - son[LEFT]->dad = newMe; - if (son[RIGHT]) - son[RIGHT]->dad = newMe; + if (child[LEFT]) + child[LEFT]->parent = newMe; + if (child[RIGHT]) + child[RIGHT]->parent = newMe; } newMe->balance = balance; if (racine == this) racine = newMe; } - else if (son[LEFT]) + else if (child[LEFT]) { - startNode = dad; + startNode = parent; diff = 0; - if (dad) + if (parent) { - if (this == dad->son[LEFT]) + if (this == parent->child[LEFT]) diff = -1; - if (this == dad->son[RIGHT]) + if (this == parent->child[RIGHT]) diff = 1; } - if (dad) + if (parent) { - if (dad->son[LEFT] == this) - dad->son[LEFT] = son[LEFT]; - if (dad->son[RIGHT] == this) - dad->son[RIGHT] = son[LEFT]; + if (parent->child[LEFT] == this) + parent->child[LEFT] = child[LEFT]; + if (parent->child[RIGHT] == this) + parent->child[RIGHT] = child[LEFT]; } - if (son[LEFT]->dad == this) - son[LEFT]->dad = dad; + if (child[LEFT]->parent == this) + child[LEFT]->parent = parent; if (racine == this) - racine = son[LEFT]; + racine = child[LEFT]; } - else if (son[RIGHT]) + else if (child[RIGHT]) { - startNode = dad; + startNode = parent; diff = 0; - if (dad) + if (parent) { - if (this == dad->son[LEFT]) + if (this == parent->child[LEFT]) diff = -1; - if (this == dad->son[RIGHT]) + if (this == parent->child[RIGHT]) diff = 1; } - if (dad) + if (parent) { - if (dad->son[LEFT] == this) - dad->son[LEFT] = son[RIGHT]; - if (dad->son[RIGHT] == this) - dad->son[RIGHT] = son[RIGHT]; + if (parent->child[LEFT] == this) + parent->child[LEFT] = child[RIGHT]; + if (parent->child[RIGHT] == this) + parent->child[RIGHT] = child[RIGHT]; } - if (son[RIGHT]->dad == this) - son[RIGHT]->dad = dad; + if (child[RIGHT]->parent == this) + child[RIGHT]->parent = parent; if (racine == this) - racine = son[RIGHT]; + racine = child[RIGHT]; } else { - startNode = dad; + startNode = parent; diff = 0; - if (dad) + if (parent) { - if (this == dad->son[LEFT]) + if (this == parent->child[LEFT]) diff = -1; - if (this == dad->son[RIGHT]) + if (this == parent->child[RIGHT]) diff = 1; } - if (dad) + if (parent) { - if (dad->son[LEFT] == this) - dad->son[LEFT] = NULL; - if (dad->son[RIGHT] == this) - dad->son[RIGHT] = NULL; + if (parent->child[LEFT] == this) + parent->child[LEFT] = NULL; + if (parent->child[RIGHT] == this) + parent->child[RIGHT] = NULL; } if (racine == this) racine = NULL; } - dad = son[RIGHT] = son[LEFT] = NULL; + parent = child[RIGHT] = child[LEFT] = NULL; balance = 0; return avl_no_err; } @@ -828,43 +828,43 @@ AVLTree::Insert (AVLTree * &racine, int insertType, AVLTree * insertL, } else if (insertType == found_on_left) { - if (insertR == NULL || insertR->son[LEFT]) + if (insertR == NULL || insertR->child[LEFT]) { // cout << "ngou?\n"; return avl_ins_err; } - insertR->son[LEFT] = this; - dad = insertR; + insertR->child[LEFT] = this; + parent = insertR; insertOn(LEFT, insertR); } else if (insertType == found_on_right) { - if (insertL == NULL || insertL->son[RIGHT]) + if (insertL == NULL || insertL->child[RIGHT]) { // cout << "ngou?\n"; return avl_ins_err; } - insertL->son[RIGHT] = this; - dad = insertL; + insertL->child[RIGHT] = this; + parent = insertL; insertOn(RIGHT, insertL); } else if (insertType == found_between) { if (insertR == NULL || insertL == NULL - || (insertR->son[LEFT] != NULL && insertL->son[RIGHT] != NULL)) + || (insertR->child[LEFT] != NULL && insertL->child[RIGHT] != NULL)) { // cout << "ngou?\n"; return avl_ins_err; } - if (insertR->son[LEFT] == NULL) + if (insertR->child[LEFT] == NULL) { - insertR->son[LEFT] = this; - dad = insertR; + insertR->child[LEFT] = this; + parent = insertR; } - else if (insertL->son[RIGHT] == NULL) + else if (insertL->child[RIGHT] == NULL) { - insertL->son[RIGHT] = this; - dad = insertL; + insertL->child[RIGHT] = this; + parent = insertL; } insertBetween (insertL, insertR); } @@ -877,22 +877,22 @@ AVLTree::Insert (AVLTree * &racine, int insertType, AVLTree * insertL, } // et on insere - if (insertL->son[RIGHT]) + if (insertL->child[RIGHT]) { - insertL = insertL->son[RIGHT]->leafFromDad(insertL, LEFT); - if (insertL->son[LEFT]) + insertL = insertL->child[RIGHT]->leafFromParent(insertL, LEFT); + if (insertL->child[LEFT]) { // cout << "ngou?\n"; return avl_ins_err; } - insertL->son[LEFT] = this; - this->dad = insertL; + insertL->child[LEFT] = this; + this->parent = insertL; insertBetween (insertL->elem[LEFT], insertL); } else { - insertL->son[RIGHT] = this; - dad = insertL; + insertL->child[RIGHT] = this; + parent = insertL; insertBetween (insertL, insertL->elem[RIGHT]); } } @@ -915,24 +915,24 @@ AVLTree::Relocate (AVLTree * to) to->elem[LEFT] = elem[LEFT]; to->elem[RIGHT] = elem[RIGHT]; - if (dad) + if (parent) { - if (dad->son[LEFT] == this) - dad->son[LEFT] = to; - if (dad->son[RIGHT] == this) - dad->son[RIGHT] = to; + if (parent->child[LEFT] == this) + parent->child[LEFT] = to; + if (parent->child[RIGHT] == this) + parent->child[RIGHT] = to; } - if (son[RIGHT]) + if (child[RIGHT]) { - son[RIGHT]->dad = to; + child[RIGHT]->parent = to; } - if (son[LEFT]) + if (child[LEFT]) { - son[LEFT]->dad = to; + child[LEFT]->parent = to; } - to->dad = dad; - to->son[RIGHT] = son[RIGHT]; - to->son[LEFT] = son[LEFT]; + to->parent = parent; + to->child[RIGHT] = child[RIGHT]; + to->child[LEFT] = child[LEFT]; } diff --git a/src/livarot/AVL.h b/src/livarot/AVL.h index cc0f095cc..741abfaf2 100644 --- a/src/livarot/AVL.h +++ b/src/livarot/AVL.h @@ -30,7 +30,7 @@ public: protected: - AVLTree *son[2]; + AVLTree *child[2]; AVLTree(); virtual ~AVLTree(); @@ -57,7 +57,7 @@ protected: private: - AVLTree *dad; + AVLTree *parent; int balance; @@ -78,7 +78,7 @@ private: void insertOn(Side s, AVLTree *of); void insertBetween(AVLTree *l, AVLTree *r); AVLTree *leaf(AVLTree *from, Side s); - AVLTree *leafFromDad(AVLTree *from, Side s); + AVLTree *leafFromParent(AVLTree *from, Side s); }; #endif diff --git a/src/livarot/PathCutting.cpp b/src/livarot/PathCutting.cpp index 201f64b54..0dc7ede50 100644 --- a/src/livarot/PathCutting.cpp +++ b/src/livarot/PathCutting.cpp @@ -641,21 +641,21 @@ Path** Path::SubPathsWithNesting(int &outNb,bool killNoSurf,int nbNest,int* } curAdd=NULL; } - Path* hasDad=NULL; + Path* hasParent=NULL; for (int j=0;j= 0 ) { - int dadMvt=conts[nesting[j]]; + int parentMvt=conts[nesting[j]]; for (int k=0;kdescr_cmd.empty() == false && res[k]->descr_cmd[0]->associated == dadMvt ) { - hasDad=res[k]; + if ( res[k] && res[k]->descr_cmd.empty() == false && res[k]->descr_cmd[0]->associated == parentMvt ) { + hasParent=res[k]; break; } } } if ( conts[j] > i ) break; } - if ( hasDad ) { - curAdd=hasDad; + if ( hasParent ) { + curAdd=hasParent; increment=true; } else { curAdd=new Path; diff --git a/src/livarot/ShapeMisc.cpp b/src/livarot/ShapeMisc.cpp index e5a98f0cf..c0bfe9428 100644 --- a/src/livarot/ShapeMisc.cpp +++ b/src/livarot/ShapeMisc.cpp @@ -373,7 +373,7 @@ Shape::ConvertToFormeNested (Path * dest, int nbP, Path * *orig, int /*wildPath* int lastPtUsed = 0; do { - int dadContour=-1; + int parentContour=-1; int childEdge = -1; bool foundChild = false; int startBord = -1; @@ -387,10 +387,10 @@ Shape::ConvertToFormeNested (Path * dest, int nbP, Path * *orig, int /*wildPath* { int askTo = pData[fi].askForWindingB; if (askTo < 0 || askTo >= numberOfEdges() ) { - dadContour=-1; + parentContour=-1; } else { - dadContour = GPOINTER_TO_INT(swdData[askTo].misc); - dadContour-=1; // pour compenser le decalage + parentContour = GPOINTER_TO_INT(swdData[askTo].misc); + parentContour-=1; // pour compenser le decalage childEdge = getPoint(fi).incidentEdge[FIRST]; } } @@ -463,7 +463,7 @@ Shape::ConvertToFormeNested (Path * dest, int nbP, Path * *orig, int /*wildPath* contStart=(int*)g_realloc(contStart,(nbNest+1)*sizeof(int)); contStart[nbNest]=dest->descr_cmd.size(); if (foundChild) { - nesting[nbNest++]=dadContour; + nesting[nbNest++]=parentContour; foundChild = false; } else { nesting[nbNest++]=-1; // contient des bouts de coupure -> a part @@ -504,7 +504,7 @@ Shape::ConvertToFormeNested (Path * dest, int nbP, Path * *orig, int /*wildPath* contStart=(int*)g_realloc(contStart,(nbNest+1)*sizeof(int)); contStart[nbNest]=dest->descr_cmd.size(); if (foundChild) { - nesting[nbNest++]=dadContour; + nesting[nbNest++]=parentContour; foundChild = false; } else { nesting[nbNest++]=-1; // contient des bouts de coupure -> a part diff --git a/src/livarot/sweep-event.cpp b/src/livarot/sweep-event.cpp index 6f3a4d246..48354fc46 100644 --- a/src/livarot/sweep-event.cpp +++ b/src/livarot/sweep-event.cpp @@ -146,11 +146,11 @@ void SweepEventQueue::remove(SweepEvent *e) } while (2 * curInd + 1 < nbEvt) { - int const son1 = 2 * curInd + 1; - int const son2 = son1 + 1; - int const no1 = inds[son1]; - int const no2 = inds[son2]; - if (son2 < nbEvt) { + int const child1 = 2 * curInd + 1; + int const child2 = child1 + 1; + int const no1 = inds[child1]; + int const no2 = inds[child2]; + if (child2 < nbEvt) { if (px[1] > events[no1].posx[1] || (px[1] == events[no1].posx[1] && px[0] > events[no1].posx[0])) @@ -159,28 +159,28 @@ void SweepEventQueue::remove(SweepEvent *e) || (events[no2].posx[1] == events[no1].posx[1] && events[no2].posx[0] > events[no1].posx[0])) { - events[to].ind = son1; + events[to].ind = child1; events[no1].ind = curInd; - inds[son1] = to; + inds[child1] = to; inds[curInd] = no1; - curInd = son1; + curInd = child1; } else { - events[to].ind = son2; + events[to].ind = child2; events[no2].ind = curInd; - inds[son2] = to; + inds[child2] = to; inds[curInd] = no2; - curInd = son2; + curInd = child2; } } else { if (px[1] > events[no2].posx[1] || (px[1] == events[no2].posx[1] && px[0] > events[no2].posx[0])) { - events[to].ind = son2; + events[to].ind = child2; events[no2].ind = curInd; - inds[son2] = to; + inds[child2] = to; inds[curInd] = no2; - curInd = son2; + curInd = child2; } else { break; } @@ -190,9 +190,9 @@ void SweepEventQueue::remove(SweepEvent *e) || (px[1] == events[no1].posx[1] && px[0] > events[no1].posx[0])) { - events[to].ind = son1; + events[to].ind = child1; events[no1].ind = curInd; - inds[son1] = to; + inds[child1] = to; inds[curInd] = no1; } diff --git a/src/livarot/sweep-tree.cpp b/src/livarot/sweep-tree.cpp index 0cfd6bc52..7a016a2ee 100644 --- a/src/livarot/sweep-tree.cpp +++ b/src/livarot/sweep-tree.cpp @@ -131,8 +131,8 @@ SweepTree::Find(Geom::Point const &px, SweepTree *newOne, SweepTree *&insertL, } } if (y < 0) { - if (son[LEFT]) { - return (static_cast(son[LEFT]))->Find(px, newOne, + if (child[LEFT]) { + return (static_cast(child[LEFT]))->Find(px, newOne, insertL, insertR, sweepSens); } else { @@ -145,8 +145,8 @@ SweepTree::Find(Geom::Point const &px, SweepTree *newOne, SweepTree *&insertL, } } } else { - if (son[RIGHT]) { - return (static_cast(son[RIGHT]))->Find(px, newOne, + if (child[RIGHT]) { + return (static_cast(child[RIGHT]))->Find(px, newOne, insertL, insertR, sweepSens); } else { @@ -189,9 +189,9 @@ SweepTree::Find(Geom::Point const &px, SweepTree * &insertL, } if (y < 0) { - if (son[LEFT]) + if (child[LEFT]) { - return (static_cast(son[LEFT]))->Find(px, insertL, + return (static_cast(child[LEFT]))->Find(px, insertL, insertR); } else @@ -210,9 +210,9 @@ SweepTree::Find(Geom::Point const &px, SweepTree * &insertL, } else { - if (son[RIGHT]) + if (child[RIGHT]) { - return (static_cast(son[RIGHT]))->Find(px, insertL, + return (static_cast(child[RIGHT]))->Find(px, insertL, insertR); } else diff --git a/src/splivarot.cpp b/src/splivarot.cpp index e5006884c..5c7b389ff 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -371,18 +371,18 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool // objects are not in parent/child relationship; // find their lowest common ancestor - Inkscape::XML::Node *dad = LCA(a, b); - if (dad == NULL) { + Inkscape::XML::Node *parent = LCA(a, b); + if (parent == NULL) { boolop_display_error_message(desktop, _("Unable to determine the z-order of the objects selected for difference, XOR, division, or path cut.")); return; } // find the children of the LCA that lead from it to the a and b - Inkscape::XML::Node *as = AncetreFils(a, dad); - Inkscape::XML::Node *bs = AncetreFils(b, dad); + Inkscape::XML::Node *as = AncetreFils(a, parent); + Inkscape::XML::Node *bs = AncetreFils(b, parent); // find out which comes first - for (Inkscape::XML::Node *child = dad->firstChild(); child; child = child->next()) { + for (Inkscape::XML::Node *child = parent->firstChild(); child; child = child->next()) { if (child == as) { /* a first, so reverse. */ reverseOrderForOp = true; diff --git a/src/ui/tools/spray-tool.cpp b/src/ui/tools/spray-tool.cpp index 0ded1e44b..91c606e8e 100644 --- a/src/ui/tools/spray-tool.cpp +++ b/src/ui/tools/spray-tool.cpp @@ -404,7 +404,7 @@ static bool sp_spray_recursive(SPDesktop *desktop, SPItem *item_copied; if(_fid <= population) { - // duplicate + // Duplicate SPDocument *doc = item->document; Inkscape::XML::Document* xml_doc = doc->getReprDoc(); Inkscape::XML::Node *old_repr = item->getRepr(); @@ -413,13 +413,13 @@ static bool sp_spray_recursive(SPDesktop *desktop, parent->appendChild(copy); SPObject *new_obj = doc->getObjectByRepr(copy); - item_copied = SP_ITEM(new_obj); //convertion object->item + item_copied = SP_ITEM(new_obj); // Convertion object->item Geom::Point center=item->getCenter(); sp_spray_scale_rel(center,desktop, item_copied, Geom::Scale(_scale,_scale)); sp_spray_scale_rel(center,desktop, item_copied, Geom::Scale(scale,scale)); sp_spray_rotate_rel(center,desktop,item_copied, Geom::Rotate(angle)); - //Move the cursor p + // Move the cursor p Geom::Point move = (Geom::Point(cos(tilt)*cos(dp)*dr/(1-ratio)+sin(tilt)*sin(dp)*dr/(1+ratio), -sin(tilt)*cos(dp)*dr/(1-ratio)+cos(tilt)*sin(dp)*dr/(1+ratio)))+(p-a->midpoint()); sp_item_move_rel(item_copied, Geom::Translate(move[Geom::X], -move[Geom::Y])); did = true; @@ -427,10 +427,10 @@ static bool sp_spray_recursive(SPDesktop *desktop, } } else if (mode == SPRAY_MODE_SINGLE_PATH) { - SPItem *father = NULL; //initial Object - SPItem *item_copied = NULL; //Projected Object - SPItem *unionResult = NULL; //previous union - SPItem *son = NULL; //father copy + SPItem *parent_item = NULL; // Initial object + SPItem *item_copied = NULL; // Projected object + SPItem *unionResult = NULL; // Previous union + SPItem *child_item = NULL; // Parent copy int i=1; for (GSList *items = g_slist_copy(const_cast(selection->itemList())); @@ -439,31 +439,31 @@ static bool sp_spray_recursive(SPDesktop *desktop, SPItem *item1 = SP_ITEM(items->data); if (i == 1) { - father = item1; + parent_item = item1; } if (i == 2) { unionResult = item1; } i++; } - SPDocument *doc = father->document; + SPDocument *doc = parent_item->document; Inkscape::XML::Document* xml_doc = doc->getReprDoc(); - Inkscape::XML::Node *old_repr = father->getRepr(); + Inkscape::XML::Node *old_repr = parent_item->getRepr(); Inkscape::XML::Node *parent = old_repr->parent(); - Geom::OptRect a = father->documentVisualBounds(); + Geom::OptRect a = parent_item->documentVisualBounds(); if (a) { if (i == 2) { Inkscape::XML::Node *copy1 = old_repr->duplicate(xml_doc); parent->appendChild(copy1); SPObject *new_obj1 = doc->getObjectByRepr(copy1); - son = SP_ITEM(new_obj1); // conversion object->item - unionResult = son; + child_item = SP_ITEM(new_obj1); // Conversion object->item + unionResult = child_item; Inkscape::GC::release(copy1); } if (_fid <= population) { // Rules the population of objects sprayed - // duplicates the father + // Duplicates the parent item Inkscape::XML::Node *copy2 = old_repr->duplicate(xml_doc); parent->appendChild(copy2); SPObject *new_obj2 = doc->getObjectByRepr(copy2); @@ -472,18 +472,18 @@ static bool sp_spray_recursive(SPDesktop *desktop, // Move around the cursor Geom::Point move = (Geom::Point(cos(tilt)*cos(dp)*dr/(1-ratio)+sin(tilt)*sin(dp)*dr/(1+ratio), -sin(tilt)*cos(dp)*dr/(1-ratio)+cos(tilt)*sin(dp)*dr/(1+ratio)))+(p-a->midpoint()); - Geom::Point center=father->getCenter(); + Geom::Point center = parent_item->getCenter(); sp_spray_scale_rel(center, desktop, item_copied, Geom::Scale(_scale, _scale)); sp_spray_scale_rel(center, desktop, item_copied, Geom::Scale(scale, scale)); sp_spray_rotate_rel(center, desktop, item_copied, Geom::Rotate(angle)); sp_item_move_rel(item_copied, Geom::Translate(move[Geom::X], -move[Geom::Y])); - // union and duplication + // Union and duplication selection->clear(); selection->add(item_copied); selection->add(unionResult); sp_selected_path_union_skip_undo(selection, selection->desktop()); - selection->add(father); + selection->add(parent_item); Inkscape::GC::release(copy2); did = true; } @@ -500,15 +500,15 @@ static bool sp_spray_recursive(SPDesktop *desktop, // Creation of the clone Inkscape::XML::Node *clone = xml_doc->createElement("svg:use"); - // Ad the clone to the list of the father's sons + // Ad the clone to the list of the parent's children parent->appendChild(clone); - // Generates the link between father and son attributes + // Generates the link between parent and child attributes gchar *href_str = g_strdup_printf("#%s", old_repr->attribute("id")); clone->setAttribute("xlink:href", href_str, false); g_free(href_str); SPObject *clone_object = doc->getObjectByRepr(clone); - // conversion object->item + // Conversion object->item item_copied = SP_ITEM(clone_object); Geom::Point center = item->getCenter(); sp_spray_scale_rel(center, desktop, item_copied, Geom::Scale(_scale, _scale)); @@ -582,9 +582,9 @@ static void sp_spray_update_area(SprayTool *tc) static void sp_spray_switch_mode(SprayTool *tc, gint mode, bool with_shift) { - // select the button mode + // Select the button mode SP_EVENT_CONTEXT(tc)->desktop->setToolboxSelectOneValue("spray_tool_mode", mode); - // need to set explicitly, because the prefs may not have changed by the previous + // Need to set explicitly, because the prefs may not have changed by the previous tc->mode = mode; tc->update_cursor(with_shift); } @@ -631,7 +631,7 @@ bool SprayTool::root_handler(GdkEvent* event) { Geom::Point motion_doc(desktop->dt2doc(motion_dt)); sp_spray_extinput(this, event); - // draw the dilating cursor + // Draw the dilating cursor double radius = get_dilate_radius(this); Geom::Affine const sm (Geom::Scale(radius/(1-this->ratio), radius/(1+this->ratio)) ); sp_canvas_item_affine_absolute(this->dilate_area, (sm*Geom::Rotate(this->tilt))*Geom::Translate(desktop->w2d(motion_w))); @@ -645,19 +645,19 @@ bool SprayTool::root_handler(GdkEvent* event) { this->message_context->flash(Inkscape::ERROR_MESSAGE, _("Nothing selected! Select objects to spray.")); } - // dilating: + // Dilating: if (this->is_drawing && ( event->motion.state & GDK_BUTTON1_MASK )) { sp_spray_dilate(this, motion_w, motion_doc, motion_doc - this->last_push, event->button.state & GDK_SHIFT_MASK? true : false); //this->last_push = motion_doc; this->has_dilated = true; - // it's slow, so prevent clogging up with events + // It's slow, so prevent clogging up with events gobble_motion_events(GDK_BUTTON1_MASK); return TRUE; } } break; - /*Spray with the scroll*/ + /* Spray with the scroll */ case GDK_SCROLL: { if (event->scroll.state & GDK_BUTTON1_MASK) { double temp ; @@ -708,7 +708,7 @@ bool SprayTool::root_handler(GdkEvent* event) { if (this->is_dilating && event->button.button == 1 && !this->space_panning) { if (!this->has_dilated) { - // if we did not rub, do a light tap + // If we did not rub, do a light tap this->pressure = 0.03; sp_spray_dilate(this, motion_w, desktop->dt2doc(motion_dt), Geom::Point(0,0), MOD__SHIFT(event)); } @@ -784,7 +784,7 @@ bool SprayTool::root_handler(GdkEvent* event) { if (this->width > 1.0) { this->width = 1.0; } - // the same spinbutton is for alt+x + // The same spinbutton is for alt+x desktop->setToolboxAdjustmentValue("altx-spray", this->width * 100); sp_spray_update_area(this); ret = TRUE; -- cgit v1.2.3 From 7dd239eed97761b22ef635b6896a8f65c4939462 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Thu, 6 Feb 2014 15:29:15 +0100 Subject: Added new base class to handle viewBox and preserveAspectRatio. Updated sp-root, sp-symbol, sp-image, sp-pattern, marker to use new class. Fixed some viewport issues when % used. (bzr r13002) --- src/CMakeLists.txt | 3 +- src/Makefile_insert | 3 +- src/document.cpp | 10 -- src/marker.cpp | 257 ++++---------------------------------- src/marker.h | 14 +-- src/sp-image.cpp | 347 ++++++++++++++++++++-------------------------------- src/sp-image.h | 14 +-- src/sp-pattern.cpp | 55 ++------- src/sp-pattern.h | 6 +- src/sp-root.cpp | 327 ++++++++++--------------------------------------- src/sp-root.h | 15 +-- src/sp-symbol.cpp | 234 ++--------------------------------- src/sp-symbol.h | 15 +-- src/viewbox.cpp | 277 +++++++++++++++++++++++++++++++++++++++++ src/viewbox.h | 66 ++++++++++ 15 files changed, 601 insertions(+), 1042 deletions(-) create mode 100644 src/viewbox.cpp create mode 100644 src/viewbox.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 54b15d342..d1a3d194e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -78,7 +78,7 @@ set(sp_SRC sp-use-reference.cpp sp-use.cpp splivarot.cpp - + viewbox.cpp # ------- # Headers @@ -163,6 +163,7 @@ set(sp_SRC sp-tspan.h sp-use-reference.h sp-use.h + viewbox.h ) set(inkscape_SRC diff --git a/src/Makefile_insert b/src/Makefile_insert index 5e441560a..7aedb38ee 100644 --- a/src/Makefile_insert +++ b/src/Makefile_insert @@ -228,7 +228,8 @@ ink_common_sources += \ uri-references.cpp uri-references.h \ vanishing-point.cpp vanishing-point.h \ verbs.cpp verbs.h \ - version.cpp version.h + version.cpp version.h \ + viewbox.cpp viewbox.h # Additional dependencies diff --git a/src/document.cpp b/src/document.cpp index 634462001..6f957cace 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -381,16 +381,6 @@ SPDocument *SPDocument::createDoc(Inkscape::XML::Document *rdoc, rroot->setAttribute("inkscape:version", Inkscape::version_string); /* fixme: Again, I moved these here to allow version determining in ::build (Lauris) */ - /* Quick hack 2 - get default image size into document */ - if (!rroot->attribute("width")) rroot->setAttribute("width", "100%"); - if (!rroot->attribute("height")) rroot->setAttribute("height", "100%"); - /* End of quick hack 2 */ - - /* Quick hack 3 - Set uri attributes */ -// if (uri) { // this is done in do_change_uri() -// rroot->setAttribute("sodipodi:docname", uri); -// } - /* End of quick hack 3 */ /* Eliminate obsolete sodipodi:docbase, for privacy reasons */ rroot->setAttribute("sodipodi:docbase", NULL); diff --git a/src/marker.cpp b/src/marker.cpp index b9464186d..f6e55b3ec 100644 --- a/src/marker.cpp +++ b/src/marker.cpp @@ -47,18 +47,15 @@ namespace { bool markerRegistered = SPFactory::instance().registerObject("svg:marker", createMarker); } -SPMarker::SPMarker() : SPGroup() { - this->aspect_clip = 0; - this->aspect_align = 0; - this->aspect_set = 0; - this->markerUnits = 0; - this->orient_auto = 0; - this->markerUnits_set = 0; - this->orient_set = 0; - this->orient = 0; - - this->viewBox = Geom::OptRect(); - this->c2p.setIdentity(); +SPMarker::SPMarker() : SPGroup(), SPViewBox() { + + this->markerUnits = 0; + this->markerUnits_set = 0; + + this->orient_auto = 0; + this->orient_set = 0; + this->orient = 0; + this->views = NULL; } @@ -177,133 +174,14 @@ void SPMarker::set(unsigned int key, const gchar* value) { break; case SP_ATTR_VIEWBOX: - this->viewBox = Geom::OptRect(); - - if (value) { - double x, y, width, height; - char *eptr; - - /* fixme: We have to take original item affine into account */ - /* fixme: Think (Lauris) */ - eptr = (gchar *) value; - x = g_ascii_strtod (eptr, &eptr); - - while (*eptr && ((*eptr == ',') || (*eptr == ' '))) { - eptr++; - } - - y = g_ascii_strtod (eptr, &eptr); - - while (*eptr && ((*eptr == ',') || (*eptr == ' '))) { - eptr++; - } - - width = g_ascii_strtod (eptr, &eptr); - - while (*eptr && ((*eptr == ',') || (*eptr == ' '))) { - eptr++; - } - - height = g_ascii_strtod (eptr, &eptr); - - while (*eptr && ((*eptr == ',') || (*eptr == ' '))) { - eptr++; - } - - if ((width > 0) && (height > 0)) { - /* Set viewbox */ - this->viewBox = Geom::Rect(Geom::Point(x, y), Geom::Point(x + width, y + height)); - } - } - - this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG); - break; + set_viewBox( value ); + this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG); + break; case SP_ATTR_PRESERVEASPECTRATIO: - /* Do setup before, so we can use break to escape */ - this->aspect_set = FALSE; - this->aspect_align = SP_ASPECT_NONE; - this->aspect_clip = SP_ASPECT_MEET; - - this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG); - - if (value) { - int len; - gchar c[256]; - const gchar *p, *e; - unsigned int align, clip; - p = value; - - while (*p && *p == 32) { - p += 1; - } - - if (!*p) { - break; - } - - e = p; - - while (*e && *e != 32) { - e += 1; - } - - len = e - p; - - if (len > 8) { - break; - } - - memcpy (c, value, len); - - c[len] = 0; - - /* Now the actual part */ - if (!strcmp (c, "none")) { - align = SP_ASPECT_NONE; - } else if (!strcmp (c, "xMinYMin")) { - align = SP_ASPECT_XMIN_YMIN; - } else if (!strcmp (c, "xMidYMin")) { - align = SP_ASPECT_XMID_YMIN; - } else if (!strcmp (c, "xMaxYMin")) { - align = SP_ASPECT_XMAX_YMIN; - } else if (!strcmp (c, "xMinYMid")) { - align = SP_ASPECT_XMIN_YMID; - } else if (!strcmp (c, "xMidYMid")) { - align = SP_ASPECT_XMID_YMID; - } else if (!strcmp (c, "xMaxYMid")) { - align = SP_ASPECT_XMAX_YMID; - } else if (!strcmp (c, "xMinYMax")) { - align = SP_ASPECT_XMIN_YMAX; - } else if (!strcmp (c, "xMidYMax")) { - align = SP_ASPECT_XMID_YMAX; - } else if (!strcmp (c, "xMaxYMax")) { - align = SP_ASPECT_XMAX_YMAX; - } else { - break; - } - - clip = SP_ASPECT_MEET; - - while (*e && *e == 32) { - e += 1; - } - - if (*e) { - if (!strcmp (e, "meet")) { - clip = SP_ASPECT_MEET; - } else if (!strcmp (e, "slice")) { - clip = SP_ASPECT_SLICE; - } else { - break; - } - } - - this->aspect_set = TRUE; - this->aspect_align = align; - this->aspect_clip = clip; - } - break; + set_preserveAspectRatio( value ); + this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG); + break; default: SPGroup::set(key, value); @@ -312,112 +190,23 @@ void SPMarker::set(unsigned int key, const gchar* value) { } void SPMarker::update(SPCtx *ctx, guint flags) { - SPItemCtx rctx; - // fixme: We have to set up clip here too + SPItemCtx ictx; // Copy parent context - rctx.flags = ctx->flags; + ictx.flags = ctx->flags; // Initialize transformations - rctx.i2doc = Geom::identity(); - rctx.i2vp = Geom::identity(); + ictx.i2doc = Geom::identity(); + ictx.i2vp = Geom::identity(); // Set up viewport - rctx.viewport = Geom::Rect::from_xywh(0, 0, this->markerWidth.computed, this->markerHeight.computed); - - // Start with identity transform - this->c2p.setIdentity(); + ictx.viewport = Geom::Rect::from_xywh(0, 0, this->markerWidth.computed, this->markerHeight.computed); - // Viewbox is always present, either implicitly or explicitly - Geom::Rect vb; - if (this->viewBox) { - vb = *this->viewBox; - } else { - vb = rctx.viewport; - } + SPItemCtx rctx = get_rctx( &ictx ); - // Now set up viewbox transformation - - // Determine actual viewbox in viewport coordinates - // double x = 0; - // double y = 0; - double width = 0; - double height = 0; - - if (this->aspect_align == SP_ASPECT_NONE) { - // x = 0.0; - // y = 0.0; - width = rctx.viewport.width(); - height = rctx.viewport.height(); - } else { - double scalex, scaley, scale; - // Things are getting interesting - scalex = rctx.viewport.width() / (vb.width()); - scaley = rctx.viewport.height() / (vb.height()); - scale = (this->aspect_clip == SP_ASPECT_MEET) ? MIN (scalex, scaley) : MAX (scalex, scaley); - width = (vb.width()) * scale; - height = (vb.height()) * scale; - - // Now place viewbox to requested position - /*switch (marker->aspect_align) { - case SP_ASPECT_XMIN_YMIN: - x = 0.0; - y = 0.0; - break; - case SP_ASPECT_XMID_YMIN: - x = 0.5 * (rctx.viewport.width() - width); - y = 0.0; - break; - case SP_ASPECT_XMAX_YMIN: - x = 1.0 * (rctx.viewport.width() - width); - y = 0.0; - break; - case SP_ASPECT_XMIN_YMID: - x = 0.0; - y = 0.5 * (rctx.viewport.height() - height); - break; - case SP_ASPECT_XMID_YMID: - x = 0.5 * (rctx.viewport.width() - width); - y = 0.5 * (rctx.viewport.height() - height); - break; - case SP_ASPECT_XMAX_YMID: - x = 1.0 * (rctx.viewport.width() - width); - y = 0.5 * (rctx.viewport.height() - height); - break; - case SP_ASPECT_XMIN_YMAX: - x = 0.0; - y = 1.0 * (rctx.viewport.height() - height); - break; - case SP_ASPECT_XMID_YMAX: - x = 0.5 * (rctx.viewport.width() - width); - y = 1.0 * (rctx.viewport.height() - height); - break; - case SP_ASPECT_XMAX_YMAX: - x = 1.0 * (rctx.viewport.width() - width); - y = 1.0 * (rctx.viewport.height() - height); - break; - default: - x = 0.0; - y = 0.0; - break; - }*/ - } - - // TODO fixme: all that work is done to figure out x and y, which are just ignored. Check why. - - // viewbox transformation and reference translation - this->c2p = Geom::Translate(-this->refX.computed, -this->refY.computed) * - Geom::Scale(width / vb.width(), height / vb.height()); - - rctx.i2doc = this->c2p * rctx.i2doc; - - // If viewBox is set reinitialize child viewport - // Otherwise it already correct - if (this->viewBox) { - rctx.viewport = *this->viewBox; - rctx.i2vp = Geom::identity(); - } + // Shift according to refX, refY + this->c2p = Geom::Translate(this->viewBox.left()-this->refX.computed, this->viewBox.top()-this->refY.computed) * this->c2p; // And invoke parent method SPGroup::update((SPCtx *) &rctx, flags); diff --git a/src/marker.h b/src/marker.h index b780950de..d41df69b4 100644 --- a/src/marker.h +++ b/src/marker.h @@ -31,8 +31,9 @@ struct SPMarkerView; #include "sp-item-group.h" #include "sp-marker-loc.h" #include "uri-references.h" +#include "viewbox.h" -class SPMarker : public SPGroup { +class SPMarker : public SPGroup, public SPViewBox { public: SPMarker(); virtual ~SPMarker(); @@ -54,17 +55,6 @@ public: unsigned int orient_auto : 1; float orient; - /* viewBox; */ - Geom::OptRect viewBox; - - /* preserveAspectRatio */ - unsigned int aspect_set : 1; - unsigned int aspect_align : 4; - unsigned int aspect_clip : 1; - - /* Child to parent additional transform */ - Geom::Affine c2p; - /* Private views */ SPMarkerView *views; diff --git a/src/sp-image.cpp b/src/sp-image.cpp index 8f7a60ca6..5f630f7b7 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -119,14 +119,12 @@ SPObject* createImage() { bool imageRegistered = SPFactory::instance().registerObject("svg:image", createImage); } -SPImage::SPImage() : SPItem() { - this->aspect_clip = 0; +SPImage::SPImage() : SPItem(), SPViewBox() { this->x.unset(); this->y.unset(); this->width.unset(); this->height.unset(); - this->aspect_align = SP_ASPECT_NONE; this->clipbox = Geom::Rect(); this->sx = this->sy = 1.0; this->ox = this->oy = 0.0; @@ -195,8 +193,8 @@ void SPImage::set(unsigned int key, const gchar* value) { break; case SP_ATTR_X: - if (!this->x.readAbsolute(value)) { - /* fixme: em, ex, % are probably valid, but require special treatment (Lauris) */ + /* ex, em not handled correctly. */ + if (!this->x.read(value)) { this->x.unset(); } @@ -204,8 +202,8 @@ void SPImage::set(unsigned int key, const gchar* value) { break; case SP_ATTR_Y: - if (!this->y.readAbsolute(value)) { - /* fixme: em, ex, % are probably valid, but require special treatment (Lauris) */ + /* ex, em not handled correctly. */ + if (!this->y.read(value)) { this->y.unset(); } @@ -213,8 +211,8 @@ void SPImage::set(unsigned int key, const gchar* value) { break; case SP_ATTR_WIDTH: - if (!this->width.readAbsolute(value)) { - /* fixme: em, ex, % are probably valid, but require special treatment (Lauris) */ + /* ex, em not handled correctly. */ + if (!this->width.read(value)) { this->width.unset(); } @@ -222,8 +220,8 @@ void SPImage::set(unsigned int key, const gchar* value) { break; case SP_ATTR_HEIGHT: - if (!this->height.readAbsolute(value)) { - /* fixme: em, ex, % are probably valid, but require special treatment (Lauris) */ + /* ex, em not handled correctly. */ + if (!this->height.read(value)) { this->height.unset(); } @@ -231,67 +229,8 @@ void SPImage::set(unsigned int key, const gchar* value) { break; case SP_ATTR_PRESERVEASPECTRATIO: - /* Do setup before, so we can use break to escape */ - this->aspect_align = SP_ASPECT_NONE; - this->aspect_clip = SP_ASPECT_MEET; + set_preserveAspectRatio( value ); this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG); - - if (value) { - int len; - gchar c[256]; - const gchar *p, *e; - unsigned int align, clip; - p = value; - while (*p && *p == 32) p += 1; - if (!*p) break; - e = p; - while (*e && *e != 32) e += 1; - len = e - p; - if (len > 8) break; - memcpy (c, value, len); - c[len] = 0; - /* Now the actual part */ - if (!strcmp (c, "none")) { - align = SP_ASPECT_NONE; - } else if (!strcmp (c, "xMinYMin")) { - align = SP_ASPECT_XMIN_YMIN; - } else if (!strcmp (c, "xMidYMin")) { - align = SP_ASPECT_XMID_YMIN; - } else if (!strcmp (c, "xMaxYMin")) { - align = SP_ASPECT_XMAX_YMIN; - } else if (!strcmp (c, "xMinYMid")) { - align = SP_ASPECT_XMIN_YMID; - } else if (!strcmp (c, "xMidYMid")) { - align = SP_ASPECT_XMID_YMID; - } else if (!strcmp (c, "xMaxYMid")) { - align = SP_ASPECT_XMAX_YMID; - } else if (!strcmp (c, "xMinYMax")) { - align = SP_ASPECT_XMIN_YMAX; - } else if (!strcmp (c, "xMidYMax")) { - align = SP_ASPECT_XMID_YMAX; - } else if (!strcmp (c, "xMaxYMax")) { - align = SP_ASPECT_XMAX_YMAX; - } else { - break; - } - - clip = SP_ASPECT_MEET; - - while (*e && *e == 32) e += 1; - - if (*e) { - if (!strcmp (e, "meet")) { - clip = SP_ASPECT_MEET; - } else if (!strcmp (e, "slice")) { - clip = SP_ASPECT_SLICE; - } else { - break; - } - } - - this->aspect_align = align; - this->aspect_clip = clip; - } break; #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) @@ -322,7 +261,79 @@ void SPImage::set(unsigned int key, const gchar* value) { sp_image_set_curve(this); //creates a curve at the image's boundary for snapping } +// BLIP +#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) +void SPImage::apply_profile(Inkscape::Pixbuf *pixbuf) { + + // TODO: this will prevent using MIME data when exporting. + // Integrate color correction into loading. + pixbuf->ensurePixelFormat(Inkscape::Pixbuf::PF_GDK); + int imagewidth = pixbuf->width(); + int imageheight = pixbuf->height(); + int rowstride = pixbuf->rowstride();; + guchar* px = pixbuf->pixels(); + + if ( px ) { + DEBUG_MESSAGE( lcmsFive, "in 's sp_image_update. About to call colorprofile_get_handle()" ); + + guint profIntent = Inkscape::RENDERING_INTENT_UNKNOWN; + cmsHPROFILE prof = Inkscape::CMSSystem::getHandle( this->document, + &profIntent, + this->color_profile ); + if ( prof ) { + cmsProfileClassSignature profileClass = cmsGetDeviceClass( prof ); + if ( profileClass != cmsSigNamedColorClass ) { + int intent = INTENT_PERCEPTUAL; + + switch ( profIntent ) { + case Inkscape::RENDERING_INTENT_RELATIVE_COLORIMETRIC: + intent = INTENT_RELATIVE_COLORIMETRIC; + break; + case Inkscape::RENDERING_INTENT_SATURATION: + intent = INTENT_SATURATION; + break; + case Inkscape::RENDERING_INTENT_ABSOLUTE_COLORIMETRIC: + intent = INTENT_ABSOLUTE_COLORIMETRIC; + break; + case Inkscape::RENDERING_INTENT_PERCEPTUAL: + case Inkscape::RENDERING_INTENT_UNKNOWN: + case Inkscape::RENDERING_INTENT_AUTO: + default: + intent = INTENT_PERCEPTUAL; + } + + cmsHPROFILE destProf = cmsCreate_sRGBProfile(); + cmsHTRANSFORM transf = cmsCreateTransform( prof, + TYPE_RGBA_8, + destProf, + TYPE_RGBA_8, + intent, 0 ); + if ( transf ) { + guchar* currLine = px; + for ( int y = 0; y < imageheight; y++ ) { + // Since the types are the same size, we can do the transformation in-place + cmsDoTransform( transf, currLine, currLine, imagewidth ); + currLine += rowstride; + } + + cmsDeleteTransform( transf ); + } else { + DEBUG_MESSAGE( lcmsSix, "in 's sp_image_update. Unable to create LCMS transform." ); + } + + cmsCloseProfile( destProf ); + } else { + DEBUG_MESSAGE( lcmsSeven, "in 's sp_image_update. Profile type is named color. Can't transform." ); + } + } else { + DEBUG_MESSAGE( lcmsEight, "in 's sp_image_update. No profile found." ); + } + } +} +#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) + void SPImage::update(SPCtx *ctx, unsigned int flags) { + SPDocument *doc = this->document; SPItem::update(ctx, flags); @@ -339,170 +350,84 @@ void SPImage::update(SPCtx *ctx, unsigned int flags) { doc->getBase()); if (pixbuf) { -// BLIP #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - if ( this->color_profile ) - { - // TODO: this will prevent using MIME data when exporting. - // Integrate color correction into loading. - pixbuf->ensurePixelFormat(Inkscape::Pixbuf::PF_GDK); - int imagewidth = pixbuf->width(); - int imageheight = pixbuf->height(); - int rowstride = pixbuf->rowstride();; - guchar* px = pixbuf->pixels(); - - if ( px ) { - DEBUG_MESSAGE( lcmsFive, "in 's sp_image_update. About to call colorprofile_get_handle()" ); - - guint profIntent = Inkscape::RENDERING_INTENT_UNKNOWN; - cmsHPROFILE prof = Inkscape::CMSSystem::getHandle( this->document, - &profIntent, - this->color_profile ); - if ( prof ) { - cmsProfileClassSignature profileClass = cmsGetDeviceClass( prof ); - if ( profileClass != cmsSigNamedColorClass ) { - int intent = INTENT_PERCEPTUAL; - - switch ( profIntent ) { - case Inkscape::RENDERING_INTENT_RELATIVE_COLORIMETRIC: - intent = INTENT_RELATIVE_COLORIMETRIC; - break; - case Inkscape::RENDERING_INTENT_SATURATION: - intent = INTENT_SATURATION; - break; - case Inkscape::RENDERING_INTENT_ABSOLUTE_COLORIMETRIC: - intent = INTENT_ABSOLUTE_COLORIMETRIC; - break; - case Inkscape::RENDERING_INTENT_PERCEPTUAL: - case Inkscape::RENDERING_INTENT_UNKNOWN: - case Inkscape::RENDERING_INTENT_AUTO: - default: - intent = INTENT_PERCEPTUAL; - } - - cmsHPROFILE destProf = cmsCreate_sRGBProfile(); - cmsHTRANSFORM transf = cmsCreateTransform( prof, - TYPE_RGBA_8, - destProf, - TYPE_RGBA_8, - intent, 0 ); - if ( transf ) { - guchar* currLine = px; - for ( int y = 0; y < imageheight; y++ ) { - // Since the types are the same size, we can do the transformation in-place - cmsDoTransform( transf, currLine, currLine, imagewidth ); - currLine += rowstride; - } - - cmsDeleteTransform( transf ); - } else { - DEBUG_MESSAGE( lcmsSix, "in 's sp_image_update. Unable to create LCMS transform." ); - } - - cmsCloseProfile( destProf ); - } else { - DEBUG_MESSAGE( lcmsSeven, "in 's sp_image_update. Profile type is named color. Can't transform." ); - } - } else { - DEBUG_MESSAGE( lcmsEight, "in 's sp_image_update. No profile found." ); - } - } - } -#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) - + if ( this->color_profile ) apply_profile( pixbuf ); +#endif this->pixbuf = pixbuf; } } } + SPItemCtx *ictx = (SPItemCtx *) ctx; + + // Why continue without a pixbuf? So we can display "Missing Image" png. + // Eventually, we should properly support SVG image type (i.e. render it ourselves). + if (this->pixbuf) { - /* fixme: We are slightly violating spec here (Lauris) */ + if (!this->x._set) { + this->x.unit = SVGLength::PX; + this->x.computed = 0; + } + + if (!this->y._set) { + this->y.unit = SVGLength::PX; + this->y.computed = 0; + } + if (!this->width._set) { + this->width.unit = SVGLength::PX; this->width.computed = this->pixbuf->width(); } if (!this->height._set) { + this->height.unit = SVGLength::PX; this->height.computed = this->pixbuf->height(); } } - this->clipbox = Geom::Rect::from_xywh( - this->x.computed, this->y.computed, - this->width.computed, this->height.computed); + + // Calculate x, y, width, height from parent/initial viewport, see sp-root.cpp + if (this->x.unit == SVGLength::PERCENT) { + this->x.computed = this->x.value * ictx->viewport.width(); + } + + if (this->y.unit == SVGLength::PERCENT) { + this->y.computed = this->y.value * ictx->viewport.height(); + } + + if (this->width.unit == SVGLength::PERCENT) { + this->width.computed = this->width.value * ictx->viewport.width(); + } + + if (this->height.unit == SVGLength::PERCENT) { + this->height.computed = this->height.value * ictx->viewport.height(); + } + + // Image creates a new viewport + ictx->viewport= Geom::Rect::from_xywh( this->x.computed, this->y.computed, + this->width.computed, this->height.computed); + + this->clipbox = ictx->viewport; this->ox = this->x.computed; this->oy = this->y.computed; if (this->pixbuf) { - int pixwidth = this->pixbuf->width(); - int pixheight = this->pixbuf->height(); - - this->sx = this->width.computed / pixwidth; - this->sy = this->height.computed / pixheight; - - // preserveAspectRatio calculate bounds / clipping rectangle -- EAF - if (this->aspect_align != SP_ASPECT_NONE) { - double x, y; - - switch (this->aspect_align) { - case SP_ASPECT_XMIN_YMIN: - x = 0.0; - y = 0.0; - break; - case SP_ASPECT_XMID_YMIN: - x = 0.5; - y = 0.0; - break; - case SP_ASPECT_XMAX_YMIN: - x = 1.0; - y = 0.0; - break; - case SP_ASPECT_XMIN_YMID: - x = 0.0; - y = 0.5; - break; - case SP_ASPECT_XMID_YMID: - x = 0.5; - y = 0.5; - break; - case SP_ASPECT_XMAX_YMID: - x = 1.0; - y = 0.5; - break; - case SP_ASPECT_XMIN_YMAX: - x = 0.0; - y = 1.0; - break; - case SP_ASPECT_XMID_YMAX: - x = 0.5; - y = 1.0; - break; - case SP_ASPECT_XMAX_YMAX: - x = 1.0; - y = 1.0; - break; - default: - x = 0.0; - y = 0.0; - break; - } - if (this->aspect_clip == SP_ASPECT_SLICE) { - double scale = std::max(this->sx, this->sy); - this->sx = scale; - this->sy = scale; - } else { - double scale = std::min(this->sx, this->sy); - this->sx = scale; - this->sy = scale; - } + // Viewbox is either from SVG (not supported) or dimensions of pixbuf (PNG, JPG) + this->viewBox = Geom::Rect::from_xywh(0, 0, this->pixbuf->width(), this->pixbuf->height()); + this->viewBox_set = true; - double vw = pixwidth * this->sx; - double vh = pixheight * this->sy; - this->ox += x * (this->width.computed - vw); - this->oy += y * (this->height.computed - vh); - } + // SPItemCtx rctx = + get_rctx( ictx ); + + this->ox = c2p[4]; + this->oy = c2p[5]; + this->sx = c2p[0]; + this->sy = c2p[3]; } + + // TODO: eliminate ox, oy, sx, sy sp_image_update_canvas_image ((SPImage *) this); } diff --git a/src/sp-image.h b/src/sp-image.h index 3b7208487..50eb731d7 100644 --- a/src/sp-image.h +++ b/src/sp-image.h @@ -18,6 +18,7 @@ #include #include "svg/svg-length.h" #include "sp-shape.h" +#include "viewbox.h" #define SP_IMAGE(obj) (dynamic_cast((SPObject*)obj)) #define SP_IS_IMAGE(obj) (dynamic_cast((SPObject*)obj) != NULL) @@ -25,7 +26,7 @@ #define SP_IMAGE_HREF_MODIFIED_FLAG SP_OBJECT_USER_MODIFIED_FLAG_A namespace Inkscape { class Pixbuf; } -class SPImage : public SPItem { +class SPImage : public SPItem, public SPViewBox { public: SPImage(); virtual ~SPImage(); @@ -39,13 +40,6 @@ public: double sx, sy; double ox, oy; - // Added by EAF - /* preserveAspectRatio */ - unsigned int aspect_align : 4; - unsigned int aspect_clip : 1; - //int trimx, trimy, trimwidth, trimheight; - //double viewx, viewy, viewwidth, viewheight; - SPCurve *curve; // This curve is at the image's boundary for snapping gchar *href; @@ -69,6 +63,10 @@ public: virtual Inkscape::DrawingItem* show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags); virtual void snappoints(std::vector &p, Inkscape::SnapPreferences const *snapprefs) const; virtual Geom::Affine set_transform(Geom::Affine const &transform); + +#if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) + void apply_profile(Inkscape::Pixbuf *pixbuf); +#endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) }; /* Return duplicate of curve or NULL */ diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index ad5449f34..711f26428 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -53,7 +53,7 @@ namespace { bool patternRegistered = SPFactory::instance().registerObject("svg:pattern", createPattern); } -SPPattern::SPPattern() : SPPaintServer() { +SPPattern::SPPattern() : SPPaintServer(), SPViewBox() { this->href = NULL; this->ref = new SPPatternReference(this); @@ -72,8 +72,6 @@ SPPattern::SPPattern() : SPPaintServer() { this->y.unset(); this->width.unset(); this->height.unset(); - - this->viewBox_set = FALSE; } SPPattern::~SPPattern() { @@ -90,6 +88,7 @@ void SPPattern::build(SPDocument* doc, Inkscape::XML::Node* repr) { this->readAttr( "width" ); this->readAttr( "height" ); this->readAttr( "viewBox" ); + this->readAttr( "preserveAspectRatio" ); this->readAttr( "xlink:href" ); /* Register ourselves */ @@ -180,50 +179,16 @@ void SPPattern::set(unsigned int key, const gchar* value) { this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; - case SP_ATTR_VIEWBOX: { - /* fixme: Think (Lauris) */ - double x, y, width, height; - char *eptr; - - if (value) { - eptr = (gchar *) value; - x = g_ascii_strtod (eptr, &eptr); - - while (*eptr && ((*eptr == ',') || (*eptr == ' '))) { - eptr++; - } - - y = g_ascii_strtod (eptr, &eptr); - - while (*eptr && ((*eptr == ',') || (*eptr == ' '))) { - eptr++; - } - - width = g_ascii_strtod (eptr, &eptr); - - while (*eptr && ((*eptr == ',') || (*eptr == ' '))) { - eptr++; - } - - height = g_ascii_strtod (eptr, &eptr); - - while (*eptr && ((*eptr == ',') || (*eptr == ' '))) { - eptr++; - } + case SP_ATTR_VIEWBOX: + set_viewBox( value ); + this->requestModified(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG); + break; - if ((width > 0) && (height > 0)) { - this->viewBox = Geom::Rect::from_xywh(x, y, width, height); - this->viewBox_set = TRUE; - } else { - this->viewBox_set = FALSE; - } - } else { - this->viewBox_set = FALSE; - } + case SP_ATTR_PRESERVEASPECTRATIO: + set_preserveAspectRatio( value ); + this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG); + break; - this->requestModified(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG); - break; - } case SP_ATTR_XLINK_HREF: if ( value && this->href && ( strcmp(value, this->href) == 0 ) ) { /* Href unchanged, do nothing. */ diff --git a/src/sp-pattern.h b/src/sp-pattern.h index 4e3657ccf..f69ba10b3 100644 --- a/src/sp-pattern.h +++ b/src/sp-pattern.h @@ -25,12 +25,13 @@ class SPPatternReference; #include "svg/svg-length.h" #include "sp-paint-server.h" #include "uri-references.h" +#include "viewbox.h" #include #include -class SPPattern : public SPPaintServer { +class SPPattern : public SPPaintServer, public SPViewBox { public: SPPattern(); virtual ~SPPattern(); @@ -52,9 +53,6 @@ public: SVGLength y; SVGLength width; SVGLength height; - /* VieBox */ - Geom::Rect viewBox; - guint viewBox_set : 1; sigc::connection modified_connection; diff --git a/src/sp-root.cpp b/src/sp-root.cpp index 5466649a2..bc870b116 100644 --- a/src/sp-root.cpp +++ b/src/sp-root.cpp @@ -42,12 +42,9 @@ SPObject *createRoot() bool rootRegistered = SPFactory::instance().registerObject("svg:svg", createRoot); } -SPRoot::SPRoot() : SPGroup() +SPRoot::SPRoot() : SPGroup(), SPViewBox() { - this->aspect_set = 0; - this->aspect_align = 0; this->onload = NULL; - this->aspect_clip = 0; static Inkscape::Version const zero_version(0, 0); @@ -57,15 +54,11 @@ SPRoot::SPRoot() : SPGroup() this->version.inkscape = zero_version; this->original.inkscape = zero_version; - this->x.unset(); - this->y.unset(); + this->x.unset(SVGLength::PERCENT, 0.0, 0.0); // Ignored for root SVG element + this->y.unset(SVGLength::PERCENT, 0.0, 0.0); this->width.unset(SVGLength::PERCENT, 1.0, 1.0); this->height.unset(SVGLength::PERCENT, 1.0, 1.0); - this->viewBox_set = false; - - this->c2p.setIdentity(); - this->defs = NULL; } @@ -129,9 +122,9 @@ void SPRoot::set(unsigned int key, const gchar *value) break; case SP_ATTR_X: - if (!this->x.readAbsolute(value)) { - /* fixme: em, ex, % are probably valid, but require special treatment (Lauris) */ - this->x.unset(); + /* Valid for non-root SVG elements; ex, em not handled correctly. */ + if (!this->x.read(value)) { + this->x.unset(SVGLength::PERCENT, 0.0, 0.0); } /* fixme: I am almost sure these do not require viewport flag (Lauris) */ @@ -139,9 +132,9 @@ void SPRoot::set(unsigned int key, const gchar *value) break; case SP_ATTR_Y: - if (!this->y.readAbsolute(value)) { - /* fixme: em, ex, % are probably valid, but require special treatment (Lauris) */ - this->y.unset(); + /* Valid for non-root SVG elements; ex, em not handled correctly. */ + if (!this->y.read(value)) { + this->y.unset(SVGLength::PERCENT, 0.0, 0.0); } /* fixme: I am almost sure these do not require viewport flag (Lauris) */ @@ -149,153 +142,27 @@ void SPRoot::set(unsigned int key, const gchar *value) break; case SP_ATTR_WIDTH: - if (!this->width.readAbsolute(value) || !(this->width.computed > 0.0)) { - /* fixme: em, ex, % are probably valid, but require special treatment (Lauris) */ + if (!this->width.read(value) || !(this->width.computed > 0.0)) { this->width.unset(SVGLength::PERCENT, 1.0, 1.0); } - this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG); break; case SP_ATTR_HEIGHT: - if (!this->height.readAbsolute(value) || !(this->height.computed > 0.0)) { - /* fixme: em, ex, % are probably valid, but require special treatment (Lauris) */ + if (!this->height.read(value) || !(this->height.computed > 0.0)) { this->height.unset(SVGLength::PERCENT, 1.0, 1.0); } - this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG); break; case SP_ATTR_VIEWBOX: - if (value) { - double x, y, width, height; - char *eptr; - - /* fixme: We have to take original item affine into account */ - /* fixme: Think (Lauris) */ - eptr = (gchar *) value; - x = g_ascii_strtod(eptr, &eptr); - - while (*eptr && ((*eptr == ',') || (*eptr == ' '))) { - eptr++; - } - - y = g_ascii_strtod(eptr, &eptr); - - while (*eptr && ((*eptr == ',') || (*eptr == ' '))) { - eptr++; - } - - width = g_ascii_strtod(eptr, &eptr); - - while (*eptr && ((*eptr == ',') || (*eptr == ' '))) { - eptr++; - } - - height = g_ascii_strtod(eptr, &eptr); - - while (*eptr && ((*eptr == ',') || (*eptr == ' '))) { - eptr++; - } - - if ((width > 0) && (height > 0)) { - /* Set viewbox */ - this->viewBox = Geom::Rect::from_xywh(x, y, width, height); - this->viewBox_set = TRUE; - } else { - this->viewBox_set = FALSE; - } - } else { - this->viewBox_set = FALSE; - } - + set_viewBox( value ); this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG); break; case SP_ATTR_PRESERVEASPECTRATIO: - /* Do setup before, so we can use break to escape */ - this->aspect_set = FALSE; - this->aspect_align = SP_ASPECT_XMID_YMID; - this->aspect_clip = SP_ASPECT_MEET; - + set_preserveAspectRatio( value ); this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG); - - if (value) { - int len; - gchar c[256]; - gchar const *p, *e; - unsigned int align, clip; - p = value; - - while (*p && *p == 32) { - p += 1; - } - - if (!*p) { - break; - } - - e = p; - - while (*e && *e != 32) { - e += 1; - } - - len = e - p; - - if (len > 8) { - break; - } - - memcpy(c, value, len); - - c[len] = 0; - - /* Now the actual part */ - if (!strcmp(c, "none")) { - align = SP_ASPECT_NONE; - } else if (!strcmp(c, "xMinYMin")) { - align = SP_ASPECT_XMIN_YMIN; - } else if (!strcmp(c, "xMidYMin")) { - align = SP_ASPECT_XMID_YMIN; - } else if (!strcmp(c, "xMaxYMin")) { - align = SP_ASPECT_XMAX_YMIN; - } else if (!strcmp(c, "xMinYMid")) { - align = SP_ASPECT_XMIN_YMID; - } else if (!strcmp(c, "xMidYMid")) { - align = SP_ASPECT_XMID_YMID; - } else if (!strcmp(c, "xMaxYMid")) { - align = SP_ASPECT_XMAX_YMID; - } else if (!strcmp(c, "xMinYMax")) { - align = SP_ASPECT_XMIN_YMAX; - } else if (!strcmp(c, "xMidYMax")) { - align = SP_ASPECT_XMID_YMAX; - } else if (!strcmp(c, "xMaxYMax")) { - align = SP_ASPECT_XMAX_YMAX; - } else { - break; - } - - clip = SP_ASPECT_MEET; - - while (*e && *e == 32) { - e += 1; - } - - if (*e) { - if (!strcmp(e, "meet")) { - clip = SP_ASPECT_MEET; - } else if (!strcmp(e, "slice")) { - clip = SP_ASPECT_SLICE; - } else { - break; - } - } - - this->aspect_set = TRUE; - this->aspect_align = align; - this->aspect_clip = clip; - } break; case SP_ATTR_ONLOAD: @@ -356,141 +223,75 @@ void SPRoot::update(SPCtx *ctx, guint flags) { SPItemCtx *ictx = (SPItemCtx *) ctx; - /* fixme: This will be invoked too often (Lauris) */ - /* fixme: We should calculate only if parent viewport has changed (Lauris) */ - /* If position is specified as percentage, calculate actual values */ - if (this->x.unit == SVGLength::PERCENT) { - this->x.computed = this->x.value * ictx->viewport.width(); - } - - if (this->y.unit == SVGLength::PERCENT) { - this->y.computed = this->y.value * ictx->viewport.height(); - } - - if (this->width.unit == SVGLength::PERCENT) { - this->width.computed = this->width.value * ictx->viewport.width(); - } - - if (this->height.unit == SVGLength::PERCENT) { - this->height.computed = this->height.value * ictx->viewport.height(); - } - - /* Create copy of item context */ - SPItemCtx rctx = *ictx; - - /* Calculate child to parent transformation */ - this->c2p.setIdentity(); + if( !this->parent ) { - if (this->parent) { /* - * fixme: I am not sure whether setting x and y does or does not - * fixme: translate the content of inner SVG. - * fixme: Still applying translation and setting viewport to width and - * fixme: height seems natural, as this makes the inner svg element - * fixme: self-contained. The spec is vague here. + * This is the root SVG element: + * + * x, y, width, and height apply to positioning the SVG element inside a parent. + * For the root SVG in Inkscape there is no parent, thus special rules apply: + * If width, height not set, width = 100%, height = 100% (as always). + * If width and height are in percent, they are percent of viewBox width/height. + * If width, height, and viewBox are not set... pick "random" width/height. + * x, y are ignored. + * initial viewport = (0 0 width height) */ - this->c2p = Geom::Affine(Geom::Translate(this->x.computed, this->y.computed)); - } - - if (this->viewBox_set) { - double x, y, width, height; - /* Determine actual viewbox in viewport coordinates */ - if (this->aspect_align == SP_ASPECT_NONE) { - x = 0.0; - y = 0.0; - width = this->width.computed; - height = this->height.computed; - } else { - double scalex, scaley, scale; - /* Things are getting interesting */ - scalex = this->width.computed / this->viewBox.width(); - scaley = this->height.computed / this->viewBox.height(); - scale = (this->aspect_clip == SP_ASPECT_MEET) ? MIN(scalex, scaley) : MAX(scalex, scaley); - width = this->viewBox.width() * scale; - height = this->viewBox.height() * scale; - - /* Now place viewbox to requested position */ - /* todo: Use an array lookup to find the 0.0/0.5/1.0 coefficients, - as is done for dialogs/align.cpp. */ - switch (this->aspect_align) { - case SP_ASPECT_XMIN_YMIN: - x = 0.0; - y = 0.0; - break; - - case SP_ASPECT_XMID_YMIN: - x = 0.5 * (this->width.computed - width); - y = 0.0; - break; - - case SP_ASPECT_XMAX_YMIN: - x = 1.0 * (this->width.computed - width); - y = 0.0; - break; - - case SP_ASPECT_XMIN_YMID: - x = 0.0; - y = 0.5 * (this->height.computed - height); - break; - - case SP_ASPECT_XMID_YMID: - x = 0.5 * (this->width.computed - width); - y = 0.5 * (this->height.computed - height); - break; + if( this->viewBox_set ) { - case SP_ASPECT_XMAX_YMID: - x = 1.0 * (this->width.computed - width); - y = 0.5 * (this->height.computed - height); - break; + if( this->width._set ) { + // Check if this is necessary + if (this->width.unit == SVGLength::PERCENT) { + this->width.computed = this->width.value * this->viewBox.width(); + } + } else { + this->width.set( SVGLength::PX, this->viewBox.width(), this->viewBox.width() ); + } - case SP_ASPECT_XMIN_YMAX: - x = 0.0; - y = 1.0 * (this->height.computed - height); - break; + if( this->height._set ) { + if (this->height.unit == SVGLength::PERCENT) { + this->height.computed = this->height.value * this->viewBox.height(); + } + } else { + this->height.set(SVGLength::PX, this->viewBox.height(), this->viewBox.height() ); + } - case SP_ASPECT_XMID_YMAX: - x = 0.5 * (this->width.computed - width); - y = 1.0 * (this->height.computed - height); - break; + } else { - case SP_ASPECT_XMAX_YMAX: - x = 1.0 * (this->width.computed - width); - y = 1.0 * (this->height.computed - height); - break; + if( !this->width._set ) { + this->width.set( SVGLength::PX, 100, 100 ); // Random default + } - default: - x = 0.0; - y = 0.0; - break; + if( !this->height._set ) { + this->height.set( SVGLength::PX, 100, 100 ); // Random default } } - /* Compose additional transformation from scale and position */ - Geom::Scale const viewBox_length(this->viewBox.dimensions()); - Geom::Scale const new_length(width, height); + // Ignore x, y values for root element + this->x.unset(SVGLength::PERCENT, 0.0, 0.0); + this->y.unset(SVGLength::PERCENT, 0.0, 0.0); + } - /* Append viewbox transformation */ - /* TODO: The below looks suspicious to me (pjrm): I wonder whether the RHS - expression should have c2p at the beginning rather than at the end. Test it. */ - this->c2p = Geom::Translate(-this->viewBox.min()) * (new_length * viewBox_length.inverse()) * Geom::Translate(x, y) * this->c2p; + // Calculate x, y, width, height from parent/initial viewport + if (this->x.unit == SVGLength::PERCENT) { + this->x.computed = this->x.value * ictx->viewport.width(); } - rctx.i2doc = this->c2p * rctx.i2doc; + if (this->y.unit == SVGLength::PERCENT) { + this->y.computed = this->y.value * ictx->viewport.height(); + } - /* Initialize child viewport */ - if (this->viewBox_set) { - rctx.viewport = this->viewBox; - } else { - /* fixme: I wonder whether this logic is correct (Lauris) */ - Geom::Point minp(0, 0); - if (this->parent) { - minp = Geom::Point(this->x.computed, this->y.computed); - } + if (this->width.unit == SVGLength::PERCENT) { + this->width.computed = this->width.value * ictx->viewport.width(); + } - rctx.viewport = Geom::Rect::from_xywh(minp[Geom::X], minp[Geom::Y], this->width.computed, this->height.computed); + if (this->height.unit == SVGLength::PERCENT) { + this->height.computed = this->height.value * ictx->viewport.height(); } - rctx.i2vp = Geom::identity(); + // Calculate new viewport + ictx->viewport = Geom::Rect::from_xywh( this->x.computed, this->y.computed, + this->width.computed, this->height.computed ); + SPItemCtx rctx = get_rctx( ictx ); /* And invoke parent method */ SPGroup::update((SPCtx *) &rctx, flags); diff --git a/src/sp-root.h b/src/sp-root.h index 2931391ff..1c9faed9b 100644 --- a/src/sp-root.h +++ b/src/sp-root.h @@ -18,6 +18,7 @@ #include "svg/svg-length.h" #include "enums.h" #include "sp-item-group.h" +#include "viewbox.h" #define SP_ROOT(obj) (dynamic_cast((SPObject*)obj)) #define SP_IS_ROOT(obj) (dynamic_cast((SPObject*)obj) != NULL) @@ -25,7 +26,7 @@ class SPDefs; /** \ element */ -class SPRoot : public SPGroup { +class SPRoot : public SPGroup, public SPViewBox { public: SPRoot(); virtual ~SPRoot(); @@ -40,18 +41,6 @@ public: SVGLength width; SVGLength height; - /* viewBox; */ - bool viewBox_set; - Geom::Rect viewBox; - - /* preserveAspectRatio */ - unsigned int aspect_set : 1; - unsigned int aspect_align : 4; - unsigned int aspect_clip : 1; - - /** Child to parent additional transform. */ - Geom::Affine c2p; - gchar *onload; /** diff --git a/src/sp-symbol.cpp b/src/sp-symbol.cpp index 8ffc2ab2c..817411a32 100644 --- a/src/sp-symbol.cpp +++ b/src/sp-symbol.cpp @@ -36,13 +36,7 @@ namespace { bool symbolRegistered = SPFactory::instance().registerObject("svg:symbol", createSymbol); } -SPSymbol::SPSymbol() : SPGroup() { - this->aspect_align = 0; - this->aspect_clip = 0; - this->aspect_set = 0; - - this->viewBox_set = FALSE; - this->c2p = Geom::identity(); +SPSymbol::SPSymbol() : SPGroup(), SPViewBox() { } SPSymbol::~SPSymbol() { @@ -62,134 +56,15 @@ void SPSymbol::release() { void SPSymbol::set(unsigned int key, const gchar* value) { switch (key) { case SP_ATTR_VIEWBOX: - if (value) { - double x, y, width, height; - char *eptr; - - /* fixme: We have to take original item affine into account */ - /* fixme: Think (Lauris) */ - eptr = (gchar *) value; - x = g_ascii_strtod (eptr, &eptr); - - while (*eptr && ((*eptr == ',') || (*eptr == ' '))) { - eptr++; - } - - y = g_ascii_strtod (eptr, &eptr); - - while (*eptr && ((*eptr == ',') || (*eptr == ' '))) { - eptr++; - } - - width = g_ascii_strtod (eptr, &eptr); - - while (*eptr && ((*eptr == ',') || (*eptr == ' '))) { - eptr++; - } - - height = g_ascii_strtod (eptr, &eptr); - - while (*eptr && ((*eptr == ',') || (*eptr == ' '))) { - eptr++; - } - - if ((width > 0) && (height > 0)) { - /* Set viewbox */ - this->viewBox = Geom::Rect::from_xywh(x, y, width, height); - this->viewBox_set = TRUE; - } else { - this->viewBox_set = FALSE; - } - } else { - this->viewBox_set = FALSE; - } - + set_viewBox( value ); + std::cout << "Symbol: ViewBox: " << viewBox << std::endl; this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG); break; case SP_ATTR_PRESERVEASPECTRATIO: - /* Do setup before, so we can use break to escape */ - this->aspect_set = FALSE; - this->aspect_align = SP_ASPECT_NONE; - this->aspect_clip = SP_ASPECT_MEET; + set_preserveAspectRatio( value ); + std::cout << "Symbol: Preserve aspect ratio: " << aspect_align << ", " << aspect_clip << std::endl; this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG); - - if (value) { - int len; - gchar c[256]; - const gchar *p, *e; - unsigned int align, clip; - p = value; - - while (*p && *p == 32) { - p += 1; - } - - if (!*p) { - break; - } - - e = p; - - while (*e && *e != 32) { - e += 1; - } - - len = e - p; - - if (len > 8) { - break; - } - - memcpy (c, value, len); - - c[len] = 0; - - /* Now the actual part */ - if (!strcmp (c, "none")) { - align = SP_ASPECT_NONE; - } else if (!strcmp (c, "xMinYMin")) { - align = SP_ASPECT_XMIN_YMIN; - } else if (!strcmp (c, "xMidYMin")) { - align = SP_ASPECT_XMID_YMIN; - } else if (!strcmp (c, "xMaxYMin")) { - align = SP_ASPECT_XMAX_YMIN; - } else if (!strcmp (c, "xMinYMid")) { - align = SP_ASPECT_XMIN_YMID; - } else if (!strcmp (c, "xMidYMid")) { - align = SP_ASPECT_XMID_YMID; - } else if (!strcmp (c, "xMaxYMid")) { - align = SP_ASPECT_XMAX_YMID; - } else if (!strcmp (c, "xMinYMax")) { - align = SP_ASPECT_XMIN_YMAX; - } else if (!strcmp (c, "xMidYMax")) { - align = SP_ASPECT_XMID_YMAX; - } else if (!strcmp (c, "xMaxYMax")) { - align = SP_ASPECT_XMAX_YMAX; - } else { - break; - } - - clip = SP_ASPECT_MEET; - - while (*e && *e == 32) { - e += 1; - } - - if (*e) { - if (!strcmp (e, "meet")) { - clip = SP_ASPECT_MEET; - } else if (!strcmp (e, "slice")) { - clip = SP_ASPECT_SLICE; - } else { - break; - } - } - - this->aspect_set = TRUE; - this->aspect_align = align; - this->aspect_clip = clip; - } break; default: @@ -204,105 +79,10 @@ void SPSymbol::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) void SPSymbol::update(SPCtx *ctx, guint flags) { - SPItemCtx *ictx = (SPItemCtx *) ctx; - SPItemCtx rctx; - if (this->cloned) { - /* Cloned is actually renderable */ - - /* fixme: We have to set up clip here too */ - - /* Create copy of item context */ - rctx = *ictx; - - /* Calculate child to parent transformation */ - /* Apply parent translation (set up as vewport) */ - this->c2p = Geom::Translate(rctx.viewport.min()); - - if (this->viewBox_set) { - double x, y, width, height; - - /* Determine actual viewbox in viewport coordinates */ - if (this->aspect_align == SP_ASPECT_NONE) { - x = 0.0; - y = 0.0; - width = rctx.viewport.width(); - height = rctx.viewport.height(); - } else { - double scalex, scaley, scale; - /* Things are getting interesting */ - scalex = rctx.viewport.width() / this->viewBox.width(); - scaley = rctx.viewport.height() / this->viewBox.height(); - scale = (this->aspect_clip == SP_ASPECT_MEET) ? MIN (scalex, scaley) : MAX (scalex, scaley); - width = this->viewBox.width() * scale; - height = this->viewBox.height() * scale; - - /* Now place viewbox to requested position */ - switch (this->aspect_align) { - case SP_ASPECT_XMIN_YMIN: - x = 0.0; - y = 0.0; - break; - case SP_ASPECT_XMID_YMIN: - x = 0.5 * (rctx.viewport.width() - width); - y = 0.0; - break; - case SP_ASPECT_XMAX_YMIN: - x = 1.0 * (rctx.viewport.width() - width); - y = 0.0; - break; - case SP_ASPECT_XMIN_YMID: - x = 0.0; - y = 0.5 * (rctx.viewport.height() - height); - break; - case SP_ASPECT_XMID_YMID: - x = 0.5 * (rctx.viewport.width() - width); - y = 0.5 * (rctx.viewport.height() - height); - break; - case SP_ASPECT_XMAX_YMID: - x = 1.0 * (rctx.viewport.width() - width); - y = 0.5 * (rctx.viewport.height() - height); - break; - case SP_ASPECT_XMIN_YMAX: - x = 0.0; - y = 1.0 * (rctx.viewport.height() - height); - break; - case SP_ASPECT_XMID_YMAX: - x = 0.5 * (rctx.viewport.width() - width); - y = 1.0 * (rctx.viewport.height() - height); - break; - case SP_ASPECT_XMAX_YMAX: - x = 1.0 * (rctx.viewport.width() - width); - y = 1.0 * (rctx.viewport.height() - height); - break; - default: - x = 0.0; - y = 0.0; - break; - } - } - - /* Compose additional transformation from scale and position */ - Geom::Affine q; - q[0] = width / this->viewBox.width(); - q[1] = 0.0; - q[2] = 0.0; - q[3] = height / this->viewBox.height(); - q[4] = -this->viewBox.left() * q[0] + x; - q[5] = -this->viewBox.top() * q[3] + y; - - /* Append viewbox transformation */ - this->c2p = q * this->c2p; - } - rctx.i2doc = this->c2p * (Geom::Affine)rctx.i2doc; - - /* If viewBox is set initialize child viewport */ - /* Otherwise has set it up already */ - if (this->viewBox_set) { - rctx.viewport = this->viewBox; - rctx.i2vp = Geom::identity(); - } + SPItemCtx *ictx = (SPItemCtx *) ctx; + SPItemCtx rctx = get_rctx( ictx ); // And invoke parent method SPGroup::update((SPCtx *) &rctx, flags); diff --git a/src/sp-symbol.h b/src/sp-symbol.h index 7a43ed658..d1e62e923 100644 --- a/src/sp-symbol.h +++ b/src/sp-symbol.h @@ -25,24 +25,13 @@ #include "svg/svg-length.h" #include "enums.h" #include "sp-item-group.h" +#include "viewbox.h" -class SPSymbol : public SPGroup { +class SPSymbol : public SPGroup, public SPViewBox { public: SPSymbol(); virtual ~SPSymbol(); - /* viewBox; */ - unsigned int viewBox_set : 1; - Geom::Rect viewBox; - - /* preserveAspectRatio */ - unsigned int aspect_set : 1; - unsigned int aspect_align : 4; - unsigned int aspect_clip : 1; - - /* Child to parent additional transform */ - Geom::Affine c2p; - virtual void build(SPDocument *document, Inkscape::XML::Node *repr); virtual void release(); virtual void set(unsigned int key, gchar const* value); diff --git a/src/viewbox.cpp b/src/viewbox.cpp new file mode 100644 index 000000000..2314cbf6a --- /dev/null +++ b/src/viewbox.cpp @@ -0,0 +1,277 @@ +/* + * viewBox helper class, common code used by root, symbol, marker, pattern, image, view + * + * Authors: + * Lauris Kaplinski (code extracted from symbol.cpp) + * Tavmjong Bah + * + * Copyright (C) 2013 Tavmjong Bah, authors + * + * Released under GNU GPL, read the file 'COPYING' for more information + * + */ + +#include <2geom/transforms.h> + +#include "viewbox.h" +#include "attributes.h" +#include "enums.h" +#include "sp-item.h" + +SPViewBox::SPViewBox() { + + this->viewBox_set = FALSE; + + this->aspect_set = FALSE; + this->aspect_align = SP_ASPECT_XMID_YMID; // Default per spec; + this->aspect_clip = SP_ASPECT_MEET; + + this->c2p = Geom::identity(); +} + +SPViewBox::~SPViewBox() { +} + +void SPViewBox::set_viewBox(const gchar* value) { + + if (value) { + double x, y, width, height; + char *eptr; + + eptr = (gchar *) value; + x = g_ascii_strtod (eptr, &eptr); + + while (*eptr && ((*eptr == ',') || (*eptr == ' '))) { + eptr++; + } + + y = g_ascii_strtod (eptr, &eptr); + + while (*eptr && ((*eptr == ',') || (*eptr == ' '))) { + eptr++; + } + + width = g_ascii_strtod (eptr, &eptr); + + while (*eptr && ((*eptr == ',') || (*eptr == ' '))) { + eptr++; + } + + height = g_ascii_strtod (eptr, &eptr); + + while (*eptr && ((*eptr == ',') || (*eptr == ' '))) { + eptr++; + } + + if ((width > 0) && (height > 0)) { + /* Set viewbox */ + this->viewBox = Geom::Rect::from_xywh(x, y, width, height); + this->viewBox_set = TRUE; + } else { + this->viewBox_set = FALSE; + } + } else { + this->viewBox_set = FALSE; + } + + // The C++ way? + // std::string sv( value ); + // std::replace( sv.begin(), sv.end(), ',', ' '); + // std::stringstream ss( sv ); + // double x, y, width, height; + // ss >> x >> y >> width >> height; +} + +void SPViewBox::set_preserveAspectRatio(const gchar* value) { + + /* Do setup before, so we can use break to escape */ + this->aspect_set = FALSE; + this->aspect_align = SP_ASPECT_XMID_YMID; // Default per spec + this->aspect_clip = SP_ASPECT_MEET; + + if (value) { + int len; + gchar c[256]; + const gchar *p, *e; + unsigned int align, clip; + p = value; + + while (*p && *p == 32) { + p += 1; + } + + if (!*p) { + return; + } + + e = p; + + while (*e && *e != 32) { + e += 1; + } + + len = e - p; + + if (len > 8) { + return; + } + + memcpy (c, value, len); + + c[len] = 0; + + /* Now the actual part */ + if (!strcmp (c, "none")) { + align = SP_ASPECT_NONE; + } else if (!strcmp (c, "xMinYMin")) { + align = SP_ASPECT_XMIN_YMIN; + } else if (!strcmp (c, "xMidYMin")) { + align = SP_ASPECT_XMID_YMIN; + } else if (!strcmp (c, "xMaxYMin")) { + align = SP_ASPECT_XMAX_YMIN; + } else if (!strcmp (c, "xMinYMid")) { + align = SP_ASPECT_XMIN_YMID; + } else if (!strcmp (c, "xMidYMid")) { + align = SP_ASPECT_XMID_YMID; + } else if (!strcmp (c, "xMaxYMid")) { + align = SP_ASPECT_XMAX_YMID; + } else if (!strcmp (c, "xMinYMax")) { + align = SP_ASPECT_XMIN_YMAX; + } else if (!strcmp (c, "xMidYMax")) { + align = SP_ASPECT_XMID_YMAX; + } else if (!strcmp (c, "xMaxYMax")) { + align = SP_ASPECT_XMAX_YMAX; + } else { + return; + } + + clip = SP_ASPECT_MEET; + + while (*e && *e == 32) { + e += 1; + } + + if (*e) { + if (!strcmp (e, "meet")) { + clip = SP_ASPECT_MEET; + } else if (!strcmp (e, "slice")) { + clip = SP_ASPECT_SLICE; + } else { + return; + } + } + + this->aspect_set = TRUE; + this->aspect_align = align; + this->aspect_clip = clip; + } +} + +// Apply scaling from viewbox +void SPViewBox::apply_viewbox(const Geom::Rect& in) { + + /* Determine actual viewbox in viewport coordinates */ + double x = 0.0; + double y = 0.0; + double width = in.width(); + double height = in.height(); + // std::cout << " width: " << width << " height: " << height << std::endl; + + if (this->aspect_align != SP_ASPECT_NONE) { + double scalex, scaley, scale; + /* Things are getting interesting */ + scalex = in.width() / this->viewBox.width(); + scaley = in.height() / this->viewBox.height(); + scale = (this->aspect_clip == SP_ASPECT_MEET) ? MIN (scalex, scaley) : MAX (scalex, scaley); + width = this->viewBox.width() * scale; + height = this->viewBox.height() * scale; + + /* Now place viewbox to requested position */ + switch (this->aspect_align) { + case SP_ASPECT_XMIN_YMIN: + break; + case SP_ASPECT_XMID_YMIN: + x = 0.5 * (in.width() - width); + break; + case SP_ASPECT_XMAX_YMIN: + x = 1.0 * (in.width() - width); + break; + case SP_ASPECT_XMIN_YMID: + y = 0.5 * (in.height() - height); + break; + case SP_ASPECT_XMID_YMID: + x = 0.5 * (in.width() - width); + y = 0.5 * (in.height() - height); + break; + case SP_ASPECT_XMAX_YMID: + x = 1.0 * (in.width() - width); + y = 0.5 * (in.height() - height); + break; + case SP_ASPECT_XMIN_YMAX: + y = 1.0 * (in.height() - height); + break; + case SP_ASPECT_XMID_YMAX: + x = 0.5 * (in.width() - width); + y = 1.0 * (in.height() - height); + break; + case SP_ASPECT_XMAX_YMAX: + x = 1.0 * (in.width() - width); + y = 1.0 * (in.height() - height); + break; + default: + break; + } + } + + /* Viewbox transform from scale and position */ + Geom::Affine q; + q[0] = width / this->viewBox.width(); + q[1] = 0.0; + q[2] = 0.0; + q[3] = height / this->viewBox.height(); + q[4] = -this->viewBox.left() * q[0] + x; + q[5] = -this->viewBox.top() * q[3] + y; + + // std::cout << " q\n" << q << std::endl; + + /* Append viewbox transformation */ + this->c2p = q * this->c2p; +} + +SPItemCtx SPViewBox::get_rctx(const SPItemCtx* ictx) { + + /* Create copy of item context */ + SPItemCtx rctx = *ictx; + + /* Calculate child to parent transformation */ + /* Apply parent translation (set up as viewport) */ + this->c2p = Geom::Translate(rctx.viewport.min()); + + if (this->viewBox_set) { + // Adjusts c2p for viewbox + apply_viewbox( rctx.viewport ); + } + + rctx.i2doc = this->c2p * rctx.i2doc; + + /* If viewBox is set initialize child viewport */ + /* Otherwise it is already correct */ + if (this->viewBox_set) { + rctx.viewport = this->viewBox; + rctx.i2vp = Geom::identity(); + } + + return rctx; +} + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-basic-offset:2 + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=2:tabstop=8:softtabstop=2:fileencoding=utf-8:textwidth=99 : diff --git a/src/viewbox.h b/src/viewbox.h new file mode 100644 index 000000000..24356ed17 --- /dev/null +++ b/src/viewbox.h @@ -0,0 +1,66 @@ +#ifndef __SP_VIEWBOX_H__ +#define __SP_VIEWBOX_H__ + +/* + * viewBox helper class, common code used by root, symbol, marker, pattern, image, view + * + * Authors: + * Lauris Kaplinski (code extracted from sp-symbol.h) + * Tavmjong Bah + * + * Copyright (C) 2013 Tavmjong Bah, authors + * + * Released under GNU GPL, read the file 'COPYING' for more information + * + */ + +#include <2geom/rect.h> +#include + +namespace Geom { +class Rect; +} +class SPItemCtx; + +class SPViewBox { + + public: + + SPViewBox(); + ~SPViewBox(); + + /* viewBox; */ + unsigned int viewBox_set : 1; + Geom::Rect viewBox; // Could use optrect + + /* preserveAspectRatio */ + unsigned int aspect_set : 1; + unsigned int aspect_align : 4; + unsigned int aspect_clip : 1; + + /* Child to parent additional transform */ + Geom::Affine c2p; + + void set_viewBox(const gchar* value); + void set_preserveAspectRatio(const gchar* value); + + /* Adjusts c2p for viewbox */ + void apply_viewbox(const Geom::Rect& in); + + SPItemCtx get_rctx( const SPItemCtx* ictx); + +}; + +#endif + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-basic-offset:2 + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=2:tabstop=8:softtabstop=2:fileencoding=utf-8:textwidth=99 : -- cgit v1.2.3 From 837c1a0ef4f2e0eb5000b4b993fd0b40d0a531db Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Thu, 6 Feb 2014 20:28:35 +0100 Subject: Markers are never shown directly, even if outside of section. (bzr r13003) --- src/marker.cpp | 10 +++++++--- src/marker.h | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/marker.cpp b/src/marker.cpp index f6e55b3ec..900f8a2ca 100644 --- a/src/marker.cpp +++ b/src/marker.cpp @@ -283,8 +283,12 @@ Inkscape::XML::Node* SPMarker::write(Inkscape::XML::Document *xml_doc, Inkscape: } Inkscape::DrawingItem* SPMarker::show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) { - // CPPIFY: correct? - return SPGroup::show(drawing, key, flags); + // Markers in tree are never shown directly even if outside of . + return 0; +} + +Inkscape::DrawingItem* SPMarker::private_show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) { + return SPGroup::show(drawing, key, flags); } void SPMarker::hide(unsigned int key) { @@ -364,7 +368,7 @@ sp_marker_show_instance ( SPMarker *marker, Inkscape::DrawingItem *parent, } if (!v->items[pos]) { /* Parent class ::show method */ - v->items[pos] = marker->show(parent->drawing(), key, SP_ITEM_REFERENCE_FLAGS); + v->items[pos] = marker->private_show(parent->drawing(), key, SP_ITEM_REFERENCE_FLAGS); if (v->items[pos]) { /* fixme: Position (Lauris) */ diff --git a/src/marker.h b/src/marker.h index d41df69b4..21ad63a41 100644 --- a/src/marker.h +++ b/src/marker.h @@ -65,6 +65,7 @@ public: virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags); virtual Inkscape::DrawingItem* show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags); + virtual Inkscape::DrawingItem* private_show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags); virtual void hide(unsigned int key); virtual Geom::OptRect bbox(Geom::Affine const &transform, SPItem::BBoxType type) const; -- cgit v1.2.3 From 9dc9db77232e264edcfec1e6ba6437130ac4c0eb Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Fri, 7 Feb 2014 13:27:42 +0100 Subject: Prevent attempt to initialize/compare std::string with/to null pointer. (bzr r13004) --- src/document.cpp | 2 +- src/uri-references.cpp | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/document.cpp b/src/document.cpp index 6f957cace..470d0cc5a 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -473,7 +473,7 @@ SPDocument *SPDocument::createChildDoc(std::string const &uri) SPDocument *parent = this; SPDocument *document = NULL; - while(parent != NULL && document == NULL) { + while(parent != NULL && parent->getURI() != NULL && document == NULL) { // Check myself and any parents int he chain if(uri == parent->getURI()) { document = parent; diff --git a/src/uri-references.cpp b/src/uri-references.cpp index abe16ec9d..de293716b 100644 --- a/src/uri-references.cpp +++ b/src/uri-references.cpp @@ -58,7 +58,7 @@ void URIReference::attach(const URI &uri) throw(BadURIException) // The path contains references to seperate document files to load. if(document && uri.getPath()) { - std::string base = std::string(document->getBase()); + std::string base = std::string(document->getBase() ? document->getBase() : ""); std::string path = uri.getFullPath(base); if(!path.empty()) document = document->createChildDoc(path); @@ -184,3 +184,14 @@ sp_uri_reference_resolve (SPDocument *document, const gchar *uri) return ref; } + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : -- cgit v1.2.3 From f11d3869c683c6aeb40ca7ff84d3a721f8e86ba2 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Fri, 7 Feb 2014 13:38:46 +0100 Subject: Slightly improved fix to previous check-in. (bzr r13005) --- src/uri-references.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/uri-references.cpp b/src/uri-references.cpp index de293716b..ea8078b28 100644 --- a/src/uri-references.cpp +++ b/src/uri-references.cpp @@ -58,7 +58,7 @@ void URIReference::attach(const URI &uri) throw(BadURIException) // The path contains references to seperate document files to load. if(document && uri.getPath()) { - std::string base = std::string(document->getBase() ? document->getBase() : ""); + std::string base = document->getBase() ? document->getBase() : ""; std::string path = uri.getFullPath(base); if(!path.empty()) document = document->createChildDoc(path); -- cgit v1.2.3 From ec4c32a8921fc72e855f2ca8ec608af499dc34d2 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Fri, 7 Feb 2014 21:08:10 +0100 Subject: Fix for Bug #1275443 (Including picture results in crash). Fixed bugs: - https://launchpad.net/bugs/1275443 (bzr r13006) --- src/extension/internal/image-resolution.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/extension/internal/image-resolution.cpp b/src/extension/internal/image-resolution.cpp index aee46aaba..18eb97f80 100644 --- a/src/extension/internal/image-resolution.cpp +++ b/src/extension/internal/image-resolution.cpp @@ -322,6 +322,12 @@ void ImageResolution::readjfif(char const *fn) { y_ = cinfo.Y_density * 2.54; ok_ = true; } + /* According to http://www.jpeg.org/public/jfif.pdf (page 7): + * "Xdensity and Ydensity should always be non-zero". + * but in some cases, they are (see LP bug #1275443) */ + if (x_ == 0 or y_ == 0) { + ok_ = false; + } } jpeg_destroy_decompress(&cinfo); fclose(ifd); -- cgit v1.2.3 From 042cc81dd7c3ca2f0d42b68356f4b450074c8473 Mon Sep 17 00:00:00 2001 From: David Mathog Date: Sat, 8 Feb 2014 08:17:30 +0100 Subject: EMF/WMF support: Various changes (see bug #1263242 c35 for details) EMF support: - linear gradients: improve numeric stability on round-trip editing - linear gradients: fix scaling issue libTERE/text_reassemble update: - improve handling of whitespace created with large x kerns - fix handling of absolute RTL-positioning of LTR text in EMF files WMF support: - fix support for 'textout' records and Placeable headers - add support for CREATEPATTERNBRUSH - fix offset on load if opened via GUI (bug #1250250) Fixed bugs: - https://launchpad.net/bugs/1263242 - https://launchpad.net/bugs/1250250 (bzr r13008) --- src/extension/internal/emf-inout.cpp | 2 + src/extension/internal/emf-inout.h | 1 + src/extension/internal/emf-print.cpp | 40 +++++---- src/extension/internal/emf-print.h | 3 +- src/extension/internal/text_reassemble.c | 137 ++++++++++++++++++++----------- src/extension/internal/text_reassemble.h | 7 +- src/extension/internal/wmf-inout.cpp | 44 +++++++++- src/libuemf/README | 6 ++ src/libuemf/uemf_utf.c | 95 +++++++++++++++------ src/libuemf/uwmf.c | 22 ++--- 10 files changed, 250 insertions(+), 107 deletions(-) (limited to 'src') diff --git a/src/extension/internal/emf-inout.cpp b/src/extension/internal/emf-inout.cpp index cca541c5b..276dee362 100644 --- a/src/extension/internal/emf-inout.cpp +++ b/src/extension/internal/emf-inout.cpp @@ -4,6 +4,7 @@ /* Authors: * Ulf Erikson * Jon A. Cruz + * David Mathog * Abhishek Sharma * * Copyright (C) 2006-2008 Authors @@ -1563,6 +1564,7 @@ int Emf::myEnhMetaFileProc(char *contents, unsigned int length, PEMF_CALLBACK_DA tsp.vadvance = 0.0; /* meaningful only when a complex contains two or more lines */ tsp.taln = ALILEFT + ALIBASE; tsp.ldir = LDIR_LR; + tsp.spaces = 0; // this field is only used for debugging tsp.color.Red = 0; /* RGB Black */ tsp.color.Green = 0; /* RGB Black */ tsp.color.Blue = 0; /* RGB Black */ diff --git a/src/extension/internal/emf-inout.h b/src/extension/internal/emf-inout.h index 97f93e71b..a97cb0a54 100644 --- a/src/extension/internal/emf-inout.h +++ b/src/extension/internal/emf-inout.h @@ -3,6 +3,7 @@ */ /* Authors: * Ulf Erikson + * David Mathog * * Copyright (C) 2006-2008 Authors * diff --git a/src/extension/internal/emf-print.cpp b/src/extension/internal/emf-print.cpp index 2680718cf..6d5bb6f4b 100644 --- a/src/extension/internal/emf-print.cpp +++ b/src/extension/internal/emf-print.cpp @@ -124,7 +124,7 @@ unsigned int PrintEmf::begin(Inkscape::Extension::Print *mod, SPDocument *doc) char *rec; gchar const *utf8_fn = mod->get_param_string("destination"); - // Typially PX2WORLD is 1200/90, using inkscape's default dpi + // Typically PX2WORLD is 1200/90, using inkscape's default dpi PX2WORLD = 1200.0 / Inkscape::Util::Quantity::convert(1.0, "in", "px"); FixPPTCharPos = mod->get_param_bool("FixPPTCharPos"); FixPPTDashLine = mod->get_param_bool("FixPPTDashLine"); @@ -848,7 +848,7 @@ Geom::Path PrintEmf::pathv_to_rect(Geom::PathVector const &pathv, bool *is_rect, int vertices; Geom::Path pR = pathv_to_simple_polygon(pathv, &vertices); *is_rect = false; - if(vertices==4){ // or else it cannot be a rectangle rectangle + if(vertices==4){ // or else it cannot be a rectangle int vertex_count=0; /* Get the ends of the LAST line segment. Find minimum rotation to align rectangle with X,Y axes. (Very degenerate if it is rotated 45 degrees.) */ @@ -862,12 +862,17 @@ Geom::Path PrintEmf::pathv_to_rect(Geom::PathVector const &pathv, bool *is_rect, if(fabs(ang) < fabs(*angle))*angle = -ang; // y increases down, flips sign on angle } } + + /* For increased numerical stability, snap the angle to the nearest 1/100th of a degree. */ + double convert = 36000.0/ (2.0 * M_PI); + *angle = round(*angle * convert)/convert; for(Geom::Path::const_iterator cit = pR.begin(); cit != pR.end_open();++cit) { P1_lead = cit->finalPoint(); v1 = unit_vector(P1 - P1_trail); v2 = unit_vector(P1_lead - P1 ); - if(!Geom::are_near(dot(v1,v2), 0.0, 1e-5))break; // P1 is center of a turn that is not 90 degrees + // P1 is center of a turn that is not 90 degrees. Limit comes from cos(89.9) = .001745 + if(!Geom::are_near(dot(v1,v2), 0.0, 2e-3))break; P1_trail = P1; P1 = P1_lead; vertex_count++; @@ -985,12 +990,13 @@ unsigned int PrintEmf::fill( int rectDir=0; Geom::Path pathRect; if(FixPPTLinGrad && brush_stat && gv.mode == DRAW_LINEAR_GRADIENT){ - pathRect = pathv_to_rect(pathv, &is_Rect, &angle); + Geom::PathVector pvr = pathv * fill_transform; + pathRect = pathv_to_rect(pvr, &is_Rect, &angle); if(is_Rect){ /* Gradientfill records can only be used if the gradient is parallel to the sides of the rectangle. That must be checked here so that we can fall back to another form of gradient fill if it is not the case. */ - rectDir = vector_rect_alignment(angle, gv.p2 - gv.p1); + rectDir = vector_rect_alignment(angle, (gv.p2 - gv.p1) * fill_transform); if(!rectDir)is_Rect = false; } if(!is_Rect && !FixPPTGrad2Polys)brush_stat=0; // fall all the way back to a solid fill @@ -1094,26 +1100,27 @@ unsigned int PrintEmf::fill( U_XFORM tmpTransform; double wRect, hRect; - /* coordinates, w,h and transform for the ENTIRE retangle */ - ul = get_pathrect_corner(pathRect, angle, 0) * fill_transform * PX2WORLD; - ur = get_pathrect_corner(pathRect, angle, 1) * fill_transform * PX2WORLD; - lr = get_pathrect_corner(pathRect, angle, 2) * fill_transform * PX2WORLD; + /* coordinates: upper left, upper right, and lower right corners of the rectangle. + inkscape transform already applied, but needs to be scaled to EMF coordinates. */ + ul = get_pathrect_corner(pathRect, angle, 0) * PX2WORLD; + ur = get_pathrect_corner(pathRect, angle, 1) * PX2WORLD; + lr = get_pathrect_corner(pathRect, angle, 2) * PX2WORLD; wRect = Geom::distance(ul,ur); hRect = Geom::distance(ur,lr); /* The basic rectangle for all of these is placed with its UL corner at 0,0 with a size wRect,hRect. Apply a world transform to place/scale it into the appropriate position on the drawing. Actual gradientfill records are either this entire rectangle or slices of it as defined by the stops. + This rectangle has already been transformed by tf (whatever rotation/scale) Inkscape had applied to it. */ Geom::Affine tf2 = Geom::Rotate(-angle); // the rectangle may be drawn skewed to the coordinate system - tf2 *= tf; // the coordinate system of the rectangular path may be rotated tmpTransform.eM11 = tf2[0]; tmpTransform.eM12 = tf2[1]; tmpTransform.eM21 = tf2[2]; tmpTransform.eM22 = tf2[3]; - tmpTransform.eDx = (ul)[Geom::X]; - tmpTransform.eDy = (ul)[Geom::Y]; + tmpTransform.eDx = round((ul)[Geom::X]); // use explicit round for better stability + tmpTransform.eDy = round((ul)[Geom::Y]); rec = U_EMRSAVEDC_set(); if (!rec || emf_append((PU_ENHMETARECORD)rec, et, U_REC_FREE)) { @@ -1138,10 +1145,10 @@ unsigned int PrintEmf::fill( gMode = U_GRADIENT_FILL_RECT_V; } doff_base = doff_range; - rcb.left = outUL[X]; - rcb.top = outUL[Y]; - rcb.right = outLR[X]; - rcb.bottom = outLR[Y]; + rcb.left = round(outUL[X]); // use explicit round for better stability + rcb.top = round(outUL[Y]); + rcb.right = round(outLR[X]); + rcb.bottom = round(outLR[Y]); sp_color_get_rgb_floatv(&tg->vector.stops[istop].color, rgb); opa = tg->vector.stops[istop].opacity; c2 = U_RGBA(255 * rgb[0], 255 * rgb[1], 255 * rgb[2], 255 * opa); @@ -1157,7 +1164,6 @@ unsigned int PrintEmf::fill( c1 = c2; // for next stop ug4.UpperLeft = 0; ug4.LowerRight= 1; - /* NEED to push world transform here for rotations */ rec = U_EMRGRADIENTFILL_set(rcb, 2, 1, gMode, ut, (uint32_t *) &ug4 ); if (!rec || emf_append((PU_ENHMETARECORD)rec, et, U_REC_FREE)) { g_error("Fatal programming error in PrintEmf::fill at U_EMRGRADIENTFILL_set"); diff --git a/src/extension/internal/emf-print.h b/src/extension/internal/emf-print.h index 8fc9908e3..1e4970a46 100644 --- a/src/extension/internal/emf-print.h +++ b/src/extension/internal/emf-print.h @@ -1,8 +1,9 @@ /** @file * @brief Enhanced Metafile printing - implementation */ -/* Author: +/* Authors: * Ulf Erikson + * David Mathog * * Copyright (C) 2006-2008 Authors * diff --git a/src/extension/internal/text_reassemble.c b/src/extension/internal/text_reassemble.c index cd84910fc..e28e5effb 100644 --- a/src/extension/internal/text_reassemble.c +++ b/src/extension/internal/text_reassemble.c @@ -67,11 +67,11 @@ Optional compiler switches for development: File: text_reassemble.c -Version: 0.0.10 -Date: 06-MAY-2013 +Version: 0.0.12 +Date: 07-FEB-2014 Author: David Mathog, Biology Division, Caltech email: mathog@caltech.edu -Copyright: 2013 David Mathog and California Institute of Technology (Caltech) +Copyright: 2014 David Mathog and California Institute of Technology (Caltech) */ #ifdef __cplusplus @@ -665,7 +665,7 @@ FT_INFO *ftinfo_clear(FT_INFO *fti){ free(fsp->file); /* release memory holding copies of paths */ free(fsp->fontspec); /* release memory holding copies of font names */ FcPatternDestroy(fsp->fpat); /* release memory for FontConfig fpats */ - FcFontSetDestroy(fti->fonts[i].fontset); + FcFontSetDestroy(fsp->fontset); if(fsp->alts){ free(fsp->alts); } } free(fti->fonts); @@ -726,9 +726,10 @@ int ftinfo_find_loaded_by_src(const FT_INFO *fti, const uint8_t *filename){ */ int ftinfo_load_fontname(FT_INFO *fti, const char *fontspec){ - FcPattern *pattern, *fpat; - FcFontSet *fontset; - FcResult result = FcResultMatch; + FcPattern *pattern = NULL; + FcPattern *fpat = NULL; + FcFontSet *fontset = NULL; + FcResult result = FcResultMatch; char *filename; double fd; FNT_SPECS *fsp; @@ -738,38 +739,45 @@ int ftinfo_load_fontname(FT_INFO *fti, const char *fontspec){ if(!fti)return(-1); /* If it is already loaded, do not load it again */ - if((status = ftinfo_find_loaded_by_spec(fti, (uint8_t *) fontspec))>=0){ - return(status); - } + status = ftinfo_find_loaded_by_spec(fti, (uint8_t *) fontspec); + if(status >= 0){ return(status); } + status = 0; /* was -1, reset to 0 */ ftinfo_make_insertable(fti); fi_idx = fti->used; - if(!(pattern = FcNameParse((const FcChar8 *)fontspec)) )return(2); - if(!FcConfigSubstitute(NULL, pattern, FcMatchPattern) )return(3); - FcDefaultSubstitute(pattern); - /* get a fontset, trimmed to only those with new glyphs as needed, so that missing glyph's may be handled */ - if(!(fontset = FcFontSort (NULL,pattern, FcTrue, NULL, &result)) - || result != FcResultMatch)return(4); - if(!(fpat = FcFontRenderPrepare(NULL, pattern, fontset->fonts[0])) )return(405); - if(FcPatternGetString( fpat, FC_FILE, 0, (FcChar8 **)&filename) != FcResultMatch)return(5); - if(FcPatternGetDouble( fpat, FC_SIZE, 0, &fd) != FcResultMatch)return(6); - - /* copy these into memory for external use */ - fsp = &(fti->fonts[fti->used]); - fsp->fontset = fontset; - fsp->alts = NULL; /* Initially no links to alternate fonts */ - fsp->space = 0; - fsp->file = (uint8_t *) U_strdup((char *) filename); - fsp->fontspec = (uint8_t *) U_strdup((char *) fontspec); - fsp->fpat = fpat; - fsp->fsize = fd; - + pattern = FcNameParse((const FcChar8 *)fontspec); + while(1) { /* this is NOT a loop, it uses breaks to avoid gotos and deep nesting */ + if(!(pattern)){ status = -2; break; } + if(!FcConfigSubstitute(NULL, pattern, FcMatchPattern)){ status = -3; break; }; + FcDefaultSubstitute(pattern); + /* get a fontset, trimmed to only those with new glyphs as needed, so that missing glyph's may be handled */ + if(!(fontset = FcFontSort (NULL,pattern, FcTrue, NULL, &result)) || (result != FcResultMatch)){ status = -4; break; } + if(!(fpat = FcFontRenderPrepare(NULL, pattern, fontset->fonts[0]))){ status = -405; break; } + if(FcPatternGetString( fpat, FC_FILE, 0, (FcChar8 **)&filename) != FcResultMatch){ status = -5; break; } + if(FcPatternGetDouble( fpat, FC_SIZE, 0, &fd) != FcResultMatch){ status = -6; break; } + + /* copy these into memory for external use */ + fsp = &(fti->fonts[fti->used]); + fsp->fontset = fontset; + fsp->alts = NULL; /* Initially no links to alternate fonts */ + fsp->space = 0; + fsp->file = (uint8_t *) U_strdup((char *) filename); + fsp->fontspec = (uint8_t *) U_strdup((char *) fontspec); + fsp->fpat = fpat; + fsp->fsize = fd; + break; + } /* release FC's own memory related to this call that does not need to be kept around so that face will work */ - FcPatternDestroy(pattern); + if(pattern)FcPatternDestroy(pattern); /* done with this memory */ + if(status<0){ + if(fontset)FcFontSetDestroy(fontset); + if(fpat)FcPatternDestroy(fpat); + return(status); + } /* get the current face */ - if(FT_New_Face( fti->library, (const char *) fsp->file, 0, &(fsp->face) )){ return(8); } + if(FT_New_Face( fti->library, (const char *) fsp->file, 0, &(fsp->face) )){ return(-8); } if(FT_Set_Char_Size( fsp->face, /* handle to face object */ @@ -777,12 +785,12 @@ int ftinfo_load_fontname(FT_INFO *fti, const char *fontspec){ fd*64, /* char_height in 1/64th of points */ 72, /* horizontal device resolution, DPI */ 72) /* vebrical device resolution, DPI */ - ){ return(9); } + ){ return(-9); } /* The space advance is needed in various places. Get it now, and get it in the font units, so that it can be scaled later with the text size */ status = TR_getadvance(fti, fsp,' ',0,FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP, FT_KERNING_UNSCALED, NULL, NULL); - if(status < 0)return(7); + if(status < 0)return(-7); fsp->spcadv = ((double) status)/(64.0); fti->used++; @@ -1380,7 +1388,7 @@ printf("Overlap rprect (LL,UR) dst:(%lf,%lf),(%lf,%lf) src:(%lf,%lf),(%lf,%lf)\n } /** - \brief Check for a text element upstream from the start element and in the reversed direction. + \brief Check for various sorts of invalid text elements upstream (language dir changes, draw order backwards from language direction) \returns 0 on success (not upstream), 1 if upstream, anything else is an error. \param bri pointer to the BR_INFO structure \param dst index of the destination bounding rectangle. @@ -1405,6 +1413,12 @@ int brinfo_upstream(BR_INFO *bri, int dst, int src, int ddir, int sdir){ else if( ddir == LDIR_LR && sdir == LDIR_RL){ if((br_src->xll + br_src->xur)/2.0 <= br_dst->xll ){ status = 1; } } + else if( ddir == LDIR_RL && sdir == LDIR_RL){ + if(br_dst->xur <= (br_src->xll + br_src->xur)/2.0){ status = 1; } + } + else if( ddir == LDIR_LR && sdir == LDIR_LR){ + if((br_src->xll + br_src->xur)/2.0 <= br_dst->xll ){ status = 1; } + } return(status); } @@ -1490,13 +1504,19 @@ TR_INFO *trinfo_init(TR_INFO *tri){ !(tri->bri = brinfo_init()) || !(tri->cxi = cxinfo_init()) ){ tri = trinfo_release(tri); } + tri->out = NULL; /* This will allocate as needed, it might not ever be needed. */ + tri->qe = 0.0; + tri->esc = 0.0; + tri->x = DBL_MAX; + tri->y = DBL_MAX; + tri->dirty = 0; tri->use_kern = 1; - tri->usebk = BKCLR_NONE; tri->load_flags = FT_LOAD_NO_SCALE; tri->kern_mode = FT_KERNING_UNSCALED; - tri->out = NULL; /* This will allocate as needed, it might not ever be needed. */ tri->outspace = 0; tri->outused = 0; + tri->usebk = BKCLR_NONE; + memset(&(tri->bkcolor),0,sizeof(TRCOLORREF)); return(tri); } @@ -1552,9 +1572,6 @@ TR_INFO *trinfo_release_except_FC(TR_INFO *tri){ */ TR_INFO *trinfo_clear(TR_INFO *tri){ if(tri){ - tri->dirty = 0; /* set these back to their defaults */ - tri->esc = 0.0; - /* Do NOT modify use_kern, usebk, load_flags, or kern_mode */ if(tri->bri)tri->bri=brinfo_release(tri->bri); if(tri->tpi)tri->tpi=tpinfo_release(tri->tpi); @@ -1565,6 +1582,11 @@ TR_INFO *trinfo_clear(TR_INFO *tri){ tri->outused = 0; tri->outspace = 0; }; + /* Do NOT modify: qe, use_kern, usebk, load_flags, kern_mode, or bkcolor. Set the rest back to their defaults */ + tri->esc = 0.0; + tri->x = DBL_MAX; + tri->y = DBL_MAX; + tri->dirty = 0; if(!(tri->tpi = tpinfo_init()) || /* re-init the pieces just released */ !(tri->bri = brinfo_init()) || !(tri->cxi = cxinfo_init()) @@ -1958,7 +1980,7 @@ void TR_layout_2_svg(TR_INFO *tri){ cutat=strcspn((char *)fti->fonts[tsp->fi_idx].fontspec,":"); sprintf(obuf,"font-family:%.*s;",cutat,fti->fonts[tsp->fi_idx].fontspec); TRPRINT(tri, obuf); - sprintf(obuf,"\n\">%s\n",tsp->string); + sprintf(obuf,"\n\">%s\n",&tsp->string[tsp->spaces]); TRPRINT(tri, obuf); #endif /* DBG_TR_INPUT debugging code, original text objects */ } @@ -2278,7 +2300,10 @@ int TR_layout_analyze(TR_INFO *tri){ next logical piece of text is "upstream" positionally of its logical predecessor. The meaning of such a construct is at best ambiguous. The test is only applied with respect to the first text chunk. This sort of construct may appear when a valid initial construct like [1->English][2<-Hebrew][3->English] is edited - and the leading chunk of text removed. + and the leading chunk of text removed. + + Also reject reversed order text as in (English) (draw order) arranged as . This happens + if the language direction field is incorrect, perhaps due to a corrupt or malformed input file. */ if(brinfo_upstream(bri, dst_rt, /* index into bri for dst */ @@ -2422,10 +2447,28 @@ int TR_layout_analyze(TR_INFO *tri){ } } - /* if x or y kern is less than the quantization error it is probably noise, set it to zero */ - if(fabs(tspj->xkern)qe)tspj->xkern = 0.0; - if(fabs(tspj->ykern)qe)tspj->ykern = 0.0; - + /* if x or y kern is less than twice the quantization error it is probably noise, set it to zero */ + if(fabs(tspj->xkern) <= 2.0*tri->qe)tspj->xkern = 0.0; + if(fabs(tspj->ykern) <= 2.0*tri->qe)tspj->ykern = 0.0; + + /* reintroduce spaces on the leading edge of text "j" if the kerning can be in part or in whole replaced + with 1 or 2 spaces */ + if(tspj->ykern == 0.0){ + double spaces = tspj->xkern/spcadv; /* negative on RL language, positive on LR */ + if((ldir == LDIR_RL && (spaces <= -0.9 && spaces >= -2.1)) || + (ldir == LDIR_LR && (spaces >= 0.9 && spaces <= 2.1)) ){ + int ispaces = lround(spaces); + tspj->xkern -= ((double)ispaces*spcadv); + if(ispaces<0)ispaces=-ispaces; + size_t slen = strlen((char *)tspj->string); + uint8_t *newstring = malloc(1 + ispaces + slen); + sprintf((char *)newstring," "); /* start with two spaces, possibly overwrite one in the next line */ + memcpy(newstring+ispaces,tspj->string,slen+1); /* copy existing string to proper position */ + free(tspj->string); + tspj->string = newstring; + tspj->spaces = ispaces; // only needed to fix optional debugging SVG output later + } + } tspi = tspj; lastldir = ldir; @@ -2699,7 +2742,7 @@ int main(int argc, char *argv[]){ tsp.weight = 80; tsp.condensed = 100; tsp.decoration = 0; /* none */ - tsp.co = 0; + tsp.spaces = 0; /* none */ tsp.fi_idx = -1; /* set to an invalid */ tsp.rt_tidx = -1; /* set to an invalid */ tsp.xkern = tsp.ykern = 0.0; diff --git a/src/extension/internal/text_reassemble.h b/src/extension/internal/text_reassemble.h index d85b233be..6c1acafe5 100644 --- a/src/extension/internal/text_reassemble.h +++ b/src/extension/internal/text_reassemble.h @@ -4,11 +4,11 @@ See text_reassemble.c for notes File: text_reassemble.h -Version: 0.0.12 -Date: 14-MAY-2013 +Version: 0.0.13 +Date: 06-FEB-2014 Author: David Mathog, Biology Division, Caltech email: mathog@caltech.edu -Copyright: 2013 David Mathog and California Institute of Technology (Caltech) +Copyright: 2014 David Mathog and California Institute of Technology (Caltech) */ #ifndef _TEXT_REASSEMBLE_ @@ -189,6 +189,7 @@ typedef struct { int weight; /**< weight, as in FontConfig */ int condensed; /**< condensed, as in FontConfig */ int decoration; /**< text decorations, ignored during assembly, used during output */ + int spaces; /**< count of spaces converted from wide kerning (1 or 2) */ TRCOLORREF decColor; /**< text decoration color, ignored during assembly, used during output */ int co; /**< condensed override, if set Font name included narrow */ int rt_tidx; /**< index of rectangle that contains it */ diff --git a/src/extension/internal/wmf-inout.cpp b/src/extension/internal/wmf-inout.cpp index a72c16a88..fc54350df 100644 --- a/src/extension/internal/wmf-inout.cpp +++ b/src/extension/internal/wmf-inout.cpp @@ -4,6 +4,7 @@ /* Authors: * Ulf Erikson * Jon A. Cruz + * David Mathog * Abhishek Sharma * * Copyright (C) 2006-2008 Authors @@ -1079,6 +1080,28 @@ Wmf::select_brush(PWMF_CALLBACK_DATA d, int index) g_message("Please send WMF file to developers - select_brush U_WMR_DIBCREATEPATTERNBRUSH not bm16 or dib, not handled"); } } + else if(iType == U_WMR_CREATEPATTERNBRUSH){ + uint32_t tidx; + int cbPx; + U_BITMAP16 Bm16h; + const char *px; + if(U_WMRCREATEPATTERNBRUSH_get(record, &Bm16h, &cbPx, &px)){ + tidx = add_bm16_image(d, Bm16h, px); + if(tidx == 0xFFFFFFFF){ // Problem with the image, for instance, an unsupported bitmap16 type + double r, g, b; + r = SP_COLOR_U_TO_F( U_RGBAGetR(d->dc[d->level].textColor)); + g = SP_COLOR_U_TO_F( U_RGBAGetG(d->dc[d->level].textColor)); + b = SP_COLOR_U_TO_F( U_RGBAGetB(d->dc[d->level].textColor)); + d->dc[d->level].style.fill.value.color.set( r, g, b ); + d->dc[d->level].fill_mode = DRAW_PAINT; + } + else { + d->dc[d->level].fill_idx = tidx; + d->dc[d->level].fill_mode = DRAW_IMAGE; + } + d->dc[d->level].fill_set = true; + } + } } @@ -1488,6 +1511,7 @@ int Wmf::myMetaFileProc(const char *contents, unsigned int length, PWMF_CALLBACK tsp.vadvance = 0.0; /* meaningful only when a complex contains two or more lines */ tsp.taln = ALILEFT + ALIBASE; tsp.ldir = LDIR_LR; + tsp.spaces = 0; // this field is only used for debugging tsp.color.Red = 0; /* RGB Black */ tsp.color.Green = 0; /* RGB Black */ tsp.color.Blue = 0; /* RGB Black */ @@ -1498,6 +1522,7 @@ int Wmf::myMetaFileProc(const char *contents, unsigned int length, PWMF_CALLBACK tsp.condensed = 100; tsp.co = 0; tsp.fi_idx = -1; /* set to an invalid */ + tsp.rt_tidx = -1; /* set to an invalid */ SVGOStringStream dbg_str; @@ -1568,7 +1593,10 @@ int Wmf::myMetaFileProc(const char *contents, unsigned int length, PWMF_CALLBACK d->dc[d->level].sizeView.x = d->dc[d->level].sizeWnd.x = 0; d->dc[d->level].sizeView.y = d->dc[d->level].sizeWnd.y = 0; - // Upper left corner in device units, usually both 0, but not always + /* Upper left corner in device units, usually both 0, but not always. + If a placeable header is used, and later a windoworg/windowext are found, then + the placeable information will be ignored. + */ d->ulCornerInX = Placeable.Dst.left; d->ulCornerInY = Placeable.Dst.top; @@ -1805,6 +1833,8 @@ std::cout << "BEFORE DRAW" { dbg_str << "\n"; nSize = U_WMRSETWINDOWORG_get(contents, &d->dc[d->level].winorg); + d->ulCornerOutX = 0.0; // In the examples seen to date if this record is used with a placeable header, that header is ignored + d->ulCornerOutY = 0.0; break; } case U_WMR_SETWINDOWEXT: @@ -2322,12 +2352,12 @@ std::cout << "BEFORE DRAW" break; case U_WMR_CREATEBRUSHINDIRECT: case U_WMR_DIBCREATEPATTERNBRUSH: + case U_WMR_CREATEPATTERNBRUSH: // <- this one did not display properly on XP, DIBCREATEPATTERNBRUSH works select_brush(d, index); break; case U_WMR_CREATEFONTINDIRECT: select_font(d, index); break; - case U_WMR_CREATEPATTERNBRUSH: // <- this one did not display properly on XP, DIBCREATEPATTERNBRUSH works case U_WMR_CREATEPALETTE: case U_WMR_CREATEBITMAPINDIRECT: case U_WMR_CREATEBITMAP: @@ -2376,6 +2406,7 @@ std::cout << "BEFORE DRAW" if(iType == U_WMR_TEXTOUT){ dbg_str << "\n"; nSize = U_WMRTEXTOUT_get(contents, &Dst, &tlen, &text); + Opts=0; } else { dbg_str << "\n"; @@ -3053,7 +3084,14 @@ Wmf::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri ) // Scale and translate objects double scale = Inkscape::Util::Quantity::convert(1, "px", doc_unit); ShapeEditor::blockSetItem(true); - doc->getRoot()->scaleChildItemsRec(Geom::Scale(scale), Geom::Point(0, doc->getHeight().value("px"))); + double dh; + if(SP_ACTIVE_DOCUMENT){ // for file menu open or import, or paste from clipboard + dh = SP_ACTIVE_DOCUMENT->getHeight().value("px"); + } + else { // for open via --file on command line + dh = doc->getHeight().value("px"); + } + doc->getRoot()->scaleChildItemsRec(Geom::Scale(scale), Geom::Point(0, dh)); ShapeEditor::blockSetItem(false); Inkscape::DocumentUndo::setUndoSensitive(doc, saved); diff --git a/src/libuemf/README b/src/libuemf/README index 4c23cdd52..cfa322178 100644 --- a/src/libuemf/README +++ b/src/libuemf/README @@ -366,6 +366,12 @@ History (Note, version numbers in files represent the libUEMF release where it was last modified, so not all files will show the same version numbers in each release.) +0.1.11 2014-01-29 + Fixed bug in uwmf.c (wrong minimum record size on U_WMRTEXTOUT) + Fixed bug in uwmf.c (U_WMRCREATEPATTERNBRUSH not right) + Added error handling to uemf_utf.c for cases where src is a null pointer. + Added a test of createpatternbrush to testlib_wmf + 0.1.10 2014-01-14 Slight changes in documentation for uemf.h. Fixed typo in uemf_endian.c. diff --git a/src/libuemf/uemf_utf.c b/src/libuemf/uemf_utf.c index f329e74d9..bce60af4d 100644 --- a/src/libuemf/uemf_utf.c +++ b/src/libuemf/uemf_utf.c @@ -12,11 +12,11 @@ /* File: uemf_utf.c -Version: 0.0.4 -Date: 19-MAR-2013 +Version: 0.0.5 +Date: 29-JAN-2014 Author: David Mathog, Biology Division, Caltech email: mathog@caltech.edu -Copyright: 2013 David Mathog and California Institute of Technology (Caltech) +Copyright: 2014 David Mathog and California Institute of Technology (Caltech) */ #ifdef __cplusplus @@ -68,9 +68,14 @@ These functions are used for development and debugging and should be be includie void wchar8show( const char *src ){ - printf("char show\n"); - size_t srclen = 0; - while(*src){ printf("%d %d %x\n",(int) srclen,*src,*src); srclen++; src++; } + if(!src){ + printf("char show \n"); + } + else { + printf("char show\n"); + size_t srclen = 0; + while(*src){ printf("%d %d %x\n",(int) srclen,*src,*src); srclen++; src++; } + } } /** @@ -80,9 +85,14 @@ void wchar8show( void wchar16show( const uint16_t *src ){ - printf("uint16_t show\n"); - size_t srclen = 0; - while(*src){ printf("%d %d %x\n",(int) srclen,*src,*src); srclen++; src++; } + if(!src){ + printf("uint16_t show \n"); + } + else { + printf("uint16_t show\n"); + size_t srclen = 0; + while(*src){ printf("%d %d %x\n",(int) srclen,*src,*src); srclen++; src++; } + } } /** @@ -91,9 +101,14 @@ void wchar16show( void wchar32show( const uint32_t *src ){ - printf("uint32_t show\n"); - size_t srclen = 0; - while(*src){ printf("%d %d %x\n",(int) srclen,*src,*src); srclen++; src++; } + if(!src){ + printf("uint32_t show \n"); + } + else { + printf("uint32_t show\n"); + size_t srclen = 0; + while(*src){ printf("%d %d %x\n",(int) srclen,*src,*src); srclen++; src++; } + } } /** @@ -104,13 +119,19 @@ void wchartshow( const wchar_t *src ){ uint32_t val; - printf("wchar_t show\n"); - size_t srclen = 0; - while(*src){ - val = *src; // because *src is wchar_t is not strictly an integer type, can cause warnings on next line - printf("%d %d %x\n",(int) srclen,val,val); - srclen++; - src++; + if(!src){ + printf("wchar_t show \n"); + } + else { + printf("wchar_t show\n"); + size_t srclen = 0; + if(!src)return; + while(*src){ + val = *src; // because *src is wchar_t is not strictly an integer type, can cause warnings on next line + printf("%d %d %x\n",(int) srclen,val,val); + srclen++; + src++; + } } } @@ -127,7 +148,9 @@ size_t wchar16len( const uint16_t *src ){ size_t srclen = 0; - while(*src){ srclen++; src++; } + if(src){ + while(*src){ srclen++; src++; } + } return(srclen); } @@ -139,7 +162,9 @@ size_t wchar32len( const uint32_t *src ){ size_t srclen = 0; - while(*src){ srclen++; src++; } + if(src){ + while(*src){ srclen++; src++; } + } return(srclen); } @@ -154,9 +179,11 @@ void wchar16strncpy( const uint16_t *src, size_t nchars ){ - for(;nchars;nchars--,dst++,src++){ - *dst = *src; - if(!*src)break; + if(src){ + for(;nchars;nchars--,dst++,src++){ + *dst = *src; + if(!*src)break; + } } } @@ -172,8 +199,10 @@ void wchar16strncpypad( const uint16_t *src, size_t nchars ){ - for(;*src && nchars;nchars--,dst++,src++){ *dst = *src; } - for(;nchars;nchars--,dst++){ *dst = 0; } // Pad the remainder + if(src){ + for(;*src && nchars;nchars--,dst++,src++){ *dst = *src; } + for(;nchars;nchars--,dst++){ *dst = 0; } // Pad the remainder + } } /* For the following converstion functions, remember that iconv() modifies ALL of its parameters, @@ -197,6 +226,7 @@ uint16_t *U_Utf32leToUtf16le( char *dst,*dst2; size_t srclen,dstlen,status; + if(!src)return(NULL); if(max){ srclen = 4*max; } else { srclen = 4 + 4*wchar32len(src); } //include terminator, length in BYTES @@ -226,6 +256,8 @@ uint32_t *U_Utf16leToUtf32le( char *dst,*dst2; char *src2 = (char *) src; size_t srclen,dstlen,status; + + if(!src)return(NULL); if(max){ srclen = 2*max; } else { srclen = 2*wchar16len(src)+2; } // include terminator, length in BYTES dstlen = 2*(2 + srclen); // This should always work @@ -261,6 +293,8 @@ uint32_t *U_Latin1ToUtf32le( char *dst,*dst2; char *src2 = (char *) src; size_t srclen,dstlen,status; + + if(!src)return(NULL); if(max){ srclen = max; } else { srclen = strlen(src)+1; } // include terminator, length in BYTES dstlen = sizeof(uint32_t)*(1 + srclen); // This should always work but might waste some space @@ -290,6 +324,8 @@ uint32_t *U_Utf8ToUtf32le( char *dst,*dst2; char *src2 = (char *) src; size_t srclen,dstlen,status; + + if(!src)return(NULL); if(max){ srclen = max; } else { srclen = strlen(src)+1; } // include terminator, length in BYTES dstlen = sizeof(uint32_t)*(1 + srclen); // This should always work but might waste some space @@ -319,6 +355,8 @@ char *U_Utf32leToUtf8( char *dst,*dst2; char *src2 = (char *) src; size_t srclen,dstlen,status; + + if(!src)return(NULL); if(max){ srclen = 4*max; } else { srclen = 4*(1 + wchar32len(src)); } //include terminator, length in BYTES dstlen = 1 + srclen; // This should always work but might waste some space @@ -349,6 +387,7 @@ uint16_t *U_Utf8ToUtf16le( size_t srclen,dstlen,status; iconv_t conv; + if(!src)return(NULL); if(max){ srclen = max; } else { srclen = strlen(src)+1; } // include terminator, length in BYTES dstlen = 2 * (1 + srclen); // this will always work, but may waste space @@ -378,6 +417,8 @@ char *U_Utf16leToUtf8( char *dst, *dst2; char *ret=NULL; size_t srclen,dstlen,status; + + if(!src)return(NULL); if(max){ srclen = 2*max; } else { srclen = 2*(1 +wchar16len(src)); } //include terminator, length in BYTES dstlen = 1 + 2*srclen; // this will always work, but may waste space @@ -410,6 +451,8 @@ char *U_Utf16leToLatin1( char *dst, *dst2; char *ret=NULL; size_t srclen,dstlen,status; + + if(!src)return(NULL); if(max){ srclen = 2*max; } else { srclen = 2*(1 +wchar16len(src)); } //include terminator, length in BYTES dstlen = 1 + srclen; // this will always work as latin1 is always 1 byte/character diff --git a/src/libuemf/uwmf.c b/src/libuemf/uwmf.c index a6ac963cb..be1feadea 100644 --- a/src/libuemf/uwmf.c +++ b/src/libuemf/uwmf.c @@ -19,11 +19,11 @@ /* File: uwmf.c -Version: 0.0.12 -Date: 25-NOV-2013 +Version: 0.0.13 +Date: 30-JAN-2014 Author: David Mathog, Biology Division, Caltech email: mathog@caltech.edu -Copyright: 2013 David Mathog and California Institute of Technology (Caltech) +Copyright: 2014 David Mathog and California Institute of Technology (Caltech) */ #ifdef __cplusplus @@ -4271,13 +4271,12 @@ char *U_WMRCREATEPATTERNBRUSH_set( if(!Bm16 || !Pattern)return(NULL); cbPat = (((Bm16->Width * Bm16->BitsPixel + 15) >> 4) << 1) * Bm16->Height; - irecsize = U_SIZE_METARECORD + 14 + 4 + 18 + cbPat; /* core WMR + truncated Bm16 + pattern */ + irecsize = U_SIZE_METARECORD + 14 + 18 + cbPat; /* core WMR + truncated Bm16 + 18 spaces bytes + pattern */ record = malloc(irecsize); if(record){ U_WMRCORE_SETRECHEAD(record,irecsize,U_WMR_CREATEPATTERNBRUSH); off = U_SIZE_METARECORD; - memcpy(record + off, Bm16, 14); off+=14; /* Truncated bitmap16 object*/ - memset(record + off, 0, 4); off+=4; /* 4 bytes of its "bits", which are ignored */ + memcpy(record + off, Bm16, 14); off+=14; /* Truncated bitmap16 object, last 4 bytes are to be ignored*/ memset(record + off, 0, 18); off+=18; /* 18 bytes of zero, which are ignored */ memcpy(record + off, Pattern, cbPat); /* The pattern array */ } @@ -5359,7 +5358,7 @@ int U_WMRTEXTOUT_get( ){ int16_t L2; int off; - int size = U_WMRCORE_RECSAFE_get(contents, (U_SIZE_WMRPATBLT)); + int size = U_WMRCORE_RECSAFE_get(contents, (U_SIZE_WMRTEXTOUT)); if(!size)return(0); *Length = *(int16_t *)(contents + offsetof(U_WMRTEXTOUT, Length)); *string = contents + offsetof(U_WMRTEXTOUT, String); /* May not be null terminated!!! */ @@ -6851,12 +6850,15 @@ int U_WMRCREATEPATTERNBRUSH_get( const char **Pattern ){ int off = U_SIZE_METARECORD; - int size = U_WMRCORE_RECSAFE_get(contents, (U_SIZE_WMRSETDIBTODEV)); + /* size in next one is + 6 (core header) + 14 (truncated bitmap16) + 18 bytes reserved + 2 bytes (at least) for data */ + int size = U_WMRCORE_RECSAFE_get(contents, (U_SIZE_METARECORD + 14 + 18 + 2)); if(!size)return(0); memset(Bm16, 0, U_SIZE_BITMAP16); - memcpy(Bm16, contents + off, 14); /* BM16 is truncated in this record type */ + /* BM16 is truncated in this record type to 14 bytes, last 4 bytes must be ignored, so they are not even copied */ + memcpy(Bm16, contents + off, 10); *pasize = (((Bm16->Width * Bm16->BitsPixel + 15) >> 4) << 1) * Bm16->Height; - off += 36; /* skip [truncated bitmap16 object and 18 bytes of reserved */ + off += 32; /* skip [14 bytes of truncated bitmap16 object and 18 bytes of reserved */ *Pattern = (contents + off); return(size); } -- cgit v1.2.3 From d4ba8eaa4a621ac60d99a4aad7531d080cece2cd Mon Sep 17 00:00:00 2001 From: David Mathog Date: Sat, 8 Feb 2014 09:44:12 +0100 Subject: DrawingContext: change variable names ct to dc (bug #1272073) Fixed bugs: - https://launchpad.net/bugs/1272073 (bzr r13009) --- src/display/canvas-arena.cpp | 8 +-- src/display/drawing-context.cpp | 22 +++---- src/display/drawing-context.h | 6 +- src/display/drawing-group.cpp | 12 ++-- src/display/drawing-group.h | 4 +- src/display/drawing-image.cpp | 52 ++++++++-------- src/display/drawing-image.h | 2 +- src/display/drawing-item.cpp | 96 ++++++++++++++--------------- src/display/drawing-item.h | 10 ++-- src/display/drawing-shape.cpp | 54 ++++++++--------- src/display/drawing-shape.h | 4 +- src/display/drawing-surface.cpp | 24 ++++---- src/display/drawing-surface.h | 2 +- src/display/drawing-text.cpp | 120 ++++++++++++++++++------------------- src/display/drawing-text.h | 8 +-- src/display/drawing.cpp | 16 ++--- src/display/drawing.h | 2 +- src/display/nr-filter-image.cpp | 12 ++-- src/display/nr-filter-slot.cpp | 6 +- src/display/nr-filter-slot.h | 2 +- src/display/nr-filter.cpp | 4 +- src/display/nr-filter.h | 4 +- src/display/nr-style.cpp | 32 +++++----- src/display/nr-style.h | 8 +-- src/helper/pixbuf-ops.cpp | 4 +- src/helper/png-write.cpp | 12 ++-- src/sp-mesh-array.cpp | 4 +- src/sp-pattern.cpp | 12 ++-- src/ui/cache/svg_preview_cache.cpp | 4 +- src/ui/dialog/clonetiler.cpp | 4 +- src/ui/tools/flood-tool.cpp | 12 ++-- src/widgets/icon.cpp | 4 +- 32 files changed, 283 insertions(+), 283 deletions(-) (limited to 'src') diff --git a/src/display/canvas-arena.cpp b/src/display/canvas-arena.cpp index 8e25c1843..404a94828 100644 --- a/src/display/canvas-arena.cpp +++ b/src/display/canvas-arena.cpp @@ -216,10 +216,10 @@ sp_canvas_arena_render (SPCanvasItem *item, SPCanvasBuf *buf) Geom::OptIntRect r = buf->rect; if (!r || r->hasZeroArea()) return; - Inkscape::DrawingContext ct(buf->ct, r->min()); + Inkscape::DrawingContext dc(buf->ct, r->min()); arena->drawing.update(Geom::IntRect::infinite(), arena->ctx); - arena->drawing.render(ct, *r); + arena->drawing.render(dc, *r); } static double @@ -386,9 +386,9 @@ sp_canvas_arena_render_surface (SPCanvasArena *ca, cairo_surface_t *surface, Geo g_return_if_fail (ca != NULL); g_return_if_fail (SP_IS_CANVAS_ARENA (ca)); - Inkscape::DrawingContext ct(surface, r.min()); + Inkscape::DrawingContext dc(surface, r.min()); ca->drawing.update(Geom::IntRect::infinite(), ca->ctx); - ca->drawing.render(ct, r); + ca->drawing.render(dc, r); } /* diff --git a/src/display/drawing-context.cpp b/src/display/drawing-context.cpp index de5beb0f6..319136e06 100644 --- a/src/display/drawing-context.cpp +++ b/src/display/drawing-context.cpp @@ -25,27 +25,27 @@ using Geom::Y; */ DrawingContext::Save::Save() - : _ct(NULL) + : _dc(NULL) {} -DrawingContext::Save::Save(DrawingContext &ct) - : _ct(&ct) +DrawingContext::Save::Save(DrawingContext &dc) + : _dc(&dc) { - _ct->save(); + _dc->save(); } DrawingContext::Save::~Save() { - if (_ct) { - _ct->restore(); + if (_dc) { + _dc->restore(); } } -void DrawingContext::Save::save(DrawingContext &ct) +void DrawingContext::Save::save(DrawingContext &dc) { - if (_ct) { + if (_dc) { // TODO: it might be better to treat this occurence as a bug - _ct->restore(); + _dc->restore(); } - _ct = &ct; - _ct->save(); + _dc = &dc; + _dc->save(); } /** diff --git a/src/display/drawing-context.h b/src/display/drawing-context.h index 35be9a86b..d990bcb73 100644 --- a/src/display/drawing-context.h +++ b/src/display/drawing-context.h @@ -31,11 +31,11 @@ public: class Save { public: Save(); - Save(DrawingContext &ct); + Save(DrawingContext &dc); ~Save(); - void save(DrawingContext &ct); + void save(DrawingContext &dc); private: - DrawingContext *_ct; + DrawingContext *_dc; }; DrawingContext(cairo_t *ct, Geom::Point const &origin); diff --git a/src/display/drawing-group.cpp b/src/display/drawing-group.cpp index b5ce18891..38ace001f 100644 --- a/src/display/drawing-group.cpp +++ b/src/display/drawing-group.cpp @@ -98,12 +98,12 @@ DrawingGroup::_updateItem(Geom::IntRect const &area, UpdateContext const &ctx, u } unsigned -DrawingGroup::_renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags, DrawingItem *stop_at) +DrawingGroup::_renderItem(DrawingContext &dc, Geom::IntRect const &area, unsigned flags, DrawingItem *stop_at) { if (stop_at == NULL) { // normal rendering for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { - i->render(ct, area, flags, stop_at); + i->render(dc, area, flags, stop_at); } } else { // background rendering @@ -111,11 +111,11 @@ DrawingGroup::_renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigne if (&*i == stop_at) return RENDER_OK; // do not render the stop_at item at all if (i->isAncestorOf(stop_at)) { // render its ancestors without masks, opacity or filters - i->render(ct, area, flags | RENDER_FILTER_BACKGROUND, stop_at); + i->render(dc, area, flags | RENDER_FILTER_BACKGROUND, stop_at); // stop further rendering return RENDER_OK; } else { - i->render(ct, area, flags, stop_at); + i->render(dc, area, flags, stop_at); } } } @@ -123,10 +123,10 @@ DrawingGroup::_renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigne } void -DrawingGroup::_clipItem(DrawingContext &ct, Geom::IntRect const &area) +DrawingGroup::_clipItem(DrawingContext &dc, Geom::IntRect const &area) { for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { - i->clip(ct, area); + i->clip(dc, area); } } diff --git a/src/display/drawing-group.h b/src/display/drawing-group.h index 775fec8c4..651e9d8af 100644 --- a/src/display/drawing-group.h +++ b/src/display/drawing-group.h @@ -34,9 +34,9 @@ public: protected: virtual unsigned _updateItem(Geom::IntRect const &area, UpdateContext const &ctx, unsigned flags, unsigned reset); - virtual unsigned _renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags, + virtual unsigned _renderItem(DrawingContext &dc, Geom::IntRect const &area, unsigned flags, DrawingItem *stop_at); - virtual void _clipItem(DrawingContext &ct, Geom::IntRect const &area); + virtual void _clipItem(DrawingContext &dc, Geom::IntRect const &area); virtual DrawingItem *_pickItem(Geom::Point const &p, double delta, unsigned flags); virtual bool _canClip(); diff --git a/src/display/drawing-image.cpp b/src/display/drawing-image.cpp index 1b9214c49..8fd81caac 100644 --- a/src/display/drawing-image.cpp +++ b/src/display/drawing-image.cpp @@ -102,22 +102,22 @@ DrawingImage::_updateItem(Geom::IntRect const &, UpdateContext const &, unsigned return STATE_ALL; } -unsigned DrawingImage::_renderItem(DrawingContext &ct, Geom::IntRect const &/*area*/, unsigned /*flags*/, DrawingItem * /*stop_at*/) +unsigned DrawingImage::_renderItem(DrawingContext &dc, Geom::IntRect const &/*area*/, unsigned /*flags*/, DrawingItem * /*stop_at*/) { bool outline = _drawing.outline(); if (!outline) { if (!_pixbuf) return RENDER_OK; - Inkscape::DrawingContext::Save save(ct); - ct.transform(_ctm); - ct.newPath(); - ct.rectangle(_clipbox); - ct.clip(); + Inkscape::DrawingContext::Save save(dc); + dc.transform(_ctm); + dc.newPath(); + dc.rectangle(_clipbox); + dc.clip(); - ct.translate(_origin); - ct.scale(_scale); - ct.setSource(_pixbuf->getSurfaceRaw(), 0, 0); + dc.translate(_origin); + dc.scale(_scale); + dc.setSource(_pixbuf->getSurfaceRaw(), 0, 0); if (_style) { // See: http://www.w3.org/TR/SVG/painting.html#ImageRenderingProperty @@ -128,24 +128,24 @@ unsigned DrawingImage::_renderItem(DrawingContext &ct, Geom::IntRect const &/*ar // Do nothing break; case SP_CSS_COLOR_RENDERING_OPTIMIZEQUALITY: - ct.patternSetFilter( CAIRO_FILTER_BEST ); + dc.patternSetFilter( CAIRO_FILTER_BEST ); break; case SP_CSS_COLOR_RENDERING_OPTIMIZESPEED: default: - ct.patternSetFilter( CAIRO_FILTER_NEAREST ); + dc.patternSetFilter( CAIRO_FILTER_NEAREST ); break; } } - ct.paint(_opacity); + dc.paint(_opacity); } else { // outline; draw a rect instead Inkscape::Preferences *prefs = Inkscape::Preferences::get(); guint32 rgba = prefs->getInt("/options/wireframecolors/images", 0xff0000ff); - { Inkscape::DrawingContext::Save save(ct); - ct.transform(_ctm); - ct.newPath(); + { Inkscape::DrawingContext::Save save(dc); + dc.transform(_ctm); + dc.newPath(); Geom::Rect r = bounds(); Geom::Point c00 = r.corner(0); @@ -153,21 +153,21 @@ unsigned DrawingImage::_renderItem(DrawingContext &ct, Geom::IntRect const &/*ar Geom::Point c11 = r.corner(2); Geom::Point c10 = r.corner(1); - ct.moveTo(c00); + dc.moveTo(c00); // the box - ct.lineTo(c10); - ct.lineTo(c11); - ct.lineTo(c01); - ct.lineTo(c00); + dc.lineTo(c10); + dc.lineTo(c11); + dc.lineTo(c01); + dc.lineTo(c00); // the diagonals - ct.lineTo(c11); - ct.moveTo(c10); - ct.lineTo(c01); + dc.lineTo(c11); + dc.moveTo(c10); + dc.lineTo(c01); } - ct.setLineWidth(0.5); - ct.setSource(rgba); - ct.stroke(); + dc.setLineWidth(0.5); + dc.setSource(rgba); + dc.stroke(); } return RENDER_OK; } diff --git a/src/display/drawing-image.h b/src/display/drawing-image.h index cebaafc85..64e4517b0 100644 --- a/src/display/drawing-image.h +++ b/src/display/drawing-image.h @@ -38,7 +38,7 @@ public: protected: virtual unsigned _updateItem(Geom::IntRect const &area, UpdateContext const &ctx, unsigned flags, unsigned reset); - virtual unsigned _renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags, + virtual unsigned _renderItem(DrawingContext &dc, Geom::IntRect const &area, unsigned flags, DrawingItem *stop_at); virtual DrawingItem *_pickItem(Geom::Point const &p, double delta, unsigned flags); diff --git a/src/display/drawing-item.cpp b/src/display/drawing-item.cpp index a9b07bb6e..13e7b61eb 100644 --- a/src/display/drawing-item.cpp +++ b/src/display/drawing-item.cpp @@ -24,60 +24,60 @@ namespace Inkscape { #ifdef WITH_CSSBLEND -void set_cairo_blend_operator( DrawingContext &ct, unsigned blend_mode ) { +void set_cairo_blend_operator( DrawingContext &dc, unsigned blend_mode ) { // All of the blend modes are implemented in Cairo as of 1.10. // For a detailed description, see: // http://cairographics.org/operators/ switch (blend_mode) { case SP_CSS_BLEND_MULTIPLY: - ct.setOperator(CAIRO_OPERATOR_MULTIPLY); + dc.setOperator(CAIRO_OPERATOR_MULTIPLY); break; case SP_CSS_BLEND_SCREEN: - ct.setOperator(CAIRO_OPERATOR_SCREEN); + dc.setOperator(CAIRO_OPERATOR_SCREEN); break; case SP_CSS_BLEND_DARKEN: - ct.setOperator(CAIRO_OPERATOR_DARKEN); + dc.setOperator(CAIRO_OPERATOR_DARKEN); break; case SP_CSS_BLEND_LIGHTEN: - ct.setOperator(CAIRO_OPERATOR_LIGHTEN); + dc.setOperator(CAIRO_OPERATOR_LIGHTEN); break; case SP_CSS_BLEND_OVERLAY: - ct.setOperator(CAIRO_OPERATOR_OVERLAY); + dc.setOperator(CAIRO_OPERATOR_OVERLAY); break; case SP_CSS_BLEND_COLORDODGE: - ct.setOperator(CAIRO_OPERATOR_COLOR_DODGE); + dc.setOperator(CAIRO_OPERATOR_COLOR_DODGE); break; case SP_CSS_BLEND_COLORBURN: - ct.setOperator(CAIRO_OPERATOR_COLOR_BURN); + dc.setOperator(CAIRO_OPERATOR_COLOR_BURN); break; case SP_CSS_BLEND_HARDLIGHT: - ct.setOperator(CAIRO_OPERATOR_HARD_LIGHT); + dc.setOperator(CAIRO_OPERATOR_HARD_LIGHT); break; case SP_CSS_BLEND_SOFTLIGHT: - ct.setOperator(CAIRO_OPERATOR_SOFT_LIGHT); + dc.setOperator(CAIRO_OPERATOR_SOFT_LIGHT); break; case SP_CSS_BLEND_DIFFERENCE: - ct.setOperator(CAIRO_OPERATOR_DIFFERENCE); + dc.setOperator(CAIRO_OPERATOR_DIFFERENCE); break; case SP_CSS_BLEND_EXCLUSION: - ct.setOperator(CAIRO_OPERATOR_EXCLUSION); + dc.setOperator(CAIRO_OPERATOR_EXCLUSION); break; case SP_CSS_BLEND_HUE: - ct.setOperator(CAIRO_OPERATOR_HSL_HUE); + dc.setOperator(CAIRO_OPERATOR_HSL_HUE); break; case SP_CSS_BLEND_SATURATION: - ct.setOperator(CAIRO_OPERATOR_HSL_SATURATION); + dc.setOperator(CAIRO_OPERATOR_HSL_SATURATION); break; case SP_CSS_BLEND_COLOR: - ct.setOperator(CAIRO_OPERATOR_HSL_COLOR); + dc.setOperator(CAIRO_OPERATOR_HSL_COLOR); break; case SP_CSS_BLEND_LUMINOSITY: - ct.setOperator(CAIRO_OPERATOR_HSL_LUMINOSITY); + dc.setOperator(CAIRO_OPERATOR_HSL_LUMINOSITY); break; case SP_CSS_BLEND_NORMAL: default: - ct.setOperator(CAIRO_OPERATOR_OVER); + dc.setOperator(CAIRO_OPERATOR_OVER); break; } } @@ -545,7 +545,7 @@ struct MaskLuminanceToAlpha { * @param flags Rendering options. This deals mainly with cache control. */ unsigned -DrawingItem::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flags, DrawingItem *stop_at) +DrawingItem::render(DrawingContext &dc, Geom::IntRect const &area, unsigned flags, DrawingItem *stop_at) { bool outline = _drawing.outline(); bool render_filters = _drawing.renderFilters(); @@ -560,7 +560,7 @@ DrawingItem::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flag // TODO convert outline rendering to a separate virtual function if (outline) { - _renderOutline(ct, area, flags); + _renderOutline(dc, area, flags); return RENDER_OK; } @@ -573,9 +573,9 @@ DrawingItem::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flag if (_cache) { _cache->prepare(); #ifdef WITH_CSSBLEND - set_cairo_blend_operator( ct, _blend_mode ); + set_cairo_blend_operator( dc, _blend_mode ); #endif - _cache->paintFromCache(ct, carea); + _cache->paintFromCache(dc, carea); if (!carea) return RENDER_OK; } else { // There is no cache. This could be because caching of this item @@ -625,7 +625,7 @@ DrawingItem::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flag // filters and opacity do not apply when rendering the ancestors of the filtered // element if ((flags & RENDER_FILTER_BACKGROUND) || !needs_intermediate_rendering) { - return _renderItem(ct, *carea, flags & ~RENDER_FILTER_BACKGROUND, stop_at); + return _renderItem(dc, *carea, flags & ~RENDER_FILTER_BACKGROUND, stop_at); } // iarea is the bounding box for intermediate rendering @@ -688,9 +688,9 @@ DrawingItem::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flag } if (bg_root) { DrawingSurface bg(*iarea); - DrawingContext bgct(bg); - bg_root->render(bgct, *iarea, flags | RENDER_FILTER_BACKGROUND, this); - _filter->render(this, ict, &bgct); + DrawingContext bgdc(bg); + bg_root->render(bgdc, *iarea, flags | RENDER_FILTER_BACKGROUND, this); + _filter->render(this, ict, &bgdc); rendered = true; } } @@ -716,20 +716,20 @@ DrawingItem::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flag cachect.fill(); _cache->markClean(*carea); } - ct.rectangle(*carea); - ct.setSource(&intermediate); + dc.rectangle(*carea); + dc.setSource(&intermediate); #ifdef WITH_CSSBLEND - set_cairo_blend_operator( ct, _blend_mode ); + set_cairo_blend_operator( dc, _blend_mode ); #endif - ct.fill(); - ct.setSource(0,0,0,0); - // the call above is to clear a ref on the intermediate surface held by ct + dc.fill(); + dc.setSource(0,0,0,0); + // the call above is to clear a ref on the intermediate surface held by dc return render_result; } void -DrawingItem::_renderOutline(DrawingContext &ct, Geom::IntRect const &area, unsigned flags) +DrawingItem::_renderOutline(DrawingContext &dc, Geom::IntRect const &area, unsigned flags) { // intersect with bbox rather than drawbox, as we want to render things outside // of the clipping path as well @@ -738,7 +738,7 @@ DrawingItem::_renderOutline(DrawingContext &ct, Geom::IntRect const &area, unsig // just render everything: item, clip, mask // First, render the object itself - _renderItem(ct, *carea, flags, NULL); + _renderItem(dc, *carea, flags, NULL); // render clip and mask, if any guint32 saved_rgba = _drawing.outlinecolor; // save current outline color @@ -746,12 +746,12 @@ DrawingItem::_renderOutline(DrawingContext &ct, Geom::IntRect const &area, unsig Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (_clip) { _drawing.outlinecolor = prefs->getInt("/options/wireframecolors/clips", 0x00ff00ff); // green clips - _clip->render(ct, *carea, flags); + _clip->render(dc, *carea, flags); } // render mask as an object, using a different color if (_mask) { _drawing.outlinecolor = prefs->getInt("/options/wireframecolors/masks", 0x0000ffff); // blue masks - _mask->render(ct, *carea, flags); + _mask->render(dc, *carea, flags); } _drawing.outlinecolor = saved_rgba; // restore outline color } @@ -765,31 +765,31 @@ DrawingItem::_renderOutline(DrawingContext &ct, Geom::IntRect const &area, unsig * of render() for details. */ void -DrawingItem::clip(Inkscape::DrawingContext &ct, Geom::IntRect const &area) +DrawingItem::clip(Inkscape::DrawingContext &dc, Geom::IntRect const &area) { // don't bother if the object does not implement clipping (e.g. DrawingImage) if (!_canClip()) return; if (!_visible) return; if (!area.intersects(_bbox)) return; - ct.setSource(0,0,0,1); - ct.pushGroup(); + dc.setSource(0,0,0,1); + dc.pushGroup(); // rasterize the clipping path - _clipItem(ct, area); + _clipItem(dc, area); if (_clip) { // The item used as the clipping path itself has a clipping path. // Render this item's clipping path onto a temporary surface, then composite it // with the item using the IN operator - ct.pushGroup(); - _clip->clip(ct, area); - ct.popGroupToSource(); - ct.setOperator(CAIRO_OPERATOR_IN); - ct.paint(); + dc.pushGroup(); + _clip->clip(dc, area); + dc.popGroupToSource(); + dc.setOperator(CAIRO_OPERATOR_IN); + dc.paint(); } - ct.popGroupToSource(); - ct.setOperator(CAIRO_OPERATOR_OVER); - ct.paint(); - ct.setSource(0,0,0,0); + dc.popGroupToSource(); + dc.setOperator(CAIRO_OPERATOR_OVER); + dc.paint(); + dc.setSource(0,0,0,0); } /** diff --git a/src/display/drawing-item.h b/src/display/drawing-item.h index 1796d29d6..913706021 100644 --- a/src/display/drawing-item.h +++ b/src/display/drawing-item.h @@ -123,8 +123,8 @@ public: void *data() const { return _user_data; } void update(Geom::IntRect const &area = Geom::IntRect::infinite(), UpdateContext const &ctx = UpdateContext(), unsigned flags = STATE_ALL, unsigned reset = 0); - unsigned render(DrawingContext &ct, Geom::IntRect const &area, unsigned flags = 0, DrawingItem *stop_at = NULL); - void clip(DrawingContext &ct, Geom::IntRect const &area); + unsigned render(DrawingContext &dc, Geom::IntRect const &area, unsigned flags = 0, DrawingItem *stop_at = NULL); + void clip(DrawingContext &dc, Geom::IntRect const &area); DrawingItem *pick(Geom::Point const &p, double delta, unsigned flags = 0); protected: @@ -141,7 +141,7 @@ protected: RENDER_OK = 0, RENDER_STOP = 1 }; - void _renderOutline(DrawingContext &ct, Geom::IntRect const &area, unsigned flags); + void _renderOutline(DrawingContext &dc, Geom::IntRect const &area, unsigned flags); void _markForUpdate(unsigned state, bool propagate); void _markForRendering(); void _invalidateFilterBackground(Geom::IntRect const &area); @@ -150,9 +150,9 @@ protected: Geom::OptIntRect _cacheRect(); virtual unsigned _updateItem(Geom::IntRect const &/*area*/, UpdateContext const &/*ctx*/, unsigned /*flags*/, unsigned /*reset*/) { return 0; } - virtual unsigned _renderItem(DrawingContext &/*ct*/, Geom::IntRect const &/*area*/, unsigned /*flags*/, + virtual unsigned _renderItem(DrawingContext &/*dc*/, Geom::IntRect const &/*area*/, unsigned /*flags*/, DrawingItem * /*stop_at*/) { return RENDER_OK; } - virtual void _clipItem(DrawingContext &/*ct*/, Geom::IntRect const &/*area*/) {} + virtual void _clipItem(DrawingContext &/*dc*/, Geom::IntRect const &/*area*/) {} virtual DrawingItem *_pickItem(Geom::Point const &/*p*/, double /*delta*/, unsigned /*flags*/) { return NULL; } virtual bool _canClip() { return false; } diff --git a/src/display/drawing-shape.cpp b/src/display/drawing-shape.cpp index 03d7f51b5..f99f9442f 100644 --- a/src/display/drawing-shape.cpp +++ b/src/display/drawing-shape.cpp @@ -150,7 +150,7 @@ DrawingShape::_updateItem(Geom::IntRect const &area, UpdateContext const &ctx, u } unsigned -DrawingShape::_renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags, DrawingItem *stop_at) +DrawingShape::_renderItem(DrawingContext &dc, Geom::IntRect const &area, unsigned flags, DrawingItem *stop_at) { if (!_curve || !_style) return RENDER_OK; if (!area.intersects(_bbox)) return RENDER_OK; // skip if not within bounding box @@ -160,67 +160,67 @@ DrawingShape::_renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigne if (outline) { guint32 rgba = _drawing.outlinecolor; - { Inkscape::DrawingContext::Save save(ct); - ct.transform(_ctm); - ct.path(_curve->get_pathvector()); + { Inkscape::DrawingContext::Save save(dc); + dc.transform(_ctm); + dc.path(_curve->get_pathvector()); } - { Inkscape::DrawingContext::Save save(ct); - ct.setSource(rgba); - ct.setLineWidth(0.5); - ct.setTolerance(0.5); - ct.stroke(); + { Inkscape::DrawingContext::Save save(dc); + dc.setSource(rgba); + dc.setLineWidth(0.5); + dc.setTolerance(0.5); + dc.stroke(); } } else { bool has_stroke, has_fill; // we assume the context has no path - Inkscape::DrawingContext::Save save(ct); - ct.transform(_ctm); + Inkscape::DrawingContext::Save save(dc); + dc.transform(_ctm); // update fill and stroke paints. // this cannot be done during nr_arena_shape_update, because we need a Cairo context // to render svg:pattern - has_fill = _nrstyle.prepareFill(ct, _item_bbox); - has_stroke = _nrstyle.prepareStroke(ct, _item_bbox); + has_fill = _nrstyle.prepareFill(dc, _item_bbox); + has_stroke = _nrstyle.prepareStroke(dc, _item_bbox); has_stroke &= (_nrstyle.stroke_width != 0); if (has_fill || has_stroke) { // TODO: remove segments outside of bbox when no dashes present - ct.path(_curve->get_pathvector()); + dc.path(_curve->get_pathvector()); if (has_fill) { - _nrstyle.applyFill(ct); - ct.fillPreserve(); + _nrstyle.applyFill(dc); + dc.fillPreserve(); } if (has_stroke) { - _nrstyle.applyStroke(ct); - ct.strokePreserve(); + _nrstyle.applyStroke(dc); + dc.strokePreserve(); } - ct.newPath(); // clear path + dc.newPath(); // clear path } // has fill or stroke pattern } // marker rendering for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { - i->render(ct, area, flags, stop_at); + i->render(dc, area, flags, stop_at); } return RENDER_OK; } -void DrawingShape::_clipItem(DrawingContext &ct, Geom::IntRect const & /*area*/) +void DrawingShape::_clipItem(DrawingContext &dc, Geom::IntRect const & /*area*/) { if (!_curve) return; - Inkscape::DrawingContext::Save save(ct); + Inkscape::DrawingContext::Save save(dc); // handle clip-rule if (_style) { if (_style->clip_rule.computed == SP_WIND_RULE_EVENODD) { - ct.setFillRule(CAIRO_FILL_RULE_EVEN_ODD); + dc.setFillRule(CAIRO_FILL_RULE_EVEN_ODD); } else { - ct.setFillRule(CAIRO_FILL_RULE_WINDING); + dc.setFillRule(CAIRO_FILL_RULE_WINDING); } } - ct.transform(_ctm); - ct.path(_curve->get_pathvector()); - ct.fill(); + dc.transform(_ctm); + dc.path(_curve->get_pathvector()); + dc.fill(); } DrawingItem * diff --git a/src/display/drawing-shape.h b/src/display/drawing-shape.h index 52496d86e..47b9e807e 100644 --- a/src/display/drawing-shape.h +++ b/src/display/drawing-shape.h @@ -33,9 +33,9 @@ public: protected: virtual unsigned _updateItem(Geom::IntRect const &area, UpdateContext const &ctx, unsigned flags, unsigned reset); - virtual unsigned _renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags, + virtual unsigned _renderItem(DrawingContext &dc, Geom::IntRect const &area, unsigned flags, DrawingItem *stop_at); - virtual void _clipItem(DrawingContext &ct, Geom::IntRect const &area); + virtual void _clipItem(DrawingContext &dc, Geom::IntRect const &area); virtual DrawingItem *_pickItem(Geom::Point const &p, double delta, unsigned flags); virtual bool _canClip(); diff --git a/src/display/drawing-surface.cpp b/src/display/drawing-surface.cpp index bddccbd96..94e0e1ab5 100644 --- a/src/display/drawing-surface.cpp +++ b/src/display/drawing-surface.cpp @@ -267,7 +267,7 @@ DrawingCache::prepare() * parameter to the bounds of the region that must be repainted. */ void -DrawingCache::paintFromCache(DrawingContext &ct, Geom::OptIntRect &area) +DrawingCache::paintFromCache(DrawingContext &dc, Geom::OptIntRect &area) { if (!area) return; @@ -296,10 +296,10 @@ DrawingCache::paintFromCache(DrawingContext &ct, Geom::OptIntRect &area) cairo_rectangle_int_t tmp; for (int i = 0; i < nr; ++i) { cairo_region_get_rectangle(cache_region, i, &tmp); - ct.rectangle(_convertRect(tmp)); + dc.rectangle(_convertRect(tmp)); } - ct.setSource(this); - ct.fill(); + dc.setSource(this); + dc.fill(); } cairo_region_destroy(cache_region); } @@ -310,21 +310,21 @@ DrawingCache::_dumpCache(Geom::OptIntRect const &area) { static int dumpnr = 0; cairo_surface_t *surface = ink_cairo_surface_copy(_surface); - DrawingContext ct(surface, _origin); + DrawingContext dc(surface, _origin); if (!cairo_region_is_empty(_clean_region)) { - Inkscape::DrawingContext::Save save(ct); + Inkscape::DrawingContext::Save save(dc); int nr = cairo_region_num_rectangles(_clean_region); cairo_rectangle_int_t tmp; for (int i = 0; i < nr; ++i) { cairo_region_get_rectangle(_clean_region, i, &tmp); - ct.rectangle(_convertRect(tmp)); + dc.rectangle(_convertRect(tmp)); } - ct.setSource(0,1,0,0.1); - ct.fill(); + dc.setSource(0,1,0,0.1); + dc.fill(); } - ct.rectangle(*area); - ct.setSource(1,0,0,0.1); - ct.fill(); + dc.rectangle(*area); + dc.setSource(1,0,0,0.1); + dc.fill(); char *fn = g_strdup_printf("dump%d.png", dumpnr++); cairo_surface_write_to_png(surface, fn); cairo_surface_destroy(surface); diff --git a/src/display/drawing-surface.h b/src/display/drawing-surface.h index 1ec848405..e937cca55 100644 --- a/src/display/drawing-surface.h +++ b/src/display/drawing-surface.h @@ -65,7 +65,7 @@ public: void markClean(Geom::IntRect const &area = Geom::IntRect::infinite()); void scheduleTransform(Geom::IntRect const &new_area, Geom::Affine const &trans); void prepare(); - void paintFromCache(DrawingContext &ct, Geom::OptIntRect &area); + void paintFromCache(DrawingContext &dc, Geom::OptIntRect &area); protected: cairo_region_t *_clean_region; diff --git a/src/display/drawing-text.cpp b/src/display/drawing-text.cpp index f652a2970..f5a0f0af5 100644 --- a/src/display/drawing-text.cpp +++ b/src/display/drawing-text.cpp @@ -195,7 +195,7 @@ DrawingText::_updateItem(Geom::IntRect const &area, UpdateContext const &ctx, un return DrawingGroup::_updateItem(area, ctx, flags, reset); } -void DrawingText::decorateStyle(DrawingContext &ct, double vextent, double xphase, Geom::Point const &p1, Geom::Point const &p2) +void DrawingText::decorateStyle(DrawingContext &dc, double vextent, double xphase, Geom::Point const &p1, Geom::Point const &p2) { double wave[16]={ 0.000000, 0.382499, 0.706825, 0.923651, 1.000000, 0.923651, 0.706825, 0.382499, @@ -235,12 +235,12 @@ pf = Geom::Point(step * round(p2[Geom::X]/step),p2[Geom::Y]); if(_nrstyle.text_decoration_style & TEXT_DECORATION_STYLE_ISDOUBLE){ ps -= Geom::Point(0, vextent/12.0); pf -= Geom::Point(0, vextent/12.0); - ct.moveTo(ps); - ct.lineTo(pf); + dc.moveTo(ps); + dc.lineTo(pf); ps += Geom::Point(0, vextent/6.0); pf += Geom::Point(0, vextent/6.0); - ct.moveTo(ps); - ct.lineTo(pf); + dc.moveTo(ps); + dc.lineTo(pf); } /* The next three have a problem in that they are phase dependent. The bits of a line are not necessarily passing through this routine in order, so we have to use the xphase information @@ -251,14 +251,14 @@ pf = Geom::Point(step * round(p2[Geom::X]/step),p2[Geom::Y]); while(1){ if(dots[i]>0){ if(ps[Geom::X]> pf[Geom::X])break; - ct.moveTo(ps); + dc.moveTo(ps); ps += Geom::Point(step * (double)dots[i], 0.0); if(ps[Geom::X]>= pf[Geom::X]){ - ct.lineTo(pf); + dc.lineTo(pf); break; } else { - ct.lineTo(ps); + dc.lineTo(ps); } ps += Geom::Point(step * 4.0, 0.0); } @@ -272,14 +272,14 @@ pf = Geom::Point(step * round(p2[Geom::X]/step),p2[Geom::Y]); while(1){ if(dashes[i]>0){ if(ps[Geom::X]> pf[Geom::X])break; - ct.moveTo(ps); + dc.moveTo(ps); ps += Geom::Point(step * (double)dashes[i], 0.0); if(ps[Geom::X]>= pf[Geom::X]){ - ct.lineTo(pf); + dc.lineTo(pf); break; } else { - ct.lineTo(ps); + dc.lineTo(ps); } ps += Geom::Point(step * 8.0, 0.0); } @@ -293,23 +293,23 @@ pf = Geom::Point(step * round(p2[Geom::X]/step),p2[Geom::Y]); double amp = vextent/10.0; double x = ps[Geom::X]; double y = ps[Geom::Y]; - ct.moveTo(Geom::Point(x, y + amp * wave[i])); + dc.moveTo(Geom::Point(x, y + amp * wave[i])); while(1){ i = ((i + 1) & 15); x += step; - ct.lineTo(Geom::Point(x, y + amp * wave[i])); + dc.lineTo(Geom::Point(x, y + amp * wave[i])); if(x >= pf[Geom::X])break; } } else { // TEXT_DECORATION_STYLE_SOLID, also default in case it was not set for some reason - ct.moveTo(ps); - ct.lineTo(pf); -// ct.revrectangle(Geom::Rect(ps,pf)); + dc.moveTo(ps); + dc.lineTo(pf); +// dc.revrectangle(Geom::Rect(ps,pf)); } } /* returns scaled line thickness */ -double DrawingText::decorateItem(DrawingContext &ct, Geom::Affine const &aff, double phase_length) +double DrawingText::decorateItem(DrawingContext &dc, Geom::Affine const &aff, double phase_length) { double tsp_width_adj = _nrstyle.tspan_width / _nrstyle.font_size; double tsp_asc_adj = _nrstyle.ascender / _nrstyle.font_size; @@ -321,8 +321,8 @@ double DrawingText::decorateItem(DrawingContext &ct, Geom::Affine const &aff, do double scale = aff.descrim(); double xphase = phase_length/ _nrstyle.font_size; // used to figure out phase of patterns - Inkscape::DrawingContext::Save save(ct); - ct.transform(aff); // must be leftmost affine in span + Inkscape::DrawingContext::Save save(dc); + dc.transform(aff); // must be leftmost affine in span Geom::Point p1; Geom::Point p2; @@ -331,52 +331,52 @@ double DrawingText::decorateItem(DrawingContext &ct, Geom::Affine const &aff, do if(_nrstyle.text_decoration_line & TEXT_DECORATION_LINE_UNDERLINE){ p1 = Geom::Point(0.0, -_nrstyle.underline_position); p2 = Geom::Point(tsp_width_adj,-_nrstyle.underline_position); - decorateStyle(ct, tsp_size_adj, xphase, p1, p2); + decorateStyle(dc, tsp_size_adj, xphase, p1, p2); } if(_nrstyle.text_decoration_line & TEXT_DECORATION_LINE_OVERLINE){ p1 = Geom::Point(0.0, tsp_asc_adj -_nrstyle.underline_position + 1 * final_underline_thickness); p2 = Geom::Point(tsp_width_adj,tsp_asc_adj -_nrstyle.underline_position + 1 * final_underline_thickness); - decorateStyle(ct, tsp_size_adj, xphase, p1, p2); + decorateStyle(dc, tsp_size_adj, xphase, p1, p2); } if(_nrstyle.text_decoration_line & TEXT_DECORATION_LINE_LINETHROUGH){ thickness = final_line_through_thickness; p1 = Geom::Point(0.0, _nrstyle.line_through_position); p2 = Geom::Point(tsp_width_adj,_nrstyle.line_through_position); - decorateStyle(ct, tsp_size_adj, xphase, p1, p2); + decorateStyle(dc, tsp_size_adj, xphase, p1, p2); } // Obviously this does not blink, but it does indicate which text has been set with that attribute if(_nrstyle.text_decoration_line & TEXT_DECORATION_LINE_BLINK){ thickness = final_line_through_thickness; p1 = Geom::Point(0.0, _nrstyle.line_through_position - 2*final_line_through_thickness); p2 = Geom::Point(tsp_width_adj,_nrstyle.line_through_position - 2*final_line_through_thickness); - decorateStyle(ct, tsp_size_adj, xphase, p1, p2); + decorateStyle(dc, tsp_size_adj, xphase, p1, p2); p1 = Geom::Point(0.0, _nrstyle.line_through_position + 2*final_line_through_thickness); p2 = Geom::Point(tsp_width_adj,_nrstyle.line_through_position + 2*final_line_through_thickness); - decorateStyle(ct, tsp_size_adj, xphase, p1, p2); + decorateStyle(dc, tsp_size_adj, xphase, p1, p2); } thickness *= scale; return(thickness); } -unsigned DrawingText::_renderItem(DrawingContext &ct, Geom::IntRect const &/*area*/, unsigned /*flags*/, DrawingItem * /*stop_at*/) +unsigned DrawingText::_renderItem(DrawingContext &dc, Geom::IntRect const &/*area*/, unsigned /*flags*/, DrawingItem * /*stop_at*/) { if (_drawing.outline()) { guint32 rgba = _drawing.outlinecolor; - Inkscape::DrawingContext::Save save(ct); - ct.setSource(rgba); - ct.setTolerance(0.5); // low quality, but good enough for outline mode + Inkscape::DrawingContext::Save save(dc); + dc.setSource(rgba); + dc.setTolerance(0.5); // low quality, but good enough for outline mode for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { DrawingGlyphs *g = dynamic_cast(&*i); if (!g) throw InvalidItemException(); - Inkscape::DrawingContext::Save save(ct); + Inkscape::DrawingContext::Save save(dc); // skip glyphs with singular transforms if (g->_ctm.isSingular()) continue; - ct.transform(g->_ctm); + dc.transform(g->_ctm); if(g->_drawable){ - ct.path(*g->_font->PathVector(g->_glyph)); - ct.fill(); + dc.path(*g->_font->PathVector(g->_glyph)); + dc.fill(); } } return RENDER_OK; @@ -398,11 +398,11 @@ unsigned DrawingText::_renderItem(DrawingContext &ct, Geom::IntRect const &/*are // Therefore, only apply this ctm temporarily. bool has_stroke, has_fill; { - Inkscape::DrawingContext::Save save(ct); - ct.transform(_ctm); + Inkscape::DrawingContext::Save save(dc); + dc.transform(_ctm); - has_fill = _nrstyle.prepareFill( ct, _item_bbox); - has_stroke = _nrstyle.prepareStroke(ct, _item_bbox); + has_fill = _nrstyle.prepareFill( dc, _item_bbox); + has_stroke = _nrstyle.prepareStroke(dc, _item_bbox); } if (has_fill || has_stroke) { @@ -418,11 +418,11 @@ unsigned DrawingText::_renderItem(DrawingContext &ct, Geom::IntRect const &/*are invset = true; } - Inkscape::DrawingContext::Save save(ct); + Inkscape::DrawingContext::Save save(dc); if (g->_ctm.isSingular()) continue; - ct.transform(g->_ctm); + dc.transform(g->_ctm); if (g->_drawable) { - ct.path(*g->_font->PathVector(g->_glyph)); + dc.path(*g->_font->PathVector(g->_glyph)); } // get the leftmost affine transform (leftmost defined with respect to the x axis of the first transform). // That way the decoration will work no matter what mix of L->R, R->L text is in the span. @@ -448,17 +448,17 @@ unsigned DrawingText::_renderItem(DrawingContext &ct, Geom::IntRect const &/*are // draw the text itself // we need to apply this object's ctm again - Inkscape::DrawingContext::Save save(ct); - ct.transform(_ctm); + Inkscape::DrawingContext::Save save(dc); + dc.transform(_ctm); if (has_fill) { - _nrstyle.applyFill(ct); - ct.fillPreserve(); + _nrstyle.applyFill(dc); + dc.fillPreserve(); } if (has_stroke) { - _nrstyle.applyStroke(ct); - ct.strokePreserve(); + _nrstyle.applyStroke(dc); + dc.strokePreserve(); } - ct.newPath(); // clear path + dc.newPath(); // clear path // draw text decoration if (_nrstyle.text_decoration_line != TEXT_DECORATION_LINE_CLEAR && decorate) { @@ -477,27 +477,27 @@ unsigned DrawingText::_renderItem(DrawingContext &ct, Geom::IntRect const &/*are _nrstyle.fill.color.v.c[2], 1.0); } - ct.setSource(ergba); - ct.setTolerance(0.5); - double thickness = decorateItem(ct, aff, phase_length); - ct.setLineWidth(thickness); - ct.strokePreserve(); - ct.newPath(); // clear path + dc.setSource(ergba); + dc.setTolerance(0.5); + double thickness = decorateItem(dc, aff, phase_length); + dc.setLineWidth(thickness); + dc.strokePreserve(); + dc.newPath(); // clear path } } return RENDER_OK; } -void DrawingText::_clipItem(DrawingContext &ct, Geom::IntRect const &/*area*/) +void DrawingText::_clipItem(DrawingContext &dc, Geom::IntRect const &/*area*/) { - Inkscape::DrawingContext::Save save(ct); + Inkscape::DrawingContext::Save save(dc); // handle clip-rule if (_style) { if (_style->clip_rule.computed == SP_WIND_RULE_EVENODD) { - ct.setFillRule(CAIRO_FILL_RULE_EVEN_ODD); + dc.setFillRule(CAIRO_FILL_RULE_EVEN_ODD); } else { - ct.setFillRule(CAIRO_FILL_RULE_WINDING); + dc.setFillRule(CAIRO_FILL_RULE_WINDING); } } @@ -507,13 +507,13 @@ void DrawingText::_clipItem(DrawingContext &ct, Geom::IntRect const &/*area*/) throw InvalidItemException(); } - Inkscape::DrawingContext::Save save(ct); - ct.transform(g->_ctm); + Inkscape::DrawingContext::Save save(dc); + dc.transform(g->_ctm); if(g->_drawable){ - ct.path(*g->_font->PathVector(g->_glyph)); + dc.path(*g->_font->PathVector(g->_glyph)); } } - ct.fill(); + dc.fill(); } DrawingItem * diff --git a/src/display/drawing-text.h b/src/display/drawing-text.h index fd122b54b..b863ca2a4 100644 --- a/src/display/drawing-text.h +++ b/src/display/drawing-text.h @@ -62,14 +62,14 @@ public: protected: virtual unsigned _updateItem(Geom::IntRect const &area, UpdateContext const &ctx, unsigned flags, unsigned reset); - virtual unsigned _renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned flags, + virtual unsigned _renderItem(DrawingContext &dc, Geom::IntRect const &area, unsigned flags, DrawingItem *stop_at); - virtual void _clipItem(DrawingContext &ct, Geom::IntRect const &area); + virtual void _clipItem(DrawingContext &dc, Geom::IntRect const &area); virtual DrawingItem *_pickItem(Geom::Point const &p, double delta, unsigned flags); virtual bool _canClip(); - double decorateItem(DrawingContext &ct, Geom::Affine const &aff, double phase_length); - void decorateStyle(DrawingContext &ct, double vextent, double xphase, Geom::Point const &p1, Geom::Point const &p2); + double decorateItem(DrawingContext &dc, Geom::Affine const &aff, double phase_length); + void decorateStyle(DrawingContext &dc, double vextent, double xphase, Geom::Point const &p1, Geom::Point const &p2); NRStyle _nrstyle; friend class DrawingGlyphs; diff --git a/src/display/drawing.cpp b/src/display/drawing.cpp index c192e4565..6e728b03d 100644 --- a/src/display/drawing.cpp +++ b/src/display/drawing.cpp @@ -167,22 +167,22 @@ Drawing::update(Geom::IntRect const &area, UpdateContext const &ctx, unsigned fl } void -Drawing::render(DrawingContext &ct, Geom::IntRect const &area, unsigned flags) +Drawing::render(DrawingContext &dc, Geom::IntRect const &area, unsigned flags) { if (_root) { - _root->render(ct, area, flags); + _root->render(dc, area, flags); } if (colorMode() == COLORMODE_GRAYSCALE) { // apply grayscale filter on top of everything - cairo_surface_t *input = ct.rawTarget(); + cairo_surface_t *input = dc.rawTarget(); cairo_surface_t *out = ink_cairo_surface_create_identical(input); ink_cairo_surface_filter(input, out, _grayscale_colormatrix); - Geom::Point origin = ct.targetLogicalBounds().min(); - ct.setSource(out, origin[Geom::X], origin[Geom::Y]); - ct.setOperator(CAIRO_OPERATOR_SOURCE); - ct.paint(); - ct.setOperator(CAIRO_OPERATOR_OVER); + Geom::Point origin = dc.targetLogicalBounds().min(); + dc.setSource(out, origin[Geom::X], origin[Geom::Y]); + dc.setOperator(CAIRO_OPERATOR_SOURCE); + dc.paint(); + dc.setOperator(CAIRO_OPERATOR_OVER); cairo_surface_destroy(out); } diff --git a/src/display/drawing.h b/src/display/drawing.h index 74ab57fae..cc74833ba 100644 --- a/src/display/drawing.h +++ b/src/display/drawing.h @@ -68,7 +68,7 @@ public: void setGrayscaleMatrix(gdouble value_matrix[20]); void update(Geom::IntRect const &area = Geom::IntRect::infinite(), UpdateContext const &ctx = UpdateContext(), unsigned flags = DrawingItem::STATE_ALL, unsigned reset = 0); - void render(DrawingContext &ct, Geom::IntRect const &area, unsigned flags = 0); + void render(DrawingContext &dc, Geom::IntRect const &area, unsigned flags = 0); DrawingItem *pick(Geom::Point const &p, double delta, unsigned flags); sigc::signal signal_request_update; diff --git a/src/display/nr-filter-image.cpp b/src/display/nr-filter-image.cpp index 92bb9dcaa..154d1ab32 100644 --- a/src/display/nr-filter-image.cpp +++ b/src/display/nr-filter-image.cpp @@ -108,17 +108,17 @@ void FilterImage::render_cairo(FilterSlot &slot) Geom::Rect sa = slot.get_slot_area(); cairo_surface_t *out = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, sa.width(), sa.height()); - Inkscape::DrawingContext ct(out, sa.min()); - ct.transform(user2pb); // we are now in primitive units - ct.translate(feImageX, feImageY); -// ct.scale(scaleX, scaleY); No scaling should be done + Inkscape::DrawingContext dc(out, sa.min()); + dc.transform(user2pb); // we are now in primitive units + dc.translate(feImageX, feImageY); +// dc.scale(scaleX, scaleY); No scaling should be done Geom::IntRect render_rect = area.roundOutwards(); - ct.translate(render_rect.min()); + dc.translate(render_rect.min()); // Update to renderable state drawing.update(render_rect); - drawing.render(ct, render_rect); + drawing.render(dc, render_rect); SVGElem->invoke_hide(key); // For the moment, we'll assume that any image is in sRGB color space diff --git a/src/display/nr-filter-slot.cpp b/src/display/nr-filter-slot.cpp index 755a30a74..e4c2f048e 100644 --- a/src/display/nr-filter-slot.cpp +++ b/src/display/nr-filter-slot.cpp @@ -25,13 +25,13 @@ namespace Inkscape { namespace Filters { -FilterSlot::FilterSlot(DrawingItem *item, DrawingContext *bgct, +FilterSlot::FilterSlot(DrawingItem *item, DrawingContext *bgdc, DrawingContext &graphic, FilterUnits const &u) : _item(item) , _source_graphic(graphic.rawTarget()) - , _background_ct(bgct ? bgct->raw() : NULL) + , _background_ct(bgdc ? bgdc->raw() : NULL) , _source_graphic_area(graphic.targetLogicalBounds().roundOutwards()) // fixme - , _background_area(bgct ? bgct->targetLogicalBounds().roundOutwards() : Geom::IntRect()) // fixme + , _background_area(bgdc ? bgdc->targetLogicalBounds().roundOutwards() : Geom::IntRect()) // fixme , _units(u) , _last_out(NR_FILTER_SOURCEGRAPHIC) , filterquality(FILTER_QUALITY_BEST) diff --git a/src/display/nr-filter-slot.h b/src/display/nr-filter-slot.h index 805027bfe..f3c98b8d9 100644 --- a/src/display/nr-filter-slot.h +++ b/src/display/nr-filter-slot.h @@ -28,7 +28,7 @@ namespace Filters { class FilterSlot { public: /** Creates a new FilterSlot object. */ - FilterSlot(DrawingItem *item, DrawingContext *bgct, + FilterSlot(DrawingItem *item, DrawingContext *bgdc, DrawingContext &graphic, FilterUnits const &u); /** Destroys the FilterSlot object and all its contents */ virtual ~FilterSlot(); diff --git a/src/display/nr-filter.cpp b/src/display/nr-filter.cpp index af9c15cd8..11984ba76 100644 --- a/src/display/nr-filter.cpp +++ b/src/display/nr-filter.cpp @@ -98,7 +98,7 @@ Filter::~Filter() } -int Filter::render(Inkscape::DrawingItem const *item, DrawingContext &graphic, DrawingContext *bgct) +int Filter::render(Inkscape::DrawingItem const *item, DrawingContext &graphic, DrawingContext *bgdc) { if (_primitive.empty()) { // when no primitives are defined, clear source graphic @@ -150,7 +150,7 @@ int Filter::render(Inkscape::DrawingItem const *item, DrawingContext &graphic, D } } - FilterSlot slot(const_cast(item), bgct, graphic, units); + FilterSlot slot(const_cast(item), bgdc, graphic, units); slot.set_quality(filterquality); slot.set_blurquality(blurquality); diff --git a/src/display/nr-filter.h b/src/display/nr-filter.h index 5df38ffe9..f9dcf1d84 100644 --- a/src/display/nr-filter.h +++ b/src/display/nr-filter.h @@ -28,12 +28,12 @@ namespace Filters { class Filter { public: - /** Given background state from @a bgct and an intermediate rendering from the surface + /** Given background state from @a bgdc and an intermediate rendering from the surface * backing @a graphic, modify the contents of the surface backing @a graphic to represent * the results of filter rendering. @a bgarea and @a area specify bounding boxes * of both surfaces in world coordinates; Cairo contexts are assumed to be in default state * (0,0 = surface origin, no path, OVER operator) */ - int render(Inkscape::DrawingItem const *item, DrawingContext &graphic, DrawingContext *bgct); + int render(Inkscape::DrawingItem const *item, DrawingContext &graphic, DrawingContext *bgdc); /** * Creates a new filter primitive under this filter object. diff --git a/src/display/nr-style.cpp b/src/display/nr-style.cpp index 317f38635..403b139e0 100644 --- a/src/display/nr-style.cpp +++ b/src/display/nr-style.cpp @@ -207,14 +207,14 @@ void NRStyle::set(SPStyle *style) update(); } -bool NRStyle::prepareFill(Inkscape::DrawingContext &ct, Geom::OptRect const &paintbox) +bool NRStyle::prepareFill(Inkscape::DrawingContext &dc, Geom::OptRect const &paintbox) { // update fill pattern if (!fill_pattern) { switch (fill.type) { case PAINT_SERVER: { - //fill_pattern = sp_paint_server_create_pattern(fill.server, ct.raw(), paintbox, fill.opacity); - fill_pattern = fill.server->pattern_new(ct.raw(), paintbox, fill.opacity); + //fill_pattern = sp_paint_server_create_pattern(fill.server, dc.raw(), paintbox, fill.opacity); + fill_pattern = fill.server->pattern_new(dc.raw(), paintbox, fill.opacity); } break; case PAINT_COLOR: { @@ -229,19 +229,19 @@ bool NRStyle::prepareFill(Inkscape::DrawingContext &ct, Geom::OptRect const &pai return true; } -void NRStyle::applyFill(Inkscape::DrawingContext &ct) +void NRStyle::applyFill(Inkscape::DrawingContext &dc) { - ct.setSource(fill_pattern); - ct.setFillRule(fill_rule); + dc.setSource(fill_pattern); + dc.setFillRule(fill_rule); } -bool NRStyle::prepareStroke(Inkscape::DrawingContext &ct, Geom::OptRect const &paintbox) +bool NRStyle::prepareStroke(Inkscape::DrawingContext &dc, Geom::OptRect const &paintbox) { if (!stroke_pattern) { switch (stroke.type) { case PAINT_SERVER: { - //stroke_pattern = sp_paint_server_create_pattern(stroke.server, ct.raw(), paintbox, stroke.opacity); - stroke_pattern = stroke.server->pattern_new(ct.raw(), paintbox, stroke.opacity); + //stroke_pattern = sp_paint_server_create_pattern(stroke.server, dc.raw(), paintbox, stroke.opacity); + stroke_pattern = stroke.server->pattern_new(dc.raw(), paintbox, stroke.opacity); } break; case PAINT_COLOR: { @@ -256,14 +256,14 @@ bool NRStyle::prepareStroke(Inkscape::DrawingContext &ct, Geom::OptRect const &p return true; } -void NRStyle::applyStroke(Inkscape::DrawingContext &ct) +void NRStyle::applyStroke(Inkscape::DrawingContext &dc) { - ct.setSource(stroke_pattern); - ct.setLineWidth(stroke_width); - ct.setLineCap(line_cap); - ct.setLineJoin(line_join); - ct.setMiterLimit(miter_limit); - cairo_set_dash(ct.raw(), dash, n_dash, dash_offset); // fixme + dc.setSource(stroke_pattern); + dc.setLineWidth(stroke_width); + dc.setLineCap(line_cap); + dc.setLineJoin(line_join); + dc.setMiterLimit(miter_limit); + cairo_set_dash(dc.raw(), dash, n_dash, dash_offset); // fixme } void NRStyle::update() diff --git a/src/display/nr-style.h b/src/display/nr-style.h index 8fd736cc3..e54eef547 100644 --- a/src/display/nr-style.h +++ b/src/display/nr-style.h @@ -28,10 +28,10 @@ struct NRStyle { ~NRStyle(); void set(SPStyle *); - bool prepareFill(Inkscape::DrawingContext &ct, Geom::OptRect const &paintbox); - bool prepareStroke(Inkscape::DrawingContext &ct, Geom::OptRect const &paintbox); - void applyFill(Inkscape::DrawingContext &ct); - void applyStroke(Inkscape::DrawingContext &ct); + bool prepareFill(Inkscape::DrawingContext &dc, Geom::OptRect const &paintbox); + bool prepareStroke(Inkscape::DrawingContext &dc, Geom::OptRect const &paintbox); + void applyFill(Inkscape::DrawingContext &dc); + void applyStroke(Inkscape::DrawingContext &dc); void update(); enum PaintType { diff --git a/src/helper/pixbuf-ops.cpp b/src/helper/pixbuf-ops.cpp index cd4f539ec..1ba6628c5 100644 --- a/src/helper/pixbuf-ops.cpp +++ b/src/helper/pixbuf-ops.cpp @@ -140,10 +140,10 @@ Inkscape::Pixbuf *sp_generate_internal_bitmap(SPDocument *doc, gchar const */*fi cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height); if (cairo_surface_status(surface) == CAIRO_STATUS_SUCCESS) { - Inkscape::DrawingContext ct(surface, Geom::Point(0,0)); + Inkscape::DrawingContext dc(surface, Geom::Point(0,0)); // render items - drawing.render(ct, final_bbox, Inkscape::DrawingItem::RENDER_BYPASS_CACHE); + drawing.render(dc, final_bbox, Inkscape::DrawingItem::RENDER_BYPASS_CACHE); inkpb = new Inkscape::Pixbuf(surface); } diff --git a/src/helper/png-write.cpp b/src/helper/png-write.cpp index a16fe8e12..a7ebe7423 100644 --- a/src/helper/png-write.cpp +++ b/src/helper/png-write.cpp @@ -335,14 +335,14 @@ sp_export_get_rows(guchar const **rows, void **to_free, int row, int num_rows, v cairo_surface_t *s = cairo_image_surface_create_for_data( px, CAIRO_FORMAT_ARGB32, ebp->width, num_rows, stride); - Inkscape::DrawingContext ct(s, bbox.min()); - ct.setSource(ebp->background); - ct.setOperator(CAIRO_OPERATOR_SOURCE); - ct.paint(); - ct.setOperator(CAIRO_OPERATOR_OVER); + Inkscape::DrawingContext dc(s, bbox.min()); + dc.setSource(ebp->background); + dc.setOperator(CAIRO_OPERATOR_SOURCE); + dc.paint(); + dc.setOperator(CAIRO_OPERATOR_OVER); /* Render */ - ebp->drawing->render(ct, bbox); + ebp->drawing->render(dc, bbox); cairo_surface_destroy(s); *to_free = px; diff --git a/src/sp-mesh-array.cpp b/src/sp-mesh-array.cpp index 5a204e8b0..ab14e75d2 100644 --- a/src/sp-mesh-array.cpp +++ b/src/sp-mesh-array.cpp @@ -1925,10 +1925,10 @@ guint SPMeshNodeArray::color_pick( std::vector icorners, SPItem* item ) { /* Find visible area */ cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, ibox.width(), ibox.height()); - Inkscape::DrawingContext ct(s, ibox.min()); + Inkscape::DrawingContext dc(s, ibox.min()); /* Render copy and pick color */ - pick_drawing->render(ct, ibox); + pick_drawing->render(dc, ibox); double R = 0, G = 0, B = 0, A = 0; ink_cairo_surface_average_color(s, R, G, B, A); cairo_surface_destroy(s); diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index 711f26428..425ca9efa 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -639,25 +639,25 @@ cairo_pattern_t* SPPattern::pattern_new(cairo_t *base_ct, Geom::OptRect const &b // Create drawing surface with size of pattern tile (in tile space) but with number of pixels // based on required resolution (c). Inkscape::DrawingSurface pattern_surface(pattern_tile, c.ceil()); - Inkscape::DrawingContext ct(pattern_surface); + Inkscape::DrawingContext dc(pattern_surface); pattern_tile *= pattern_surface.drawingTransform(); Geom::IntRect one_tile = pattern_tile.roundOutwards(); // render pattern. if (needs_opacity) { - ct.pushGroup(); // this group is for pattern + opacity + dc.pushGroup(); // this group is for pattern + opacity } // TODO: make sure there are no leaks. Inkscape::UpdateContext ctx; // UpdateContext is structure with only ctm! ctx.ctm = vb2ps * pattern_surface.drawingTransform(); - ct.transform( pattern_surface.drawingTransform().inverse() ); + dc.transform( pattern_surface.drawingTransform().inverse() ); drawing.update(Geom::IntRect::infinite(), ctx); // Render drawing to pattern_surface via drawing context, this calls root->render // which is really DrawingItem->render(). - drawing.render(ct, one_tile); + drawing.render(dc, one_tile); for (SPObject *child = shown->firstChild() ; child != NULL; child = child->getNext() ) { if (SP_IS_ITEM (child)) { SP_ITEM(child)->invoke_hide(dkey); @@ -673,8 +673,8 @@ cairo_pattern_t* SPPattern::pattern_new(cairo_t *base_ct, Geom::OptRect const &b // cairo_surface_write_to_png( pattern_surface.raw(), "sp-pattern.png" ); if (needs_opacity) { - ct.popGroupToSource(); // pop raw pattern - ct.paint(opacity); // apply opacity + dc.popGroupToSource(); // pop raw pattern + dc.paint(opacity); // apply opacity } cairo_pattern_t *cp = cairo_pattern_create_for_surface(pattern_surface.raw()); diff --git a/src/ui/cache/svg_preview_cache.cpp b/src/ui/cache/svg_preview_cache.cpp index a09489f6d..f1d6304cb 100644 --- a/src/ui/cache/svg_preview_cache.cpp +++ b/src/ui/cache/svg_preview_cache.cpp @@ -56,9 +56,9 @@ GdkPixbuf* render_pixbuf(Inkscape::Drawing &drawing, double scale_factor, Geom:: /* Render */ cairo_surface_t *s = cairo_image_surface_create( CAIRO_FORMAT_ARGB32, psize, psize); - Inkscape::DrawingContext ct(s, area.min()); + Inkscape::DrawingContext dc(s, area.min()); - drawing.render(ct, area, Inkscape::DrawingItem::RENDER_BYPASS_CACHE); + drawing.render(dc, area, Inkscape::DrawingItem::RENDER_BYPASS_CACHE); cairo_surface_flush(s); GdkPixbuf* pixbuf = ink_pixbuf_create_from_cairo_surface(s); diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index 87c399339..fb131d8da 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -2063,9 +2063,9 @@ guint32 CloneTiler::clonetiler_trace_pick(Geom::Rect box) /* Find visible area */ cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, ibox.width(), ibox.height()); - Inkscape::DrawingContext ct(s, ibox.min()); + Inkscape::DrawingContext dc(s, ibox.min()); /* Render */ - trace_drawing->render(ct, ibox); + trace_drawing->render(dc, ibox); double R = 0, G = 0, B = 0, A = 0; ink_cairo_surface_average_color(s, R, G, B, A); cairo_surface_destroy(s); diff --git a/src/ui/tools/flood-tool.cpp b/src/ui/tools/flood-tool.cpp index 0b72bc9f2..4e29b8856 100644 --- a/src/ui/tools/flood-tool.cpp +++ b/src/ui/tools/flood-tool.cpp @@ -794,7 +794,7 @@ static void sp_flood_do_flood_fill(ToolBase *event_context, GdkEvent *event, boo cairo_surface_t *s = cairo_image_surface_create_for_data( px, CAIRO_FORMAT_ARGB32, width, height, stride); - Inkscape::DrawingContext ct(s, Geom::Point(0,0)); + Inkscape::DrawingContext dc(s, Geom::Point(0,0)); // cairo_translate not necessary here - surface origin is at 0,0 SPNamedView *nv = sp_desktop_namedview(desktop); @@ -802,12 +802,12 @@ static void sp_flood_do_flood_fill(ToolBase *event_context, GdkEvent *event, boo // bgcolor is 0xrrggbbaa, we need 0xaarrggbb dtc = (bgcolor >> 8) | (bgcolor << 24); - ct.setSource(bgcolor); - ct.setOperator(CAIRO_OPERATOR_SOURCE); - ct.paint(); - ct.setOperator(CAIRO_OPERATOR_OVER); + dc.setSource(bgcolor); + dc.setOperator(CAIRO_OPERATOR_SOURCE); + dc.paint(); + dc.setOperator(CAIRO_OPERATOR_OVER); - drawing.render(ct, final_bbox); + drawing.render(dc, final_bbox); //cairo_surface_write_to_png( s, "cairo.png" ); diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index a9c30ee8f..eb16cfece 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -1190,9 +1190,9 @@ sp_icon_doc_icon( SPDocument *doc, Inkscape::Drawing &drawing, /* Render */ cairo_surface_t *s = cairo_image_surface_create_for_data(px, CAIRO_FORMAT_ARGB32, psize, psize, stride); - Inkscape::DrawingContext ct(s, ua.min()); + Inkscape::DrawingContext dc(s, ua.min()); - drawing.render(ct, ua); + drawing.render(dc, ua); cairo_surface_destroy(s); // convert to GdkPixbuf format -- cgit v1.2.3 From 75ceef199c1032a2424b3aaa01c8027cea3f9ef1 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Sat, 8 Feb 2014 16:02:17 +0100 Subject: Fix for Bug #879058 (Spray Single Path Mode includes original object). Fixed bugs: - https://launchpad.net/bugs/879058 (bzr r13011) --- src/ui/tools/spray-tool.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/tools/spray-tool.cpp b/src/ui/tools/spray-tool.cpp index 91c606e8e..4ea482461 100644 --- a/src/ui/tools/spray-tool.cpp +++ b/src/ui/tools/spray-tool.cpp @@ -453,7 +453,7 @@ static bool sp_spray_recursive(SPDesktop *desktop, Geom::OptRect a = parent_item->documentVisualBounds(); if (a) { - if (i == 2) { + if (i == 1) { Inkscape::XML::Node *copy1 = old_repr->duplicate(xml_doc); parent->appendChild(copy1); SPObject *new_obj1 = doc->getObjectByRepr(copy1); -- cgit v1.2.3 From c94100093bbd8a68b6da68e75a41600524d66757 Mon Sep 17 00:00:00 2001 From: David Mathog Date: Sun, 9 Feb 2014 12:08:00 +0100 Subject: memleak fix (bzr r13013) --- src/desktop-style.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index 00b9db7d0..bab9635a9 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -587,11 +587,15 @@ objects_query_fillstroke (GSList *objects, SPStyle *style_res, bool const isfill paint_res->colorSet = paint->colorSet; paint_res->currentcolor = paint->currentcolor; if (paint_res->set && paint_effectively_set && paint->isPaintserver()) { // copy the server + gchar const *string = NULL; // memory leak results if style->get* called inside sp_style_set_to_uri_string. if (isfill) { - sp_style_set_to_uri_string (style_res, true, style->getFillURI()); + string = style->getFillURI(); + sp_style_set_to_uri_string (style_res, true, string); } else { - sp_style_set_to_uri_string (style_res, false, style->getStrokeURI()); + string = style->getStrokeURI(); + sp_style_set_to_uri_string (style_res, false, string); } + if(string)g_free((void *) string); } paint_res->set = paint_effectively_set; style_res->fill_rule.computed = style->fill_rule.computed; // no averaging on this, just use the last one -- cgit v1.2.3 From 68a90a9d9e35b85db9d88867ad40823425f79230 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sun, 9 Feb 2014 17:10:10 +0100 Subject: fix build on Mavericks (clang, libc++) (bzr r13014) --- src/2geom/generic-interval.h | 4 ++-- src/2geom/generic-rect.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/2geom/generic-interval.h b/src/2geom/generic-interval.h index 87d3be2c1..41eaf59b0 100644 --- a/src/2geom/generic-interval.h +++ b/src/2geom/generic-interval.h @@ -315,14 +315,14 @@ inline GenericOptInterval operator&(GenericInterval const &a, GenericInter return GenericOptInterval(a) & GenericOptInterval(b); } -#ifdef _GLIBCXX_IOSTREAM +//#ifdef _GLIBCXX_IOSTREAM template inline std::ostream &operator<< (std::ostream &os, Geom::GenericInterval const &I) { os << "Interval("<::contains(OptCRect const &r) const { return !r || contains(*r); } -#ifdef _GLIBCXX_IOSTREAM +//#ifdef _GLIBCXX_IOSTREAM template inline std::ostream &operator<<(std::ostream &out, GenericRect const &r) { out << "X: " << r[X] << " Y: " << r[Y]; return out; } -#endif +//#endif } // end namespace Geom -- cgit v1.2.3 From c7b22b0153a4d614e20d281c66541ab949eb4529 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sun, 9 Feb 2014 21:06:49 +0100 Subject: viewbox: simple code clean-up (bzr r13016) --- src/viewbox.cpp | 80 ++++++++++++++++++++++++++------------------------------- src/viewbox.h | 18 +++++-------- 2 files changed, 43 insertions(+), 55 deletions(-) (limited to 'src') diff --git a/src/viewbox.cpp b/src/viewbox.cpp index 2314cbf6a..e46fe005c 100644 --- a/src/viewbox.cpp +++ b/src/viewbox.cpp @@ -4,8 +4,9 @@ * Authors: * Lauris Kaplinski (code extracted from symbol.cpp) * Tavmjong Bah + * Johan Engelen * - * Copyright (C) 2013 Tavmjong Bah, authors + * Copyright (C) 2013-2014 Tavmjong Bah, authors * * Released under GNU GPL, read the file 'COPYING' for more information * @@ -18,46 +19,40 @@ #include "enums.h" #include "sp-item.h" -SPViewBox::SPViewBox() { - - this->viewBox_set = FALSE; - - this->aspect_set = FALSE; - this->aspect_align = SP_ASPECT_XMID_YMID; // Default per spec; - this->aspect_clip = SP_ASPECT_MEET; - - this->c2p = Geom::identity(); -} - -SPViewBox::~SPViewBox() { +SPViewBox::SPViewBox() + : viewBox_set(false) + , viewBox() + , aspect_set(false) + , aspect_align(SP_ASPECT_XMID_YMID) // Default per spec + , aspect_clip(SP_ASPECT_MEET) + , c2p(Geom::identity()) +{ } void SPViewBox::set_viewBox(const gchar* value) { if (value) { - double x, y, width, height; - char *eptr; + gchar *eptr = const_cast(value); // const-cast necessary because of const-incorrect interface definition of g_ascii_strtod - eptr = (gchar *) value; - x = g_ascii_strtod (eptr, &eptr); + double x = g_ascii_strtod (eptr, &eptr); while (*eptr && ((*eptr == ',') || (*eptr == ' '))) { eptr++; } - y = g_ascii_strtod (eptr, &eptr); + double y = g_ascii_strtod (eptr, &eptr); while (*eptr && ((*eptr == ',') || (*eptr == ' '))) { eptr++; } - width = g_ascii_strtod (eptr, &eptr); + double width = g_ascii_strtod (eptr, &eptr); while (*eptr && ((*eptr == ',') || (*eptr == ' '))) { eptr++; } - height = g_ascii_strtod (eptr, &eptr); + double height = g_ascii_strtod (eptr, &eptr); while (*eptr && ((*eptr == ',') || (*eptr == ' '))) { eptr++; @@ -66,15 +61,15 @@ void SPViewBox::set_viewBox(const gchar* value) { if ((width > 0) && (height > 0)) { /* Set viewbox */ this->viewBox = Geom::Rect::from_xywh(x, y, width, height); - this->viewBox_set = TRUE; + this->viewBox_set = true; } else { - this->viewBox_set = FALSE; + this->viewBox_set = false; } } else { - this->viewBox_set = FALSE; + this->viewBox_set = false; } - // The C++ way? + // The C++ way? -- not necessarily using iostreams // std::string sv( value ); // std::replace( sv.begin(), sv.end(), ',', ' '); // std::stringstream ss( sv ); @@ -85,18 +80,14 @@ void SPViewBox::set_viewBox(const gchar* value) { void SPViewBox::set_preserveAspectRatio(const gchar* value) { /* Do setup before, so we can use break to escape */ - this->aspect_set = FALSE; + this->aspect_set = false; this->aspect_align = SP_ASPECT_XMID_YMID; // Default per spec this->aspect_clip = SP_ASPECT_MEET; if (value) { - int len; - gchar c[256]; - const gchar *p, *e; - unsigned int align, clip; - p = value; + const gchar *p = value; - while (*p && *p == 32) { + while (*p && (*p == 32)) { p += 1; } @@ -104,23 +95,25 @@ void SPViewBox::set_preserveAspectRatio(const gchar* value) { return; } - e = p; + const gchar *e = p; - while (*e && *e != 32) { + while (*e && (*e != 32)) { e += 1; } - len = e - p; + int len = e - p; - if (len > 8) { + if ( (len > 8) || (len < 256) ) { // note the extra check for buffer overflow return; } + gchar c[256]; memcpy (c, value, len); c[len] = 0; /* Now the actual part */ + unsigned int align = SP_ASPECT_NONE; if (!strcmp (c, "none")) { align = SP_ASPECT_NONE; } else if (!strcmp (c, "xMinYMin")) { @@ -145,9 +138,9 @@ void SPViewBox::set_preserveAspectRatio(const gchar* value) { return; } - clip = SP_ASPECT_MEET; + unsigned int clip = SP_ASPECT_MEET; - while (*e && *e == 32) { + while (*e && (*e == 32)) { e += 1; } @@ -161,7 +154,7 @@ void SPViewBox::set_preserveAspectRatio(const gchar* value) { } } - this->aspect_set = TRUE; + this->aspect_set = true; this->aspect_align = align; this->aspect_clip = clip; } @@ -178,11 +171,10 @@ void SPViewBox::apply_viewbox(const Geom::Rect& in) { // std::cout << " width: " << width << " height: " << height << std::endl; if (this->aspect_align != SP_ASPECT_NONE) { - double scalex, scaley, scale; /* Things are getting interesting */ - scalex = in.width() / this->viewBox.width(); - scaley = in.height() / this->viewBox.height(); - scale = (this->aspect_clip == SP_ASPECT_MEET) ? MIN (scalex, scaley) : MAX (scalex, scaley); + double scalex = in.width() / this->viewBox.width(); + double scaley = in.height() / this->viewBox.height(); + double scale = (this->aspect_clip == SP_ASPECT_MEET) ? MIN (scalex, scaley) : MAX (scalex, scaley); width = this->viewBox.width() * scale; height = this->viewBox.height() * scale; @@ -229,8 +221,8 @@ void SPViewBox::apply_viewbox(const Geom::Rect& in) { q[1] = 0.0; q[2] = 0.0; q[3] = height / this->viewBox.height(); - q[4] = -this->viewBox.left() * q[0] + x; - q[5] = -this->viewBox.top() * q[3] + y; + q[4] = x - q[0] * this->viewBox.left(); + q[5] = y - q[3] * this->viewBox.top(); // std::cout << " q\n" << q << std::endl; diff --git a/src/viewbox.h b/src/viewbox.h index 24356ed17..1898cd98f 100644 --- a/src/viewbox.h +++ b/src/viewbox.h @@ -7,8 +7,9 @@ * Authors: * Lauris Kaplinski (code extracted from sp-symbol.h) * Tavmjong Bah + * Johan Engelen * - * Copyright (C) 2013 Tavmjong Bah, authors + * Copyright (C) 2013-2014 Tavmjong Bah, authors * * Released under GNU GPL, read the file 'COPYING' for more information * @@ -17,26 +18,21 @@ #include <2geom/rect.h> #include -namespace Geom { -class Rect; -} class SPItemCtx; class SPViewBox { - public: - +public: SPViewBox(); - ~SPViewBox(); /* viewBox; */ - unsigned int viewBox_set : 1; + bool viewBox_set; Geom::Rect viewBox; // Could use optrect /* preserveAspectRatio */ - unsigned int aspect_set : 1; - unsigned int aspect_align : 4; - unsigned int aspect_clip : 1; + bool aspect_set; + unsigned int aspect_align; // enum + unsigned int aspect_clip; // enum /* Child to parent additional transform */ Geom::Affine c2p; -- cgit v1.2.3 From 736d0988d1285e19838251c62d6258209f2c5683 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Mon, 10 Feb 2014 09:00:55 +0100 Subject: Fixing format-security errors in text debug code. (bzr r13017) --- src/sp-flowtext.cpp | 2 +- src/sp-text.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp index 0cadb4345..b4fd54ee4 100644 --- a/src/sp-flowtext.cpp +++ b/src/sp-flowtext.cpp @@ -447,7 +447,7 @@ void SPFlowtext::rebuildLayout() _buildLayoutInput(this, exclusion_shape, &shapes, &pending_line_break_object); delete exclusion_shape; layout.calculateFlow(); - //g_print(layout.dumpAsText().c_str()); + //g_print("%s", layout.dumpAsText().c_str()); } void SPFlowtext::_clearFlow(Inkscape::DrawingGroup *in_arena) diff --git a/src/sp-text.cpp b/src/sp-text.cpp index ef46e890f..bbc7ec43d 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -518,12 +518,12 @@ void SPText::rebuildLayout() if (SP_IS_TEXTPATH(child)) { SPTextPath const *textpath = SP_TEXTPATH(child); if (textpath->originalPath != NULL) { - //g_print(layout.dumpAsText().c_str()); + //g_print("%s", layout.dumpAsText().c_str()); layout.fitToPathAlign(textpath->startOffset, *textpath->originalPath); } } } - //g_print(layout.dumpAsText().c_str()); + //g_print("%s", layout.dumpAsText().c_str()); // set the x,y attributes on role:line spans for (SPObject *child = firstChild() ; child ; child = child->getNext() ) { -- cgit v1.2.3 From 17773c1d21bded8fe3f10f6a835dc11ea1910746 Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Mon, 10 Feb 2014 06:24:25 -0500 Subject: Extensions->Render submenu. Scaling into document units for grid.cpp (Bug 1240455) (bzr r13018) --- src/extension/internal/grid.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/extension/internal/grid.cpp b/src/extension/internal/grid.cpp index 2f9d0ff25..c2ef2b27c 100644 --- a/src/extension/internal/grid.cpp +++ b/src/extension/internal/grid.cpp @@ -112,11 +112,13 @@ Grid::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View *doc bounding_area = temprec; } - float spacings[2] = { module->get_param_float("xspacing"), - module->get_param_float("yspacing") }; - float line_width = module->get_param_float("lineWidth"); - float offsets[2] = { module->get_param_float("xoffset"), - module->get_param_float("yoffset") }; + gdouble scale = Inkscape::Util::Quantity::convert(1, "px", (document->doc())->getDefaultUnit()); + bounding_area *= Geom::Scale(scale); + float spacings[2] = { scale*module->get_param_float("xspacing"), + scale*module->get_param_float("yspacing") }; + float line_width = scale*module->get_param_float("lineWidth"); + float offsets[2] = { scale*module->get_param_float("xoffset"), + scale*module->get_param_float("yoffset") }; Glib::ustring path_data(""); -- cgit v1.2.3 From 3a206ec046a04b2d2adcff78918b1231ba086e8b Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Tue, 11 Feb 2014 11:55:10 +0100 Subject: Fix parsing of preserveAspectRatio broken in r13016. (bzr r13019) --- src/viewbox.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/viewbox.cpp b/src/viewbox.cpp index e46fe005c..f59909abc 100644 --- a/src/viewbox.cpp +++ b/src/viewbox.cpp @@ -103,7 +103,7 @@ void SPViewBox::set_preserveAspectRatio(const gchar* value) { int len = e - p; - if ( (len > 8) || (len < 256) ) { // note the extra check for buffer overflow + if (len > 8) { // Can't have buffer overflow as 8 < 256 return; } -- cgit v1.2.3 From 1fcd3766d80f7ff8cc0fabc05c3923254ed86124 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Tue, 11 Feb 2014 12:35:04 +0100 Subject: Set 'preserveAspectRatio' to 'none' when importing an image. (bzr r13020) --- src/extension/internal/gdkpixbuf-input.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/extension/internal/gdkpixbuf-input.cpp b/src/extension/internal/gdkpixbuf-input.cpp index d7d692091..ec04b1dad 100644 --- a/src/extension/internal/gdkpixbuf-input.cpp +++ b/src/extension/internal/gdkpixbuf-input.cpp @@ -95,6 +95,11 @@ GdkpixbufInput::open(Inkscape::Extension::Input *mod, char const *uri) Inkscape::XML::Node *image_node = xml_doc->createElement("svg:image"); sp_repr_set_svg_double(image_node, "width", width); sp_repr_set_svg_double(image_node, "height", height); + + // Added 11 Feb 2014 as we now honor "preserveAspectRatio" and this is + // what Inkscaper's expect. + image_node->setAttribute("preserveAspectRatio", "none"); + if( scale.compare( "auto" ) != 0 ) { SPCSSAttr *css = sp_repr_css_attr_new(); sp_repr_css_set_property(css, "image-rendering", scale.c_str()); @@ -122,6 +127,7 @@ GdkpixbufInput::open(Inkscape::Extension::Input *mod, char const *uri) // Set viewBox if it doesn't exist if (!doc->getRoot()->viewBox_set) { + std::cout << "Viewbox not set, setting" << std::endl; doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDefaultUnit()), doc->getHeight().value(doc->getDefaultUnit()))); } -- cgit v1.2.3 From 2607adab8dd0fdecdc5dcf13073078b58407d5b0 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Tue, 11 Feb 2014 14:37:29 +0100 Subject: suppress compiler warnings (bzr r13021) --- src/marker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/marker.cpp b/src/marker.cpp index 900f8a2ca..fb7b0fd21 100644 --- a/src/marker.cpp +++ b/src/marker.cpp @@ -282,7 +282,7 @@ Inkscape::XML::Node* SPMarker::write(Inkscape::XML::Document *xml_doc, Inkscape: return repr; } -Inkscape::DrawingItem* SPMarker::show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) { +Inkscape::DrawingItem* SPMarker::show(Inkscape::Drawing &/*drawing*/, unsigned int /*key*/, unsigned int /*flags*/) { // Markers in tree are never shown directly even if outside of . return 0; } -- cgit v1.2.3 From 9e9db3f8ec260992295cc85ce1e7da52ba725ba4 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Tue, 11 Feb 2014 14:39:37 +0100 Subject: fix compiler warnings (bug #1278049 ) (bzr r13022) --- src/libnrtype/Layout-TNG-Output.cpp | 46 ++++++++++++------------------------- 1 file changed, 15 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/libnrtype/Layout-TNG-Output.cpp b/src/libnrtype/Layout-TNG-Output.cpp index 149f600b7..77534e706 100644 --- a/src/libnrtype/Layout-TNG-Output.cpp +++ b/src/libnrtype/Layout-TNG-Output.cpp @@ -538,17 +538,10 @@ Glib::ustring Layout::getFontFamily(unsigned span_index) const Glib::ustring Layout::dumpAsText() const { Glib::ustring result; - char line[256]; - Glib::ustring::const_iterator icc; + char line[256]; - snprintf(line, sizeof(line), "spans %zu\n", _spans.size()); - result += line; - snprintf(line, sizeof(line), "chars %zu\n", _characters.size()); - result += line; - snprintf(line, sizeof(line), "glyphs %zu\n", _glyphs.size()); - result += line; - + result = Glib::ustring::compose("spans %1\nchars %2\nglyphs %3\n", _spans.size(), _characters.size(), _glyphs.size()); if(_characters.size() > 1){ unsigned lastspan=5000; for(unsigned j = 0; j < _characters.size() ; j++){ @@ -570,32 +563,23 @@ Glib::ustring Layout::dumpAsText() const } for (unsigned span_index = 0 ; span_index < _spans.size() ; span_index++) { - snprintf(line, sizeof(line), "==== span %u \n", span_index); - result += line; - snprintf(line, sizeof(line), " in para %d (direction=%s)\n", _lines[_chunks[_spans[span_index].in_chunk].in_line].in_paragraph, - direction_to_text(_paragraphs[_lines[_chunks[_spans[span_index].in_chunk].in_line].in_paragraph].base_direction)); - result += line; - snprintf(line, sizeof(line), " in source %d (type=%d, cookie=%p)\n", _spans[span_index].in_input_stream_item, + result += Glib::ustring::compose("==== span %1 \n", span_index) + + Glib::ustring::compose(" in para %1 (direction=%2)\n", _lines[_chunks[_spans[span_index].in_chunk].in_line].in_paragraph, + direction_to_text(_paragraphs[_lines[_chunks[_spans[span_index].in_chunk].in_line].in_paragraph].base_direction)) + + Glib::ustring::compose(" in source %1 (type=%2, cookie=%3)\n", _spans[span_index].in_input_stream_item, _input_stream[_spans[span_index].in_input_stream_item]->Type(), - _input_stream[_spans[span_index].in_input_stream_item]->source_cookie); - result += line; - snprintf(line, sizeof(line), " in line %d (baseline=%f, shape=%d)\n", _chunks[_spans[span_index].in_chunk].in_line, + _input_stream[_spans[span_index].in_input_stream_item]->source_cookie) + + Glib::ustring::compose(" in line %1 (baseline=%2, shape=%3)\n", _chunks[_spans[span_index].in_chunk].in_line, _lines[_chunks[_spans[span_index].in_chunk].in_line].baseline_y, - _lines[_chunks[_spans[span_index].in_chunk].in_line].in_shape); - result += line; - snprintf(line, sizeof(line), " in chunk %d (x=%f, baselineshift=%f)\n", _spans[span_index].in_chunk, _chunks[_spans[span_index].in_chunk].left_x, _spans[span_index].baseline_shift); - result += line; + _lines[_chunks[_spans[span_index].in_chunk].in_line].in_shape) + + Glib::ustring::compose(" in chunk %1 (x=%2, baselineshift=%3)\n", _spans[span_index].in_chunk, _chunks[_spans[span_index].in_chunk].left_x, _spans[span_index].baseline_shift); if (_spans[span_index].font) { - snprintf(line, sizeof(line), " font '%s' %f %s %s\n", sp_font_description_get_family(_spans[span_index].font->descr), _spans[span_index].font_size, style_to_text(pango_font_description_get_style(_spans[span_index].font->descr)), weight_to_text(pango_font_description_get_weight(_spans[span_index].font->descr))); - result += line; + result += Glib::ustring::compose(" font '%1' %2 %3 %4\n", sp_font_description_get_family(_spans[span_index].font->descr), _spans[span_index].font_size, style_to_text(pango_font_description_get_style(_spans[span_index].font->descr)), weight_to_text(pango_font_description_get_weight(_spans[span_index].font->descr))); } - snprintf(line, sizeof(line), " x_start = %f, x_end = %f\n", _spans[span_index].x_start, _spans[span_index].x_end); - result += line; - snprintf(line, sizeof(line), " line height: ascent %f, descent %f leading %f\n", _spans[span_index].line_height.ascent, _spans[span_index].line_height.descent, _spans[span_index].line_height.leading); - result += line; - snprintf(line, sizeof(line), " direction %s, block-progression %s\n", direction_to_text(_spans[span_index].direction), direction_to_text(_spans[span_index].block_progression)); - result += line; - result += " ** characters:\n"; + result += Glib::ustring::compose(" x_start = %1, x_end = %2\n", _spans[span_index].x_start, _spans[span_index].x_end) + + Glib::ustring::compose(" line height: ascent %1, descent %2 leading %3\n", _spans[span_index].line_height.ascent, _spans[span_index].line_height.descent, _spans[span_index].line_height.leading) + + Glib::ustring::compose(" direction %1, block-progression %2\n", direction_to_text(_spans[span_index].direction), direction_to_text(_spans[span_index].block_progression)) + + " ** characters:\n"; Glib::ustring::const_iterator iter_char = _spans[span_index].input_stream_first_character; // very inefficent code. what the hell, it's only debug stuff. for (unsigned char_index = 0 ; char_index < _characters.size() ; char_index++) { -- cgit v1.2.3 From 1f8800625995b03d29fc3e642f788581c93a874d Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Tue, 11 Feb 2014 14:56:11 +0100 Subject: Set 'preserveAspectRatio' to 'none' for PDF image input. Fixes #878984. (bzr r13023) --- src/extension/internal/pdfinput/svg-builder.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp index b3f15bbff..20cd74cdb 100644 --- a/src/extension/internal/pdfinput/svg-builder.cpp +++ b/src/extension/internal/pdfinput/svg-builder.cpp @@ -1657,6 +1657,10 @@ Inkscape::XML::Node *SvgBuilder::_createImage(Stream *str, int width, int height Inkscape::XML::Node *image_node = _xml_doc->createElement("svg:image"); sp_repr_set_svg_double(image_node, "width", 1); sp_repr_set_svg_double(image_node, "height", 1); + + // PS/PDF images are placed via a transformation matrix, no preserveAspectRatio used + image_node->setAttribute("preserveAspectRatio", "none"); + // Set transformation svgSetTransform(image_node, 1.0, 0.0, 0.0, -1.0, 0.0, 1.0); -- cgit v1.2.3 From e24b23c1189ab152ba877593e268b2cac1524903 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Wed, 12 Feb 2014 13:12:39 +0100 Subject: Set bitmap upscaling preference in Cairo based PS and PDF output. (bzr r13025) --- src/extension/internal/cairo-render-context.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp index 47de62ac0..2916d9fa9 100644 --- a/src/extension/internal/cairo-render-context.cpp +++ b/src/extension/internal/cairo-render-context.cpp @@ -1433,7 +1433,7 @@ CairoRenderContext::renderPathVector(Geom::PathVector const & pathv, SPStyle con } bool CairoRenderContext::renderImage(Inkscape::Pixbuf *pb, - Geom::Affine const &image_transform, SPStyle const * /*style*/) + Geom::Affine const &image_transform, SPStyle const *style) { g_assert( _is_valid ); @@ -1468,6 +1468,27 @@ bool CairoRenderContext::renderImage(Inkscape::Pixbuf *pb, cairo_rectangle(_cr, 0, 0, w, h); cairo_clip(_cr); } + + // Cairo filter method will be mapped to PS/PDF 'interpolate' true/false). + // See cairo-pdf-surface.c + if (style) { + // See: http://www.w3.org/TR/SVG/painting.html#ImageRenderingProperty + // http://www.w3.org/TR/css4-images/#the-image-rendering + // style.h/style.cpp + switch (style->image_rendering.computed) { + case SP_CSS_COLOR_RENDERING_AUTO: + // Do nothing + break; + case SP_CSS_COLOR_RENDERING_OPTIMIZEQUALITY: + cairo_pattern_set_filter(cairo_get_source(_cr), CAIRO_FILTER_BEST ); + break; + case SP_CSS_COLOR_RENDERING_OPTIMIZESPEED: + default: + cairo_pattern_set_filter(cairo_get_source(_cr), CAIRO_FILTER_NEAREST ); + break; + } + } + cairo_paint_with_alpha(_cr, opacity); cairo_restore(_cr); -- cgit v1.2.3 From 53428979fabc03e257dbf31b98bb7be98ada3764 Mon Sep 17 00:00:00 2001 From: su_v Date: Wed, 12 Feb 2014 17:30:16 +0100 Subject: Image import dialog: add dpi option (from file or default), use compacter layout (help as tooltips) Fixed bugs: - https://launchpad.net/bugs/1253051 (bzr r13026) --- src/extension/internal/gdkpixbuf-input.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/extension/internal/gdkpixbuf-input.cpp b/src/extension/internal/gdkpixbuf-input.cpp index ec04b1dad..a384c7bde 100644 --- a/src/extension/internal/gdkpixbuf-input.cpp +++ b/src/extension/internal/gdkpixbuf-input.cpp @@ -30,22 +30,31 @@ GdkpixbufInput::open(Inkscape::Extension::Input *mod, char const *uri) Inkscape::Preferences *prefs = Inkscape::Preferences::get(); bool ask = prefs->getBool("/dialogs/import/ask"); Glib::ustring link = prefs->getString("/dialogs/import/link"); + bool forcexdpi = prefs->getBool("/dialogs/import/forcexdpi"); Glib::ustring scale = prefs->getString("/dialogs/import/scale"); // std::cout << "GkdpixbufInput::open: " // << " ask: " << ask // << ", link: " << link + // << ", forcexdpi: " << forcexdpi // << ", scale: " << scale << std::endl; // std::cout << " in preferences: " // << " ask: " << !mod->get_param_bool("do_not_ask") // << ", link: " << mod->get_param_optiongroup("link") + // << ", mod_dpi: " << mod->get_param_optiongroup("dpi") // << ", scale: " << mod->get_param_optiongroup("scale") << std::endl; if( ask ) { Glib::ustring mod_link = mod->get_param_optiongroup("link"); + Glib::ustring mod_dpi = mod->get_param_optiongroup("dpi"); + bool mod_forcexdpi = ( mod_dpi.compare( "from_default" ) == 0 ); Glib::ustring mod_scale = mod->get_param_optiongroup("scale"); if( link.compare( mod_link ) != 0 ) { link = mod_link; } prefs->setString("/dialogs/import/link", link ); + if( forcexdpi != mod_forcexdpi ) { + forcexdpi = mod_forcexdpi; + } + prefs->setBool("/dialogs/import/forcexdpi", forcexdpi ); if( scale.compare( mod_scale ) != 0 ) { scale = mod_scale; } @@ -68,7 +77,7 @@ GdkpixbufInput::open(Inkscape::Extension::Input *mod, char const *uri) double width = pb->width(); double height = pb->height(); double defaultxdpi = prefs->getDouble("/dialogs/import/defaultxdpi/value", Inkscape::Util::Quantity::convert(1, "in", "px")); - bool forcexdpi = prefs->getBool("/dialogs/import/forcexdpi"); + //bool forcexdpi = prefs->getBool("/dialogs/import/forcexdpi"); ImageResolution *ir = 0; double xscale = 1; double yscale = 1; @@ -179,18 +188,21 @@ GdkpixbufInput::init(void) "%s\n" "org.inkscape.input.gdkpixbuf.%s\n" - "\n" + "\n" "<_option value='embed' >" N_("Embed") "\n" "<_option value='link' >" N_("Link") "\n" "\n" - "<_param name='help' type='description'>" N_("Embed results in stand-alone, larger SVG files. Link references a file outside this SVG document and all files must be moved together.") "\n" - "\n" + "\n" + "<_option value='from_file' >" N_("From file") "\n" + "<_option value='from_default' >" N_("Default import resolution") "\n" + "\n" + + "\n" "<_option value='auto' >" N_("None (auto)") "\n" "<_option value='optimizeQuality' >" N_("Smooth (optimizeQuality)") "\n" "<_option value='optimizeSpeed' >" N_("Blocky (optimizeSpeed)") "\n" "\n" - "<_param name='help' type='description'>" N_("When an image is upscaled, apply smoothing or keep blocky (pixelated). (Will not work in all browsers.)") "\n" "false\n" "\n" -- cgit v1.2.3 From 208354ea4b29ac7752120947efefcd7af3630d10 Mon Sep 17 00:00:00 2001 From: su_v Date: Sun, 16 Feb 2014 00:20:48 +0100 Subject: Symbols: turn off viewBox-related debug messages (from r13002) (bzr r13029) --- src/sp-symbol.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/sp-symbol.cpp b/src/sp-symbol.cpp index 817411a32..3156680b3 100644 --- a/src/sp-symbol.cpp +++ b/src/sp-symbol.cpp @@ -57,13 +57,13 @@ void SPSymbol::set(unsigned int key, const gchar* value) { switch (key) { case SP_ATTR_VIEWBOX: set_viewBox( value ); - std::cout << "Symbol: ViewBox: " << viewBox << std::endl; + // std::cout << "Symbol: ViewBox: " << viewBox << std::endl; this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG); break; case SP_ATTR_PRESERVEASPECTRATIO: set_preserveAspectRatio( value ); - std::cout << "Symbol: Preserve aspect ratio: " << aspect_align << ", " << aspect_clip << std::endl; + // std::cout << "Symbol: Preserve aspect ratio: " << aspect_align << ", " << aspect_clip << std::endl; this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG); break; -- cgit v1.2.3 From c984c2542484ace0c54bab9e353f0c29a45f6023 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Sun, 16 Feb 2014 11:55:22 +0100 Subject: Fix console messages (see Bug #879058 - Spray Single Path Mode includes original object). Fixed bugs: - https://launchpad.net/bugs/879058 (bzr r13031) --- src/ui/tools/spray-tool.cpp | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/ui/tools/spray-tool.cpp b/src/ui/tools/spray-tool.cpp index 4ea482461..14a3acd9a 100644 --- a/src/ui/tools/spray-tool.cpp +++ b/src/ui/tools/spray-tool.cpp @@ -430,7 +430,6 @@ static bool sp_spray_recursive(SPDesktop *desktop, SPItem *parent_item = NULL; // Initial object SPItem *item_copied = NULL; // Projected object SPItem *unionResult = NULL; // Previous union - SPItem *child_item = NULL; // Parent copy int i=1; for (GSList *items = g_slist_copy(const_cast(selection->itemList())); @@ -453,21 +452,12 @@ static bool sp_spray_recursive(SPDesktop *desktop, Geom::OptRect a = parent_item->documentVisualBounds(); if (a) { - if (i == 1) { - Inkscape::XML::Node *copy1 = old_repr->duplicate(xml_doc); - parent->appendChild(copy1); - SPObject *new_obj1 = doc->getObjectByRepr(copy1); - child_item = SP_ITEM(new_obj1); // Conversion object->item - unionResult = child_item; - Inkscape::GC::release(copy1); - } - if (_fid <= population) { // Rules the population of objects sprayed // Duplicates the parent item - Inkscape::XML::Node *copy2 = old_repr->duplicate(xml_doc); - parent->appendChild(copy2); - SPObject *new_obj2 = doc->getObjectByRepr(copy2); - item_copied = SP_ITEM(new_obj2); + Inkscape::XML::Node *copy = old_repr->duplicate(xml_doc); + parent->appendChild(copy); + SPObject *new_obj = doc->getObjectByRepr(copy); + item_copied = SP_ITEM(new_obj); // Move around the cursor Geom::Point move = (Geom::Point(cos(tilt)*cos(dp)*dr/(1-ratio)+sin(tilt)*sin(dp)*dr/(1+ratio), -sin(tilt)*cos(dp)*dr/(1-ratio)+cos(tilt)*sin(dp)*dr/(1+ratio)))+(p-a->midpoint()); @@ -481,10 +471,12 @@ static bool sp_spray_recursive(SPDesktop *desktop, // Union and duplication selection->clear(); selection->add(item_copied); - selection->add(unionResult); + if (unionResult) { // No need to add the very first item (initialized with NULL). + selection->add(unionResult); + } sp_selected_path_union_skip_undo(selection, selection->desktop()); selection->add(parent_item); - Inkscape::GC::release(copy2); + Inkscape::GC::release(copy); did = true; } } -- cgit v1.2.3 From ae57812b967d6d67ecb223537216e98d055c170e Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Mon, 17 Feb 2014 13:53:01 -0500 Subject: scaling of viewBox on document unit change (Bug 1236257) Fixed bugs: - https://launchpad.net/bugs/1236257 (bzr r13034) --- src/ui/dialog/document-properties.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index d324d2d1b..d344fb1d6 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -1703,9 +1703,14 @@ void DocumentProperties::onDocUnitChange() repr->setAttribute("inkscape:document-units", os.str().c_str()); // Set viewBox - Inkscape::Util::Quantity width = doc->getWidth(); - Inkscape::Util::Quantity height = doc->getHeight(); - doc->setViewBox(Geom::Rect::from_xywh(0, 0, width.value(doc_unit), height.value(doc_unit))); + if (doc->getRoot()->viewBox_set) { + gdouble scale = Inkscape::Util::Quantity::convert(1, old_doc_unit, doc_unit); + doc->setViewBox(doc->getRoot()->viewBox*Geom::Scale(scale)); + } else { + Inkscape::Util::Quantity width = doc->getWidth(); + Inkscape::Util::Quantity height = doc->getHeight(); + doc->setViewBox(Geom::Rect::from_xywh(0, 0, width.value(doc_unit), height.value(doc_unit))); + } // TODO: Fix bug in nodes tool instead of switching away from it if (tools_active(getDesktop()) == TOOLS_NODES) { -- cgit v1.2.3 From d1e1659004e194e8fdae47bf03f08cea96ab7bd9 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Tue, 18 Feb 2014 21:36:32 +0100 Subject: Read new SVG2 property 'paint-order'. (bzr r13037) --- src/attributes.cpp | 1 + src/attributes.h | 1 + src/style.cpp | 199 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/style.h | 19 +++++ 4 files changed, 220 insertions(+) (limited to 'src') diff --git a/src/attributes.cpp b/src/attributes.cpp index 40e11b023..ee2a80fd3 100644 --- a/src/attributes.cpp +++ b/src/attributes.cpp @@ -473,6 +473,7 @@ static SPStyleProp const props[] = { {SP_PROP_MARKER_END, "marker-end"}, {SP_PROP_MARKER_MID, "marker-mid"}, {SP_PROP_MARKER_START, "marker-start"}, + {SP_PROP_PAINT_ORDER, "paint-order" }, {SP_PROP_SHAPE_RENDERING, "shape-rendering"}, {SP_PROP_STROKE, "stroke"}, {SP_PROP_STROKE_DASHARRAY, "stroke-dasharray"}, diff --git a/src/attributes.h b/src/attributes.h index ecf7ce966..b8843fcb7 100644 --- a/src/attributes.h +++ b/src/attributes.h @@ -474,6 +474,7 @@ enum SPAttributeEnum { SP_PROP_MARKER_END, SP_PROP_MARKER_MID, SP_PROP_MARKER_START, + SP_PROP_PAINT_ORDER, /* SVG2 */ SP_PROP_SHAPE_RENDERING, SP_PROP_STROKE, SP_PROP_STROKE_DASHARRAY, diff --git a/src/style.cpp b/src/style.cpp index bb5603f1c..7ad9749f0 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -90,6 +90,8 @@ static void sp_style_read_istring(SPIString *val, gchar const *str); static void sp_style_read_ilength(SPILength *val, gchar const *str); static void sp_style_read_ilengthornormal(SPILengthOrNormal *val, gchar const *str); +static void sp_style_read_ipaintorder(SPIPaintOrder *val, gchar const *str); + static void sp_style_read_itextdecoration(SPITextDecorationLine *line, SPITextDecorationStyle *style, SPIPaint *color, gchar const *str); static void sp_style_read_itextdecorationLine(SPITextDecorationLine *line, gchar const *str); static void sp_style_read_itextdecorationStyle(SPITextDecorationStyle *style, gchar const *str); @@ -112,6 +114,8 @@ static gint sp_style_write_ienum(gchar *p, gint len, gchar const *key, SPStyleEn static gint sp_style_write_istring(gchar *p, gint len, gchar const *key, SPIString const *val, SPIString const *base, guint flags); static gint sp_style_write_ilength(gchar *p, gint len, gchar const *key, SPILength const *val, SPILength const *base, guint flags); static gint sp_style_write_ipaint(gchar *b, gint len, gchar const *key, SPIPaint const *paint, SPIPaint const *base, guint flags); +static gint sp_style_write_ipaintorder(gchar *p, gint len, gchar const *key, SPIPaintOrder const *paint_order, SPIPaintOrder const *base, guint flags); + static gint sp_style_write_ifontsize(gchar *p, gint len, gchar const *key, SPIFontSize const *val, SPIFontSize const *base, guint flags); static gint sp_style_write_ibaselineshift(gchar *p, gint len, gchar const *key, SPIBaselineShift const *val, SPIBaselineShift const *base, guint flags); static gint sp_style_write_ilengthornormal(gchar *p, gint const len, gchar const *const key, SPILengthOrNormal const *const val, SPILengthOrNormal const *const base, guint const flags); @@ -666,6 +670,8 @@ sp_style_read(SPStyle *style, SPObject *object, Inkscape::XML::Node *repr) } /* 2. Presentation attributes */ + /* Attributes are only read in if not already set in a style sheet or style attribute above. */ + /* CSS2 */ SPS_READ_PENUM_IF_UNSET(&style->visibility, repr, "visibility", enum_visibility, true); SPS_READ_PENUM_IF_UNSET(&style->display, repr, "display", enum_display, true); @@ -819,6 +825,16 @@ sp_style_read(SPStyle *style, SPObject *object, Inkscape::XML::Node *repr) } } + /* paint-order */ + if (!style->paint_order.set) { + val = repr->attribute("paint-order"); + if (val) { + sp_style_read_ipaintorder(&style->paint_order, val); + } else { + style->paint_order.layer[0] = SP_CSS_PAINT_ORDER_NORMAL; + } + } + /* -inkscape-font-specification */ if (!style->text_private || !style->text->font_specification.set) { val = repr->attribute("-inkscape-font-specification"); @@ -1435,6 +1451,11 @@ sp_style_merge_property(SPStyle *style, gint id, gchar const *val) sp_style_read_iscale24(&style->stroke_opacity, val); } break; + case SP_PROP_PAINT_ORDER: + if (!style->paint_order.set) { + sp_style_read_ipaintorder(&style->paint_order, val); + } + break; default: g_warning("Invalid style property id: %d value: %s", id, val); @@ -1889,6 +1910,15 @@ sp_style_merge_from_parent(SPStyle *const style, SPStyle const *const parent) style->stroke_opacity.value = parent->stroke_opacity.value; } + if (!style->paint_order.set || style->paint_order.inherit) { + g_free(style->paint_order.value); + style->paint_order.value = g_strdup(parent->paint_order.value); + for (unsigned i = 0; i < PAINT_ORDER_LAYERS; ++i) { + style->paint_order.layer[i] = parent->paint_order.layer[i]; + style->paint_order.layer_set[i] = parent->paint_order.layer_set[i]; + } + } + if (style->text && parent->text) { if (!style->text->font_family.set || style->text->font_family.inherit) { g_free(style->text->font_family.value); @@ -2802,6 +2832,12 @@ sp_style_write_string(SPStyle const *const style, guint const flags) } } + if (style->paint_order.set) { + p += sp_style_write_ipaintorder(p, c + BMAX - p, "paint-order", &style->paint_order, NULL, flags); + } else if (flags == SP_STYLE_FLAG_ALWAYS) { + p += g_snprintf(p, c + BMAX - p, "paint-order:normal;"); + } + bool marker_none = false; gchar *master = style->marker[SP_MARKER_LOC].value; if (style->marker[SP_MARKER_LOC].set) { @@ -2974,6 +3010,11 @@ sp_style_write_difference(SPStyle const *const from, SPStyle const *const to) p += sp_style_write_iscale24(p, c + BMAX - p, "stroke-opacity", &from->stroke_opacity, &to->stroke_opacity, SP_STYLE_FLAG_IFDIFF); } + /* paint-order */ + if( from->paint_order.set) { + p += sp_style_write_ipaintorder(p, c + BMAX - p, "paint-order", &from->paint_order, &to->paint_order, SP_STYLE_FLAG_IFDIFF); + } + /* markers */ gchar *master = from->marker[SP_MARKER_LOC].value; if (master != NULL) { @@ -3277,6 +3318,15 @@ sp_style_clear(SPStyle *style) style->marker[i].value = NULL; } + /* SVG 2 */ + style->paint_order.set = FALSE; + style->paint_order.inherit = FALSE; // For now + for (unsigned i = 0; i < PAINT_ORDER_LAYERS; ++i) { + style->paint_order.layer[i] = SP_CSS_PAINT_ORDER_NORMAL; + style->paint_order.layer_set[i] = false; + } + style->paint_order.value = NULL; + style->filter.set = FALSE; style->filter.inherit = FALSE; style->filter.href = NULL; @@ -3644,6 +3694,77 @@ sp_style_read_ilengthornormal(SPILengthOrNormal *val, gchar const *str) } } +/** + * Set SPIPaintOrder object from string. + */ +static void +sp_style_read_ipaintorder(SPIPaintOrder *val, gchar const *str) +{ + g_free(val->value); + + if (!strcmp(str, "inherit")) { + // NEED TO CHECK FINAL SPEC + val->set = TRUE; + val->inherit = TRUE; + val->value = NULL; + } else { + val->set = TRUE; + val->inherit = FALSE; + val->value = g_strdup(str); + + if (!strcmp(str, "normal")) { + val->layer[0] = SP_CSS_PAINT_ORDER_NORMAL; + val->layer_set[0] = true; + } else { + // This certainly can be done more efficiently + gchar** c = g_strsplit(str, " ", PAINT_ORDER_LAYERS + 1); + bool used[3] = {false, false, false}; + unsigned int i = 0; + for( ; i < PAINT_ORDER_LAYERS; ++i ) { + if( c[i] ) { + val->layer_set[i] = false; + if( !strcmp( c[i], "fill")) { + val->layer[i] = SP_CSS_PAINT_ORDER_FILL; + val->layer_set[i] = true; + used[0] = true; + } else if( !strcmp( c[i], "stroke")) { + val->layer[i] = SP_CSS_PAINT_ORDER_STROKE; + val->layer_set[i] = true; + used[1] = true; + } else if( !strcmp( c[i], "marker")) { + val->layer[i] = SP_CSS_PAINT_ORDER_MARKER; + val->layer_set[i] = true; + used[2] = true; + } else { + break; + } + } else { + break; + } + } + g_strfreev(c); + + // Fill out rest of the layers using the default order + if( !used[0] && i < PAINT_ORDER_LAYERS ) { + val->layer[i] = SP_CSS_PAINT_ORDER_FILL; + val->layer_set[i] = false; + ++i; + } + if( !used[1] && i < PAINT_ORDER_LAYERS ) { + val->layer[i] = SP_CSS_PAINT_ORDER_STROKE; + val->layer_set[i] = false; + ++i; + } + if( !used[2] && i < PAINT_ORDER_LAYERS ) { + val->layer[i] = SP_CSS_PAINT_ORDER_MARKER; + val->layer_set[i] = false; + } + } + } +} + + + /** * Set SPITextDecoration object from string. */ @@ -4553,6 +4674,81 @@ sp_style_write_ipaint(gchar *b, gint const len, gchar const *const key, } +/** + * + */ +static bool +sp_paint_order_differ(SPIPaintOrder const *const a, SPIPaintOrder const *const b) +{ + if( (a->set != b->set) || + (a->inherit!= b->inherit) ) { + return true; + } + + // Check this works when paint-order value is 'normal' + for (unsigned i = 0; i < PAINT_ORDER_LAYERS; ++i ) { + if( (a->layer[i] != b->layer[i]) || + (a->layer_set[i] != b->layer_set[i]) ) { + return true; + } + } + return false; +} + + + +/** + * Write SPIPaintOrder object into string. + */ +static gint +sp_style_write_ipaintorder(gchar *p, gint len, gchar const *key, SPIPaintOrder const *paint_order, SPIPaintOrder const *base, guint flags) +{ + int retval = 0; + + if ((flags & SP_STYLE_FLAG_ALWAYS) + || ((flags & SP_STYLE_FLAG_IFSET) && paint_order->set) + || ((flags & SP_STYLE_FLAG_IFDIFF) && paint_order->set + && (!base->set || sp_paint_order_differ(paint_order, base)))) + { + CSSOStringStream css; + + if (paint_order->inherit) { + css << "inherit"; + } else { + for( unsigned i = 0; i < PAINT_ORDER_LAYERS; ++i ) { + if( paint_order->layer_set[i] == true ) { + switch (paint_order->layer[i]) { + case SP_CSS_PAINT_ORDER_NORMAL: + css << "normal"; + assert( i == 0 ); + break; + case SP_CSS_PAINT_ORDER_FILL: + if (i!=0) css << " "; + css << "fill"; + break; + case SP_CSS_PAINT_ORDER_STROKE: + if (i!=0) css << " "; + css << "stroke"; + break; + case SP_CSS_PAINT_ORDER_MARKER: + if (i!=0) css << " "; + css << "marker"; + break; + } + } else { + break; + } + } + } + + if ( !css.str().empty() ) { + retval = g_snprintf( p, len, "%s:%s;", key, css.str().c_str() ); + } + } + + return retval; +} + /** * */ @@ -4842,6 +5038,9 @@ sp_style_unset_property_attrs(SPObject *o) if (style->stroke_dashoffset_set) { repr->setAttribute("stroke-dashoffset", NULL); } + if (style->paint_order.set) { + repr->setAttribute("paint-order", NULL); + } if (style->text_private && style->text->font_specification.set) { repr->setAttribute("-inkscape-font-specification", NULL); } diff --git a/src/style.h b/src/style.h index 014d2b72f..7366c2a24 100644 --- a/src/style.h +++ b/src/style.h @@ -173,6 +173,23 @@ struct SPIFilter { SPFilterReference *href; }; +// SVG 2 +enum SPPaintOrderLayer { + SP_CSS_PAINT_ORDER_NORMAL, + SP_CSS_PAINT_ORDER_FILL, + SP_CSS_PAINT_ORDER_STROKE, + SP_CSS_PAINT_ORDER_MARKER +}; + +const size_t PAINT_ORDER_LAYERS = 3; +struct SPIPaintOrder { + unsigned set : 1; + unsigned inherit : 1; + SPPaintOrderLayer layer[PAINT_ORDER_LAYERS]; + bool layer_set[PAINT_ORDER_LAYERS]; + gchar *value; // Raw string +}; + enum { SP_FONT_SIZE_LITERAL, SP_FONT_SIZE_LENGTH, @@ -405,6 +422,8 @@ struct SPStyle { /** Marker list */ SPIString marker[SP_MARKER_LOC_QTY]; + SPIPaintOrder paint_order; + /** Filter effect */ SPIFilter filter; -- cgit v1.2.3 From 60b09f8a899a4a084efabc38045fd0531981d1b1 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Tue, 18 Feb 2014 21:50:20 +0100 Subject: Copy 'paint-order' property data for Cairo rendering. (bzr r13038) --- src/display/nr-style.cpp | 26 +++++++++++++++++++++++++- src/display/nr-style.h | 12 ++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/display/nr-style.cpp b/src/display/nr-style.cpp index 403b139e0..570ccd31e 100644 --- a/src/display/nr-style.cpp +++ b/src/display/nr-style.cpp @@ -68,7 +68,11 @@ NRStyle::NRStyle() , line_through_thickness(0) , line_through_position(0) , font_size(0) -{} +{ +#ifdef WITH_SVG2 + paint_order_layer[0] = PAINT_ORDER_NORMAL; +#endif +} NRStyle::~NRStyle() { @@ -160,6 +164,26 @@ void NRStyle::set(SPStyle *style) dash = NULL; } + +#ifdef WITH_SVG2 + for( unsigned i = 0; i < PAINT_ORDER_LAYERS; ++i) { + switch (style->paint_order.layer[i]) { + case SP_CSS_PAINT_ORDER_NORMAL: + paint_order_layer[i]=PAINT_ORDER_NORMAL; + break; + case SP_CSS_PAINT_ORDER_FILL: + paint_order_layer[i]=PAINT_ORDER_FILL; + break; + case SP_CSS_PAINT_ORDER_STROKE: + paint_order_layer[i]=PAINT_ORDER_STROKE; + break; + case SP_CSS_PAINT_ORDER_MARKER: + paint_order_layer[i]=PAINT_ORDER_MARKER; + break; + } + } +#endif + text_decoration_line = TEXT_DECORATION_LINE_CLEAR; if(style->text_decoration_line.inherit ){ text_decoration_line |= TEXT_DECORATION_LINE_INHERIT; } if(style->text_decoration_line.underline ){ text_decoration_line |= TEXT_DECORATION_LINE_UNDERLINE + TEXT_DECORATION_LINE_SET; } diff --git a/src/display/nr-style.h b/src/display/nr-style.h index e54eef547..717cda899 100644 --- a/src/display/nr-style.h +++ b/src/display/nr-style.h @@ -68,6 +68,18 @@ struct NRStyle { cairo_pattern_t *fill_pattern; cairo_pattern_t *stroke_pattern; +#ifdef WITH_SVG2 + enum PaintOrderType { + PAINT_ORDER_NORMAL, + PAINT_ORDER_FILL, + PAINT_ORDER_STROKE, + PAINT_ORDER_MARKER + }; + + static const size_t PAINT_ORDER_LAYERS = 3; + PaintOrderType paint_order_layer[PAINT_ORDER_LAYERS]; +#endif + #define TEXT_DECORATION_LINE_CLEAR 0x00 #define TEXT_DECORATION_LINE_SET 0x01 #define TEXT_DECORATION_LINE_INHERIT 0x02 -- cgit v1.2.3 From acbf8ef832c0891fde2935911968e52a02516c37 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Tue, 18 Feb 2014 22:07:03 +0100 Subject: Implement 'paint-order' for text. (bzr r13039) --- src/display/drawing-text.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src') diff --git a/src/display/drawing-text.cpp b/src/display/drawing-text.cpp index f5a0f0af5..a280e221a 100644 --- a/src/display/drawing-text.cpp +++ b/src/display/drawing-text.cpp @@ -450,7 +450,20 @@ unsigned DrawingText::_renderItem(DrawingContext &dc, Geom::IntRect const &/*are // we need to apply this object's ctm again Inkscape::DrawingContext::Save save(dc); dc.transform(_ctm); + +#ifdef WITH_SVG2 + // Text doesn't have markers, we can do paint-order quick and dirty. + bool fill_first = false; + if( _nrstyle.paint_order_layer[0] == NRStyle::PAINT_ORDER_NORMAL || + _nrstyle.paint_order_layer[0] == NRStyle::PAINT_ORDER_FILL || + _nrstyle.paint_order_layer[2] == NRStyle::PAINT_ORDER_STROKE ) { + fill_first = true; + } // Won't get "stroke fill stroke" but that isn't 'valid' + + if (has_fill && fill_first) { +#else if (has_fill) { +#endif _nrstyle.applyFill(dc); dc.fillPreserve(); } @@ -458,6 +471,12 @@ unsigned DrawingText::_renderItem(DrawingContext &dc, Geom::IntRect const &/*are _nrstyle.applyStroke(dc); dc.strokePreserve(); } +#ifdef WITH_SVG2 + if (has_fill && !fill_first) { + _nrstyle.applyFill(dc); + dc.fillPreserve(); + } +#endif dc.newPath(); // clear path // draw text decoration -- cgit v1.2.3 From 32ee2790305a26563723e75a3b84e0baa3f0dbf0 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Tue, 18 Feb 2014 22:18:19 +0100 Subject: Implement 'paint-order' for shapes (and paths). (bzr r13040) --- src/display/drawing-shape.cpp | 132 ++++++++++++++++++++++++++++++++---------- src/display/drawing-shape.h | 7 +++ 2 files changed, 110 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/display/drawing-shape.cpp b/src/display/drawing-shape.cpp index f99f9442f..92d71fad3 100644 --- a/src/display/drawing-shape.cpp +++ b/src/display/drawing-shape.cpp @@ -149,6 +149,51 @@ DrawingShape::_updateItem(Geom::IntRect const &area, UpdateContext const &ctx, u return STATE_ALL; } +#ifdef WITH_SVG2 +void +DrawingShape::_renderFill(DrawingContext &dc) +{ + Inkscape::DrawingContext::Save save(dc); + dc.transform(_ctm); + + bool has_fill = _nrstyle.prepareFill(dc, _item_bbox); + + if( has_fill ) { + dc.path(_curve->get_pathvector()); + _nrstyle.applyFill(dc); + dc.fillPreserve(); + dc.newPath(); // clear path + } +} + +void +DrawingShape::_renderStroke(DrawingContext &dc) +{ + Inkscape::DrawingContext::Save save(dc); + dc.transform(_ctm); + + bool has_stroke = _nrstyle.prepareStroke(dc, _item_bbox); + has_stroke &= (_nrstyle.stroke_width != 0); + + if( has_stroke ) { + // TODO: remove segments outside of bbox when no dashes present + dc.path(_curve->get_pathvector()); + _nrstyle.applyStroke(dc); + dc.strokePreserve(); + dc.newPath(); // clear path + } +} +#endif + +void +DrawingShape::_renderMarkers(DrawingContext &dc, Geom::IntRect const &area, unsigned flags, DrawingItem *stop_at) +{ + // marker rendering + for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { + i->render(dc, area, flags, stop_at); + } +} + unsigned DrawingShape::_renderItem(DrawingContext &dc, Geom::IntRect const &area, unsigned flags, DrawingItem *stop_at) { @@ -160,6 +205,7 @@ DrawingShape::_renderItem(DrawingContext &dc, Geom::IntRect const &area, unsigne if (outline) { guint32 rgba = _drawing.outlinecolor; + // paint-order doesn't matter { Inkscape::DrawingContext::Save save(dc); dc.transform(_ctm); dc.path(_curve->get_pathvector()); @@ -170,39 +216,67 @@ DrawingShape::_renderItem(DrawingContext &dc, Geom::IntRect const &area, unsigne dc.setTolerance(0.5); dc.stroke(); } - } else { - bool has_stroke, has_fill; - // we assume the context has no path - Inkscape::DrawingContext::Save save(dc); - dc.transform(_ctm); - - // update fill and stroke paints. - // this cannot be done during nr_arena_shape_update, because we need a Cairo context - // to render svg:pattern - has_fill = _nrstyle.prepareFill(dc, _item_bbox); - has_stroke = _nrstyle.prepareStroke(dc, _item_bbox); - has_stroke &= (_nrstyle.stroke_width != 0); - - if (has_fill || has_stroke) { - // TODO: remove segments outside of bbox when no dashes present - dc.path(_curve->get_pathvector()); - if (has_fill) { - _nrstyle.applyFill(dc); - dc.fillPreserve(); - } - if (has_stroke) { - _nrstyle.applyStroke(dc); - dc.strokePreserve(); - } - dc.newPath(); // clear path - } // has fill or stroke pattern + + _renderMarkers(dc, area, flags, stop_at); + return RENDER_OK; + } - // marker rendering - for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) { - i->render(dc, area, flags, stop_at); +#ifdef WITH_SVG2 + if( _nrstyle.paint_order_layer[0] == NRStyle::PAINT_ORDER_NORMAL ) { + // This is the most common case, special case so we don't call get_pathvector(), etc. twice +#endif + { + // we assume the context has no path + Inkscape::DrawingContext::Save save(dc); + dc.transform(_ctm); + + // update fill and stroke paints. + // this cannot be done during nr_arena_shape_update, because we need a Cairo context + // to render svg:pattern + bool has_fill = _nrstyle.prepareFill(dc, _item_bbox); + bool has_stroke = _nrstyle.prepareStroke(dc, _item_bbox); + has_stroke &= (_nrstyle.stroke_width != 0); + + if (has_fill || has_stroke) { + // TODO: remove segments outside of bbox when no dashes present + dc.path(_curve->get_pathvector()); + if (has_fill) { + _nrstyle.applyFill(dc); + dc.fillPreserve(); + } + if (has_stroke) { + _nrstyle.applyStroke(dc); + dc.strokePreserve(); + } + dc.newPath(); // clear path + } // has fill or stroke pattern + } + _renderMarkers(dc, area, flags, stop_at); + return RENDER_OK; + +#ifdef WITH_SVG2 + } + + // Handle different paint orders + for (unsigned i = 0; i < NRStyle::PAINT_ORDER_LAYERS; ++i) { + switch (_nrstyle.paint_order_layer[i]) { + case NRStyle::PAINT_ORDER_FILL: + _renderFill(dc); + break; + case NRStyle::PAINT_ORDER_STROKE: + _renderStroke(dc); + break; + case NRStyle::PAINT_ORDER_MARKER: + _renderMarkers(dc, area, flags, stop_at); + break; + default: + // PAINT_ORDER_AUTO Should not happen + break; + } } return RENDER_OK; +#endif } void DrawingShape::_clipItem(DrawingContext &dc, Geom::IntRect const & /*area*/) diff --git a/src/display/drawing-shape.h b/src/display/drawing-shape.h index 47b9e807e..405c789e0 100644 --- a/src/display/drawing-shape.h +++ b/src/display/drawing-shape.h @@ -39,6 +39,13 @@ protected: virtual DrawingItem *_pickItem(Geom::Point const &p, double delta, unsigned flags); virtual bool _canClip(); +#ifdef WITH_SVG2 + void _renderFill(DrawingContext &dc); + void _renderStroke(DrawingContext &dc); +#endif + void _renderMarkers(DrawingContext &dc, Geom::IntRect const &area, unsigned flags, + DrawingItem *stop_at); + SPCurve *_curve; SPStyle *_style; NRStyle _nrstyle; -- cgit v1.2.3 From 1eee6e772bc5ab528982db64c68ceb4a46f7f0ac Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Wed, 19 Feb 2014 08:18:55 +0100 Subject: Fix for Bug #1281104 (Open Clipart import dialog crashes with concurrent searches). Fixed bugs: - https://launchpad.net/bugs/1281104 (bzr r13042) --- src/ui/dialog/ocaldialogs.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/ocaldialogs.cpp b/src/ui/dialog/ocaldialogs.cpp index 93fcab863..f676e75fd 100644 --- a/src/ui/dialog/ocaldialogs.cpp +++ b/src/ui/dialog/ocaldialogs.cpp @@ -1166,8 +1166,6 @@ void ImportDialog::on_xml_file_read(const Glib::RefPtr& result // free the document xmlFreeDoc(doc); - // free the global variables that may have been allocated by the parser - xmlCleanupParser(); } @@ -1336,7 +1334,8 @@ ImportDialog::ImportDialog(Gtk::Window& parent_window, FileDialogType file_types */ ImportDialog::~ImportDialog() { - + // free the global variables that may have been allocated by the parser + xmlCleanupParser(); } /** -- cgit v1.2.3 From aaeae24dd99afc7055d71912aba076a838c199b6 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Wed, 19 Feb 2014 21:35:45 +0100 Subject: Fix for SPSwitch updates. Fixed bugs: - https://launchpad.net/bugs/1254373 (bzr r13044) --- src/sp-switch.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/sp-switch.cpp b/src/sp-switch.cpp index b4841c0d0..db6db9909 100644 --- a/src/sp-switch.cpp +++ b/src/sp-switch.cpp @@ -82,16 +82,22 @@ gchar *SPSwitch::description() const { ngettext(_("of %d object"), _("of %d objects"), len), len); } -void SPSwitch::child_added(Inkscape::XML::Node* /*child*/, Inkscape::XML::Node* /*ref*/) { +void SPSwitch::child_added(Inkscape::XML::Node* child, Inkscape::XML::Node* ref) { + SPGroup::child_added(child, ref); + this->_reevaluate(true); } -void SPSwitch::remove_child(Inkscape::XML::Node *) { - this->_reevaluate(); +void SPSwitch::remove_child(Inkscape::XML::Node *child) { + SPGroup::remove_child(child); + + this->_reevaluate(); } -void SPSwitch::order_changed (Inkscape::XML::Node *, Inkscape::XML::Node *, Inkscape::XML::Node *) +void SPSwitch::order_changed (Inkscape::XML::Node *child, Inkscape::XML::Node *old_ref, Inkscape::XML::Node *new_ref) { + SPGroup::order_changed(child, old_ref, new_ref); + this->_reevaluate(); } -- cgit v1.2.3 From 048e27577b22844eaaab36d1884a511092e6ddf7 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Thu, 20 Feb 2014 11:37:22 -0500 Subject: Add test for URI and help with data uris. (bzr r13045) --- src/uri-test.h | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/uri.cpp | 50 +++++++++++++++++++++++++++++--- src/uri.h | 2 ++ 3 files changed, 138 insertions(+), 4 deletions(-) create mode 100644 src/uri-test.h (limited to 'src') diff --git a/src/uri-test.h b/src/uri-test.h new file mode 100644 index 000000000..2a4cdab46 --- /dev/null +++ b/src/uri-test.h @@ -0,0 +1,90 @@ + +#ifndef SEEN_URI_TEST_H +#define SEEN_URI_TEST_H +/* + * Test uri.h + * + * Written to aid with refactoring the uri handling to support fullPath + * and data URIs and also cover code which wasn't before tested. + * + * Copyright 2014 (c) BasisTech Boston + * + */ +#include + +#include "uri.h" + +using Inkscape::URI; + +class URITest : public CxxTest::TestSuite +{ +public: + void stringTest( std::string result, std::string expected ) + { + if ( !result.empty() && !expected.empty() ) { + TS_ASSERT_EQUALS( result, expected ); + } else if ( result.empty() && !expected.empty() ) { + TS_FAIL( std::string("Expected (") + expected + "), found null" ); + } else if ( !result.empty() && expected.empty() ) { + TS_FAIL( std::string("Expected null, found (") + result + ")" ); + } + } + + std::string ValueOrEmpty(const char* s) { + return s == NULL ? std::string() : s; + } + + void toStringTest( std::string uri, std::string expected ) { + stringTest( URI(uri.c_str()).toString(), expected ); + } + void pathTest( std::string uri, std::string expected ) { + stringTest( ValueOrEmpty(URI(uri.c_str()).getPath()), expected ); + } + + void testToString() + { + char const* cases[][2] = { + { "foo", "foo" }, + { "#foo", "#foo" }, + { "blah.svg#h", "blah.svg#h" }, + //{ "data:data", "data:data" }, + }; + + for ( size_t i = 0; i < G_N_ELEMENTS(cases); i++ ) { + toStringTest( std::string(cases[i][0]), std::string(cases[i][1]) ); + } + } + + void testPath() + { + char const* cases[][2] = { + { "foo.svg", "foo.svg" }, + { "foo.svg#bar", "foo.svg" }, + { "#bar", NULL }, + { "data:data", NULL }, + }; + + for ( size_t i = 0; i < G_N_ELEMENTS(cases); i++ ) { + pathTest( ValueOrEmpty(cases[i][0]), ValueOrEmpty(cases[i][1]) ); + } + } + void testFullPath() { + std::ofstream fhl("/tmp/cxxtest-uri.svg", std::ofstream::out); + stringTest( URI("cxxtest-uri.svg").getFullPath("/tmp"), std::string("/tmp/cxxtest-uri.svg") ); + stringTest( URI("cxxtest-uri.svg").getFullPath("/usr/../tmp"), std::string("/tmp/cxxtest-uri.svg") ); + } + +}; + +#endif // SEEN_URI_TEST_H + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/uri.cpp b/src/uri.cpp index 89f6f33e4..a48aa8274 100644 --- a/src/uri.cpp +++ b/src/uri.cpp @@ -11,6 +11,8 @@ #include #include "uri.h" #include +#include +#include // XXX #include #include @@ -26,6 +28,10 @@ URI::URI(gchar const *preformed) throw(BadURIException) { if (!preformed) { throw MalformedURIException(); } + if( strncmp(preformed, "data:", 5)==0 ) { + parseDataUri( preformed + 5 ); + preformed = ""; // g_free? + } uri = xmlParseURI(preformed); if (!uri) { throw MalformedURIException(); @@ -135,6 +141,38 @@ gchar *URI::to_native_filename(gchar const* uri) throw(BadURIException) filename = tmp.toNativeFilename(); return filename; } + +/* + * Parse data:... uris so we can access their data transparently. + * otherwise data: is considered a malformed protocol like http: + * and two // as appended and the data is stored in the path of the uri. + */ +bool URI::parseDataUri(const char *uri) { + + int len = (strchr(uri, ',') - uri) * sizeof(char); + + const char *data; + std::string head; + if (len > 0) { + head = std::string(uri, len); + data = uri + len; + } else { + head = "text/plain"; + data = uri; + } + + //bool base64 = false; + std::cout << "Header: " << head << "\n"; + std::cout << "Data: " << data << "\n"; + /*while(uri < data) { + if (strncmp(uri,"base64",6) == 0) + base64 = true; + if (strncmp(uri,"image/", + data = strchr(uri, ';'); + }*/ + return true; +} + /* * Returns the absolute path to an existing file referenced in this URI, * if the uri is data, the path is empty or the file doesn't exist, then @@ -149,12 +187,16 @@ const std::string URI::getFullPath(std::string const base) const { if(!base.empty() && !path.empty() && path[0] != '/') { path = Glib::build_filename(base, path); } - // Check the existance of the file - if(! g_file_test(path.c_str(), G_FILE_TEST_EXISTS) - || g_file_test(path.c_str(), G_FILE_TEST_IS_DIR) ) { + // Normalise path, this only works if all parts of the path exist + char *output = realpath(path.c_str(), NULL); + if(output == NULL) { + path.clear(); + } else // Re-check the existance of the file (make damn sure) + if(! g_file_test(output, G_FILE_TEST_EXISTS) + || g_file_test(output, G_FILE_TEST_IS_DIR) ) { path.clear(); } - return path; + return std::string( output ); } diff --git a/src/uri.h b/src/uri.h index 74820cb29..74e567805 100644 --- a/src/uri.h +++ b/src/uri.h @@ -121,6 +121,8 @@ public: URI &operator=(URI const &uri); private: + bool parseDataUri(const char *uri); + class Impl { public: static Impl *create(xmlURIPtr uri); -- cgit v1.2.3 From bf6ba105405a7eac70f1d36490d51962a4041ac0 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Thu, 20 Feb 2014 18:58:24 +0100 Subject: Reverting r13045. 1. It contains a memleak realpath allocates new memory if the second argument is NULL. In the added code, this memory is never freed. 2. Breaks build on Windows (realpath(...) not found) 3. Please don't add functions that use C-strings unnecessarily. Simply rewrite parseDataUri to parseDataUri(const std::string &uri), and use C++'s string methods. ("#include " is a huge red flag upon code review) 4. Please read this about "realpath" http://insanecoding.blogspot.ch/2007/11/pathmax-simply-isnt.html (bzr r13046) --- src/uri.cpp | 50 ++++---------------------------------------------- src/uri.h | 2 -- 2 files changed, 4 insertions(+), 48 deletions(-) (limited to 'src') diff --git a/src/uri.cpp b/src/uri.cpp index a48aa8274..89f6f33e4 100644 --- a/src/uri.cpp +++ b/src/uri.cpp @@ -11,8 +11,6 @@ #include #include "uri.h" #include -#include -#include // XXX #include #include @@ -28,10 +26,6 @@ URI::URI(gchar const *preformed) throw(BadURIException) { if (!preformed) { throw MalformedURIException(); } - if( strncmp(preformed, "data:", 5)==0 ) { - parseDataUri( preformed + 5 ); - preformed = ""; // g_free? - } uri = xmlParseURI(preformed); if (!uri) { throw MalformedURIException(); @@ -141,38 +135,6 @@ gchar *URI::to_native_filename(gchar const* uri) throw(BadURIException) filename = tmp.toNativeFilename(); return filename; } - -/* - * Parse data:... uris so we can access their data transparently. - * otherwise data: is considered a malformed protocol like http: - * and two // as appended and the data is stored in the path of the uri. - */ -bool URI::parseDataUri(const char *uri) { - - int len = (strchr(uri, ',') - uri) * sizeof(char); - - const char *data; - std::string head; - if (len > 0) { - head = std::string(uri, len); - data = uri + len; - } else { - head = "text/plain"; - data = uri; - } - - //bool base64 = false; - std::cout << "Header: " << head << "\n"; - std::cout << "Data: " << data << "\n"; - /*while(uri < data) { - if (strncmp(uri,"base64",6) == 0) - base64 = true; - if (strncmp(uri,"image/", - data = strchr(uri, ';'); - }*/ - return true; -} - /* * Returns the absolute path to an existing file referenced in this URI, * if the uri is data, the path is empty or the file doesn't exist, then @@ -187,16 +149,12 @@ const std::string URI::getFullPath(std::string const base) const { if(!base.empty() && !path.empty() && path[0] != '/') { path = Glib::build_filename(base, path); } - // Normalise path, this only works if all parts of the path exist - char *output = realpath(path.c_str(), NULL); - if(output == NULL) { - path.clear(); - } else // Re-check the existance of the file (make damn sure) - if(! g_file_test(output, G_FILE_TEST_EXISTS) - || g_file_test(output, G_FILE_TEST_IS_DIR) ) { + // Check the existance of the file + if(! g_file_test(path.c_str(), G_FILE_TEST_EXISTS) + || g_file_test(path.c_str(), G_FILE_TEST_IS_DIR) ) { path.clear(); } - return std::string( output ); + return path; } diff --git a/src/uri.h b/src/uri.h index 74e567805..74820cb29 100644 --- a/src/uri.h +++ b/src/uri.h @@ -121,8 +121,6 @@ public: URI &operator=(URI const &uri); private: - bool parseDataUri(const char *uri); - class Impl { public: static Impl *create(xmlURIPtr uri); -- cgit v1.2.3 From 8a6810210b3b1ce2cb82055063eee635174be637 Mon Sep 17 00:00:00 2001 From: Raphael Rosch Date: Thu, 20 Feb 2014 14:22:58 -0500 Subject: crash on cut n paste, or alt+scroll.. Fixed bugs: - https://launchpad.net/bugs/1171109 (bzr r13047) --- src/document.cpp | 16 +++++++--------- src/id-clash.cpp | 39 ++++++++++++++++++++++++++++----------- 2 files changed, 35 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/document.cpp b/src/document.cpp index 470d0cc5a..112503320 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -1544,15 +1544,13 @@ void SPDocument::importDefs(SPDocument *source) // Prevent duplicates of solid swatches by checking if equivalent swatch already exists if (src && SP_IS_GRADIENT(src)) { SPGradient *gr = SP_GRADIENT(src); - if (gr->isSolid() || gr->getVector()->isSolid()) { - for (SPObject *trg = this->getDefs()->firstChild() ; trg ; trg = trg->getNext()) { - if (trg && SP_IS_GRADIENT(trg) && src != trg) { - if (gr->isEquivalent(SP_GRADIENT(trg))) { - // Change object references to the existing equivalent gradient - change_def_references(src, trg); - duplicate = true; - break; - } + for (SPObject *trg = this->getDefs()->firstChild() ; trg ; trg = trg->getNext()) { + if (trg && SP_IS_GRADIENT(trg) && src != trg) { + if (gr->isEquivalent(SP_GRADIENT(trg))) { + // Change object references to the existing equivalent gradient + change_def_references(src, trg); + duplicate = true; + break; } } } diff --git a/src/id-clash.cpp b/src/id-clash.cpp index c8eacfe02..76b8e6ff8 100644 --- a/src/id-clash.cpp +++ b/src/id-clash.cpp @@ -203,27 +203,44 @@ change_clashing_ids(SPDocument *imported_doc, SPDocument *current_doc, id_changelist_type *id_changes) { const gchar *id = elem->getId(); + bool fix_clashing_ids = true; if (id && current_doc->getObjectById(id)) { // Choose a new ID. // To try to preserve any meaningfulness that the original ID // may have had, the new ID is the old ID followed by a hyphen // and one or more digits. - std::string old_id(id); - std::string new_id(old_id + '-'); - for (;;) { - new_id += "0123456789"[std::rand() % 10]; - const char *str = new_id.c_str(); - if (current_doc->getObjectById(str) == NULL && - imported_doc->getObjectById(str) == NULL) break; + + if (SP_IS_GRADIENT(elem)) { + SPObject *cd_obj = current_doc->getObjectById(id); + + if (cd_obj && SP_IS_GRADIENT(cd_obj)) { + SPGradient *cd_gr = SP_GRADIENT(cd_obj); + if (cd_gr->isEquivalent(SP_GRADIENT(elem))) { + fix_clashing_ids = false; + } + } } - // Change to the new ID - elem->getRepr()->setAttribute("id", new_id.c_str()); - // Make a note of this change, if we need to fix up refs to it - if (refmap->find(old_id) != refmap->end()) + + if (fix_clashing_ids) { + std::string old_id(id); + std::string new_id(old_id + '-'); + for (;;) { + new_id += "0123456789"[std::rand() % 10]; + const char *str = new_id.c_str(); + if (current_doc->getObjectById(str) == NULL && + imported_doc->getObjectById(str) == NULL) break; + } + // Change to the new ID + + elem->getRepr()->setAttribute("id", new_id.c_str()); + // Make a note of this change, if we need to fix up refs to it + if (refmap->find(old_id) != refmap->end()) id_changes->push_back(id_changeitem_type(elem, old_id)); + } } + // recurse for (SPObject *child = elem->firstChild(); child; child = child->getNext() ) { -- cgit v1.2.3 From f64f2824ac11e9fb885bce8754fa6327831f3d74 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Thu, 20 Feb 2014 15:12:35 -0500 Subject: Add data uri checking back into the code (bzr r13047.1.1) --- src/uri-test.h | 2 +- src/uri.cpp | 22 ++++++++++++++++++++++ src/uri.h | 2 ++ 3 files changed, 25 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/uri-test.h b/src/uri-test.h index 2a4cdab46..9cb4ad639 100644 --- a/src/uri-test.h +++ b/src/uri-test.h @@ -47,7 +47,7 @@ public: { "foo", "foo" }, { "#foo", "#foo" }, { "blah.svg#h", "blah.svg#h" }, - //{ "data:data", "data:data" }, + { "data:data", "data:data" }, }; for ( size_t i = 0; i < G_N_ELEMENTS(cases); i++ ) { diff --git a/src/uri.cpp b/src/uri.cpp index 89f6f33e4..219bc1c96 100644 --- a/src/uri.cpp +++ b/src/uri.cpp @@ -26,6 +26,15 @@ URI::URI(gchar const *preformed) throw(BadURIException) { if (!preformed) { throw MalformedURIException(); } + // One day Inkscape::URI should use std::string by default + std::string path = std::string(preformed); + // Check for a data URI and parse seperately because + // libxml can't handle this; although svgs need to. + if( path.compare(0, 5, "data:") == 0 ) { + parseDataUri( path ); + // Empty the uri for libxml + preformed = ""; + } uri = xmlParseURI(preformed); if (!uri) { throw MalformedURIException(); @@ -135,6 +144,17 @@ gchar *URI::to_native_filename(gchar const* uri) throw(BadURIException) filename = tmp.toNativeFilename(); return filename; } + +/* + * Parse data:... uris so we can access their data transparently. + * otherwise data: is considered a malformed protocol like http: + * and two // as appended and the data is stored in the path of the uri. + */ +bool URI::parseDataUri(const std::string &uri) { + + return true; +} + /* * Returns the absolute path to an existing file referenced in this URI, * if the uri is data, the path is empty or the file doesn't exist, then @@ -149,6 +169,8 @@ const std::string URI::getFullPath(std::string const base) const { if(!base.empty() && !path.empty() && path[0] != '/') { path = Glib::build_filename(base, path); } + // Path normalisation should go here TODO + // Check the existance of the file if(! g_file_test(path.c_str(), G_FILE_TEST_EXISTS) || g_file_test(path.c_str(), G_FILE_TEST_IS_DIR) ) { diff --git a/src/uri.h b/src/uri.h index 74820cb29..a1450c27b 100644 --- a/src/uri.h +++ b/src/uri.h @@ -121,6 +121,8 @@ public: URI &operator=(URI const &uri); private: + bool parseDataUri(const std::string &uri); + class Impl { public: static Impl *create(xmlURIPtr uri); -- cgit v1.2.3 From 7f9907d4fa5836d20555343dfe5e13649cad1f30 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Thu, 20 Feb 2014 15:48:07 -0500 Subject: Not finished by improved data uri support (bzr r13047.1.2) --- src/uri-test.h | 19 ++++++++++++++++--- src/uri.cpp | 18 ++++++++++++++++++ src/uri.h | 5 +++++ 3 files changed, 39 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/uri-test.h b/src/uri-test.h index 9cb4ad639..4a2499a77 100644 --- a/src/uri-test.h +++ b/src/uri-test.h @@ -46,15 +46,28 @@ public: char const* cases[][2] = { { "foo", "foo" }, { "#foo", "#foo" }, - { "blah.svg#h", "blah.svg#h" }, - { "data:data", "data:data" }, + { "blah.svg#h", "blah.svg#h" }, + { "data:data", "data:data" }, + { "data:head,data", "data:head,data" }, }; for ( size_t i = 0; i < G_N_ELEMENTS(cases); i++ ) { toStringTest( std::string(cases[i][0]), std::string(cases[i][1]) ); } } + void testDataUri() + { + char const* cases[][2] = { + { "data:HAIL-DATUM", "HAIL-DATUM" }, + { "data:head,HAIL-DATUM", "HAIL-DATUM" }, + }; + + for ( size_t i = 0; i < G_N_ELEMENTS(cases); i++ ) { + // XXX replace this with a getData test + toStringTest( std::string(cases[i][0]), std::string(cases[i][1]) ); + } + } void testPath() { char const* cases[][2] = { @@ -71,7 +84,7 @@ public: void testFullPath() { std::ofstream fhl("/tmp/cxxtest-uri.svg", std::ofstream::out); stringTest( URI("cxxtest-uri.svg").getFullPath("/tmp"), std::string("/tmp/cxxtest-uri.svg") ); - stringTest( URI("cxxtest-uri.svg").getFullPath("/usr/../tmp"), std::string("/tmp/cxxtest-uri.svg") ); + //stringTest( URI("cxxtest-uri.svg").getFullPath("/usr/../tmp"), std::string("/tmp/cxxtest-uri.svg") ); } }; diff --git a/src/uri.cpp b/src/uri.cpp index 219bc1c96..33a2fd13d 100644 --- a/src/uri.cpp +++ b/src/uri.cpp @@ -14,6 +14,8 @@ #include #include +#include + namespace Inkscape { URI::URI(const URI &uri) { @@ -151,6 +153,22 @@ gchar *URI::to_native_filename(gchar const* uri) throw(BadURIException) * and two // as appended and the data is stored in the path of the uri. */ bool URI::parseDataUri(const std::string &uri) { + unsigned int track = 5; // Ignore start of uri 'data:' + + unsigned int head_end = uri.find(",", track); + if (head_end < uri.length()) { + std::string head = uri.substr(track, head_end); + // Head split by ';' for mime-type, charset and base64 bool + track = head_end + 1; + } else { + head = "No Head"; + } + data = uri.substr(track, uri.length()-track); + if(data_base64) { + // Parse data here + } else { + // Fill data here + } return true; } diff --git a/src/uri.h b/src/uri.h index a1450c27b..11b091928 100644 --- a/src/uri.h +++ b/src/uri.h @@ -123,6 +123,11 @@ public: private: bool parseDataUri(const std::string &uri); + std::string data_mimetype; + std::string data_charset; + bool data_base64; + std::string data; + class Impl { public: static Impl *create(xmlURIPtr uri); -- cgit v1.2.3 From eb6473340d55ce97b87d5ae6336afb5c1faea303 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Fri, 21 Feb 2014 13:40:25 +0100 Subject: Symbols dialog: update currentDesktop and currentDocument when document replaced. (bzr r13048) --- src/ui/dialog/symbols.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index 98754fb4f..62a2f8572 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -381,8 +381,10 @@ void SymbolsDialog::selectionChanged(Inkscape::Selection *selection) { } } -void SymbolsDialog::documentReplaced(SPDesktop */*desktop*/, SPDocument */*document*/) +void SymbolsDialog::documentReplaced(SPDesktop *desktop, SPDocument *document) { + currentDesktop = desktop; + currentDocument = document; rebuild(); } -- cgit v1.2.3 From 12e03b939f58c6b6dc5495e0559fe47d7a73bb48 Mon Sep 17 00:00:00 2001 From: David Mathog Date: Sat, 22 Feb 2014 10:03:23 +0100 Subject: Fix 'preserveAspectRatio' attribute of bitmap images in EMF/WMF import/export (bug #1278645). Fixed bugs: - https://launchpad.net/bugs/1278645 (bzr r13049) --- src/extension/internal/emf-inout.cpp | 2 ++ src/extension/internal/emf-print.cpp | 10 ++++----- src/extension/internal/wmf-inout.cpp | 10 +++++---- src/extension/internal/wmf-print.cpp | 16 ++++++++------ src/sp-image.cpp | 42 ++++++++---------------------------- 5 files changed, 32 insertions(+), 48 deletions(-) (limited to 'src') diff --git a/src/extension/internal/emf-inout.cpp b/src/extension/internal/emf-inout.cpp index 276dee362..b73c5e9e5 100644 --- a/src/extension/internal/emf-inout.cpp +++ b/src/extension/internal/emf-inout.cpp @@ -554,6 +554,7 @@ uint32_t Emf::add_image(PEMF_CALLBACK_DATA d, void *pEmr, uint32_t cbBits, uint else { *(d->defs) += " xlink:href=\"data:image/png;base64,"; } *(d->defs) += base64String; *(d->defs) += "\"\n"; + *(d->defs) += " preserveAspectRatio=\"none\"\n"; *(d->defs) += " />\n"; @@ -1531,6 +1532,7 @@ void Emf::common_image_extraction(PEMF_CALLBACK_DATA d, void *pEmr, tmp_image << "\"\n height=\"" << dh << "\"\n width=\"" << dw << "\"\n"; tmp_image << " transform=" << current_matrix(d, dx, dy, 1); // calculate appropriate offset + tmp_image << " preserveAspectRatio=\"none\"\n"; tmp_image << "/> \n"; *(d->outsvg) += tmp_image.str().c_str(); diff --git a/src/extension/internal/emf-print.cpp b/src/extension/internal/emf-print.cpp index 6d5bb6f4b..c103100b3 100644 --- a/src/extension/internal/emf-print.cpp +++ b/src/extension/internal/emf-print.cpp @@ -1562,7 +1562,7 @@ unsigned int PrintEmf::image( unsigned int w, /** width of bitmap */ unsigned int h, /** height of bitmap */ unsigned int rs, /** row stride (normally w*4) */ - Geom::Affine const &/*tf_ignore*/, /** WRONG affine transform, use the one from m_tr_stack */ + Geom::Affine const &tf_rect, /** affine transform only used for defining location and size of rect, for all other tranforms, use the one from m_tr_stack */ SPStyle const *style) /** provides indirect link to image object */ { double x1, y1, dw, dh; @@ -1574,10 +1574,10 @@ unsigned int PrintEmf::image( g_error("Fatal programming error in PrintEmf::image at EMRHEADER"); } - x1 = atof(style->object->getAttribute("x")); - y1 = atof(style->object->getAttribute("y")); - dw = atof(style->object->getAttribute("width")); - dh = atof(style->object->getAttribute("height")); + x1 = tf_rect[4]; + y1 = tf_rect[5]; + dw = ((double) w) * tf_rect[0]; + dh = ((double) h) * tf_rect[3]; Geom::Point pLL(x1, y1); Geom::Point pLL2 = pLL * tf; //location of LL corner in Inkscape coordinates diff --git a/src/extension/internal/wmf-inout.cpp b/src/extension/internal/wmf-inout.cpp index fc54350df..3c348f5c4 100644 --- a/src/extension/internal/wmf-inout.cpp +++ b/src/extension/internal/wmf-inout.cpp @@ -525,6 +525,7 @@ uint32_t Wmf::add_dib_image(PWMF_CALLBACK_DATA d, const char *dib, uint32_t iUsa else { *(d->defs) += " xlink:href=\"data:image/png;base64,"; } *(d->defs) += base64String; *(d->defs) += "\"\n"; + *(d->defs) += " preserveAspectRatio=\"none\"\n"; *(d->defs) += " />\n"; @@ -619,6 +620,7 @@ uint32_t Wmf::add_bm16_image(PWMF_CALLBACK_DATA d, U_BITMAP16 Bm16, const char * *(d->defs) += " xlink:href=\"data:image/png;base64,"; *(d->defs) += base64String; *(d->defs) += "\"\n"; + *(d->defs) += " preserveAspectRatio=\"none\"\n"; *(d->defs) += " />\n"; @@ -1269,6 +1271,7 @@ void Wmf::common_dib_to_image(PWMF_CALLBACK_DATA d, const char *dib, SVGOStringStream tmp_image; int dibparams; + tmp_image << "\n\t outsvg) += tmp_image.str().c_str(); + tmp_image << " preserveAspectRatio=\"none\"\n"; + tmp_image << "/> \n"; - *(d->outsvg) += "/> \n"; + *(d->outsvg) += tmp_image.str().c_str(); *(d->path) = ""; } diff --git a/src/extension/internal/wmf-print.cpp b/src/extension/internal/wmf-print.cpp index 1c7b42c82..32c7ac0bd 100644 --- a/src/extension/internal/wmf-print.cpp +++ b/src/extension/internal/wmf-print.cpp @@ -1103,7 +1103,7 @@ unsigned int PrintWmf::image( unsigned int w, /** width of bitmap */ unsigned int h, /** height of bitmap */ unsigned int rs, /** row stride (normally w*4) */ - Geom::Affine const & /*tf_ignore*/, /** WRONG affine transform, use the one from m_tr_stack */ + Geom::Affine const &tf_rect, /** affine transform only used for defining location and size of rect, for all other tranforms, use the one from m_tr_stack */ SPStyle const *style) /** provides indirect link to image object */ { double x1, y1, dw, dh; @@ -1115,15 +1115,19 @@ unsigned int PrintWmf::image( g_error("Fatal programming error in PrintWmf::image at EMRHEADER"); } - x1 = g_ascii_strtod(style->object->getAttribute("x"), NULL); - y1 = g_ascii_strtod(style->object->getAttribute("y"), NULL); - dw = g_ascii_strtod(style->object->getAttribute("width"), NULL); - dh = g_ascii_strtod(style->object->getAttribute("height"), NULL); + x1 = tf_rect[4]; + y1 = tf_rect[5]; + dw = ((double) w) * tf_rect[0]; + dh = ((double) h) * tf_rect[3]; Geom::Point pLL(x1, y1); Geom::Point pLL2 = pLL * tf; //location of LL corner in Inkscape coordinates + /* adjust scale of w and h. This works properly when there is no rotation. The values are + a bit strange when there is rotation, but since WMF cannot handle rotation in any case, all + answers are equally wrong. + */ Geom::Point pWH(dw, dh); - Geom::Point pWH2 = pWH * tf.withoutTranslation(); //adjust scale + Geom::Point pWH2 = pWH * tf.withoutTranslation(); char *px; uint32_t cbPx; diff --git a/src/sp-image.cpp b/src/sp-image.cpp index 5f630f7b7..2c20331a9 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -500,39 +500,15 @@ void SPImage::print(SPPrintContext *ctx) { int w = pb->width(); int h = pb->height(); int rs = pb->rowstride(); - //int pixskip = gdk_pixbuf_get_n_channels(pb) * gdk_pixbuf_get_bits_per_sample(pb) / 8; - int pixskip = 4; - - if (this->aspect_align == SP_ASPECT_NONE) { - Geom::Affine t; - Geom::Translate tp(this->x.computed, this->y.computed); - Geom::Scale s(this->width.computed, -this->height.computed); - Geom::Translate ti(0.0, -1.0); - t = s * tp; - t = ti * t; - sp_print_image_R8G8B8A8_N(ctx, px, w, h, rs, t, this->style); - } else { // preserveAspectRatio - double vw = this->width.computed / this->sx; - double vh = this->height.computed / this->sy; - - int trimwidth = std::min(w, ceil(this->width.computed / vw * w)); - int trimheight = std::min(h, ceil(this->height.computed / vh * h)); - int trimx = std::max(0, floor((this->x.computed - this->ox) / vw * w)); - int trimy = std::max(0, floor((this->y.computed - this->oy) / vh * h)); - - double vx = std::max(this->ox, this->x.computed); - double vy = std::max(this->oy, this->y.computed); - double vcw = std::min(this->width.computed, vw); - double vch = std::min(this->height.computed, vh); - - Geom::Affine t; - Geom::Translate tp(vx, vy); - Geom::Scale s(vcw, -vch); - Geom::Translate ti(0.0, -1.0); - t = s * tp; - t = ti * t; - sp_print_image_R8G8B8A8_N(ctx, px + trimx*pixskip + trimy*rs, trimwidth, trimheight, rs, t, this->style); - } + + double vx = this->ox; + double vy = this->oy; + + Geom::Affine t; + Geom::Translate tp(vx, vy); + Geom::Scale s(this->sx, this->sy); + t = s * tp; + sp_print_image_R8G8B8A8_N(ctx, px, w, h, rs, t, this->style); delete pb; } } -- cgit v1.2.3 From b3dad97ff32d34dc38ce51ebbdc0e9555a9ce5e6 Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Sat, 22 Feb 2014 16:37:43 -0500 Subject: offset of viewBox on document unit change (Bug 1280684) Fixed bugs: - https://launchpad.net/bugs/1280684 (bzr r13050) --- src/ui/dialog/document-properties.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index d344fb1d6..0411c789c 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -1734,8 +1734,14 @@ void DocumentProperties::onDocUnitChange() prefs->setBool("/options/transform/gradient", true); { ShapeEditor::blockSetItem(true); + gdouble viewscale = doc->getWidth().value("px")/doc->getRoot()->viewBox.width(); + if (doc->getHeight().value("px")/doc->getRoot()->viewBox.height() < viewscale) + viewscale = doc->getHeight().value("px")/doc->getRoot()->viewBox.height(); gdouble scale = Inkscape::Util::Quantity::convert(1, old_doc_unit, doc_unit); - doc->getRoot()->scaleChildItemsRec(Geom::Scale(scale), Geom::Point(0, doc->getHeight().value("px"))); + doc->getRoot()->scaleChildItemsRec(Geom::Scale(scale), Geom::Point(-viewscale*doc->getRoot()->viewBox.min()[Geom::X] + + (doc->getWidth().value("px") - viewscale*doc->getRoot()->viewBox.width())/2, + viewscale*doc->getRoot()->viewBox.min()[Geom::Y] + + (doc->getHeight().value("px") + viewscale*doc->getRoot()->viewBox.height())/2)); ShapeEditor::blockSetItem(false); } prefs->setBool("/options/transform/stroke", transform_stroke); -- cgit v1.2.3 From 9657576ce874d32248bbbc2dc204ac2fb6121dea Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sun, 23 Feb 2014 20:30:28 +0100 Subject: Fix for selcue settings. Fixed bugs: - https://launchpad.net/bugs/1274659 (bzr r13051) --- src/ui/tools/dropper-tool.cpp | 2 ++ src/ui/tools/freehand-base.cpp | 2 ++ src/ui/tools/measure-tool.cpp | 2 ++ src/ui/tools/text-tool.cpp | 2 ++ src/ui/tools/zoom-tool.cpp | 2 ++ 5 files changed, 10 insertions(+) (limited to 'src') diff --git a/src/ui/tools/dropper-tool.cpp b/src/ui/tools/dropper-tool.cpp index 9c47b50e9..88ed342df 100644 --- a/src/ui/tools/dropper-tool.cpp +++ b/src/ui/tools/dropper-tool.cpp @@ -152,6 +152,8 @@ void DropperTool::finish() { #endif cursor_dropper_fill = NULL; } + + ToolBase::finish(); } /** diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index c3c269743..1e0e6b3b6 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -167,6 +167,8 @@ void FreehandBase::finish() { } spdc_free_colors(this); + + ToolBase::finish(); } void FreehandBase::set(const Inkscape::Preferences::Entry& /*value*/) { diff --git a/src/ui/tools/measure-tool.cpp b/src/ui/tools/measure-tool.cpp index 0d823dfda..4d7f1e074 100644 --- a/src/ui/tools/measure-tool.cpp +++ b/src/ui/tools/measure-tool.cpp @@ -254,6 +254,8 @@ void MeasureTool::finish() { sp_canvas_item_ungrab(this->grabbed, GDK_CURRENT_TIME); this->grabbed = NULL; } + + ToolBase::finish(); } //void MeasureTool::setup() { diff --git a/src/ui/tools/text-tool.cpp b/src/ui/tools/text-tool.cpp index 9b5ab1016..ba68c7829 100644 --- a/src/ui/tools/text-tool.cpp +++ b/src/ui/tools/text-tool.cpp @@ -266,6 +266,8 @@ void TextTool::finish() { } this->text_selection_quads.clear(); + + ToolBase::finish(); } bool TextTool::item_handler(SPItem* item, GdkEvent* event) { diff --git a/src/ui/tools/zoom-tool.cpp b/src/ui/tools/zoom-tool.cpp index d4ede1053..0996e6cf4 100644 --- a/src/ui/tools/zoom-tool.cpp +++ b/src/ui/tools/zoom-tool.cpp @@ -63,6 +63,8 @@ void ZoomTool::finish() { sp_canvas_item_ungrab(this->grabbed, GDK_CURRENT_TIME); this->grabbed = NULL; } + + ToolBase::finish(); } void ZoomTool::setup() { -- cgit v1.2.3 From 457a6606406c6b5830fc6990866b1d2cd847602b Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Sun, 23 Feb 2014 19:48:29 -0500 Subject: fix typos in page-sizer (Bug 1240308) Fixed bugs: - https://launchpad.net/bugs/1240308 (bzr r13052) --- src/ui/widget/page-sizer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index b13567adb..b35f35403 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -555,7 +555,7 @@ PageSizer::find_paper_size (Inkscape::Util::Quantity w, Inkscape::Util::Quantity { double smaller = w.quantity; double larger = h.quantity; - if ( h < w ) { + if ( h.quantity < w.quantity ) { smaller = h.quantity; larger = w.quantity; } @@ -568,7 +568,7 @@ PageSizer::find_paper_size (Inkscape::Util::Quantity w, Inkscape::Util::Quantity double smallX = Inkscape::Util::Quantity::convert(paper.smaller, paper.unit, w.unit); double largeX = Inkscape::Util::Quantity::convert(paper.larger, paper.unit, w.unit); - g_return_val_if_fail(smallX <= largeX, _paperSizeListStore->children().end()); + g_return_val_if_fail(smallX < largeX + 0.001, _paperSizeListStore->children().end()); if ((std::abs(smaller - smallX) <= 0.1) && (std::abs(larger - largeX) <= 0.1) ) { -- cgit v1.2.3 From f6060c9447e6f2e5a70e957c19bd4eb1ae4babef Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Mon, 24 Feb 2014 20:32:07 +0100 Subject: inspired by r13052, fix up the code to hopefully work when someone has different units for height and width of the page. Fixed bugs: - https://launchpad.net/bugs/1240308 (bzr r13053) --- src/ui/widget/page-sizer.cpp | 32 ++++++++++++++++++-------------- src/util/units.cpp | 13 ++++++++++--- src/util/units.h | 8 +++++++- 3 files changed, 35 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index b35f35403..eae0d4a95 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -547,36 +547,40 @@ PageSizer::updateFitMarginsUI(Inkscape::XML::Node *nv_repr) /** * Returns an iterator pointing to a row in paperSizeListStore which - * contains a paper of the specified size (specified in px), or + * contains a paper of the specified size, or * paperSizeListStore->children().end() if no such paper exists. + * + * The code is not tested for the case where w and h have different units. */ Gtk::ListStore::iterator PageSizer::find_paper_size (Inkscape::Util::Quantity w, Inkscape::Util::Quantity h) const { - double smaller = w.quantity; - double larger = h.quantity; - if ( h.quantity < w.quantity ) { - smaller = h.quantity; larger = w.quantity; + using Inkscape::Util::Quantity; + using std::swap; + + // The code below assumes that w < h, so make sure that's the case: + if ( h < w ) { + swap(h,w); } - g_return_val_if_fail(smaller <= larger, _paperSizeListStore->children().end()); + g_return_val_if_fail(w <= h, _paperSizeListStore->children().end()); std::map::const_iterator iter; for (iter = _paperSizeTable.begin() ; iter != _paperSizeTable.end() ; ++iter) { PaperSize paper = iter->second; - double smallX = Inkscape::Util::Quantity::convert(paper.smaller, paper.unit, w.unit); - double largeX = Inkscape::Util::Quantity::convert(paper.larger, paper.unit, w.unit); + Quantity smallX (paper.smaller, paper.unit); + Quantity largeX (paper.larger, paper.unit); - g_return_val_if_fail(smallX < largeX + 0.001, _paperSizeListStore->children().end()); + g_return_val_if_fail(smallX.quantity < largeX.quantity + 0.001, _paperSizeListStore->children().end()); - if ((std::abs(smaller - smallX) <= 0.1) && - (std::abs(larger - largeX) <= 0.1) ) { - Gtk::ListStore::iterator p; + if ( are_near(w, smallX, 0.1) && are_near(h, largeX, 0.1) ) { + Gtk::ListStore::iterator p = _paperSizeListStore->children().begin(); + Gtk::ListStore::iterator pend = _paperSizeListStore->children().end(); // We need to search paperSizeListStore explicitly for the // specified paper size because it is sorted in a different // way than paperSizeTable (which is sorted alphabetically) - for (p = _paperSizeListStore->children().begin(); p != _paperSizeListStore->children().end(); ++p) { + for ( ; p != pend; ++p) { if ((*p)[_paperSizeListColumns.nameColumn] == paper.name) { return p; } @@ -601,7 +605,7 @@ PageSizer::fire_fit_canvas_to_selection_or_drawing() SPDocument *doc; SPNamedView *nv; Inkscape::XML::Node *nv_repr; - + if ((doc = sp_desktop_document(SP_ACTIVE_DESKTOP)) && (nv = sp_document_namedview(doc, 0)) && (nv_repr = nv->getRepr())) { diff --git a/src/util/units.cpp b/src/util/units.cpp index 40cce028d..d2053f60b 100644 --- a/src/util/units.cpp +++ b/src/util/units.cpp @@ -505,16 +505,23 @@ double Quantity::convert(double from_dist, char const *from, char const *to) return convert(from_dist, unit_table.getUnit(from), unit_table.getUnit(to)); } -bool Quantity::operator<(Quantity const &other) const +bool Quantity::operator<(Quantity const &rhs) const { - if (unit->type != other.unit->type) { + if (unit->type != rhs.unit->type) { g_warning("Incompatible units"); return false; } - return quantity < other.value(unit); + return quantity < rhs.value(unit); } bool Quantity::operator==(Quantity const &other) const { + /** \fixme This is overly strict. I think we should change this to: + if (unit->type != other.unit->type) { + g_warning("Incompatible units"); + return false; + } + return are_near(quantity, other.value(unit)); + */ return (*unit == *other.unit) && (quantity == other.quantity); } diff --git a/src/util/units.h b/src/util/units.h index 597371369..efe1dbec7 100644 --- a/src/util/units.h +++ b/src/util/units.h @@ -16,6 +16,7 @@ #include #include #include +#include <2geom/coord.h> #include "svg/svg-length.h" #include "unordered-containers.h" @@ -112,10 +113,15 @@ public: static double convert(double from_dist, char const *from, char const *to); /** Comparison operators. */ - bool operator<(Quantity const &other) const; + bool operator<(Quantity const &rhs) const; bool operator==(Quantity const &other) const; }; +inline bool are_near(Quantity const &a, Quantity const &b, double eps=Geom::EPSILON) +{ + return Geom::are_near(a.quantity, b.value(a.unit), eps); +} + class UnitTable { public: /** -- cgit v1.2.3 From 5033a179a05667c0de3ba2cd81595f435edbc85b Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Mon, 24 Feb 2014 21:01:23 +0100 Subject: Set the order of resize handles back to what they were before r12400. Now it's possible again to access all handles for horizontal lines + geometric bbox Fixed bugs: - https://launchpad.net/bugs/1204193 (bzr r13054) --- src/seltrans-handles.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/seltrans-handles.cpp b/src/seltrans-handles.cpp index 6dd94d297..2f9fb9076 100644 --- a/src/seltrans-handles.cpp +++ b/src/seltrans-handles.cpp @@ -17,22 +17,22 @@ SPSelTransHandle const hands[] = { //center handle will be 0 so we can reference it quickly. {HANDLE_CENTER, SP_ANCHOR_CENTER, GDK_CROSSHAIR, 12, 0.5, 0.5}, //handle-type anchor-nudge cursor image x y - {HANDLE_STRETCH, SP_ANCHOR_S, GDK_TOP_SIDE, 3, 0.5, 1}, - {HANDLE_STRETCH, SP_ANCHOR_W, GDK_RIGHT_SIDE, 2, 1, 0.5}, - {HANDLE_STRETCH, SP_ANCHOR_N, GDK_BOTTOM_SIDE, 3, 0.5, 0}, - {HANDLE_STRETCH, SP_ANCHOR_E, GDK_LEFT_SIDE, 2, 0, 0.5}, {HANDLE_SCALE, SP_ANCHOR_SE, GDK_TOP_LEFT_CORNER, 0, 0, 1}, + {HANDLE_STRETCH, SP_ANCHOR_S, GDK_TOP_SIDE, 3, 0.5, 1}, {HANDLE_SCALE, SP_ANCHOR_SW, GDK_TOP_RIGHT_CORNER, 1, 1, 1}, + {HANDLE_STRETCH, SP_ANCHOR_W, GDK_RIGHT_SIDE, 2, 1, 0.5}, {HANDLE_SCALE, SP_ANCHOR_NW, GDK_BOTTOM_RIGHT_CORNER, 0, 1, 0}, + {HANDLE_STRETCH, SP_ANCHOR_N, GDK_BOTTOM_SIDE, 3, 0.5, 0}, {HANDLE_SCALE, SP_ANCHOR_NE, GDK_BOTTOM_LEFT_CORNER, 1, 0, 0}, - {HANDLE_SKEW, SP_ANCHOR_S, GDK_SB_H_DOUBLE_ARROW, 8, 0.5, 1}, - {HANDLE_SKEW, SP_ANCHOR_W, GDK_SB_V_DOUBLE_ARROW, 9, 1, 0.5}, - {HANDLE_SKEW, SP_ANCHOR_N, GDK_SB_H_DOUBLE_ARROW, 10, 0.5, 0}, - {HANDLE_SKEW, SP_ANCHOR_E, GDK_SB_V_DOUBLE_ARROW, 11, 0, 0.5}, + {HANDLE_STRETCH, SP_ANCHOR_E, GDK_LEFT_SIDE, 2, 0, 0.5}, {HANDLE_ROTATE, SP_ANCHOR_SE, GDK_EXCHANGE, 4, 0, 1}, + {HANDLE_SKEW, SP_ANCHOR_S, GDK_SB_H_DOUBLE_ARROW, 8, 0.5, 1}, {HANDLE_ROTATE, SP_ANCHOR_SW, GDK_EXCHANGE, 5, 1, 1}, + {HANDLE_SKEW, SP_ANCHOR_W, GDK_SB_V_DOUBLE_ARROW, 9, 1, 0.5}, {HANDLE_ROTATE, SP_ANCHOR_NW, GDK_EXCHANGE, 6, 1, 0}, + {HANDLE_SKEW, SP_ANCHOR_N, GDK_SB_H_DOUBLE_ARROW, 10, 0.5, 0}, {HANDLE_ROTATE, SP_ANCHOR_NE, GDK_EXCHANGE, 7, 0, 0}, + {HANDLE_SKEW, SP_ANCHOR_E, GDK_SB_V_DOUBLE_ARROW, 11, 0, 0.5}, }; /* -- cgit v1.2.3 From 0917cc6ed7207c0535360dd757705bda30410a47 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Mon, 24 Feb 2014 21:28:00 +0100 Subject: Fix infinite loop (?) by disabling saving the order of filters when they are reordered by drag&drop in the filter editor dialog. (bug 1239296) Fixed bugs: - https://launchpad.net/bugs/1239296 (bzr r13055) --- src/ui/dialog/filter-effects-dialog.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index 6a3a4c3f1..e8b09db8b 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -1515,11 +1515,16 @@ void FilterEffectsDialog::FilterModifier::on_name_edited(const Glib::ustring& pa } void FilterEffectsDialog::FilterModifier::on_filter_reorder(const Gtk::TreeModel::Path& /*path*/) { +/* The code below is bugged. Use of "object->getRepr()->setPosition(0)" is dangerous! + Writing back the reordered list to XML (reordering XML nodes) should be implemented differently. + Note that the dialog does also not update its list of filters when the order is manually changed + using the XML dialog for(Gtk::TreeModel::iterator i = _model->children().begin(); i != _model->children().end(); ++i) { SPObject* object = (*i)[_columns.filter]; - if(object && object->getRepr()) + if(object && object->getRepr()) ; object->getRepr()->setPosition(0); } +*/ } void FilterEffectsDialog::FilterModifier::on_selection_toggled(const Glib::ustring& path) -- cgit v1.2.3 From b777ba99030a6ae4b44bb0a78ce6282f2d99cbe8 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Mon, 24 Feb 2014 20:09:35 -0500 Subject: Move filter reordering closer to the layers.cpp patern of reordering xml (bzr r13056) --- src/ui/dialog/filter-effects-dialog.cpp | 11 ++++++----- src/ui/dialog/filter-effects-dialog.h | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index e8b09db8b..b763776c6 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -1363,11 +1363,9 @@ FilterEffectsDialog::FilterModifier::FilterModifier(FilterEffectsDialog& d) sw->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); _list.get_column(1)->set_resizable(true); _list.set_reorderable(true); + _list.enable_model_drag_dest (Gdk::ACTION_MOVE); - // We can track the drag/drop reordering from the row_delete (occurs after - // row_inserted and may occur many times when adding a new item) - _model->signal_row_deleted().connect( - sigc::mem_fun(*this, &FilterModifier::on_filter_reorder)); + _list.signal_drag_drop().connect( sigc::mem_fun(*this, &FilterModifier::on_filter_move), false ); sw->set_shadow_type(Gtk::SHADOW_IN); show_all_children(); @@ -1514,7 +1512,9 @@ void FilterEffectsDialog::FilterModifier::on_name_edited(const Glib::ustring& pa } } -void FilterEffectsDialog::FilterModifier::on_filter_reorder(const Gtk::TreeModel::Path& /*path*/) { +bool FilterEffectsDialog::FilterModifier::on_filter_move(const Glib::RefPtr& /*context*/, int x, int y, guint /*time*/) { + +//const Gtk::TreeModel::Path& /*path*/) { /* The code below is bugged. Use of "object->getRepr()->setPosition(0)" is dangerous! Writing back the reordered list to XML (reordering XML nodes) should be implemented differently. Note that the dialog does also not update its list of filters when the order is manually changed @@ -1525,6 +1525,7 @@ void FilterEffectsDialog::FilterModifier::on_filter_reorder(const Gtk::TreeModel object->getRepr()->setPosition(0); } */ + return false; } void FilterEffectsDialog::FilterModifier::on_selection_toggled(const Glib::ustring& path) diff --git a/src/ui/dialog/filter-effects-dialog.h b/src/ui/dialog/filter-effects-dialog.h index ccf79e60d..3fc19e7de 100644 --- a/src/ui/dialog/filter-effects-dialog.h +++ b/src/ui/dialog/filter-effects-dialog.h @@ -86,7 +86,7 @@ private: void on_filter_selection_changed(); void on_name_edited(const Glib::ustring&, const Glib::ustring&); - void on_filter_reorder(const Gtk::TreeModel::Path& path); + bool on_filter_move(const Glib::RefPtr& /*context*/, int x, int y, guint /*time*/); void on_selection_toggled(const Glib::ustring&); void update_filters(); -- cgit v1.2.3 From 903d68d4df1de1ae21e124d6e9c12770085ea087 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Tue, 25 Feb 2014 17:08:30 +0100 Subject: Rewrite of symbol creation code. Partial fix for 1201325. Symbols cannot have 'tranform' attribute. The old code copied the group 'transform' attribute to the symbol. The new code creates an intermediate group with the required 'transform' if it is not a simple translation. A simple translation is removed and applied instead to the new element. Multiple objects can now be turned into a symbol without first grouping the objects. (At the cost that multiple groups can no longer be turned into multiple symbols at one go.) This better matches marker and pattern creation. (bzr r13057) --- src/extension/internal/cairo-renderer.cpp | 6 +- src/selection-chemistry.cpp | 223 +++++++++++++++++++----------- src/selection-chemistry.h | 3 +- src/verbs.cpp | 2 +- 4 files changed, 149 insertions(+), 85 deletions(-) (limited to 'src') diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index 6fbc85c05..aa47d8169 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -77,8 +77,8 @@ #include #endif -//#define TRACE(_args) g_printf _args -#define TRACE(_args) +#define TRACE(_args) g_printf _args +//#define TRACE(_args) //#define TEST(_args) _args #define TEST(_args) @@ -628,7 +628,7 @@ CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool page ctx->_width = d.width(); ctx->_height = d.height(); - TRACE(("setupDocument: %f x %f\n", ctx->_width, ctx->_height)); + TRACE(("Cairo Renderer: setupDocument: %f x %f\n", ctx->_width, ctx->_height)); bool ret = ctx->setupSurface(ctx->_width, ctx->_height); diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index ecf814f60..c3d37af72 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -2934,96 +2934,145 @@ void sp_selection_to_guides(SPDesktop *desktop) } /* - * Convert to , leaving all elements referencing group unchanged. + * Convert objects to . How that happens depends on what is selected: + * + * 1) A random selection of objects will be embedded into a single element. + * + * 2) Except, a single will have its content directly embedded into a ; the 'id' and + * 'style' of the are transferred to the . + * + * 3) Except, a single with a transform that isn't a translation will keep the group when + * embedded into a (with 'id' and 'style' transferred to ). This is because a + * cannot have a transform. (If the transform is a pure translation, the translation + * is moved to the referencing element that is created.) + * + * Possible improvements: + * + * Move objects inside symbol so bbox corner at 0,0 (see marker/pattern) + * + * For SVG2, set 'refX' 'refY' to object center (with compensating shift in + * transformation). */ -void sp_selection_symbols(SPDesktop *desktop, bool /*apply*/ ) +void sp_selection_symbol(SPDesktop *desktop, bool /*apply*/ ) { if (desktop == NULL) { return; } SPDocument *doc = sp_desktop_document(desktop); - doc->ensureUpToDate(); + Inkscape::XML::Document *xml_doc = doc->getReprDoc(); Inkscape::Selection *selection = sp_desktop_selection(desktop); // Check if something is selected. if (selection->isEmpty()) { - desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select groups to convert to symbols.")); + desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select objects to convert to symbol.")); return; } - GSList *items = g_slist_copy(const_cast(selection->list())); - bool hasWorked = false; + doc->ensureUpToDate(); - for ( GSList const *iter=items; iter != NULL ; iter = iter->next ) { - SPObject *object = reinterpret_cast( iter->data ); + GSList *items = g_slist_copy(const_cast(selection->list())); - // Require that we really have a group. - if( SP_IS_GROUP( object ) ) { - sp_selection_symbol( doc, object ); - hasWorked = true; - } + // Keep track of parent, this is where will be inserted. + Inkscape::XML::Node *the_first_repr = reinterpret_cast( items->data )->getRepr(); + Inkscape::XML::Node *the_parent_repr = the_first_repr->parent(); + + // Find out if we have a single group + bool single_group = false; + SPObject *the_group = NULL; + Geom::Affine transform; + if( g_slist_length( items ) == 1 ) { + SPObject *object = reinterpret_cast( items->data ); + if( SP_IS_GROUP( object ) ) { + single_group = true; + the_group = object; + + if( !sp_svg_transform_read( object->getAttribute("transform"), &transform )) + transform = Geom::identity(); + + if( transform.isTranslation() ) { + + // Create new list from group children. + g_slist_free(items); + items = object->childList(false); + + // Hack: Temporarily set clone compensation to unmoved, so that we can move clone-originals + // without disturbing clones. + // See ActorAlign::on_button_click() in src/ui/dialog/align-and-distribute.cpp + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); + prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); + + // Remove transform on group, updating clones. + SP_ITEM(object)->doWriteTransform(object->getRepr(), Geom::identity()); + + // restore compensation setting + prefs->setInt("/options/clonecompensation/value", saved_compensation); + } + } } - g_slist_free(items); + // Create new + Inkscape::XML::Node *defsrepr = doc->getDefs()->getRepr(); + Inkscape::XML::Node *symbol_repr = xml_doc->createElement("svg:symbol"); + defsrepr->appendChild(symbol_repr); - if( !hasWorked ) { - desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("No groups converted to symbols.")); - return; - } + // For a single group, copy relevant attributes. + if( single_group ) { - selection->clear(); - // Group just disappears, nothing to select. + symbol_repr->setAttribute("style", the_group->getAttribute("style")); + symbol_repr->setAttribute("class", the_group->getAttribute("class")); + symbol_repr->setAttribute("id", the_group->getAttribute("id") ); - DocumentUndo::done(doc, SP_VERB_EDIT_SYMBOL, _("Group to symbol")); -} + // This should eventually be replaced by 'refX' and 'refY' once SVG WG approves it. + // It is done here for round-tripping + symbol_repr->setAttribute("inkscape:transform-center-x", + the_group->getAttribute("inkscape:transform-center-x")); + symbol_repr->setAttribute("inkscape:transform-center-y", + the_group->getAttribute("inkscape:transform-center-y")); -void sp_selection_symbol(SPDocument *doc, SPObject *group) -{ - Inkscape::XML::Document *xml_doc = doc->getReprDoc(); + the_group->setAttribute("style", NULL); + std::string id = symbol_repr->attribute("id"); + id += "_transform"; + the_group->setAttribute("id", id.c_str()); - Inkscape::XML::Node *symbol = xml_doc->createElement("svg:symbol"); - symbol->setAttribute("style", group->getAttribute("style")); - symbol->setAttribute("title", group->getAttribute("title")); - symbol->setAttribute("transform", group->getAttribute("transform")); - - Glib::ustring id = group->getAttribute("id"); + } - // Now we need to copy all children of group - GSList* children = group->childList(false); - children = g_slist_reverse(children); - for (GSList* i = children; i != NULL; i = i->next ) { - SPObject* child = SP_OBJECT(i->data); - Inkscape::XML::Node *dup = child->getRepr()->duplicate(xml_doc); - symbol->appendChild(dup); - child->deleteObject(true); + // Move selected items to new + for (GSList *i = items; i != NULL; i = i->next) { + Inkscape::XML::Node *repr = SP_OBJECT(i->data)->getRepr(); + repr->parent()->removeChild(repr); + symbol_repr->addChild(repr,NULL); } - // Need to delete ; all elements that referenced should - // auto-magically reference . - doc->getDefs()->getRepr()->appendChild(symbol); - // Mysterious, must set symbol ID before deleting group or all items - // get turned into groups. (Linked to unlinking clones?) - symbol->setAttribute("id",id.c_str()); + if( single_group && transform.isTranslation() ) { + the_group->deleteObject(true); + } - // Create a clone of the symbol to replace the deleted group. + // Create pointing to new symbol (to replace the moved objects). Inkscape::XML::Node *clone = xml_doc->createElement("svg:use"); - clone->setAttribute("x", "0", false); - clone->setAttribute("y", "0", false); - gchar *href_str = g_strdup_printf("#%s", id.c_str()); + + const gchar *symbol_id = symbol_repr->attribute("id"); + gchar *href_str = g_strdup_printf("#%s", symbol_id); clone->setAttribute("xlink:href", href_str, false); g_free(href_str); - clone->setAttribute("inkscape:transform-center-x", group->getAttribute("inkscape:transform-center-x"), false); - clone->setAttribute("inkscape:transform-center-y", group->getAttribute("inkscape:transform-center-y"), false); - group->parent->getRepr()->appendChild(clone); + the_parent_repr->appendChild(clone); - group->deleteObject(true); + if( single_group && transform.isTranslation() ) { + if( !transform.isIdentity() ) + clone->setAttribute("transform", sp_svg_transform_write( transform )); + } - g_slist_free(children); + // Change selection to new element. + selection->set(clone); + + // Clean up + Inkscape::GC::release(symbol_repr); + g_slist_free(items); - Inkscape::GC::release(symbol); + DocumentUndo::done(doc, SP_VERB_EDIT_SYMBOL, _("Group to symbol")); } /* @@ -3049,48 +3098,64 @@ void sp_selection_unsymbol(SPDesktop *desktop) SPObject* symbol = selection->single(); // Make sure we have only one object in selection. - // Require that we really have a that references a . + // Require that we really have a . if( symbol == NULL || !SP_IS_SYMBOL( symbol )) { - desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select only one symbol to convert to group.")); + desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select only one symbol in Symbol dialog to convert to group.")); return; } doc->ensureUpToDate(); + // Create new and insert in current layer Inkscape::XML::Node *group = xml_doc->createElement("svg:g"); - group->setAttribute("style", symbol->getAttribute("style")); - group->setAttribute("title", symbol->getAttribute("title")); - group->setAttribute("transform", symbol->getAttribute("transform")); - - Glib::ustring id = symbol->getAttribute("id"); + desktop->currentLayer()->getRepr()->appendChild(group); - // Now we need to copy all children of symbol + // Move all children of symbol to group GSList* children = symbol->childList(false); - children = g_slist_reverse(children); + + // Converting a group to a symbol inserts a group for non-translational transform. + // In converting a symbol back to a group we strip out the inserted group (or any other + // group that only adds a transform to the symbol content). + if( g_slist_length( children ) == 1 ) { + SPObject *object = reinterpret_cast( children->data ); + if( SP_IS_GROUP( object ) ) { + if( object->getAttribute("style") == NULL || + object->getAttribute("class") == NULL ) { + + group->setAttribute("transform", object->getAttribute("transform")); + g_slist_free(children); + children = object->childList(false); + } + } + } + for (GSList* i = children; i != NULL; i = i->next ) { - SPObject* child = SP_OBJECT(i->data); - Inkscape::XML::Node *dup = child->getRepr()->duplicate(xml_doc); - group->appendChild(dup); - child->deleteObject(true); + Inkscape::XML::Node *repr = SP_OBJECT(i->data)->getRepr(); + repr->parent()->removeChild(repr); + group->addChild(repr,NULL); } - // So we insert inside the current layer - SPObject *parent = desktop->currentLayer(); + // Copy relevant attributes + group->setAttribute("style", symbol->getAttribute("style")); + group->setAttribute("class", symbol->getAttribute("class")); + group->setAttribute("inkscape:transform-center-x", + symbol->getAttribute("inkscape:transform-center-x")); + group->setAttribute("inkscape:transform-center-y", + symbol->getAttribute("inkscape:transform-center-y")); + - // Need to delete ; all other elements that referenced should - // auto-magically reference . - symbol->setAttribute("id","todelete"); - group->setAttribute("id",id.c_str()); // After we delete symbol with same id. + // Need to delete ; all elements that referenced should + // auto-magically reference (if deleted after setting 'id'). + Glib::ustring id = symbol->getAttribute("id"); + group->setAttribute("id",id.c_str()); symbol->deleteObject(true); - parent->getRepr()->appendChild(group); + // Change selection to new element. SPItem *group_item = static_cast(sp_desktop_document(desktop)->getObjectByRepr(group)); - Inkscape::GC::release(group); - selection->clear(); selection->set(group_item); - // Need to signal Symbol dialog to update - + // Clean up + Inkscape::GC::release(group); g_slist_free(children); DocumentUndo::done(doc, SP_VERB_EDIT_UNSYMBOL, _("Group from symbol")); diff --git a/src/selection-chemistry.h b/src/selection-chemistry.h index e86000f70..d76a67a9d 100644 --- a/src/selection-chemistry.h +++ b/src/selection-chemistry.h @@ -69,8 +69,7 @@ void sp_selection_clone_original_path_lpe(SPDesktop *desktop); void sp_selection_to_marker(SPDesktop *desktop, bool apply = true); void sp_selection_to_guides(SPDesktop *desktop); -void sp_selection_symbols(SPDesktop *desktop, bool apply = true); -void sp_selection_symbol(SPDocument *doc, SPObject *group); +void sp_selection_symbol(SPDesktop *desktop, bool apply = true); void sp_selection_unsymbol(SPDesktop *desktop); void sp_selection_tile(SPDesktop *desktop, bool apply = true); diff --git a/src/verbs.cpp b/src/verbs.cpp index 8b333383f..653d5f892 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -996,7 +996,7 @@ void EditVerb::perform(SPAction *action, void *data) sp_selection_untile(dt); break; case SP_VERB_EDIT_SYMBOL: - sp_selection_symbols(dt); + sp_selection_symbol(dt); break; case SP_VERB_EDIT_UNSYMBOL: sp_selection_unsymbol(dt); -- cgit v1.2.3 From ba65200ce8e3225340d729902c26dce142c65e57 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Tue, 25 Feb 2014 17:12:22 +0100 Subject: Revert unintended checkin. (bzr r13058) --- src/extension/internal/cairo-renderer.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index aa47d8169..6fbc85c05 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -77,8 +77,8 @@ #include #endif -#define TRACE(_args) g_printf _args -//#define TRACE(_args) +//#define TRACE(_args) g_printf _args +#define TRACE(_args) //#define TEST(_args) _args #define TEST(_args) @@ -628,7 +628,7 @@ CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool page ctx->_width = d.width(); ctx->_height = d.height(); - TRACE(("Cairo Renderer: setupDocument: %f x %f\n", ctx->_width, ctx->_height)); + TRACE(("setupDocument: %f x %f\n", ctx->_width, ctx->_height)); bool ret = ctx->setupSurface(ctx->_width, ctx->_height); -- cgit v1.2.3 From 7e85379f54292595afe296e5f0be240f6c8f7835 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Wed, 26 Feb 2014 02:08:53 +0100 Subject: Made constructors of tools use initializer lists. (bzr r13060) --- src/ui/tools/arc-tool.cpp | 49 +++++++++---------------- src/ui/tools/box3d-tool.cpp | 23 ++++-------- src/ui/tools/calligraphic-tool.cpp | 34 ++++++++---------- src/ui/tools/connector-tool.cpp | 73 +++++++++++++++----------------------- src/ui/tools/dropper-tool.cpp | 26 ++++++-------- src/ui/tools/dynamic-base.cpp | 69 +++++++++++++++++------------------ src/ui/tools/dynamic-base.h | 8 ++--- src/ui/tools/eraser-tool.cpp | 7 ++-- src/ui/tools/flood-tool.cpp | 15 +++----- src/ui/tools/freehand-base.cpp | 56 +++++++++++++---------------- src/ui/tools/freehand-base.h | 4 +-- src/ui/tools/gradient-tool.cpp | 22 +++++------- src/ui/tools/lpe-tool.cpp | 18 +++++----- src/ui/tools/measure-tool.cpp | 10 +++--- src/ui/tools/mesh-tool.cpp | 24 ++++++------- src/ui/tools/node-tool.cpp | 45 +++++++++++------------ src/ui/tools/pen-tool.cpp | 65 ++++++++++++++++++++------------- src/ui/tools/pen-tool.h | 3 +- src/ui/tools/pencil-tool.cpp | 21 +++++------ src/ui/tools/rect-tool.cpp | 20 ++++------- src/ui/tools/select-tool.cpp | 36 +++++++++---------- src/ui/tools/select-tool.h | 4 +-- src/ui/tools/spiral-tool.cpp | 22 ++++-------- src/ui/tools/spray-tool.cpp | 53 +++++++++++++-------------- src/ui/tools/spray-tool.h | 8 ++--- src/ui/tools/star-tool.cpp | 28 +++++---------- src/ui/tools/text-tool.cpp | 51 +++++++++++--------------- src/ui/tools/text-tool.h | 10 +++--- src/ui/tools/tool-base.cpp | 42 +++++++++++----------- src/ui/tools/tool-base.h | 8 +++-- src/ui/tools/tweak-tool.cpp | 45 ++++++++++------------- src/ui/tools/tweak-tool.h | 6 ++-- src/ui/tools/zoom-tool.cpp | 11 +++--- 33 files changed, 402 insertions(+), 514 deletions(-) (limited to 'src') diff --git a/src/ui/tools/arc-tool.cpp b/src/ui/tools/arc-tool.cpp index bb7dfa21c..435f4aa4b 100644 --- a/src/ui/tools/arc-tool.cpp +++ b/src/ui/tools/arc-tool.cpp @@ -69,18 +69,10 @@ const std::string& ArcTool::getPrefsPath() { const std::string ArcTool::prefsPath = "/tools/shapes/arc"; -ArcTool::ArcTool() : ToolBase() { - this->cursor_shape = cursor_ellipse_xpm; - this->hot_x = 4; - this->hot_y = 4; - this->xp = 0; - this->yp = 0; - this->tolerance = 0; - this->within_tolerance = false; - this->item_to_select = NULL; - //this->tool_url = "/tools/shapes/arc"; - - this->arc = NULL; +ArcTool::ArcTool() + : ToolBase(cursor_ellipse_xpm, 4, 4) + , arc(NULL) +{ } void ArcTool::finish() { @@ -142,13 +134,10 @@ void ArcTool::setup() { } bool ArcTool::item_handler(SPItem* item, GdkEvent* event) { - gint ret = FALSE; - switch (event->type) { case GDK_BUTTON_PRESS: if (event->button.button == 1 && !this->space_panning) { Inkscape::setup_for_drag_start(desktop, this, event); - ret = TRUE; } break; // motion and release are always on root (why?) @@ -156,13 +145,7 @@ bool ArcTool::item_handler(SPItem* item, GdkEvent* event) { break; } -// if ((SP_EVENT_CONTEXT_CLASS(sp_arc_context_parent_class))->item_handler) { -// ret = (SP_EVENT_CONTEXT_CLASS(sp_arc_context_parent_class))->item_handler(event_context, item, event); -// } - // CPPIFY: ret is overwritten... - ret = ToolBase::item_handler(item, event); - - return ret; + return ToolBase::item_handler(item, event); } bool ArcTool::root_handler(GdkEvent* event) { @@ -173,7 +156,7 @@ bool ArcTool::root_handler(GdkEvent* event) { this->tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100); - gint ret = FALSE; + bool handled = false; switch (event->type) { case GDK_BUTTON_PRESS: @@ -191,7 +174,7 @@ bool ArcTool::root_handler(GdkEvent* event) { GDK_KEY_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK, NULL, event->button.time); - ret = TRUE; + handled = true; m.unSetup(); } break; @@ -214,7 +197,7 @@ bool ArcTool::root_handler(GdkEvent* event) { gobble_motion_events(GDK_BUTTON1_MASK); - ret = TRUE; + handled = true; } else if (!sp_event_context_knot_mouseover(this)){ SnapManager &m = desktop->namedview->snap_manager; m.setup(desktop); @@ -249,7 +232,7 @@ bool ArcTool::root_handler(GdkEvent* event) { this->xp = 0; this->yp = 0; this->item_to_select = NULL; - ret = TRUE; + handled = true; } sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), event->button.time); break; @@ -278,14 +261,14 @@ bool ArcTool::root_handler(GdkEvent* event) { case GDK_KEY_KP_Down: // prevent the zoom field from activation if (!MOD__CTRL_ONLY(event)) - ret = TRUE; + handled = true; break; case GDK_KEY_x: case GDK_KEY_X: if (MOD__ALT_ONLY(event)) { desktop->setToolboxFocusTo ("altx-arc"); - ret = TRUE; + handled = true; } break; @@ -295,7 +278,7 @@ bool ArcTool::root_handler(GdkEvent* event) { sp_event_context_discard_delayed_snap_event(this); // if drawing, cancel, otherwise pass it up for deselecting this->cancel(); - ret = TRUE; + handled = true; } break; @@ -316,7 +299,7 @@ bool ArcTool::root_handler(GdkEvent* event) { case GDK_KEY_Delete: case GDK_KEY_KP_Delete: case GDK_KEY_BackSpace: - ret = this->deleteSelectedDrag(MOD__CTRL_ONLY(event)); + handled = this->deleteSelectedDrag(MOD__CTRL_ONLY(event)); break; default: @@ -346,11 +329,11 @@ bool ArcTool::root_handler(GdkEvent* event) { break; } - if (!ret) { - ret = ToolBase::root_handler(event); + if (!handled) { + handled = ToolBase::root_handler(event); } - return ret; + return handled; } void ArcTool::drag(Geom::Point pt, guint state) { diff --git a/src/ui/tools/box3d-tool.cpp b/src/ui/tools/box3d-tool.cpp index 2e345fef1..f0381a4a5 100644 --- a/src/ui/tools/box3d-tool.cpp +++ b/src/ui/tools/box3d-tool.cpp @@ -72,22 +72,13 @@ const std::string& Box3dTool::getPrefsPath() { const std::string Box3dTool::prefsPath = "/tools/shapes/3dbox"; -Box3dTool::Box3dTool() : ToolBase() { - this->cursor_shape = cursor_3dbox_xpm; - this->hot_x = 4; - this->hot_y = 4; - this->xp = 0; - this->yp = 0; - this->tolerance = 0; - this->within_tolerance = false; - this->item_to_select = NULL; - - this->box3d = NULL; - - this->ctrl_dragged = false; - this->extruded = false; - - this->_vpdrag = NULL; +Box3dTool::Box3dTool() + : ToolBase(cursor_3dbox_xpm, 4, 4) + , _vpdrag(NULL) + , box3d(NULL) + , ctrl_dragged(false) + , extruded(false) +{ } void Box3dTool::finish() { diff --git a/src/ui/tools/calligraphic-tool.cpp b/src/ui/tools/calligraphic-tool.cpp index 2c5e6561c..64097e834 100644 --- a/src/ui/tools/calligraphic-tool.cpp +++ b/src/ui/tools/calligraphic-tool.cpp @@ -105,30 +105,24 @@ const std::string& CalligraphicTool::getPrefsPath() { const std::string CalligraphicTool::prefsPath = "/tools/calligraphic"; -CalligraphicTool::CalligraphicTool() : DynamicBase() { - this->cursor_shape = cursor_calligraphy_xpm; - this->hot_x = 4; - this->hot_y = 4; - +CalligraphicTool::CalligraphicTool() + : DynamicBase(cursor_calligraphy_xpm, 4, 4) + , keep_selected(true) + , hatch_spacing(0) + , hatch_spacing_step(0) + , hatch_item(NULL) + , hatch_livarot_path(NULL) + , hatch_last_nearest(Geom::Point(0,0)) + , hatch_last_pointer(Geom::Point(0,0)) + , hatch_escaped(false) + , hatch_area(NULL) + , just_started_drawing(false) + , trace_bg(false) +{ this->vel_thin = 0.1; this->flatness = 0.9; this->cap_rounding = 0.0; - this->abs_width = false; - this->keep_selected = true; - - this->hatch_spacing = 0; - this->hatch_spacing_step = 0; - - this->hatch_last_nearest = Geom::Point(0,0); - this->hatch_last_pointer = Geom::Point(0,0); - this->hatch_escaped = false; - this->hatch_area = NULL; - this->hatch_item = NULL; - this->hatch_livarot_path = NULL; - - this->trace_bg = false; - this->just_started_drawing = false; } CalligraphicTool::~CalligraphicTool() { diff --git a/src/ui/tools/connector-tool.cpp b/src/ui/tools/connector-tool.cpp index 50cb00360..391bae2e5 100644 --- a/src/ui/tools/connector-tool.cpp +++ b/src/ui/tools/connector-tool.cpp @@ -182,54 +182,39 @@ const std::string& ConnectorTool::getPrefsPath() { const std::string ConnectorTool::prefsPath = "/tools/connector"; -ConnectorTool::ConnectorTool() : ToolBase() { - this->red_curve = 0; - this->isOrthogonal = false; - this->c1 = 0; - this->red_bpath = 0; - this->green_curve = 0; - this->selection = 0; - this->cl0 = 0; - this->cl1 = 0; - this->c0 = 0; - - this->cursor_shape = cursor_connector_xpm; - this->hot_x = 1; - this->hot_y = 1; - this->xp = 0; - this->yp = 0; - - this->red_color = 0xff00007f; - - this->newconn = NULL; - this->newConnRef = NULL; - this->curvature = 0.0; - - this->sel_changed_connection = sigc::connection(); - - this->active_shape = NULL; - this->active_shape_repr = NULL; - this->active_shape_layer_repr = NULL; - - this->active_conn = NULL; - this->active_conn_repr = NULL; - - this->active_handle = NULL; - - this->selected_handle = NULL; - - this->clickeditem = NULL; - this->clickedhandle = NULL; - +ConnectorTool::ConnectorTool() + : ToolBase(cursor_connector_xpm, 1, 1) + , selection(NULL) + , npoints(0) + , state(SP_CONNECTOR_CONTEXT_IDLE) + , red_bpath(NULL) + , red_curve(NULL) + , red_color(0xff00007f) + , green_curve(NULL) + , newconn(NULL) + , newConnRef(NULL) + , curvature(0.0) + , isOrthogonal(false) + , active_shape(NULL) + , active_shape_repr(NULL) + , active_shape_layer_repr(NULL) + , active_conn(NULL) + , active_conn_repr(NULL) + , active_handle(NULL) + , selected_handle(NULL) + , clickeditem(NULL) + , clickedhandle(NULL) + , shref(NULL) + , ehref(NULL) + , c0(NULL) + , c1(NULL) + , cl0(NULL) + , cl1(NULL) +{ for (int i = 0; i < 2; ++i) { this->endpt_handle[i] = NULL; this->endpt_handler_id[i] = 0; } - - this->shref = NULL; - this->ehref = NULL; - this->npoints = 0; - this->state = SP_CONNECTOR_CONTEXT_IDLE; } ConnectorTool::~ConnectorTool() { diff --git a/src/ui/tools/dropper-tool.cpp b/src/ui/tools/dropper-tool.cpp index 88ed342df..e9e2d6c39 100644 --- a/src/ui/tools/dropper-tool.cpp +++ b/src/ui/tools/dropper-tool.cpp @@ -72,21 +72,17 @@ const std::string& DropperTool::getPrefsPath() { const std::string DropperTool::prefsPath = "/tools/dropper"; -DropperTool::DropperTool() : ToolBase() { - this->R = 0; - this->G = 0; - this->B = 0; - this->alpha = 0; - this->dragging = false; - - this->grabbed = 0; - this->area = 0; - this->centre = Geom::Point(0, 0); - - this->cursor_shape = cursor_dropper_f_xpm; - this->hot_x = 7; - this->hot_y = 7; - +DropperTool::DropperTool() + : ToolBase(cursor_dropper_f_xpm, 7, 7) + , R(0) + , G(0) + , B(0) + , alpha(0) + , dragging(false) + , grabbed(NULL) + , area(NULL) + , centre(0, 0) +{ cursor_dropper_fill = sp_cursor_new_from_xpm(cursor_dropper_f_xpm , 7, 7); cursor_dropper_stroke = sp_cursor_new_from_xpm(cursor_dropper_s_xpm , 7, 7); } diff --git a/src/ui/tools/dynamic-base.cpp b/src/ui/tools/dynamic-base.cpp index cec58dce9..21b4b0532 100644 --- a/src/ui/tools/dynamic-base.cpp +++ b/src/ui/tools/dynamic-base.cpp @@ -23,40 +23,41 @@ namespace Inkscape { namespace UI { namespace Tools { -DynamicBase::DynamicBase() : - ToolBase(), - accumulated(NULL), - segments(NULL), - currentshape(NULL), - currentcurve(NULL), - cal1(NULL), - cal2(NULL), - point1(), - point2(), - repr(NULL), - cur(0,0), - vel(0,0), - vel_max(0), - acc(0,0), - ang(0,0), - last(0,0), - del(0,0), - pressure(DEFAULT_PRESSURE), - xtilt(0), - ytilt(0), - dragging(FALSE), - usepressure(FALSE), - usetilt(FALSE), - mass(0.3), - drag(DRAG_DEFAULT), - angle(30.0), - width(0.2), - vel_thin(0.1), - flatness(0.9), - tremor(0), - cap_rounding(0), - is_drawing(false), - abs_width(false) +DynamicBase::DynamicBase(gchar const *const *cursor_shape, gint hot_x, gint hot_y) + : ToolBase(cursor_shape, hot_x, hot_y) + , accumulated(NULL) + , segments(NULL) + , currentshape(NULL) + , currentcurve(NULL) + , cal1(NULL) + , cal2(NULL) + , point1() + , point2() + , npoints(0) + , repr(NULL) + , cur(0, 0) + , vel(0, 0) + , vel_max(0) + , acc(0, 0) + , ang(0, 0) + , last(0, 0) + , del(0, 0) + , pressure(DEFAULT_PRESSURE) + , xtilt(0) + , ytilt(0) + , dragging(false) + , usepressure(false) + , usetilt(false) + , mass(0.3) + , drag(DRAG_DEFAULT) + , angle(30.0) + , width(0.2) + , vel_thin(0.1) + , flatness(0.9) + , tremor(0) + , cap_rounding(0) + , is_drawing(false) + , abs_width(false) { } diff --git a/src/ui/tools/dynamic-base.h b/src/ui/tools/dynamic-base.h index 9218eabd3..76fcd0f02 100644 --- a/src/ui/tools/dynamic-base.h +++ b/src/ui/tools/dynamic-base.h @@ -31,7 +31,7 @@ namespace Tools { class DynamicBase : public ToolBase { public: - DynamicBase(); + DynamicBase(gchar const *const *cursor_shape, gint hot_x, gint hot_y); virtual ~DynamicBase(); virtual void set(const Inkscape::Preferences::Entry& val); @@ -81,9 +81,9 @@ protected: gdouble ytilt; /* attributes */ - guint dragging : 1; /* mouse state: mouse is dragging */ - guint usepressure : 1; - guint usetilt : 1; + bool dragging; /* mouse state: mouse is dragging */ + bool usepressure; + bool usetilt; double mass, drag; double angle; double width; diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index 270987d27..011d28663 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -103,10 +103,9 @@ const std::string& EraserTool::getPrefsPath() { const std::string EraserTool::prefsPath = "/tools/eraser"; -EraserTool::EraserTool() : DynamicBase() { - this->cursor_shape = cursor_eraser_xpm; - this->hot_x = 4; - this->hot_y = 4; +EraserTool::EraserTool() + : DynamicBase(cursor_eraser_xpm, 4, 4) +{ } EraserTool::~EraserTool() { diff --git a/src/ui/tools/flood-tool.cpp b/src/ui/tools/flood-tool.cpp index 4e29b8856..d74848dc6 100644 --- a/src/ui/tools/flood-tool.cpp +++ b/src/ui/tools/flood-tool.cpp @@ -94,17 +94,12 @@ const std::string& FloodTool::getPrefsPath() { const std::string FloodTool::prefsPath = "/tools/paintbucket"; -FloodTool::FloodTool() : ToolBase() { - this->cursor_shape = cursor_paintbucket_xpm; - this->hot_x = 11; - this->hot_y = 30; - this->xp = 0; - this->yp = 0; +FloodTool::FloodTool() + : ToolBase(cursor_paintbucket_xpm, 11, 30) + , item(NULL) +{ + // TODO: Why does the flood tool use a hardcoded tolerance instead of a pref? this->tolerance = 4; - this->within_tolerance = false; - this->item_to_select = NULL; - - this->item = NULL; } FloodTool::~FloodTool() { diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index 1e0e6b3b6..2fb4a3481 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -70,37 +70,31 @@ static void spdc_flush_white(FreehandBase *dc, SPCurve *gc); static void spdc_reset_white(FreehandBase *dc); static void spdc_free_colors(FreehandBase *dc); -FreehandBase::FreehandBase() : ToolBase() { - this->selection = 0; - this->grab = 0; - this->anchor_statusbar = false; - - this->attach = FALSE; - - this->red_color = 0xff00007f; - this->blue_color = 0x0000ff7f; - this->green_color = 0x00ff007f; - this->red_curve_is_valid = false; - - this->red_bpath = NULL; - this->red_curve = NULL; - - this->blue_bpath = NULL; - this->blue_curve = NULL; - - this->green_bpaths = NULL; - this->green_curve = NULL; - this->green_anchor = NULL; - this->green_closed = false; - - this->white_item = NULL; - this->white_curves = NULL; - this->white_anchors = NULL; - - this->sa = NULL; - this->ea = NULL; - - this->waiting_LPE_type = Inkscape::LivePathEffect::INVALID_LPE; +FreehandBase::FreehandBase(gchar const *const *cursor_shape, gint hot_x, gint hot_y) + : ToolBase(cursor_shape, hot_x, hot_y) + , selection(NULL) + , grab(NULL) + , attach(false) + , red_color(0xff00007f) + , blue_color(0x0000ff7f) + , green_color(0x00ff007f) + , red_bpath(NULL) + , red_curve(NULL) + , blue_bpath(NULL) + , blue_curve(NULL) + , green_bpaths(NULL) + , green_curve(NULL) + , green_anchor(NULL) + , green_closed(false) + , white_item(NULL) + , white_curves(NULL) + , white_anchors(NULL) + , sa(NULL) + , ea(NULL) + , waiting_LPE_type(Inkscape::LivePathEffect::INVALID_LPE) + , red_curve_is_valid(false) + , anchor_statusbar(false) +{ } FreehandBase::~FreehandBase() { diff --git a/src/ui/tools/freehand-base.h b/src/ui/tools/freehand-base.h index 7e53684e3..c8da9faed 100644 --- a/src/ui/tools/freehand-base.h +++ b/src/ui/tools/freehand-base.h @@ -37,13 +37,13 @@ namespace Tools { class FreehandBase : public ToolBase { public: - FreehandBase(); + FreehandBase(gchar const *const *cursor_shape, gint hot_x, gint hot_y); virtual ~FreehandBase(); Inkscape::Selection *selection; SPCanvasItem *grab; - guint attach : 1; + bool attach; guint32 red_color; guint32 blue_color; diff --git a/src/ui/tools/gradient-tool.cpp b/src/ui/tools/gradient-tool.cpp index 10f78a8a8..a0bbfbaf1 100644 --- a/src/ui/tools/gradient-tool.cpp +++ b/src/ui/tools/gradient-tool.cpp @@ -74,20 +74,16 @@ const std::string& GradientTool::getPrefsPath() { const std::string GradientTool::prefsPath = "/tools/gradient"; -GradientTool::GradientTool() : ToolBase() { - this->node_added = false; - this->subselcon = 0; - this->selcon = 0; - - this->cursor_addnode = false; - this->cursor_shape = cursor_gradient_xpm; - this->hot_x = 4; - this->hot_y = 4; - this->xp = 0; - this->yp = 0; +GradientTool::GradientTool() + : ToolBase(cursor_gradient_xpm, 4, 4) + , cursor_addnode(false) + , node_added(false) +// TODO: Why are these connections stored as pointers? + , selcon(NULL) + , subselcon(NULL) +{ + // TODO: This value is overwritten in the root handler this->tolerance = 6; - this->within_tolerance = false; - this->item_to_select = NULL; } GradientTool::~GradientTool() { diff --git a/src/ui/tools/lpe-tool.cpp b/src/ui/tools/lpe-tool.cpp index a5406f1c5..6c41bb160 100644 --- a/src/ui/tools/lpe-tool.cpp +++ b/src/ui/tools/lpe-tool.cpp @@ -81,16 +81,14 @@ const std::string& LpeTool::getPrefsPath() { const std::string LpeTool::prefsPath = "/tools/lpetool"; -LpeTool::LpeTool() : PenTool() { - this->mode = Inkscape::LivePathEffect::BEND_PATH; - this->shape_editor = 0; - - this->cursor_shape = cursor_crosshairs_xpm; - this->hot_x = 7; - this->hot_y = 7; - - this->canvas_bbox = NULL; - this->measuring_items = new std::map; +LpeTool::LpeTool() + : PenTool(cursor_crosshairs_xpm, 7, 7) + , shape_editor(NULL) + , canvas_bbox(NULL) + , mode(Inkscape::LivePathEffect::BEND_PATH) +// TODO: pointer? + , measuring_items(new std::map) +{ } LpeTool::~LpeTool() { diff --git a/src/ui/tools/measure-tool.cpp b/src/ui/tools/measure-tool.cpp index 4d7f1e074..380aa79e3 100644 --- a/src/ui/tools/measure-tool.cpp +++ b/src/ui/tools/measure-tool.cpp @@ -236,12 +236,10 @@ void createAngleDisplayCurve(SPDesktop *desktop, Geom::Point const ¢er, Geom } // namespace -MeasureTool::MeasureTool() : ToolBase() { - this->grabbed = 0; - - this->cursor_shape = cursor_measure_xpm; - this->hot_x = 4; - this->hot_y = 4; +MeasureTool::MeasureTool() + : ToolBase(cursor_measure_xpm, 4, 4) + , grabbed(NULL) +{ } MeasureTool::~MeasureTool() { diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index 4e7617f44..7d6d3bc23 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -75,20 +75,18 @@ const std::string& MeshTool::getPrefsPath() { const std::string MeshTool::prefsPath = "/tools/mesh"; -MeshTool::MeshTool() : ToolBase() { - this->selcon = 0; - this->node_added = false; - this->subselcon = 0; - - this->cursor_addnode = false; - this->cursor_shape = cursor_gradient_xpm; - this->hot_x = 4; - this->hot_y = 4; - this->xp = 0; - this->yp = 0; +// TODO: The gradient tool class looks like a 1:1 copy. + +MeshTool::MeshTool() + : ToolBase(cursor_gradient_xpm, 4, 4) + , cursor_addnode(false) + , node_added(false) +// TODO: Why are these connections stored as pointers? + , selcon(NULL) + , subselcon(NULL) +{ + // TODO: This value is overwritten in the root handler this->tolerance = 6; - this->within_tolerance = false; - this->item_to_select = NULL; } MeshTool::~MeshTool() { diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp index 7e33b1a4c..b1e11bd66 100644 --- a/src/ui/tools/node-tool.cpp +++ b/src/ui/tools/node-tool.cpp @@ -126,30 +126,27 @@ const std::string NodeTool::prefsPath = "/tools/nodes"; SPCanvasGroup *create_control_group(SPDesktop *d); -NodeTool::NodeTool() : ToolBase() { - this->show_handles = false; - this->single_node_transform_handles = false; - this->show_transform_handles = false; - this->cursor_drag = false; - this->live_objects = false; - this->edit_clipping_paths = false; - this->live_outline = false; - this->flashed_item = 0; - this->_transform_handle_group = 0; - this->show_path_direction = false; - this->_last_over = 0; - this->edit_masks = false; - this->show_outline = false; - this->flash_tempitem = 0; - - this->cursor_shape = cursor_node_xpm; - this->hot_x = 1; - this->hot_y = 1; - - this->_selected_nodes = 0; - this->_multipath = 0; - this->_selector = 0; - this->_path_data = 0; +NodeTool::NodeTool() + : ToolBase(cursor_node_xpm, 1, 1) + , _selected_nodes(NULL) + , _multipath(NULL) + , edit_clipping_paths(false) + , edit_masks(false) + , flashed_item(NULL) + , flash_tempitem(NULL) + , _selector(NULL) + , _path_data(NULL) + , _transform_handle_group(NULL) + , _last_over(NULL) + , cursor_drag(false) + , show_handles(false) + , show_outline(false) + , live_outline(false) + , live_objects(false) + , show_path_direction(false) + , show_transform_handles(false) + , single_node_transform_handles(false) +{ } SPCanvasGroup *create_control_group(SPDesktop *d) diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index dc5e801c0..39b69f576 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -89,29 +89,44 @@ const std::string& PenTool::getPrefsPath() { const std::string PenTool::prefsPath = "/tools/freehand/pen"; -PenTool::PenTool() : FreehandBase() { - this->polylines_only = false; - this->polylines_paraxial = false; - this->expecting_clicks_for_LPE = 0; - - this->cursor_shape = cursor_pen_xpm; - this->hot_x = 4; - this->hot_y = 4; - - this->npoints = 0; - this->mode = MODE_CLICK; - this->state = POINT; - - this->c0 = NULL; - this->c1 = NULL; - this->cl0 = NULL; - this->cl1 = NULL; - - this->events_disabled = 0; +PenTool::PenTool() + : FreehandBase(cursor_pen_xpm, 4, 4) + , p() + , npoints(0) + , mode(MODE_CLICK) + , state(POINT) + , polylines_only(false) + , polylines_paraxial(false) + , num_clicks(0) + , expecting_clicks_for_LPE(0) + , waiting_LPE(NULL) + , waiting_item(NULL) + , c0(NULL) + , c1(NULL) + , cl0(NULL) + , cl1(NULL) + , events_disabled(false) +{ +} - this->num_clicks = 0; - this->waiting_LPE = NULL; - this->waiting_item = NULL; +PenTool::PenTool(gchar const *const *cursor_shape, gint hot_x, gint hot_y) + : FreehandBase(cursor_shape, hot_x, hot_y) + , p() + , npoints(0) + , mode(MODE_CLICK) + , state(POINT) + , polylines_only(false) + , polylines_paraxial(false) + , num_clicks(0) + , expecting_clicks_for_LPE(0) + , waiting_LPE(NULL) + , waiting_item(NULL) + , c0(NULL) + , c1(NULL) + , cl0(NULL) + , cl1(NULL) + , events_disabled(false) +{ } PenTool::~PenTool() { @@ -1305,13 +1320,13 @@ static void spdc_pen_finish(PenTool *const pc, gboolean const closed) } static void pen_disable_events(PenTool *const pc) { - pc->events_disabled++; + pc->events_disabled = true; } static void pen_enable_events(PenTool *const pc) { - g_return_if_fail(pc->events_disabled != 0); + g_return_if_fail(pc->events_disabled != 0); - pc->events_disabled--; + pc->events_disabled = false; } void sp_pen_context_wait_for_LPE_mouse_clicks(PenTool *pc, Inkscape::LivePathEffect::EffectType effect_type, diff --git a/src/ui/tools/pen-tool.h b/src/ui/tools/pen-tool.h index 4452dbd68..f2b1ee04a 100644 --- a/src/ui/tools/pen-tool.h +++ b/src/ui/tools/pen-tool.h @@ -23,6 +23,7 @@ namespace Tools { class PenTool : public FreehandBase { public: PenTool(); + PenTool(gchar const *const *cursor_shape, gint hot_x, gint hot_y); virtual ~PenTool(); enum Mode { @@ -60,7 +61,7 @@ public: SPCtrlLine *cl0; SPCtrlLine *cl1; - unsigned int events_disabled : 1; + bool events_disabled; static const std::string prefsPath; diff --git a/src/ui/tools/pencil-tool.cpp b/src/ui/tools/pencil-tool.cpp index 52779d551..4fbaa50f3 100644 --- a/src/ui/tools/pencil-tool.cpp +++ b/src/ui/tools/pencil-tool.cpp @@ -83,20 +83,15 @@ const std::string& PencilTool::getPrefsPath() { const std::string PencilTool::prefsPath = "/tools/freehand/pencil"; -PencilTool::PencilTool() : - FreehandBase(), - p(), - npoints(0), - state(SP_PENCIL_CONTEXT_IDLE), - req_tangent(0,0), - is_drawing(false), - ps(), - sketch_interpolation(Geom::Piecewise >())// since PencilTool is not properly constructed... +PencilTool::PencilTool() + : FreehandBase(cursor_pencil_xpm, 4, 4) + , p() + , npoints(0) + , state(SP_PENCIL_CONTEXT_IDLE) + , req_tangent(0, 0) + , is_drawing(false) + , sketch_n(0) { - this->cursor_shape = cursor_pencil_xpm; - this->hot_x = 4; - this->hot_y = 4; - this->sketch_n = 0; } void PencilTool::setup() { diff --git a/src/ui/tools/rect-tool.cpp b/src/ui/tools/rect-tool.cpp index 263fdea84..f5153e8ce 100644 --- a/src/ui/tools/rect-tool.cpp +++ b/src/ui/tools/rect-tool.cpp @@ -66,20 +66,12 @@ const std::string& RectTool::getPrefsPath() { const std::string RectTool::prefsPath = "/tools/shapes/rect"; -RectTool::RectTool() : ToolBase() { - this->cursor_shape = cursor_rect_xpm; - this->hot_x = 4; - this->hot_y = 4; - this->xp = 0; - this->yp = 0; - this->tolerance = 0; - this->within_tolerance = false; - this->item_to_select = NULL; - - this->rect = NULL; - - this->rx = 0.0; - this->ry = 0.0; +RectTool::RectTool() + : ToolBase(cursor_rect_xpm, 4, 4) + , rect(NULL) + , rx(0) + , ry(0) +{ } void RectTool::finish() { diff --git a/src/ui/tools/select-tool.cpp b/src/ui/tools/select-tool.cpp index 498882417..85bc3fd4a 100644 --- a/src/ui/tools/select-tool.cpp +++ b/src/ui/tools/select-tool.cpp @@ -90,24 +90,24 @@ sp_load_handles(int start, int count, char const **xpm) { } } -SelectTool::SelectTool() : ToolBase() { - this->grabbed = 0; - this->item = 0; - - this->dragging = FALSE; - this->moved = FALSE; - this->button_press_shift = false; - this->button_press_ctrl = false; - this->button_press_alt = false; - this->cycling_items = NULL; - this->cycling_items_cmp = NULL; - this->cycling_items_selected_before = NULL; - this->cycling_cur_item = NULL; - this->cycling_wrap = true; - this->_seltrans = NULL; - this->_describer = NULL; - - +SelectTool::SelectTool() + // Don't load a default cursor + : ToolBase(NULL, 0, 0) + , dragging(false) + , moved(false) + , button_press_shift(false) + , button_press_ctrl(false) + , button_press_alt(false) + , cycling_items(NULL) + , cycling_items_cmp(NULL) + , cycling_items_selected_before(NULL) + , cycling_cur_item(NULL) + , cycling_wrap(true) + , item(NULL) + , grabbed(NULL) + , _seltrans(NULL) + , _describer(NULL) +{ // cursors in select context CursorSelectMouseover = sp_cursor_new_from_xpm(cursor_select_m_xpm , 1, 1); CursorSelectDragging = sp_cursor_new_from_xpm(cursor_select_d_xpm , 1, 1); diff --git a/src/ui/tools/select-tool.h b/src/ui/tools/select-tool.h index b26fc03bc..81763e8b1 100644 --- a/src/ui/tools/select-tool.h +++ b/src/ui/tools/select-tool.h @@ -35,8 +35,8 @@ public: SelectTool(); virtual ~SelectTool(); - guint dragging : 1; - guint moved : 1; + bool dragging; + bool moved; bool button_press_shift; bool button_press_ctrl; bool button_press_alt; diff --git a/src/ui/tools/spiral-tool.cpp b/src/ui/tools/spiral-tool.cpp index 005b2d239..7d33b0f67 100644 --- a/src/ui/tools/spiral-tool.cpp +++ b/src/ui/tools/spiral-tool.cpp @@ -65,21 +65,13 @@ const std::string& SpiralTool::getPrefsPath() { const std::string SpiralTool::prefsPath = "/tools/shapes/spiral"; -SpiralTool::SpiralTool() : ToolBase() { - this->cursor_shape = cursor_spiral_xpm; - this->hot_x = 4; - this->hot_y = 4; - this->xp = 0; - this->yp = 0; - this->tolerance = 0; - this->within_tolerance = false; - this->item_to_select = NULL; - - this->spiral = NULL; - - this->revo = 3.0; - this->exp = 1.0; - this->t0 = 0.0; +SpiralTool::SpiralTool() + : ToolBase(cursor_spiral_xpm, 4, 4) + , spiral(NULL) + , revo(3) + , exp(1) + , t0(0) +{ } void SpiralTool::finish() { diff --git a/src/ui/tools/spray-tool.cpp b/src/ui/tools/spray-tool.cpp index 14a3acd9a..2fc3f1c91 100644 --- a/src/ui/tools/spray-tool.cpp +++ b/src/ui/tools/spray-tool.cpp @@ -134,35 +134,30 @@ static void sp_spray_scale_rel(Geom::Point c, SPDesktop */*desktop*/, SPItem *it item->doWriteTransform(item->getRepr(), item->transform); } -SprayTool::SprayTool() : ToolBase() { - this->usetilt = 0; - this->dilate_area = 0; - this->usetext = false; - this->population = 0; - this->is_drawing = false; - this->mode = 0; - this->usepressure = 0; - - this->cursor_shape = cursor_spray_xpm; - this->hot_x = 4; - this->hot_y = 4; - - /* attributes */ - this->dragging = FALSE; - this->distrib = 1; - this->width = 0.2; - this->force = 0.2; - this->ratio = 0; - this->tilt = 0; - this->mean = 0.2; - this->rotation_variation = 0; - this->standard_deviation = 0.2; - this->scale = 1; - this->scale_variation = 1; - this->pressure = TC_DEFAULT_PRESSURE; - - this->is_dilating = false; - this->has_dilated = false; +SprayTool::SprayTool() + : ToolBase(cursor_spray_xpm, 4, 4) + , pressure(TC_DEFAULT_PRESSURE) + , dragging(false) + , usepressure(0) + , usetilt(0) + , usetext(false) + , width(0.2) + , ratio(0) + , tilt(0) + , rotation_variation(0) + , force(0.2) + , population(0) + , scale_variation(1) + , scale(1) + , mean(0.2) + , standard_deviation(0.2) + , distrib(1) + , mode(0) + , is_drawing(false) + , is_dilating(false) + , has_dilated(false) + , dilate_area(NULL) +{ } SprayTool::~SprayTool() { diff --git a/src/ui/tools/spray-tool.h b/src/ui/tools/spray-tool.h index e7362fd50..1a8f98006 100644 --- a/src/ui/tools/spray-tool.h +++ b/src/ui/tools/spray-tool.h @@ -61,10 +61,10 @@ public: gdouble pressure; /* attributes */ - guint dragging : 1; /* mouse state: mouse is dragging */ - guint usepressure : 1; - guint usetilt : 1; - bool usetext ; + bool dragging; /* mouse state: mouse is dragging */ + bool usepressure; + bool usetilt; + bool usetext; double width; double ratio; diff --git a/src/ui/tools/star-tool.cpp b/src/ui/tools/star-tool.cpp index b5d8c4418..42010788f 100644 --- a/src/ui/tools/star-tool.cpp +++ b/src/ui/tools/star-tool.cpp @@ -69,25 +69,15 @@ const std::string& StarTool::getPrefsPath() { const std::string StarTool::prefsPath = "/tools/shapes/star"; -StarTool::StarTool() : ToolBase() { - this->randomized = 0; - this->rounded = 0; - - this->cursor_shape = cursor_star_xpm; - this->hot_x = 4; - this->hot_y = 4; - this->xp = 0; - this->yp = 0; - this->tolerance = 0; - this->within_tolerance = false; - this->item_to_select = NULL; - //this->tool_url = "/tools/shapes/star"; - - this->star = NULL; - - this->magnitude = 5; - this->proportion = 0.5; - this->isflatsided = false; +StarTool::StarTool() + : ToolBase(cursor_star_xpm, 4, 4) + , star(NULL) + , magnitude(5) + , proportion(0.5) + , isflatsided(false) + , rounded(0) + , randomized(0) +{ } void StarTool::finish() { diff --git a/src/ui/tools/text-tool.cpp b/src/ui/tools/text-tool.cpp index ba68c7829..00f6a853c 100644 --- a/src/ui/tools/text-tool.cpp +++ b/src/ui/tools/text-tool.cpp @@ -91,37 +91,26 @@ const std::string& TextTool::getPrefsPath() { const std::string TextTool::prefsPath = "/tools/text"; -TextTool::TextTool() : ToolBase() { - this->preedit_string = 0; - this->unipos = 0; - - this->cursor_shape = cursor_text_xpm; - this->hot_x = 7; - this->hot_y = 7; - - this->xp = 0; - this->yp = 0; - this->tolerance = 0; - this->within_tolerance = false; - - this->imc = NULL; - - this->text = NULL; - this->pdoc = Geom::Point(0, 0); - - this->unimode = false; - - this->cursor = NULL; - this->indicator = NULL; - this->frame = NULL; - this->grabbed = NULL; - this->timeout = 0; - this->show = FALSE; - this->phase = 0; - this->nascent_object = 0; - this->over_text = 0; - this->dragging = 0; - this->creating = 0; +TextTool::TextTool() + : ToolBase(cursor_text_xpm, 7, 7) + , imc(NULL) + , text(NULL) + , pdoc(0, 0) + , unimode(false) + , unipos(0) + , cursor(NULL) + , indicator(NULL) + , frame(NULL) + , timeout(0) + , show(false) + , phase(false) + , nascent_object(false) + , over_text(false) + , dragging(0) + , creating(false) + , grabbed(NULL) + , preedit_string(NULL) +{ } TextTool::~TextTool() { diff --git a/src/ui/tools/text-tool.h b/src/ui/tools/text-tool.h index ef8a67984..c5336d378 100644 --- a/src/ui/tools/text-tool.h +++ b/src/ui/tools/text-tool.h @@ -61,15 +61,15 @@ public: SPCanvasItem *frame; // hiliting the first frame of flowtext; FIXME: make this a list to accommodate arbitrarily many chained shapes std::vector text_selection_quads; gint timeout; - guint show : 1; - guint phase : 1; - guint nascent_object : 1; // true if we're clicked on canvas to put cursor, but no text typed yet so ->text is still NULL + bool show; + bool phase; + bool nascent_object; // true if we're clicked on canvas to put cursor, but no text typed yet so ->text is still NULL - guint over_text : 1; // true if cursor is over a text object + bool over_text; // true if cursor is over a text object guint dragging : 2; // dragging selection over text - guint creating : 1; // dragging rubberband to create flowtext + bool creating; // dragging rubberband to create flowtext SPCanvasItem *grabbed; // we grab while we are creating, to get events even if the mouse goes out of the window Geom::Point p0; // initial point if the flowtext rect diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp index cc028724a..dc10e9388 100644 --- a/src/ui/tools/tool-base.cpp +++ b/src/ui/tools/tool-base.cpp @@ -90,28 +90,26 @@ SPDesktop const& ToolBase::getDesktop() const { return *desktop; } -ToolBase::ToolBase() { - this->hot_y = 0; - this->xp = 0; - this->cursor_shape = 0; - this->pref_observer = 0; - this->hot_x = 0; - this->yp = 0; - this->within_tolerance = false; - this->tolerance = 0; - //this->key = 0; - this->item_to_select = 0; - - this->desktop = NULL; - this->cursor = NULL; - this->message_context = NULL; - this->_selcue = NULL; - this->_grdrag = NULL; - this->space_panning = false; - this->shape_editor = NULL; - this->_delayed_snap_event = NULL; - this->_dse_callback_in_process = false; - //this->tool_url = NULL; +ToolBase::ToolBase(gchar const *const *cursor_shape, gint hot_x, gint hot_y) + : pref_observer(NULL) + , cursor(NULL) + , xp(0) + , yp(0) + , tolerance(0) + , within_tolerance(false) + , item_to_select(NULL) + , message_context(NULL) + , _selcue(NULL) + , _grdrag(NULL) + , shape_editor(NULL) + , space_panning(false) + , _delayed_snap_event(NULL) + , _dse_callback_in_process(false) + , desktop(NULL) + , cursor_shape(cursor_shape) + , hot_x(hot_x) + , hot_y(hot_y) +{ } ToolBase::~ToolBase() { diff --git a/src/ui/tools/tool-base.h b/src/ui/tools/tool-base.h index 43edc4bd7..a4a27a06c 100644 --- a/src/ui/tools/tool-base.h +++ b/src/ui/tools/tool-base.h @@ -110,7 +110,8 @@ public: void enableGrDrag (bool enable=true); bool deleteSelectedDrag(bool just_one); - ToolBase(); + ToolBase(gchar const *const *cursor_shape, gint hot_x, gint hot_y); + virtual ~ToolBase(); Inkscape::Preferences::Observer *pref_observer; @@ -179,8 +180,11 @@ public: SPDesktop *desktop; protected: + /// An xpm containing the shape of the tool's cursor. gchar const *const *cursor_shape; - gint hot_x, hot_y; ///< indicates the cursor's hot spot + + /// The cursor's hot spot + gint hot_x, hot_y; private: ToolBase(const ToolBase&); diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp index 0791eff5a..75650d3af 100644 --- a/src/ui/tools/tweak-tool.cpp +++ b/src/ui/tools/tweak-tool.cpp @@ -111,32 +111,25 @@ const std::string& TweakTool::getPrefsPath() { const std::string TweakTool::prefsPath = "/tools/tweak"; -TweakTool::TweakTool() : ToolBase() { - this->mode = 0; - this->dilate_area = 0; - this->usetilt = 0; - this->usepressure = 0; - this->is_drawing = false; - this->fidelity = 0; - - this->cursor_shape = cursor_push_xpm; - this->hot_x = 4; - this->hot_y = 4; - - /* attributes */ - this->dragging = FALSE; - - this->width = 0.2; - this->force = 0.2; - this->pressure = TC_DEFAULT_PRESSURE; - - this->is_dilating = false; - this->has_dilated = false; - - this->do_h = true; - this->do_s = true; - this->do_l = true; - this->do_o = false; +TweakTool::TweakTool() + : ToolBase(cursor_push_xpm, 4, 4) + , pressure(TC_DEFAULT_PRESSURE) + , dragging(false) + , usepressure(false) + , usetilt(false) + , width(0.2) + , force(0.2) + , fidelity(0) + , mode(0) + , is_drawing(false) + , is_dilating(false) + , has_dilated(false) + , dilate_area(NULL) + , do_h(true) + , do_s(true) + , do_l(true) + , do_o(false) +{ } TweakTool::~TweakTool() { diff --git a/src/ui/tools/tweak-tool.h b/src/ui/tools/tweak-tool.h index 6cbb9aded..7fe4b1856 100644 --- a/src/ui/tools/tweak-tool.h +++ b/src/ui/tools/tweak-tool.h @@ -50,9 +50,9 @@ public: gdouble pressure; /* attributes */ - guint dragging : 1; /* mouse state: mouse is dragging */ - guint usepressure : 1; - guint usetilt : 1; + bool dragging; /* mouse state: mouse is dragging */ + bool usepressure; + bool usetilt; double width; double force; diff --git a/src/ui/tools/zoom-tool.cpp b/src/ui/tools/zoom-tool.cpp index 0996e6cf4..9f99cfe2e 100644 --- a/src/ui/tools/zoom-tool.cpp +++ b/src/ui/tools/zoom-tool.cpp @@ -45,12 +45,11 @@ const std::string& ZoomTool::getPrefsPath() { const std::string ZoomTool::prefsPath = "/tools/zoom"; -ZoomTool::ZoomTool() : ToolBase() { - this->grabbed = 0; - this->cursor_shape = cursor_zoom_xpm; - this->hot_x = 6; - this->hot_y = 6; - this->escaped = false; +ZoomTool::ZoomTool() + : ToolBase(cursor_zoom_xpm, 6, 6) + , grabbed(NULL) + , escaped(false) +{ } ZoomTool::~ZoomTool() { -- cgit v1.2.3 From 6f844ef457690c841b0be91d70b1e54b61c04812 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Wed, 26 Feb 2014 10:31:28 -0500 Subject: Remove DOM directory and reduce size of inkscape. Use Inkscape::URI and save ziptool to utils. (bzr r13047.1.5) --- src/Makefile.am | 3 - src/color-profile.cpp | 14 +- src/dom/CMakeLists.txt | 61 - src/dom/Makefile.mingw | 234 -- src/dom/Makefile_insert | 56 - src/dom/css.h | 4693 --------------------------- src/dom/cssreader.cpp | 1684 ---------- src/dom/cssreader.h | 294 -- src/dom/dom.h | 2758 ---------------- src/dom/domimpl.cpp | 3071 ------------------ src/dom/domimpl.h | 2029 ------------ src/dom/domptr.cpp | 87 - src/dom/domptr.h | 339 -- src/dom/domstring.cpp | 423 --- src/dom/domstring.h | 316 -- src/dom/events.h | 1644 ---------- src/dom/io/domstream.cpp | 1228 ------- src/dom/io/domstream.h | 684 ---- src/dom/ls.h | 947 ------ src/dom/lsimpl.cpp | 441 --- src/dom/lsimpl.h | 390 --- src/dom/makefile.in | 17 - src/dom/mingwenv.bat | 2 - src/dom/prop-css.cpp | 1161 ------- src/dom/prop-css2.cpp | 1305 -------- src/dom/prop-svg.cpp | 746 ----- src/dom/smil.h | 2508 --------------- src/dom/smilimpl.cpp | 855 ----- src/dom/smilimpl.h | 766 ----- src/dom/stylesheets.h | 597 ---- src/dom/svg.h | 4758 --------------------------- src/dom/svgimpl.cpp | 2563 --------------- src/dom/svgimpl.h | 5543 -------------------------------- src/dom/svgreader.cpp | 750 ----- src/dom/svgreader.h | 187 -- src/dom/svgtypes.h | 6900 ---------------------------------------- src/dom/traversal.h | 609 ---- src/dom/ucd.cpp | 2539 --------------- src/dom/ucd.h | 335 -- src/dom/uri.cpp | 961 ------ src/dom/uri.h | 488 --- src/dom/util/ziptool.cpp | 3031 ------------------ src/dom/util/ziptool.h | 567 ---- src/dom/views-level3.h | 1967 ------------ src/dom/views.h | 218 -- src/dom/xmlreader.cpp | 998 ------ src/dom/xmlreader.h | 126 - src/dom/xmlwriter.cpp | 200 -- src/dom/xmlwriter.h | 84 - src/dom/xpath.h | 351 -- src/dom/xpathimpl.cpp | 236 -- src/dom/xpathimpl.h | 265 -- src/dom/xpathparser.cpp | 2093 ------------ src/dom/xpathparser.h | 801 ----- src/dom/xpathtoken.cpp | 1068 ------- src/dom/xpathtoken.h | 672 ---- src/extension/internal/odf.cpp | 19 +- src/extension/internal/odf.h | 9 +- src/uri.cpp | 57 +- src/uri.h | 33 +- src/util/Makefile_insert | 2 + src/util/ziptool.cpp | 3031 ++++++++++++++++++ src/util/ziptool.h | 567 ++++ 63 files changed, 3691 insertions(+), 67690 deletions(-) delete mode 100644 src/dom/CMakeLists.txt delete mode 100644 src/dom/Makefile.mingw delete mode 100644 src/dom/Makefile_insert delete mode 100644 src/dom/css.h delete mode 100644 src/dom/cssreader.cpp delete mode 100644 src/dom/cssreader.h delete mode 100644 src/dom/dom.h delete mode 100644 src/dom/domimpl.cpp delete mode 100644 src/dom/domimpl.h delete mode 100644 src/dom/domptr.cpp delete mode 100644 src/dom/domptr.h delete mode 100644 src/dom/domstring.cpp delete mode 100644 src/dom/domstring.h delete mode 100644 src/dom/events.h delete mode 100644 src/dom/io/domstream.cpp delete mode 100644 src/dom/io/domstream.h delete mode 100644 src/dom/ls.h delete mode 100644 src/dom/lsimpl.cpp delete mode 100644 src/dom/lsimpl.h delete mode 100644 src/dom/makefile.in delete mode 100644 src/dom/mingwenv.bat delete mode 100644 src/dom/prop-css.cpp delete mode 100644 src/dom/prop-css2.cpp delete mode 100644 src/dom/prop-svg.cpp delete mode 100644 src/dom/smil.h delete mode 100644 src/dom/smilimpl.cpp delete mode 100644 src/dom/smilimpl.h delete mode 100644 src/dom/stylesheets.h delete mode 100644 src/dom/svg.h delete mode 100644 src/dom/svgimpl.cpp delete mode 100644 src/dom/svgimpl.h delete mode 100644 src/dom/svgreader.cpp delete mode 100644 src/dom/svgreader.h delete mode 100644 src/dom/svgtypes.h delete mode 100644 src/dom/traversal.h delete mode 100644 src/dom/ucd.cpp delete mode 100644 src/dom/ucd.h delete mode 100644 src/dom/uri.cpp delete mode 100644 src/dom/uri.h delete mode 100644 src/dom/util/ziptool.cpp delete mode 100644 src/dom/util/ziptool.h delete mode 100644 src/dom/views-level3.h delete mode 100644 src/dom/views.h delete mode 100644 src/dom/xmlreader.cpp delete mode 100644 src/dom/xmlreader.h delete mode 100644 src/dom/xmlwriter.cpp delete mode 100644 src/dom/xmlwriter.h delete mode 100644 src/dom/xpath.h delete mode 100644 src/dom/xpathimpl.cpp delete mode 100644 src/dom/xpathimpl.h delete mode 100644 src/dom/xpathparser.cpp delete mode 100644 src/dom/xpathparser.h delete mode 100644 src/dom/xpathtoken.cpp delete mode 100644 src/dom/xpathtoken.h create mode 100644 src/util/ziptool.cpp create mode 100644 src/util/ziptool.h (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 7fbc135c5..d3f8794ee 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -23,7 +23,6 @@ endif noinst_LIBRARIES = \ - dom/libdom.a \ libcroco/libcroco.a \ libavoid/libavoid.a \ $(internal_GDL) \ @@ -108,7 +107,6 @@ endif include Makefile_insert include dialogs/Makefile_insert include display/Makefile_insert -include dom/Makefile_insert include extension/Makefile_insert include extension/dbus/Makefile_insert include extension/implementation/Makefile_insert @@ -148,7 +146,6 @@ EXTRA_DIST += \ debug/makefile.in \ dialogs/makefile.in \ display/makefile.in \ - dom/makefile.in \ extension/implementation/makefile.in \ extension/internal/makefile.in \ extension/makefile.in \ diff --git a/src/color-profile.cpp b/src/color-profile.cpp index 2736b9a3b..09eaa36e5 100644 --- a/src/color-profile.cpp +++ b/src/color-profile.cpp @@ -46,7 +46,7 @@ #include "document.h" #include "preferences.h" -#include "dom/uri.h" +#include "uri.h" #ifdef WIN32 #include @@ -331,13 +331,17 @@ void ColorProfile::set(unsigned key, gchar const *value) { gchar* escaped = g_uri_escape_string(this->href, "!*'();:@=+$,/?#[]", TRUE); //g_message("docbase:%s\n", docbase); - org::w3c::dom::URI docUri(docbase); + //org::w3c::dom::URI docUri(docbase); + Inkscape::URI docUri(docbase); + //# 2. Get href of icc file. we don't care if it's rel or abs - org::w3c::dom::URI hrefUri(escaped); + //org::w3c::dom::URI hrefUri(escaped); + Inkscape::URI hrefUri(escaped); //# 3. Resolve the href according the docBase. This follows // the w3c specs. All absolute and relative issues are considered - org::w3c::dom::URI cprofUri = docUri.resolve(hrefUri); - gchar* fullname = g_uri_unescape_string(cprofUri.getNativePath().c_str(), ""); + std::string fullpath = docUri.getFullPath(hrefUri.getFullPath("")); + + gchar* fullname = g_uri_unescape_string(fullpath.c_str(), ""); this->impl->_clearProfile(); this->impl->_profHandle = cmsOpenProfileFromFile( fullname, "r" ); if ( this->impl->_profHandle ) { diff --git a/src/dom/CMakeLists.txt b/src/dom/CMakeLists.txt deleted file mode 100644 index c3078a8e3..000000000 --- a/src/dom/CMakeLists.txt +++ /dev/null @@ -1,61 +0,0 @@ - -set(dom_SRC - cssreader.cpp - domimpl.cpp - domptr.cpp - domstring.cpp - lsimpl.cpp - prop-css2.cpp - prop-css.cpp - prop-svg.cpp - smilimpl.cpp - svgimpl.cpp - svgreader.cpp - ucd.cpp - uri.cpp - xmlreader.cpp - xpathimpl.cpp - xpathparser.cpp - xpathtoken.cpp - - io/domstream.cpp - - util/ziptool.cpp - - - # ------- - # Headers - css.h - cssreader.h - dom.h - domimpl.h - domptr.h - domstring.h - events.h - ls.h - lsimpl.h - smil.h - smilimpl.h - stylesheets.h - svg.h - svgimpl.h - svgreader.h - svgtypes.h - traversal.h - ucd.h - uri.h - views-level3.h - views.h - xmlreader.h - xmlwriter.h - xpath.h - xpathimpl.h - xpathparser.h - xpathtoken.h - - io/domstream.h - - util/ziptool.h -) - -add_inkscape_lib(dom_LIB "${dom_SRC}") diff --git a/src/dom/Makefile.mingw b/src/dom/Makefile.mingw deleted file mode 100644 index 9f75b2dbb..000000000 --- a/src/dom/Makefile.mingw +++ /dev/null @@ -1,234 +0,0 @@ -########################################################################### -# -# Makefile for testing DOM code -# -########################################################################### - -####### Sense whether we are on a DOS box or cross-compiling -ifdef ComSpec -BUILD=native -DOSSHELL=CMD_EXE -else -ifdef COMSPEC -BUILD=native -DOSSHELL=COMMAND_COM -else -BUILD=cross -endif -endif - - - - -########################################################################## -# FILE SEPARATORS -# $(S) will be set to one of these -########################################################################## -BSLASH := \\# -FSLASH := / - - - -########################################################################## -# CROSS / NATIVE SWITCHES -########################################################################## -ifeq ($(BUILD),cross) - - - -########################################################################## -# CROSS COMPILER SETTINGS -########################################################################## - -CC = i686-pc-mingw32-gcc -CXX = i686-pc-mingw32-g++ -AS = i686-pc-mingw32-as -AR = i686-pc-mingw32-ar -RANLIB = i686-pc-mingw32-ranlib -WINDRES = i686-pc-mingw32-windres -LD = i686-pc-mingw32-ld -DLLWRAP = i686-pc-mingw32-dllwrap -DLLTOOL = i686-pc-mingw32-dlltool - -####### file separator -S = $(FSLASH) - -####### escape character for echo -E = / - -####### file manipulation programs -CP = cp -RMDIR = rm -rf -MKDIR = mkdir -CPDIR = cp -rf -MSGFMT = msgfmt -RMREC = find ./inkscape -type f -name -RMREC1 = |xargs $(RM) -RMDIRREC = find ./inkscape -type d -name -RMDIRREC1 = |xargs $(RMDIR) - -####### Where is your GTK directory? -GTK=/target - -####### Same thing, file system style -GTKDOS=$(GTK) - -DTG := $(shell date +%y%m%d.%H%M) - -else - -########################################################################## -# NATIVE COMPILER SETTINGS -########################################################################## - -CC = mingw32-gcc -CXX = mingw32-g++ -AS = as -AR = mingw32-ar -RANLIB = ranlib -WINDRES = windres -DLLWRAP = dllwrap -DLLTOOL = dlltool - -####### file separator -S = $(BSLASH) - -####### escape character for echo -E = - -####### file manipulation programs -CP = copy - -####### are we on WinNt and beyond? -ifeq ($(DOSSHELL),CMD_EXE) -RMDIR = rmdir /s /q -RM = del -else -RMDIR = deltree /y -RM = del -endif -MKDIR = mkdir -CPDIR = xcopy /e /i -RMREC = cd inkscape & $(RM) /s /q -RMREC1 = & cd .. -RMDIRREC = cd inkscape & $(RMDIR) /s -RMDIRREC1 = & cd .. - -####### Where is your GTK directory? -GTK=c:/devlibs - -####### Same thing, DOS style -GTKDOS=c:\devlibs - -####### Command to process .po files --> .mo -MSGFMT = $(GTKDOS)$(S)bin$(S)msgfmt - -####### change me!! -DTG := 20080515 - -endif -########################################################################## -# END CROSS / NATIVE SWITCHES -########################################################################## - - - - -INC = -I. -I.. -CFLAGS = -Wall -g -DDOM_STANDALONE -LIBS = -lws2_32 - -DOMOBJ = \ -cssreader.o \ -domimpl.o \ -domptr.o \ -domstring.o \ -lsimpl.o \ -smilimpl.o \ -uri.o \ -xmlreader.o \ -xpathimpl.o \ -xpathparser.o \ -xpathtoken.o \ -io/base64stream.o \ -io/domstream.o \ -io/bufferstream.o \ -io/gzipstream.o \ -io/httpclient.o \ -io/stringstream.o \ -io/uristream.o \ -io/socket.o \ -odf/odfdocument.o \ -svgimpl.o \ -svgreader.o \ -ucd.o \ -util/thread.o \ -util/ziptool.o - - - -TESTOBJ = \ -work/testdom.o \ -work/testodf.o \ -work/testsvg.o \ -work/testuri.o \ -work/testxpath.o \ -work/testzip.o - -OBJ = $(DOMOBJ) - -all: testsvg.exe - -tests: testdom.exe testhttp.exe \ -testsvg.exe testuri.exe testxpath.exe testzip.exe - -testdom.exe: libdom.a work/testdom.o - $(CXX) -o $@ work/testdom.o libdom.a $(LIBS) - -testhttp.exe: libdom.a work/testhttp.o - $(CXX) -o $@ work/testhttp.o libdom.a $(LIBS) - -testodf.exe: libdom.a work/testodf.o - $(CXX) -o $@ work/testodf.o libdom.a $(LIBS) - -testsvg.exe: libdom.a work/testsvg.o - $(CXX) -o $@ work/testsvg.o libdom.a $(LIBS) - -testuri.exe: libdom.a work/testuri.o - $(CXX) -o $@ work/testuri.o libdom.a $(LIBS) - -testxpath.exe: libdom.a work/testxpath.o - $(CXX) -o $@ work/testxpath.o libdom.a $(LIBS) - -testzip.exe: libdom.a work/testzip.o - $(CXX) -o $@ work/testzip.o libdom.a $(LIBS) - - -libdom.a: $(OBJ) - ar crv $@ $(OBJ) - - -.cpp.o: - $(CXX) $(CFLAGS) $(INC) -c -o $@ $< - -clean: - $(foreach a, $(OBJ), $(shell $(RM) $(subst /,$(S), $(a)))) - $(foreach a, $(TESTOBJ), $(shell $(RM) $(subst /,$(S), $(a)))) - -$(RM) *.a - -$(RM) *.gch - -$(RM) testdom - -$(RM) testdom.exe - -$(RM) testsvg - -$(RM) testsvg.exe - -$(RM) testuri - -$(RM) testuri.exe - -$(RM) testxpath - -$(RM) testxpath.exe - -$(RM) testzip - -$(RM) testzip.exe - -$(RM) core.* - -########################################################################### -# E N D O F F I L E -########################################################################### - diff --git a/src/dom/Makefile_insert b/src/dom/Makefile_insert deleted file mode 100644 index 6d222987e..000000000 --- a/src/dom/Makefile_insert +++ /dev/null @@ -1,56 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. - -dom/all: dom/libdom.a - -dom/clean: - rm -f dom/libdom.a $(dom_libdom_a_OBJECTS) - -dom_libdom_a_SOURCES = \ - dom/css.h \ - dom/cssreader.cpp \ - dom/cssreader.h \ - dom/dom.h \ - dom/domimpl.cpp \ - dom/domimpl.h \ - dom/domptr.cpp \ - dom/domptr.h \ - dom/domstring.cpp \ - dom/domstring.h \ - dom/events.h \ - dom/ls.h \ - dom/lsimpl.cpp \ - dom/lsimpl.h \ - dom/prop-css2.cpp \ - dom/prop-css.cpp \ - dom/prop-svg.cpp \ - dom/smil.h \ - dom/smilimpl.cpp \ - dom/smilimpl.h \ - dom/stylesheets.h \ - dom/svg.h \ - dom/svgimpl.cpp \ - dom/svgimpl.h \ - dom/svgreader.cpp \ - dom/svgreader.h \ - dom/svgtypes.h \ - dom/traversal.h \ - dom/ucd.cpp \ - dom/ucd.h \ - dom/uri.cpp \ - dom/uri.h \ - dom/views.h \ - dom/views-level3.h \ - dom/xmlreader.cpp \ - dom/xmlreader.h \ - dom/xpath.h \ - dom/xpathimpl.cpp \ - dom/xpathimpl.h \ - dom/xpathparser.cpp \ - dom/xpathparser.h \ - dom/xpathtoken.h \ - dom/xpathtoken.cpp \ - dom/io/domstream.cpp \ - dom/io/domstream.h \ - dom/util/ziptool.h \ - dom/util/ziptool.cpp - diff --git a/src/dom/css.h b/src/dom/css.h deleted file mode 100644 index f270b99eb..000000000 --- a/src/dom/css.h +++ /dev/null @@ -1,4693 +0,0 @@ -/** - * @file - * Phoebe DOM Implementation. - * - * This is a C++ approximation of the W3C DOM model, which follows - * fairly closely the specifications in the various .idl files, copies of - * which are provided for reference. Most important is this one: - * - * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - */ -/* - * Authors: - * Bob Jamison - * - * Copyright (C) 2005-2008 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * ======================================================================= - * NOTES - * - * Views, Stylesheets and CSS are DOM Level 2 for the purposes of supporting - * SVG. Be prepared in the future when they make Level 3 and SVG is likewise - * updated. The API here and many of the comments come from this document: - * http://www.w3.org/TR/DOM-Level-2-Style/css.html - - */ - -#ifndef SEEN_CSS_H -#define SEEN_CSS_H - -#include "dom.h" -#include "stylesheets.h" -#include "views.h" - -#include -#include - - -namespace org { -namespace w3c { -namespace dom { -namespace css { - - - - -//Make local definitions -typedef dom::DOMString DOMString; -typedef dom::Element Element; -typedef dom::DOMImplementation DOMImplementation; - -//forward declarations -class CSSRule; -class CSSStyleSheet; -class CSSStyleDeclaration; -class CSSValue; -class Counter; -class Rect; -class RGBColor; - - - - - -/*######################################################################### -## CSSRule -#########################################################################*/ - -/** - * The CSSRule interface is the abstract base interface for any type of CSS - * statement. This includes both rule sets and at-rules. An implementation is - * expected to preserve all rules specified in a CSS style sheet, even if the - * rule is not recognized by the parser. Unrecognized rules are represented using - * the CSSUnknownRule interface. - */ -class CSSRule -{ -public: - - /** - * An integer indicating which type of rule this is. - */ - typedef enum - { - UNKNOWN_RULE = 0, - STYLE_RULE = 1, - CHARSET_RULE = 2, - IMPORT_RULE = 3, - MEDIA_RULE = 4, - FONT_FACE_RULE = 5, - PAGE_RULE = 6 - } RuleType; - - - /** - * The type of the rule, as defined above. The expectation is that - * binding-specific casting methods can be used to cast down from an instance of - * the CSSRule interface to the specific derived interface implied by the type. - */ - virtual unsigned short getType() - { - return type; - } - - /** - * The parsable textual representation of the rule. This reflects the current - * state of the rule and not its initial value. - */ - virtual DOMString getCssText() - { - return cssText; - } - - /** - * The parsable textual representation of the rule. This reflects the current - * state of the rule and not its initial value. - * Note that setting involves reparsing. - */ - virtual void setCssText(const DOMString &val) throw (dom::DOMException) - { - cssText = val; - } - - /** - * The style sheet that contains this rule. - */ - virtual CSSStyleSheet *getParentStyleSheet() - { - return parentStyleSheet; - } - - /** - * If this rule is contained inside another rule (e.g. a style rule inside an - * @media block), this is the containing rule. If this rule is not nested inside - * any other rules, this returns null. - */ - virtual CSSRule *getParentRule() - { - return parentRule; - } - - - - //################## - //# Non-API methods - //################## - - /** - * - */ - CSSRule() - { - type = UNKNOWN_RULE; - cssText = ""; - parentStyleSheet = NULL; - parentRule = NULL; - } - - /** - * - */ - CSSRule(const CSSRule &other) - { - assign(other); - } - - /** - * - */ - CSSRule &operator=(const CSSRule &other) - { - assign(other); - return *this; - } - - /** - * - */ - void assign(const CSSRule &other) - { - type = other.type; - cssText = other.cssText; - parentStyleSheet = other.parentStyleSheet; - parentRule = other.parentRule; - } - - /** - * - */ - virtual ~CSSRule() {} - -protected: - - int type; - - DOMString cssText; - - CSSStyleSheet *parentStyleSheet; - - CSSRule *parentRule; -}; - - - -/*######################################################################### -## CSSRuleList -#########################################################################*/ - -/** - * The CSSRuleList interface provides the abstraction of an ordered collection of - * CSS rules. - * - * The items in the CSSRuleList are accessible via an integral index, starting - * from 0. - */ -class CSSRuleList -{ -public: - - /** - * The number of CSSRules in the list. The range of valid child rule indices is 0 - * to length-1 inclusive. - */ - virtual unsigned long getLength() - { - return rules.size(); - } - - /** - * Used to retrieve a CSS rule by ordinal index. The order in this collection - * represents the order of the rules in the CSS style sheet. If index is greater - * than or equal to the number of rules in the list, this returns null. - */ - virtual CSSRule item(unsigned long index) - { - if (index>=rules.size()) - { - CSSRule rule; - return rule; - } - return rules[index]; - } - - - //################## - //# Non-API methods - //################## - - /** - * - */ - CSSRuleList() {} - - - /** - * - */ - CSSRuleList(const CSSRuleList &other) - : rules (other.rules) - { - } - - /** - * - */ - CSSRuleList &operator=(const CSSRuleList &other) - { - rules = other.rules; - return *this; - } - - /** - * - */ - virtual ~CSSRuleList() {} - -protected: - -friend class CSSMediaRule; -friend class CSSStyleSheet; - - /** - * - */ - virtual void addRule(const CSSRule &rule) - { - rules.push_back(rule); - } - - - /** - * - */ - virtual void deleteRule(unsigned long index) - { - if (index>=rules.size()) - return; - std::vector::iterator iter = rules.begin() + index; - rules.erase(iter); - } - - - /** - * - */ - virtual long insertRule(const CSSRule &rule, unsigned long index) - { - if (index>=rules.size()) - return -1; - std::vector::iterator iter = rules.begin() + index; - rules.insert(iter, rule); - return index; - } - - std::vectorrules; -}; - - -/*######################################################################### -## CSSStyleSheet -#########################################################################*/ - -/** - * The CSSStyleSheet interface is a concrete interface used to represent a CSS - * style sheet i.e., a style sheet whose content type is "text/css". - */ -class CSSStyleSheet : virtual public stylesheets::StyleSheet -{ -public: - - /** - * If this style sheet comes from an @import rule, the ownerRule attribute will - * contain the CSSImportRule. In that case, the ownerNode attribute in the - * StyleSheet interface will be null. If the style sheet comes from an element or - * a processing instruction, the ownerRule attribute will be null and the - * ownerNode attribute will contain the Node. - */ - virtual CSSRule *getOwnerRule() - { - return ownerRule; - } - - /** - * The list of all CSS rules contained within the style sheet. This - * includes both rule sets and at-rules. - */ - virtual CSSRuleList getCssRules() - { - return rules; - } - - /** - * Used to insert a new rule into the style sheet. The new rule now - * becomes part of the cascade. - */ - virtual unsigned long insertRule(const DOMString &/*ruleStr*/, - unsigned long index) - throw (dom::DOMException) - { - CSSRule rule; - return rules.insertRule(rule, index); - } - - /** - * Used to delete a rule from the style sheet. - */ - virtual void deleteRule(unsigned long index) - throw (dom::DOMException) - { - rules.deleteRule(index); - } - - //################## - //# Non-API methods - //################## - - /** - * - */ - CSSStyleSheet() : stylesheets::StyleSheet(), ownerRule(0) - { - } - - /** - * - */ - CSSStyleSheet(const CSSStyleSheet &other) : - stylesheets::StyleSheet(other) - { - assign(other); - } - - /** - * - */ - CSSStyleSheet &operator=(const CSSStyleSheet &other) - { - assign(other); - return *this; - } - - /** - * - */ - void assign(const CSSStyleSheet &other) - { - ownerRule = other.ownerRule; - rules = other.rules; - } - - /** - * - */ - virtual ~CSSStyleSheet() {} - -protected: - - CSSRule *ownerRule; - - CSSRuleList rules; -}; - - -/*######################################################################### -## CSSValue -#########################################################################*/ - -/** - * The CSSValue interface represents a simple or a complex value. A CSSValue - * object only occurs in a context of a CSS property. - */ -class CSSValue -{ -public: - - /** - * An integer indicating which type of unit applies to the value. - */ - typedef enum - { - CSS_INHERIT = 0, - CSS_PRIMITIVE_VALUE = 1, - CSS_VALUE_LIST = 2, - CSS_CUSTOM = 3 - } UnitTypes; - - /** - * A code defining the type of the value as defined above. - */ - virtual unsigned short getCssValueType() - { - return valueType; - } - - /** - * A string representation of the current value. - */ - virtual DOMString getCssText() - { - return cssText; - } - - /** - * A string representation of the current value. - * Note that setting implies parsing. - */ - virtual void setCssText(const DOMString &val) - throw (dom::DOMException) - { - cssText = val; - } - - //################## - //# Non-API methods - //################## - - /** - * - */ - CSSValue() - { - valueType = CSS_INHERIT; - } - - /** - * - */ - CSSValue(const CSSValue &other) - { - assign(other); - } - - /** - * - */ - CSSValue &operator=(const CSSValue &other) - { - assign(other); - return *this; - } - - /** - * - */ - void assign(const CSSValue &other) - { - cssText = other.cssText; - valueType = other.valueType; - } - - /** - * - */ - virtual ~CSSValue() {} - -protected: - - DOMString cssText; - int valueType; -}; - - - - - -/*######################################################################### -## CSSStyleDeclaration -#########################################################################*/ - -/** - * The CSSStyleDeclaration interface represents a single CSS declaration block. - * This interface may be used to determine the style properties currently set in - * a block or to set style properties explicitly within the block. - * - * While an implementation may not recognize all CSS properties within a CSS - * declaration block, it is expected to provide access to all specified - * properties in the style sheet through the CSSStyleDeclaration interface. - * Furthermore, implementations that support a specific level of CSS should - * correctly handle CSS shorthand properties for that level. For a further - * discussion of shorthand properties, see the CSS2Properties interface. - * - * This interface is also used to provide a read-only access to the computed - * values of an element. See also the ViewCSS interface. - * - * Note: The CSS Object Model doesn't provide an access to the specified or - * actual values of the CSS cascade. - */ -class CSSStyleDeclaration -{ -private: - - class CSSStyleDeclarationEntry - { - public: - CSSStyleDeclarationEntry(const DOMString &nameArg, - const DOMString &valueArg, - const DOMString &prioArg) - { - name = nameArg; - value = valueArg; - prio = prioArg; - } - virtual ~CSSStyleDeclarationEntry(){} - DOMString name; - DOMString value; - DOMString prio; - }; - - -public: - - /** - * The parsable textual representation of the declaration block (excluding the - * surrounding curly braces). - */ - virtual DOMString getCssText() - { - return cssText; - } - - /** - * The parsable textual representation of the declaration block (excluding the - * surrounding curly braces). Setting this attribute will result in the parsing - * of the new value and resetting of all the properties in the declaration block - * including the removal or addition of properties. - */ - virtual void setCssText(const DOMString &val) - throw (dom::DOMException) - { - cssText = val; - } - - /** - * Used to retrieve the value of a CSS property if it has been explicitly - * set within this declaration block. - */ - virtual DOMString getPropertyValue(const DOMString &propertyName) - { - std::vector::iterator iter; - for (iter=items.begin() ; iter!=items.end() ; ++iter) - { - if (iter->name == propertyName) - return iter->value; - } - return ""; - } - - /** - * Used to retrieve the object representation of the value of a CSS property if - * it has been explicitly set within this declaration block. This method returns - * null if the property is a shorthand property. Shorthand property values can - * only be accessed and modified as strings, using the getPropertyValue and - * setProperty methods. - */ - virtual CSSValue getPropertyCSSValue(const DOMString &/*propertyName*/) - { - CSSValue value; - return value; - } - - /** - * Used to remove a CSS property if it has been explicitly set within - * this declaration block. - */ - virtual DOMString removeProperty(const DOMString &propertyName) - throw (dom::DOMException) - { - std::vector::iterator iter; - for (iter=items.begin() ; iter!=items.end() ; ){ - if (iter->name == propertyName){ - iter = items.erase(iter); - } - else{ - ++iter; - } - } - return propertyName; - } - - /** - * Used to retrieve the priority of a CSS property (e.g. the "important" - * qualifier) if the property has been explicitly set in this declaration block. - */ - virtual DOMString getPropertyPriority(const DOMString &propertyName) - { - std::vector::iterator iter; - for (iter=items.begin() ; iter!=items.end() ; ++iter) - { - if (iter->name == propertyName) - return iter->prio; - } - return ""; - } - - /** - * Used to set a property value and priority within this declaration block. - */ - virtual void setProperty(const DOMString &propertyName, - const DOMString &value, - const DOMString &priority) - throw (dom::DOMException) - { - std::vector::iterator iter; - for (iter=items.begin() ; iter!=items.end() ; ++iter) - { - if (iter->name == propertyName) - { - iter->name = propertyName; - iter->value = value; - iter->prio = priority; - return; - } - } - CSSStyleDeclarationEntry entry(propertyName, value, priority); - items.push_back(entry); - } - - /** - * The number of properties that have been explicitly set in this declaration - * block. The range of valid indices is 0 to length-1 inclusive. - */ - virtual unsigned long getLength() - { - return items.size(); - } - - /** - * Used to retrieve the properties that have been explicitly set in this - * declaration block. The order of the properties retrieved using this method - * does not have to be the order in which they were set. This method can be used - * to iterate over all properties in this declaration block. - */ - virtual DOMString item(unsigned long index) - { - if (index>=items.size()) - return ""; - DOMString ret = items[index].name; - ret.append(":"); - ret.append(items[index].value); - return ret; - } - - /** - * The CSS rule that contains this declaration block or null if this - * CSSStyleDeclaration is not attached to a CSSRule. - */ - virtual CSSRule *getParentRule() - { - return parentRule; - } - - //################## - //# Non-API methods - //################## - - /** - * - */ - CSSStyleDeclaration() - { - parentRule = NULL; - } - - /** - * - */ - CSSStyleDeclaration(const CSSStyleDeclaration &other) - { - assign(other); - } - - /** - * - */ - CSSStyleDeclaration &operator=(const CSSStyleDeclaration &other) - { - assign(other); - return *this; - } - - /** - * - */ - void assign(const CSSStyleDeclaration &other) - { - parentRule = other.parentRule; - cssText = other.cssText; - items = other.items; - } - - /** - * - */ - virtual ~CSSStyleDeclaration() {} - -protected: - - DOMString cssText; - - CSSRule *parentRule; - - std::vector items; -}; - - - - -/*######################################################################### -## CSSStyleRule -#########################################################################*/ - -/** - * The CSSStyleRule interface represents a single rule set in a CSS style sheet. - */ -class CSSStyleRule : virtual public CSSRule -{ -public: - - /** - * The textual representation of the selector for the rule set. The - * implementation may have stripped out insignificant whitespace while parsing - * the selector. - */ - virtual DOMString getSelectorText() - { - return selectorText; - } - - /** - * The textual representation of the selector for the rule set. The - * implementation may have stripped out insignificant whitespace while parsing - * the selector. Setting implies reparsing. - */ - virtual void setSelectorText(const DOMString &val) - throw (dom::DOMException) - { - selectorText = val; - } - - - /** - * The declaration-block of this rule set. - */ - virtual CSSStyleDeclaration &getStyle() - { - return style; - } - - //################## - //# Non-API methods - //################## - - /** - * - */ - CSSStyleRule() : CSSRule() - { - type = STYLE_RULE; - selectorText = ""; - } - - - /** - * - */ - CSSStyleRule(const CSSStyleRule &other) : CSSRule(other) - { - assign(other); - } - - /** - * - */ - CSSStyleRule &operator=(const CSSStyleRule &other) - { - assign(other); - return *this; - } - - /** - * - */ - void assign(const CSSStyleRule &other) - { - selectorText = other.selectorText; - style = other.style; - } - - /** - * - */ - virtual ~CSSStyleRule() {} - -protected: - - DOMString selectorText; - - CSSStyleDeclaration style; - -}; - -/*######################################################################### -## CSSMediaRule -#########################################################################*/ - -/** - * The CSSMediaRule interface represents a @media rule in a CSS style sheet. A - * @media rule can be used to delimit style rules for specific media types. - */ -class CSSMediaRule : virtual public CSSRule -{ -public: - - /** - * A list of media types for this rule. - */ - virtual stylesheets::MediaList getMedia() - { - return mediaList; - } - - /** - * A list of all CSS rules contained within the media block. - */ - virtual CSSRuleList getCssRules() - { - return cssRules; - } - - /** - * Used to insert a new rule into the media block. - */ - virtual unsigned long insertRule(const DOMString &/*ruleStr*/, - unsigned long index) - throw (dom::DOMException) - { - if (index>cssRules.getLength()) - return 0; - CSSRule rule; - cssRules.insertRule(rule, index); - return index; - } - - /** - * Used to delete a rule from the media block. - */ - virtual void deleteRule(unsigned long index) - throw(dom::DOMException) - { - cssRules.deleteRule(index); - } - - //################## - //# Non-API methods - //################## - - /** - * - */ - CSSMediaRule() : CSSRule() - { - type = MEDIA_RULE; - } - - /** - * - */ - CSSMediaRule(const CSSMediaRule &other) : CSSRule(other) - { - assign(other); - } - - /** - * - */ - CSSMediaRule &operator=(const CSSMediaRule &other) - { - assign(other); - return *this; - } - - /** - * - */ - void assign(const CSSMediaRule &other) - { - mediaList = other.mediaList; - cssRules = other.cssRules; - } - - /** - * - */ - virtual ~CSSMediaRule() {} - -protected: - - stylesheets::MediaList mediaList; - - CSSRuleList cssRules; -}; - - - - -/*######################################################################### -## CSSFontFaceRule -#########################################################################*/ - -/** - * The CSSFontFaceRule interface represents a @font-face rule in a CSS style - * sheet. The @font-face rule is used to hold a set of font descriptions. - */ -class CSSFontFaceRule : virtual public CSSRule -{ -public: - - /** - * The declaration-block of this rule. - */ - virtual CSSStyleDeclaration getStyle() - { - return style; - } - - - //################## - //# Non-API methods - //################## - - /** - * - */ - CSSFontFaceRule() : CSSRule() - { - type = FONT_FACE_RULE; - } - - /** - * - */ - CSSFontFaceRule(const CSSFontFaceRule &other) - : CSSRule(other), - style (other.style) - { - } - - /** - * - */ - CSSFontFaceRule &operator=(const CSSFontFaceRule &other) - { - style = other.style; - return *this; - } - - /** - * - */ - void assign(const CSSFontFaceRule &other) - { - style = other.style; - } - - /** - * - */ - virtual ~CSSFontFaceRule() {} - -protected: - - CSSStyleDeclaration style; -}; - - - - -/*######################################################################### -## CSSPageRule -#########################################################################*/ - -/** - * The CSSPageRule interface represents a @page rule within a CSS style sheet. - * The @page rule is used to specify the dimensions, orientation, margins, etc. - * of a page box for paged media. - */ -class CSSPageRule : virtual public CSSRule -{ -public: - - /** - * The parsable textual representation of the page selector for the rule. - */ - virtual DOMString getSelectorText() - { - return selectorText; - } - - /** - * The parsable textual representation of the page selector for the rule. - * Setting implies parsing. - */ - virtual void setSelectorText(const DOMString &val) - throw(dom::DOMException) - { - selectorText = val; - } - - - /** - * The declaration-block of this rule. - */ - virtual CSSStyleDeclaration getStyle() - { - return style; - } - - - //################## - //# Non-API methods - //################## - - /** - * - */ - CSSPageRule() : CSSRule() - { - type = PAGE_RULE; - } - - /** - * - */ - CSSPageRule(const CSSPageRule &other) : CSSRule(other) - { - assign(other); - } - - /** - * - */ - CSSPageRule &operator=(const CSSPageRule &other) - { - assign(other); - return *this; - } - - /** - * - */ - void assign(const CSSPageRule &other) - { - selectorText = other.selectorText; - style = other.style; - } - - /** - * - */ - virtual ~CSSPageRule() {} - -protected: - - DOMString selectorText; - - CSSStyleDeclaration style; -}; - - - - - -/*######################################################################### -## CSSImportRule -#########################################################################*/ - -/** - * The CSSImportRule interface represents a @import rule within a CSS style - * sheet. The @import rule is used to import style rules from other style sheets. - */ -class CSSImportRule : virtual public CSSRule -{ -public: - - /** - * The location of the style sheet to be imported. The attribute will not contain - * the "url(...)" specifier around the URI. - */ - virtual DOMString getHref() - { - return href; - } - - /** - * A list of media types for which this style sheet may be used. - */ - virtual stylesheets::MediaList getMedia() - { - return mediaList; - } - - /** - * The style sheet referred to by this rule, if it has been loaded. The value of - * this attribute is null if the style sheet has not yet been loaded or if it - * will not be loaded (e.g. if the style sheet is for a media type not supported - * by the user agent). - */ - virtual CSSStyleSheet getStyleSheet() - { - return styleSheet; - } - - - //################## - //# Non-API methods - //################## - - /** - * - */ - CSSImportRule() : CSSRule() - { - type = IMPORT_RULE; - } - - /** - * - */ - CSSImportRule(const CSSImportRule &other) : CSSRule(other) - { - assign(other); - } - - /** - * - */ - CSSImportRule &operator=(const CSSImportRule &other) - { - assign(other); - return *this; - } - - /** - * - */ - void assign(const CSSImportRule &other) - { - href = other.href; - mediaList = other.mediaList; - styleSheet = other.styleSheet; - } - - /** - * - */ - virtual ~CSSImportRule() {} - -protected: - - DOMString href; - - stylesheets::MediaList mediaList; - - CSSStyleSheet styleSheet; -}; - - - - - - -/*######################################################################### -## CSSCharsetRule -#########################################################################*/ - -/** - * The CSSCharsetRule interface represents a @charset rule in a CSS style sheet. - * The value of the encoding attribute does not affect the encoding of text data - * in the DOM objects; this encoding is always UTF-16. After a stylesheet is - * loaded, the value of the encoding attribute is the value found in the @charset - * rule. If there was no @charset in the original document, then no - * CSSCharsetRule is created. The value of the encoding attribute may also be - * used as a hint for the encoding used on serialization of the style sheet. - * - * The value of the @charset rule (and therefore of the CSSCharsetRule) may not - * correspond to the encoding the document actually came in; character encoding - * information e.g. in an HTTP header, has priority (see CSS document - * representation) but this is not reflected in the CSSCharsetRule. - */ -class CSSCharsetRule : virtual public CSSRule -{ -public: - - /** - * The encoding information used in this @charset rule. - */ - virtual DOMString getEncoding() - { - return encoding; - } - - /** - * The encoding information used in this @charset rule. - * Setting implies parsing. - */ - virtual void setEncoding(const DOMString &val) throw (dom::DOMException) - { - encoding = val; - } - - //################## - //# Non-API methods - //################## - - /** - * - */ - CSSCharsetRule() : CSSRule() - { - type = CHARSET_RULE; - } - - /** - * - */ - CSSCharsetRule(const CSSCharsetRule &other) : CSSRule(other) - { - encoding = other.encoding; - } - - /** - * - */ - CSSCharsetRule &operator=(const CSSCharsetRule &other) - { - encoding = other.encoding; - return *this; - } - - /** - * - */ - virtual ~CSSCharsetRule() {} - -protected: - - DOMString encoding; - -}; - - - - - -/*######################################################################### -## CSSUnknownRule -#########################################################################*/ - -/** - * The CSSUnknownRule interface represents an at-rule not supported by - * this user agent. - */ -class CSSUnknownRule : virtual public CSSRule -{ -public: - - //################## - //# Non-API methods - //################## - - /** - * - */ - CSSUnknownRule() : CSSRule() - { - type = UNKNOWN_RULE; - } - - /** - * - */ - CSSUnknownRule(const CSSUnknownRule &other) : CSSRule(other) - { - } - - /** - * - */ - CSSUnknownRule &operator=(const CSSUnknownRule &/*other*/) - { - return *this; - } - - /** - * - */ - virtual ~CSSUnknownRule() {} -}; - - - - - - - -/*######################################################################### -## CSSValueList -#########################################################################*/ - -/** - * The CSSValueList interface provides the abstraction of an ordered collection - * of CSS values. - * - * Some properties allow an empty list into their syntax. In that case, these - * properties take the none identifier. So, an empty list means that the property - * has the value none. - * - * The items in the CSSValueList are accessible via an integral index, starting - * from 0. - */ -class CSSValueList : virtual public CSSValue -{ -public: - - /** - * The number of CSSValues in the list. The range of valid values of the indices - * is 0 to length-1 inclusive. - */ - virtual unsigned long getLength() - { - return items.size(); - } - - /** - * Used to retrieve a CSSValue by ordinal index. The order in this collection - * represents the order of the values in the CSS style property. If index is - * greater than or equal to the number of values in the list, this returns null. - */ - virtual CSSValue item(unsigned long index) - { - if (index>=items.size()) - { - CSSValue dummy; - return dummy; - } - return items[index]; - } - - - //################## - //# Non-API methods - //################## - - /** - * - */ - CSSValueList() - { - } - - /** - * - */ - CSSValueList(const CSSValueList &other) - : CSSValue(other), - items (other.items) - { - } - - /** - * - */ - CSSValueList &operator=(const CSSValueList &other) - { - items = other.items; - return *this; - } - - /** - * - */ - virtual ~CSSValueList() {} - -protected: - - std::vector items; -}; - - - - -/*######################################################################### -## CSSPrimitiveValue -#########################################################################*/ - -/** - * The CSSPrimitiveValue interface represents a single CSS value. This interface - * may be used to determine the value of a specific style property currently set - * in a block or to set a specific style property explicitly within the block. An - * instance of this interface might be obtained from the getPropertyCSSValue - * method of the CSSStyleDeclaration interface. A CSSPrimitiveValue object only - * occurs in a context of a CSS property. - * - * Conversions are allowed between absolute values (from millimeters to - * centimeters, from degrees to radians, and so on) but not between relative - * values. (For example, a pixel value cannot be converted to a centimeter value.) - * Percentage values can't be converted since they are relative to the parent - * value (or another property value). There is one exception for color percentage - * values: since a color percentage value is relative to the range 0-255, a color - * percentage value can be converted to a number; (see also the RGBColor - * interface). - */ -class CSSPrimitiveValue : virtual public CSSValue -{ -public: - - /** - *An integer indicating which type of unit applies to the value. - */ - typedef enum - { - CSS_UNKNOWN = 0, - CSS_NUMBER = 1, - CSS_PERCENTAGE = 2, - CSS_EMS = 3, - CSS_EXS = 4, - CSS_PX = 5, - CSS_CM = 6, - CSS_MM = 7, - CSS_IN = 8, - CSS_PT = 9, - CSS_PC = 10, - CSS_DEG = 11, - CSS_RAD = 12, - CSS_GRAD = 13, - CSS_MS = 14, - CSS_S = 15, - CSS_HZ = 16, - CSS_KHZ = 17, - CSS_DIMENSION = 18, - CSS_STRING = 19, - CSS_URI = 20, - CSS_IDENT = 21, - CSS_ATTR = 22, - CSS_COUNTER = 23, - CSS_RECT = 24, - CSS_RGBCOLOR = 25 - } UnitTypes; - - - /** - * The type of the value as defined by the constants specified above. - */ - virtual unsigned short getPrimitiveType() - { - return primitiveType; - } - - /** - * A method to set the float value with a specified unit. If the property - * attached with this value can not accept the specified unit or the float value, - * the value will be unchanged and a DOMException will be raised. - */ - virtual void setFloatValue(unsigned short unitType, - double doubleValueArg) - throw (dom::DOMException) - { - primitiveType = unitType; - doubleValue = doubleValueArg; - } - - /** - * This method is used to get a float value in a specified unit. If this CSS - * value doesn't contain a float value or can't be converted into the specified - * unit, a DOMException is raised. - */ - virtual double getFloatValue(unsigned short /*unitType*/) - throw (dom::DOMException) - { - return doubleValue; - } - - /** - * A method to set the string value with the specified unit. If the property - * attached to this value can't accept the specified unit or the string value, - * the value will be unchanged and a DOMException will be raised. - */ - virtual void setStringValue(unsigned short /*stringType*/, - const DOMString &stringValueArg) - throw (dom::DOMException) - { - stringValue = stringValueArg; - } - - /** - * This method is used to get the string value. If the CSS value doesn't contain - * a string value, a DOMException is raised. - * - * Note: Some properties (like 'font-family' or 'voice-family') convert a - * whitespace separated list of idents to a string. - */ - virtual DOMString getStringValue() throw (dom::DOMException) - { - return stringValue; - } - - /** - * This method is used to get the Counter value. If this CSS value doesn't - * contain a counter value, a DOMException is raised. Modification to the - * corresponding style property can be achieved using the Counter interface. - */ - virtual Counter *getCounterValue() throw (dom::DOMException) - { - return NULL; - } - - /** - * This method is used to get the Rect value. If this CSS value doesn't contain a - * rect value, a DOMException is raised. Modification to the corresponding style - * property can be achieved using the Rect interface. - */ - virtual Rect *getRectValue() throw (dom::DOMException) - { - return NULL; - } - - /** - * This method is used to get the RGB color. If this CSS value doesn't contain a - * RGB color value, a DOMException is raised. Modification to the corresponding - * style property can be achieved using the RGBColor interface. - */ - virtual RGBColor *getRGBColorValue() throw (dom::DOMException) - { - return NULL; - } - - //################## - //# Non-API methods - //################## - - /** - * - */ - CSSPrimitiveValue() : - CSSValue(), - primitiveType(0), - doubleValue(0), - stringValue() - { - } - - /** - * - */ - CSSPrimitiveValue(const CSSPrimitiveValue &other) : - CSSValue() - { - primitiveType = other.primitiveType; - doubleValue = other.doubleValue; - stringValue = other.stringValue; - } - - /** - * - */ - CSSPrimitiveValue &operator=(const CSSPrimitiveValue &other) - { - if(this == &other) - { - return *this; - } - primitiveType = other.primitiveType; - doubleValue = other.doubleValue; - stringValue = other.stringValue; - return *this; - } - - /** - * - */ - virtual ~CSSPrimitiveValue() {} - -protected: - - int primitiveType; - - double doubleValue; - - DOMString stringValue; - - -}; - - - -/*######################################################################### -## RGBColor -#########################################################################*/ - -/** - * The RGBColor interface is used to represent any RGB color value. This - * interface reflects the values in the underlying style property. Hence, - * modifications made to the CSSPrimitiveValue objects modify the style property. - * - * A specified RGB color is not clipped (even if the number is outside the range - * 0-255 or 0%-100%). A computed RGB color is clipped depending on the device. - * - * Even if a style sheet can only contain an integer for a color value, the - * internal storage of this integer is a float, and this can be used as a float - * in the specified or the computed style. - * - * A color percentage value can always be converted to a number and vice versa. - */ -class RGBColor -{ -public: - - /** - * This attribute is used for the red value of the RGB color. - */ - virtual CSSPrimitiveValue getRed() - { - return red; - } - - /** - * This attribute is used for the green value of the RGB color. - */ - virtual CSSPrimitiveValue getGreen() - { - return green; - } - - /** - * This attribute is used for the blue value of the RGB color. - */ - virtual CSSPrimitiveValue getBlue() - { - return blue; - } - - /** - * REPLACES: RGBColor CSSPrimitiveValue::getRGBColorValue() throw (dom::DOMException) - */ - static RGBColor getRGBColorValue(const CSSPrimitiveValue &/*val*/) - { - RGBColor col; - return col; - } - - //################## - //# Non-API methods - //################## - - /** - * - */ - RGBColor() {} - - /** - * - */ - RGBColor(const RGBColor &other) - { - assign(other); - } - - /** - * - */ - RGBColor &operator=(const RGBColor &other) - { - assign(other); - return *this; - } - - /** - * - */ - void assign(const RGBColor &other) - { - red = other.red; - green = other.green; - blue = other.blue; - } - - /** - * - */ - virtual ~RGBColor() {} - -protected: - - CSSPrimitiveValue red; - CSSPrimitiveValue green; - CSSPrimitiveValue blue; -}; - - - - -/*######################################################################### -## Rect -#########################################################################*/ - -/** - * The Rect interface is used to represent any rect value. This interface - * reflects the values in the underlying style property. Hence, modifications - * made to the CSSPrimitiveValue objects modify the style property. - */ -class Rect -{ -public: - - /** - * This attribute is used for the top of the rect. - */ - virtual CSSPrimitiveValue getTop() - { - return top; - } - - /** - * This attribute is used for the right of the rect. - */ - virtual CSSPrimitiveValue getRight() - { - return right; - } - - /** - * This attribute is used for the bottom of the rect. - */ - virtual CSSPrimitiveValue getBottom() - { - return bottom; - } - - /** - * This attribute is used for the left of the rect. - */ - virtual CSSPrimitiveValue getLeft() - { - return left; - } - - /** - * REPLACES: Rect CSSPrimitiveValue::getRectValue() throw (dom::DOMException) - */ - static Rect getRectValue(const CSSPrimitiveValue &/*val*/) - { - Rect rect; - return rect; - } - - //################## - //# Non-API methods - //################## - - /** - * - */ - Rect() {} - - /** - * - */ - Rect(const Rect &other) - { - assign(other); - } - - /** - * - */ - Rect &operator=(const Rect &other) - { - assign(other); - return *this; - } - - /** - * - */ - void assign(const Rect &other) - { - top = other.top; - right = other.right; - bottom = other.bottom; - left = other.left; - } - - /** - * - */ - virtual ~Rect() {} - -protected: - - CSSPrimitiveValue top; - CSSPrimitiveValue right; - CSSPrimitiveValue bottom; - CSSPrimitiveValue left; -}; - - - - - - -/*######################################################################### -## Counter -#########################################################################*/ - -/** - * The Counter interface is used to represent any counter or counters function - * value. This interface reflects the values in the underlying style property. - */ -class Counter -{ -public: - - /** - * This attribute is used for the identifier of the counter. - */ - virtual DOMString getIdentifier() - { - return identifier; - } - - /** - * This attribute is used for the style of the list. - */ - virtual DOMString getListStyle() - { - return listStyle; - } - - /** - * This attribute is used for the separator of the nested counters. - */ - virtual DOMString getSeparator() - { - return separator; - } - - /** - * REPLACES: Counter CSSPrimitiveValue::getCounterValue() throw (dom::DOMException) - */ - static Counter getCounterValue(const CSSPrimitiveValue &/*val*/) - { - Counter counter; - return counter; - } - - //################## - //# Non-API methods - //################## - - /** - * - */ - Counter() {} - - /** - * - */ - Counter(const Counter &other) - { - assign(other); - } - - /** - * - */ - Counter &operator=(const Counter &other) - { - assign(other); - return *this; - } - - /** - * - */ - void assign(const Counter &other) - { - identifier = other.identifier; - listStyle = other.listStyle; - separator = other.separator; - } - - /** - * - */ - virtual ~Counter() {} - -protected: - - DOMString identifier; - DOMString listStyle; - DOMString separator; - -}; - - - - -/*######################################################################### -## ElementCSSInlineStyle -#########################################################################*/ - -/** - * Inline style information attached to elements is exposed through the style - * attribute. This represents the contents of the STYLE attribute for HTML - * elements (or elements in other schemas or DTDs which use the STYLE attribute - * in the same way). The expectation is that an instance of the - * ElementCSSInlineStyle interface can be obtained by using binding-specific - * casting methods on an instance of the Element interface when the element - * supports inline CSS style informations. - */ -class ElementCSSInlineStyle -{ -public: - - /** - * The style attribute. - */ - virtual CSSStyleDeclaration getStyle() - { - return style; - } - - //################## - //# Non-API methods - //################## - - /** - * - */ - ElementCSSInlineStyle() {} - - /** - * - */ - ElementCSSInlineStyle(const ElementCSSInlineStyle &other) - : style (other.style) - { - } - - /** - * - */ - ElementCSSInlineStyle &operator=(const ElementCSSInlineStyle &other) - { - style = other.style; - return *this; - } - - /** - * - */ - virtual ~ElementCSSInlineStyle() {} - -protected: - - CSSStyleDeclaration style; -}; - - - - - - -/*######################################################################### -## CSS2Properties -#########################################################################*/ - -/** - * The CSS2Properties interface represents a convenience mechanism for retrieving - * and setting properties within a CSSStyleDeclaration. The attributes of this - * interface correspond to all the properties specified in CSS2. Getting an - * attribute of this interface is equivalent to calling the getPropertyValue - * method of the CSSStyleDeclaration interface. Setting an attribute of this - * interface is equivalent to calling the setProperty method of the - * CSSStyleDeclaration interface. - * - * A conformant implementation of the CSS module is not required to implement the - * CSS2Properties interface. If an implementation does implement this interface, - * the expectation is that language-specific methods can be used to cast from an - * instance of the CSSStyleDeclaration interface to the CSS2Properties interface. - * - * If an implementation does implement this interface, it is expected to - * understand the specific syntax of the shorthand properties, and apply their - * semantics; when the margin property is set, for example, the marginTop, - * marginRight, marginBottom and marginLeft properties are actually being set by - * the underlying implementation. - * - * When dealing with CSS "shorthand" properties, the shorthand properties should - * be decomposed into their component longhand properties as appropriate, and - * when querying for their value, the form returned should be the shortest form - * exactly equivalent to the declarations made in the ruleset. However, if there - * is no shorthand declaration that could be added to the ruleset without - * changing in any way the rules already declared in the ruleset (i.e., by adding - * longhand rules that were previously not declared in the ruleset), then the - * empty string should be returned for the shorthand property. - * - * For example, querying for the font property should not return "normal normal - * normal 14pt/normal Arial, sans-serif", when "14pt Arial, sans-serif" suffices. - * (The normals are initial values, and are implied by use of the longhand - * property.) - * - * If the values for all the longhand properties that compose a particular string - * are the initial values, then a string consisting of all the initial values - * should be returned (e.g. a border-width value of "medium" should be returned - * as such, not as ""). - * - * For some shorthand properties that take missing values from other sides, such - * as the margin, padding, and border-[width|style|color] properties, the minimum - * number of sides possible should be used; i.e., "0px 10px" will be returned - * instead of "0px 10px 0px 10px". - * - * If the value of a shorthand property can not be decomposed into its component - * longhand properties, as is the case for the font property with a value of - * "menu", querying for the values of the component longhand properties should - * return the empty string. - * */ -class CSS2Properties -{ -public: - - - /** - * return the 'azimuth' property - */ - virtual DOMString getAzimuth() - { - return azimuth; - } - - /** - * set the 'azimuth' property - */ - virtual void setAzimuth(const DOMString &val) - throw (dom::DOMException) - { - azimuth = val; - } - - /** - * return the 'background' property - */ - virtual DOMString getBackground() - { - return background; - } - - /** - * set the 'background' property - */ - virtual void setBackground(const DOMString &val) - throw (dom::DOMException) - { - background = val; - } - - /** - * return the 'backgroundAttachment' property - */ - virtual DOMString getBackgroundAttachment() - { - return backgroundAttachment; - } - - /** - * set the 'backgroundAttachment' property - */ - virtual void setBackgroundAttachment(const DOMString &val) - throw (dom::DOMException) - { - backgroundAttachment = val; - } - - /** - * return the 'backgroundColor' property - */ - virtual DOMString getBackgroundColor() - { - return backgroundColor; - } - - /** - * set the 'backgroundColor' property - */ - virtual void setBackgroundColor(const DOMString &val) - throw (dom::DOMException) - { - backgroundColor = val; - } - - /** - * return the 'backgroundImage' property - */ - virtual DOMString getBackgroundImage() - { - return backgroundImage; - } - - /** - * set the 'backgroundImage' property - */ - virtual void setBackgroundImage(const DOMString &val) - throw (dom::DOMException) - { - backgroundImage = val; - } - - /** - * return the 'backgroundPosition' property - */ - virtual DOMString getBackgroundPosition() - { - return backgroundPosition; - } - - /** - * set the 'backgroundPosition' property - */ - virtual void setBackgroundPosition(const DOMString &val) - throw (dom::DOMException) - { - backgroundPosition = val; - } - - /** - * return the 'backgroundRepeat' property - */ - virtual DOMString getBackgroundRepeat() - { - return backgroundRepeat; - } - - /** - * set the 'backgroundRepeat' property - */ - virtual void setBackgroundRepeat(const DOMString &val) - throw (dom::DOMException) - { - backgroundRepeat = val; - } - - /** - * return the 'border' property - */ - virtual DOMString getBorder() - { - return border; - } - - /** - * set the 'border' property - */ - virtual void setBorder(const DOMString &val) - throw (dom::DOMException) - { - border = val; - } - - /** - * return the 'borderCollapse' property - */ - virtual DOMString getBorderCollapse() - { - return borderCollapse; - } - - /** - * set the 'borderCollapse' property - */ - virtual void setBorderCollapse(const DOMString &val) - throw (dom::DOMException) - { - borderCollapse = val; - } - - /** - * return the 'borderColor' property - */ - virtual DOMString getBorderColor() - { - return borderColor; - } - - /** - * set the 'borderColor' property - */ - virtual void setBorderColor(const DOMString &val) - throw (dom::DOMException) - { - borderColor = val; - } - - /** - * return the 'borderSpacing' property - */ - virtual DOMString getBorderSpacing() - { - return borderSpacing; - } - - /** - * set the 'borderSpacing' property - */ - virtual void setBorderSpacing(const DOMString &val) - throw (dom::DOMException) - { - borderSpacing = val; - } - - /** - * return the 'borderStyle' property - */ - virtual DOMString getBorderStyle() - { - return borderStyle; - } - - /** - * set the 'borderStyle' property - */ - virtual void setBorderStyle(const DOMString &val) - throw (dom::DOMException) - { - borderStyle = val; - } - - /** - * return the 'borderTop' property - */ - virtual DOMString getBorderTop() - { - return borderTop; - } - - /** - * set the 'borderTop' property - */ - virtual void setBorderTop(const DOMString &val) - throw (dom::DOMException) - { - borderTop = val; - } - - /** - * return the 'borderRight' property - */ - virtual DOMString getBorderRight() - { - return borderRight; - } - - /** - * set the 'borderRight' property - */ - virtual void setBorderRight(const DOMString &val) - throw (dom::DOMException) - { - borderRight = val; - } - - /** - * return the 'borderBottom' property - */ - virtual DOMString getBorderBottom() - { - return borderBottom; - } - - /** - * set the 'borderBottom' property - */ - virtual void setBorderBottom(const DOMString &val) - throw (dom::DOMException) - { - borderBottom = val; - } - - /** - * return the 'borderLeft' property - */ - virtual DOMString getBorderLeft() - { - return borderLeft; - } - - /** - * set the 'borderLeft' property - */ - virtual void setBorderLeft(const DOMString &val) - throw (dom::DOMException) - { - borderLeft = val; - } - - /** - * return the 'borderTopColor' property - */ - virtual DOMString getBorderTopColor() - { - return borderTopColor; - } - - /** - * set the 'borderTopColor' property - */ - virtual void setBorderTopColor(const DOMString &val) - throw (dom::DOMException) - { - borderTopColor = val; - } - - /** - * return the 'borderRightColor' property - */ - virtual DOMString getBorderRightColor() - { - return borderRightColor; - } - - /** - * set the 'borderRightColor' property - */ - virtual void setBorderRightColor(const DOMString &val) - throw (dom::DOMException) - { - borderRightColor = val; - } - - /** - * return the 'borderBottomColor' property - */ - virtual DOMString getBorderBottomColor() - { - return borderBottomColor; - } - - /** - * set the 'borderBottomColor' property - */ - virtual void setBorderBottomColor(const DOMString &val) - throw (dom::DOMException) - { - borderBottomColor = val; - } - - /** - * return the 'borderLeftColor' property - */ - virtual DOMString getBorderLeftColor() - { - return borderLeftColor; - } - - /** - * set the 'borderLeftColor' property - */ - virtual void setBorderLeftColor(const DOMString &val) - throw (dom::DOMException) - { - borderLeftColor = val; - } - - /** - * return the 'borderTopStyle' property - */ - virtual DOMString getBorderTopStyle() - { - return borderTopStyle; - } - - /** - * set the 'borderTopStyle' property - */ - virtual void setBorderTopStyle(const DOMString &val) - throw (dom::DOMException) - { - borderTopStyle = val; - } - - /** - * return the 'borderRightStyle' property - */ - virtual DOMString getBorderRightStyle() - { - return borderRightStyle; - } - - /** - * set the 'borderRightStyle' property - */ - virtual void setBorderRightStyle(const DOMString &val) - throw (dom::DOMException) - { - borderRightStyle = val; - } - - /** - * return the 'borderBottomStyle' property - */ - virtual DOMString getBorderBottomStyle() - { - return borderBottomStyle; - } - - /** - * set the 'borderBottomStyle' property - */ - virtual void setBorderBottomStyle(const DOMString &val) - throw (dom::DOMException) - { - borderBottomStyle = val; - } - - /** - * return the 'borderLeftStyle' property - */ - virtual DOMString getBorderLeftStyle() - { - return borderLeftStyle; - } - - /** - * set the 'borderLeftStyle' property - */ - virtual void setBorderLeftStyle(const DOMString &val) - throw (dom::DOMException) - { - borderLeftStyle = val; - } - - /** - * return the 'borderTopWidth' property - */ - virtual DOMString getBorderTopWidth() - { - return borderTopWidth; - } - - /** - * set the 'borderTopWidth' property - */ - virtual void setBorderTopWidth(const DOMString &val) - throw (dom::DOMException) - { - borderTopWidth = val; - } - - /** - * return the 'borderRightWidth' property - */ - virtual DOMString getBorderRightWidth() - { - return borderRightWidth; - } - - /** - * set the 'borderRightWidth' property - */ - virtual void setBorderRightWidth(const DOMString &val) - throw (dom::DOMException) - { - borderRightWidth = val; - } - - /** - * return the 'borderBottomWidth' property - */ - virtual DOMString getBorderBottomWidth() - { - return borderBottomWidth; - } - - /** - * set the 'borderBottomWidth' property - */ - virtual void setBorderBottomWidth(const DOMString &val) - throw (dom::DOMException) - { - borderBottomWidth = val; - } - - /** - * return the 'borderLeftWidth' property - */ - virtual DOMString getBorderLeftWidth() - { - return borderLeftWidth; - } - - /** - * set the 'borderLeftWidth' property - */ - virtual void setBorderLeftWidth(const DOMString &val) - throw (dom::DOMException) - { - borderLeftWidth = val; - } - - /** - * return the 'borderWidth' property - */ - virtual DOMString getBorderWidth() - { - return borderWidth; - } - - /** - * set the 'borderWidth' property - */ - virtual void setBorderWidth(const DOMString &val) - throw (dom::DOMException) - { - borderWidth = val; - } - - /** - * return the 'bottom' property - */ - virtual DOMString getBottom() - { - return bottom; - } - - /** - * set the 'bottom' property - */ - virtual void setBottom(const DOMString &val) - throw (dom::DOMException) - { - bottom = val; - } - - /** - * return the 'captionSide' property - */ - virtual DOMString getCaptionSide() - { - return captionSide; - } - - /** - * set the 'captionSide' property - */ - virtual void setCaptionSide(const DOMString &val) - throw (dom::DOMException) - { - captionSide = val; - } - - /** - * return the 'clear' property - */ - virtual DOMString getClear() - { - return clear; - } - - /** - * set the 'clear' property - */ - virtual void setClear(const DOMString &val) - throw (dom::DOMException) - { - clear = val; - } - - /** - * return the 'clip' property - */ - virtual DOMString getClip() - { - return clip; - } - - /** - * set the 'clip' property - */ - virtual void setClip(const DOMString &val) - throw (dom::DOMException) - { - clip = val; - } - - /** - * return the 'color' property - */ - virtual DOMString getColor() - { - return color; - } - - /** - * set the 'color' property - */ - virtual void setColor(const DOMString &val) - throw (dom::DOMException) - { - color = val; - } - - /** - * return the 'content' property - */ - virtual DOMString getContent() - { - return content; - } - - /** - * set the 'content' property - */ - virtual void setContent(const DOMString &val) - throw (dom::DOMException) - { - content = val; - } - - /** - * return the 'counterIncrement' property - */ - virtual DOMString getCounterIncrement() - { - return counterIncrement; - } - - /** - * set the 'counterIncrement' property - */ - virtual void setCounterIncrement(const DOMString &val) - throw (dom::DOMException) - { - counterIncrement = val; - } - - /** - * return the 'counterReset' property - */ - virtual DOMString getCounterReset() - { - return counterReset; - } - - /** - * set the 'counterReset' property - */ - virtual void setCounterReset(const DOMString &val) - throw (dom::DOMException) - { - counterReset = val; - } - - /** - * return the 'cue' property - */ - virtual DOMString getCue() - { - return cue; - } - - /** - * set the 'cue' property - */ - virtual void setCue(const DOMString &val) - throw (dom::DOMException) - { - cue = val; - } - - /** - * return the 'cueAfter' property - */ - virtual DOMString getCueAfter() - { - return cueAfter; - } - - /** - * set the 'cueAfter' property - */ - virtual void setCueAfter(const DOMString &val) - throw (dom::DOMException) - { - cueAfter = val; - } - - /** - * return the 'cueBefore' property - */ - virtual DOMString getCueBefore() - { - return cueBefore; - } - - /** - * set the 'cueBefore' property - */ - virtual void setCueBefore(const DOMString &val) - throw (dom::DOMException) - { - cueBefore = val; - } - - /** - * return the 'cursor' property - */ - virtual DOMString getCursor() - { - return cursor; - } - - /** - * set the 'cursor' property - */ - virtual void setCursor(const DOMString &val) - throw (dom::DOMException) - { - cursor = val; - } - - /** - * return the 'direction' property - */ - virtual DOMString getDirection() - { - return direction; - } - - /** - * set the 'direction' property - */ - virtual void setDirection(const DOMString &val) - throw (dom::DOMException) - { - direction = val; - } - - /** - * return the 'display' property - */ - virtual DOMString getDisplay() - { - return display; - } - - /** - * set the 'display' property - */ - virtual void setDisplay(const DOMString &val) - throw (dom::DOMException) - { - display = val; - } - - /** - * return the 'elevation' property - */ - virtual DOMString getElevation() - { - return elevation; - } - - /** - * set the 'elevation' property - */ - virtual void setElevation(const DOMString &val) - throw (dom::DOMException) - { - elevation = val; - } - - /** - * return the 'emptyCells' property - */ - virtual DOMString getEmptyCells() - { - return emptyCells; - } - - /** - * set the 'emptyCells' property - */ - virtual void setEmptyCells(const DOMString &val) - throw (dom::DOMException) - { - emptyCells = val; - } - - /** - * return the 'cssFloat' property - */ - virtual DOMString getCssFloat() - { - return cssFloat; - } - - /** - * set the 'cssFloat' property - */ - virtual void setCssFloat(const DOMString &val) - throw (dom::DOMException) - { - cssFloat = val; - } - - /** - * return the 'font' property - */ - virtual DOMString getFont() - { - return font; - } - - /** - * set the 'font' property - */ - virtual void setFont(const DOMString &val) - throw (dom::DOMException) - { - font = val; - } - - /** - * return the 'fontFamily' property - */ - virtual DOMString getFontFamily() - { - return fontFamily; - } - - /** - * set the 'fontFamily' property - */ - virtual void setFontFamily(const DOMString &val) - throw (dom::DOMException) - { - fontFamily = val; - } - - /** - * return the 'fontSize' property - */ - virtual DOMString getFontSize() - { - return fontSize; - } - - /** - * set the 'fontSize' property - */ - virtual void setFontSize(const DOMString &val) - throw (dom::DOMException) - { - fontSize = val; - } - - /** - * return the 'fontSizeAdjust' property - */ - virtual DOMString getFontSizeAdjust() - { - return fontSizeAdjust; - } - - /** - * set the 'fontSizeAdjust' property - */ - virtual void setFontSizeAdjust(const DOMString &val) - throw (dom::DOMException) - { - fontSizeAdjust = val; - } - - /** - * return the 'fontStretch' property - */ - virtual DOMString getFontStretch() - { - return fontStretch; - } - - /** - * set the 'fontStretch' property - */ - virtual void setFontStretch(const DOMString &val) - throw (dom::DOMException) - { - fontStretch = val; - } - - /** - * return the 'fontStyle' property - */ - virtual DOMString getFontStyle() - { - return fontStyle; - } - - /** - * set the 'fontStyle' property - */ - virtual void setFontStyle(const DOMString &val) - throw (dom::DOMException) - { - fontStyle = val; - } - - /** - * return the 'fontVariant' property - */ - virtual DOMString getFontVariant() - { - return fontVariant; - } - - /** - * set the 'fontVariant' property - */ - virtual void setFontVariant(const DOMString &val) - throw (dom::DOMException) - { - fontVariant = val; - } - - /** - * return the 'fontWeight' property - */ - virtual DOMString getFontWeight() - { - return fontWeight; - } - - /** - * set the 'fontWeight' property - */ - virtual void setFontWeight(const DOMString &val) - throw (dom::DOMException) - { - fontWeight = val; - } - - /** - * return the 'height' property - */ - virtual DOMString getHeight() - { - return height; - } - - /** - * set the 'height' property - */ - virtual void setHeight(const DOMString &val) - throw (dom::DOMException) - { - height = val; - } - - /** - * return the 'left' property - */ - virtual DOMString getLeft() - { - return left; - } - - /** - * set the 'left' property - */ - virtual void setLeft(const DOMString &val) - throw (dom::DOMException) - { - left = val; - } - - /** - * return the 'letterSpacing' property - */ - virtual DOMString getLetterSpacing() - { - return letterSpacing; - } - - /** - * set the 'letterSpacing' property - */ - virtual void setLetterSpacing(const DOMString &val) - throw (dom::DOMException) - { - letterSpacing = val; - } - - /** - * return the 'lineHeight' property - */ - virtual DOMString getLineHeight() - { - return lineHeight; - } - - /** - * set the 'lineHeight' property - */ - virtual void setLineHeight(const DOMString &val) - throw (dom::DOMException) - { - lineHeight = val; - } - - /** - * return the 'listStyle' property - */ - virtual DOMString getListStyle() - { - return listStyle; - } - - /** - * set the 'listStyle' property - */ - virtual void setListStyle(const DOMString &val) - throw (dom::DOMException) - { - listStyle = val; - } - - /** - * return the 'listStyleImage' property - */ - virtual DOMString getListStyleImage() - { - return listStyleImage; - } - - /** - * set the 'listStyleImage' property - */ - virtual void setListStyleImage(const DOMString &val) - throw (dom::DOMException) - { - listStyleImage = val; - } - - /** - * return the 'listStylePosition' property - */ - virtual DOMString getListStylePosition() - { - return listStylePosition; - } - - /** - * set the 'listStylePosition' property - */ - virtual void setListStylePosition(const DOMString &val) - throw (dom::DOMException) - { - listStylePosition = val; - } - - /** - * return the 'listStyleType' property - */ - virtual DOMString getListStyleType() - { - return listStyleType; - } - - /** - * set the 'listStyleType' property - */ - virtual void setListStyleType(const DOMString &val) - throw (dom::DOMException) - { - listStyleType = val; - } - - /** - * return the 'margin' property - */ - virtual DOMString getMargin() - { - return margin; - } - - /** - * set the 'margin' property - */ - virtual void setMargin(const DOMString &val) - throw (dom::DOMException) - { - margin = val; - } - - /** - * return the 'marginTop' property - */ - virtual DOMString getMarginTop() - { - return marginTop; - } - - /** - * set the 'marginTop' property - */ - virtual void setMarginTop(const DOMString &val) - throw (dom::DOMException) - { - marginTop = val; - } - - /** - * return the 'marginRight' property - */ - virtual DOMString getMarginRight() - { - return marginRight; - } - - /** - * set the 'marginRight' property - */ - virtual void setMarginRight(const DOMString &val) - throw (dom::DOMException) - { - marginRight = val; - } - - /** - * return the 'marginBottom' property - */ - virtual DOMString getMarginBottom() - { - return marginBottom; - } - - /** - * set the 'marginBottom' property - */ - virtual void setMarginBottom(const DOMString &val) - throw (dom::DOMException) - { - marginBottom = val; - } - - /** - * return the 'marginLeft' property - */ - virtual DOMString getMarginLeft() - { - return marginLeft; - } - - /** - * set the 'marginLeft' property - */ - virtual void setMarginLeft(const DOMString &val) - throw (dom::DOMException) - { - marginLeft = val; - } - - /** - * return the 'markerOffset' property - */ - virtual DOMString getMarkerOffset() - { - return markerOffset; - } - - /** - * set the 'markerOffset' property - */ - virtual void setMarkerOffset(const DOMString &val) - throw (dom::DOMException) - { - markerOffset = val; - } - - /** - * return the 'marks' property - */ - virtual DOMString getMarks() - { - return marks; - } - - /** - * set the 'marks' property - */ - virtual void setMarks(const DOMString &val) - throw (dom::DOMException) - { - marks = val; - } - - /** - * return the 'maxHeight' property - */ - virtual DOMString getMaxHeight() - { - return maxHeight; - } - - /** - * set the 'maxHeight' property - */ - virtual void setMaxHeight(const DOMString &val) - throw (dom::DOMException) - { - maxHeight = val; - } - - /** - * return the 'maxWidth' property - */ - virtual DOMString getMaxWidth() - { - return maxWidth; - } - - /** - * set the 'maxWidth' property - */ - virtual void setMaxWidth(const DOMString &val) - throw (dom::DOMException) - { - maxWidth = val; - } - - /** - * return the 'minHeight' property - */ - virtual DOMString getMinHeight() - { - return minHeight; - } - - /** - * set the 'minHeight' property - */ - virtual void setMinHeight(const DOMString &val) - throw (dom::DOMException) - { - minHeight = val; - } - - /** - * return the 'minWidth' property - */ - virtual DOMString getMinWidth() - { - return minWidth; - } - - /** - * set the 'minWidth' property - */ - virtual void setMinWidth(const DOMString &val) - throw (dom::DOMException) - { - minWidth = val; - } - - /** - * return the 'orphans' property - */ - virtual DOMString getOrphans() - { - return orphans; - } - - /** - * set the 'orphans' property - */ - virtual void setOrphans(const DOMString &val) - throw (dom::DOMException) - { - orphans = val; - } - - /** - * return the 'outline' property - */ - virtual DOMString getOutline() - { - return outline; - } - - /** - * set the 'outline' property - */ - virtual void setOutline(const DOMString &val) - throw (dom::DOMException) - { - outline = val; - } - - /** - * return the 'outlineColor' property - */ - virtual DOMString getOutlineColor() - { - return outlineColor; - } - - /** - * set the 'outlineColor' property - */ - virtual void setOutlineColor(const DOMString &val) - throw (dom::DOMException) - { - outlineColor = val; - } - - /** - * return the 'outlineStyle' property - */ - virtual DOMString getOutlineStyle() - { - return outlineStyle; - } - - /** - * set the 'outlineStyle' property - */ - virtual void setOutlineStyle(const DOMString &val) - throw (dom::DOMException) - { - outlineStyle = val; - } - - /** - * return the 'outlineWidth' property - */ - virtual DOMString getOutlineWidth() - { - return outlineWidth; - } - - /** - * set the 'outlineWidth' property - */ - virtual void setOutlineWidth(const DOMString &val) - throw (dom::DOMException) - { - outlineWidth = val; - } - - /** - * return the 'overflow' property - */ - virtual DOMString getOverflow() - { - return overflow; - } - - /** - * set the 'overflow' property - */ - virtual void setOverflow(const DOMString &val) - throw (dom::DOMException) - { - overflow = val; - } - - /** - * return the 'padding' property - */ - virtual DOMString getPadding() - { - return padding; - } - - /** - * set the 'padding' property - */ - virtual void setPadding(const DOMString &val) - throw (dom::DOMException) - { - padding = val; - } - - /** - * return the 'paddingTop' property - */ - virtual DOMString getPaddingTop() - { - return paddingTop; - } - - /** - * set the 'paddingTop' property - */ - virtual void setPaddingTop(const DOMString &val) - throw (dom::DOMException) - { - paddingTop = val; - } - - /** - * return the 'paddingRight' property - */ - virtual DOMString getPaddingRight() - { - return paddingRight; - } - - /** - * set the 'paddingRight' property - */ - virtual void setPaddingRight(const DOMString &val) - throw (dom::DOMException) - { - paddingRight = val; - } - - /** - * return the 'paddingBottom' property - */ - virtual DOMString getPaddingBottom() - { - return paddingBottom; - } - - /** - * set the 'paddingBottom' property - */ - virtual void setPaddingBottom(const DOMString &val) - throw (dom::DOMException) - { - paddingBottom = val; - } - - /** - * return the 'paddingLeft' property - */ - virtual DOMString getPaddingLeft() - { - return paddingLeft; - } - - /** - * set the 'paddingLeft' property - */ - virtual void setPaddingLeft(const DOMString &val) - throw (dom::DOMException) - { - paddingLeft = val; - } - - /** - * return the 'page' property - */ - virtual DOMString getPage() - { - return page; - } - - /** - * set the 'page' property - */ - virtual void setPage(const DOMString &val) - throw (dom::DOMException) - { - page = val; - } - - /** - * return the 'pageBreakAfter' property - */ - virtual DOMString getPageBreakAfter() - { - return pageBreakAfter; - } - - /** - * set the 'pageBreakAfter' property - */ - virtual void setPageBreakAfter(const DOMString &val) - throw (dom::DOMException) - { - pageBreakAfter = val; - } - - /** - * return the 'pageBreakBefore' property - */ - virtual DOMString getPageBreakBefore() - { - return pageBreakBefore; - } - - /** - * set the 'pageBreakBefore' property - */ - virtual void setPageBreakBefore(const DOMString &val) - throw (dom::DOMException) - { - pageBreakBefore = val; - } - - /** - * return the 'pageBreakInside' property - */ - virtual DOMString getPageBreakInside() - { - return pageBreakInside; - } - - /** - * set the 'pageBreakInside' property - */ - virtual void setPageBreakInside(const DOMString &val) - throw (dom::DOMException) - { - pageBreakInside = val; - } - - /** - * return the 'pause' property - */ - virtual DOMString getPause() - { - return pause; - } - - /** - * set the 'pause' property - */ - virtual void setPause(const DOMString &val) - throw (dom::DOMException) - { - pause = val; - } - - /** - * return the 'pauseAfter' property - */ - virtual DOMString getPauseAfter() - { - return pauseAfter; - } - - /** - * set the 'pauseAfter' property - */ - virtual void setPauseAfter(const DOMString &val) - throw (dom::DOMException) - { - pauseAfter = val; - } - - /** - * return the 'pauseBefore' property - */ - virtual DOMString getPauseBefore() - { - return pauseBefore; - } - - /** - * set the 'pauseBefore' property - */ - virtual void setPauseBefore(const DOMString &val) - throw (dom::DOMException) - { - pauseBefore = val; - } - - /** - * return the 'pitch' property - */ - virtual DOMString getPitch() - { - return pitch; - } - - /** - * set the 'pitch' property - */ - virtual void setPitch(const DOMString &val) - throw (dom::DOMException) - { - pitch = val; - } - - /** - * return the 'pitchRange' property - */ - virtual DOMString getPitchRange() - { - return pitchRange; - } - - /** - * set the 'pitchRange' property - */ - virtual void setPitchRange(const DOMString &val) - throw (dom::DOMException) - { - pitchRange = val; - } - - /** - * return the 'playDuring' property - */ - virtual DOMString getPlayDuring() - { - return playDuring; - } - - /** - * set the 'playDuring' property - */ - virtual void setPlayDuring(const DOMString &val) - throw (dom::DOMException) - { - playDuring = val; - } - - /** - * return the 'position' property - */ - virtual DOMString getPosition() - { - return position; - } - - /** - * set the 'position' property - */ - virtual void setPosition(const DOMString &val) - throw (dom::DOMException) - { - position = val; - } - - /** - * return the 'quotes' property - */ - virtual DOMString getQuotes() - { - return quotes; - } - - /** - * set the 'quotes' property - */ - virtual void setQuotes(const DOMString &val) - throw (dom::DOMException) - { - quotes = val; - } - - /** - * return the 'richness' property - */ - virtual DOMString getRichness() - { - return richness; - } - - /** - * set the 'richness' property - */ - virtual void setRichness(const DOMString &val) - throw (dom::DOMException) - { - richness = val; - } - - /** - * return the 'right' property - */ - virtual DOMString getRight() - { - return right; - } - - /** - * set the 'right' property - */ - virtual void setRight(const DOMString &val) - throw (dom::DOMException) - { - right = val; - } - - /** - * return the 'size' property - */ - virtual DOMString getSize() - { - return size; - } - - /** - * set the 'size' property - */ - virtual void setSize(const DOMString &val) - throw (dom::DOMException) - { - size = val; - } - - /** - * return the 'speak' property - */ - virtual DOMString getSpeak() - { - return speak; - } - - /** - * set the 'speak' property - */ - virtual void setSpeak(const DOMString &val) - throw (dom::DOMException) - { - speak = val; - } - - /** - * return the 'speakHeader' property - */ - virtual DOMString getSpeakHeader() - { - return speakHeader; - } - - /** - * set the 'speakHeader' property - */ - virtual void setSpeakHeader(const DOMString &val) - throw (dom::DOMException) - { - speakHeader = val; - } - - /** - * return the 'speakNumeral' property - */ - virtual DOMString getSpeakNumeral() - { - return speakNumeral; - } - - /** - * set the 'speakNumeral' property - */ - virtual void setSpeakNumeral(const DOMString &val) - throw (dom::DOMException) - { - speakNumeral = val; - } - - /** - * return the 'speakPunctuation' property - */ - virtual DOMString getSpeakPunctuation() - { - return speakPunctuation; - } - - /** - * set the 'speakPunctuation' property - */ - virtual void setSpeakPunctuation(const DOMString &val) - throw (dom::DOMException) - { - speakPunctuation = val; - } - - /** - * return the 'speechRate' property - */ - virtual DOMString getSpeechRate() - { - return speechRate; - } - - /** - * set the 'speechRate' property - */ - virtual void setSpeechRate(const DOMString &val) - throw (dom::DOMException) - { - speechRate = val; - } - - /** - * return the 'stress' property - */ - virtual DOMString getStress() - { - return stress; - } - - /** - * set the 'stress' property - */ - virtual void setStress(const DOMString &val) - throw (dom::DOMException) - { - stress = val; - } - - /** - * return the 'tableLayout' property - */ - virtual DOMString getTableLayout() - { - return tableLayout; - } - - /** - * set the 'tableLayout' property - */ - virtual void setTableLayout(const DOMString &val) - throw (dom::DOMException) - { - tableLayout = val; - } - - /** - * return the 'textAlign' property - */ - virtual DOMString getTextAlign() - { - return textAlign; - } - - /** - * set the 'textAlign' property - */ - virtual void setTextAlign(const DOMString &val) - throw (dom::DOMException) - { - textAlign = val; - } - - /** - * return the 'textDecoration' property - */ - virtual DOMString getTextDecoration() - { - return textDecoration; - } - - /** - * set the 'textDecoration' property - */ - virtual void setTextDecoration(const DOMString &val) - throw (dom::DOMException) - { - textDecoration = val; - } - - /** - * return the 'textIndent' property - */ - virtual DOMString getTextIndent() - { - return textIndent; - } - - /** - * set the 'textIndent' property - */ - virtual void setTextIndent(const DOMString &val) - throw (dom::DOMException) - { - textIndent = val; - } - - /** - * return the 'textShadow' property - */ - virtual DOMString getTextShadow() - { - return textShadow; - } - - /** - * set the 'textShadow' property - */ - virtual void setTextShadow(const DOMString &val) - throw (dom::DOMException) - { - textShadow = val; - } - - /** - * return the 'textTransform' property - */ - virtual DOMString getTextTransform() - { - return textTransform; - } - - /** - * set the 'textTransform' property - */ - virtual void setTextTransform(const DOMString &val) - throw (dom::DOMException) - { - textTransform = val; - } - - /** - * return the 'top' property - */ - virtual DOMString getTop() - { - return top; - } - - /** - * set the 'top' property - */ - virtual void setTop(const DOMString &val) - throw (dom::DOMException) - { - top = val; - } - - /** - * return the 'unicodeBidi' property - */ - virtual DOMString getUnicodeBidi() - { - return unicodeBidi; - } - - /** - * set the 'unicodeBidi' property - */ - virtual void setUnicodeBidi(const DOMString &val) - throw (dom::DOMException) - { - unicodeBidi = val; - } - - /** - * return the 'verticalAlign' property - */ - virtual DOMString getVerticalAlign() - { - return verticalAlign; - } - - /** - * set the 'verticalAlign' property - */ - virtual void setVerticalAlign(const DOMString &val) - throw (dom::DOMException) - { - verticalAlign = val; - } - - /** - * return the 'visibility' property - */ - virtual DOMString getVisibility() - { - return visibility; - } - - /** - * set the 'visibility' property - */ - virtual void setVisibility(const DOMString &val) - throw (dom::DOMException) - { - visibility = val; - } - - /** - * return the 'voiceFamily' property - */ - virtual DOMString getVoiceFamily() - { - return voiceFamily; - } - - /** - * set the 'voiceFamily' property - */ - virtual void setVoiceFamily(const DOMString &val) - throw (dom::DOMException) - { - voiceFamily = val; - } - - /** - * return the 'volume' property - */ - virtual DOMString getVolume() - { - return volume; - } - - /** - * set the 'volume' property - */ - virtual void setVolume(const DOMString &val) - throw (dom::DOMException) - { - volume = val; - } - - /** - * return the 'whiteSpace' property - */ - virtual DOMString getWhiteSpace() - { - return whiteSpace; - } - - /** - * set the 'whiteSpace' property - */ - virtual void setWhiteSpace(const DOMString &val) - throw (dom::DOMException) - { - whiteSpace = val; - } - - /** - * return the 'widows' property - */ - virtual DOMString getWidows() - { - return widows; - } - - /** - * set the 'widows' property - */ - virtual void setWidows(const DOMString &val) - throw (dom::DOMException) - { - widows = val; - } - - /** - * return the 'width' property - */ - virtual DOMString getWidth() - { - return width; - } - - /** - * set the 'width' property - */ - virtual void setWidth(const DOMString &val) - throw (dom::DOMException) - { - width = val; - } - - /** - * return the 'wordSpacing' property - */ - virtual DOMString getWordSpacing() - { - return wordSpacing; - } - - /** - * set the 'wordSpacing' property - */ - virtual void setWordSpacing(const DOMString &val) - throw (dom::DOMException) - { - wordSpacing = val; - } - - /** - * return the 'zIndex' property - */ - virtual DOMString getZIndex() - { - return zIndex; - } - - /** - * set the 'zIndex' property - */ - virtual void setZIndex(const DOMString &val) - throw (dom::DOMException) - { - zIndex = val; - } - - - - //################## - //# Non-API methods - //################## - - /** - * - */ - CSS2Properties() - { - } - - /** - * - */ - CSS2Properties(const CSS2Properties &other) - { - assign(other); - } - - /** - * - */ - CSS2Properties &operator=(const CSS2Properties &other) - { - assign(other); - return *this; - } - - /** - * - */ - void assign(const CSS2Properties &other) - { - azimuth = other.azimuth; - background = other.background; - backgroundAttachment = other.backgroundAttachment; - backgroundColor = other.backgroundColor; - backgroundImage = other.backgroundImage; - backgroundPosition = other.backgroundPosition; - backgroundRepeat = other.backgroundRepeat; - border = other.border; - borderCollapse = other.borderCollapse; - borderColor = other.borderColor; - borderSpacing = other.borderSpacing; - borderStyle = other.borderStyle; - borderTop = other.borderTop; - borderRight = other.borderRight; - borderBottom = other.borderBottom; - borderLeft = other.borderLeft; - borderTopColor = other.borderTopColor; - borderRightColor = other.borderRightColor; - borderBottomColor = other.borderBottomColor; - borderLeftColor = other.borderLeftColor; - borderTopStyle = other.borderTopStyle; - borderRightStyle = other.borderRightStyle; - borderBottomStyle = other.borderBottomStyle; - borderLeftStyle = other.borderLeftStyle; - borderTopWidth = other.borderTopWidth; - borderRightWidth = other.borderRightWidth; - borderBottomWidth = other.borderBottomWidth; - borderLeftWidth = other.borderLeftWidth; - borderWidth = other.borderWidth; - bottom = other.bottom; - captionSide = other.captionSide; - clear = other.clear; - clip = other.clip; - color = other.color; - content = other.content; - counterIncrement = other.counterIncrement; - counterReset = other.counterReset; - cue = other.cue; - cueAfter = other.cueAfter; - cueBefore = other.cueBefore; - cursor = other.cursor; - direction = other.direction; - display = other.display; - elevation = other.elevation; - emptyCells = other.emptyCells; - cssFloat = other.cssFloat; - font = other.font; - fontFamily = other.fontFamily; - fontSize = other.fontSize; - fontSizeAdjust = other.fontSizeAdjust; - fontStretch = other.fontStretch; - fontStyle = other.fontStyle; - fontVariant = other.fontVariant; - fontWeight = other.fontWeight; - height = other.height; - left = other.left; - letterSpacing = other.letterSpacing; - lineHeight = other.lineHeight; - listStyle = other.listStyle; - listStyleImage = other.listStyleImage; - listStylePosition = other.listStylePosition; - listStyleType = other.listStyleType; - margin = other.margin; - marginTop = other.marginTop; - marginRight = other.marginRight; - marginBottom = other.marginBottom; - marginLeft = other.marginLeft; - markerOffset = other.markerOffset; - marks = other.marks; - maxHeight = other.maxHeight; - maxWidth = other.maxWidth; - minHeight = other.minHeight; - minWidth = other.minWidth; - orphans = other.orphans; - outline = other.outline; - outlineColor = other.outlineColor; - outlineStyle = other.outlineStyle; - outlineWidth = other.outlineWidth; - overflow = other.overflow; - padding = other.padding; - paddingTop = other.paddingTop; - paddingRight = other.paddingRight; - paddingBottom = other.paddingBottom; - paddingLeft = other.paddingLeft; - page = other.page; - pageBreakAfter = other.pageBreakAfter; - pageBreakBefore = other.pageBreakBefore; - pageBreakInside = other.pageBreakInside; - pause = other.pause; - pauseAfter = other.pauseAfter; - pauseBefore = other.pauseBefore; - pitch = other.pitch; - pitchRange = other.pitchRange; - playDuring = other.playDuring; - position = other.position; - quotes = other.quotes; - richness = other.richness; - right = other.right; - size = other.size; - speak = other.speak; - speakHeader = other.speakHeader; - speakNumeral = other.speakNumeral; - speakPunctuation = other.speakPunctuation; - speechRate = other.speechRate; - stress = other.stress; - tableLayout = other.tableLayout; - textAlign = other.textAlign; - textDecoration = other.textDecoration; - textIndent = other.textIndent; - textShadow = other.textShadow; - textTransform = other.textTransform; - top = other.top; - unicodeBidi = other.unicodeBidi; - verticalAlign = other.verticalAlign; - visibility = other.visibility; - voiceFamily = other.voiceFamily; - volume = other.volume; - whiteSpace = other.whiteSpace; - widows = other.widows; - width = other.width; - wordSpacing = other.wordSpacing; - zIndex = other.zIndex; - } - - /** - * - */ - virtual ~CSS2Properties() {} - -protected: - - //###################### - //# P R O P E R T I E S - //###################### - DOMString azimuth; - DOMString background; - DOMString backgroundAttachment; - DOMString backgroundColor; - DOMString backgroundImage; - DOMString backgroundPosition; - DOMString backgroundRepeat; - DOMString border; - DOMString borderCollapse; - DOMString borderColor; - DOMString borderSpacing; - DOMString borderStyle; - DOMString borderTop; - DOMString borderRight; - DOMString borderBottom; - DOMString borderLeft; - DOMString borderTopColor; - DOMString borderRightColor; - DOMString borderBottomColor; - DOMString borderLeftColor; - DOMString borderTopStyle; - DOMString borderRightStyle; - DOMString borderBottomStyle; - DOMString borderLeftStyle; - DOMString borderTopWidth; - DOMString borderRightWidth; - DOMString borderBottomWidth; - DOMString borderLeftWidth; - DOMString borderWidth; - DOMString bottom; - DOMString captionSide; - DOMString clear; - DOMString clip; - DOMString color; - DOMString content; - DOMString counterIncrement; - DOMString counterReset; - DOMString cue; - DOMString cueAfter; - DOMString cueBefore; - DOMString cursor; - DOMString direction; - DOMString display; - DOMString elevation; - DOMString emptyCells; - DOMString cssFloat; - DOMString font; - DOMString fontFamily; - DOMString fontSize; - DOMString fontSizeAdjust; - DOMString fontStretch; - DOMString fontStyle; - DOMString fontVariant; - DOMString fontWeight; - DOMString height; - DOMString left; - DOMString letterSpacing; - DOMString lineHeight; - DOMString listStyle; - DOMString listStyleImage; - DOMString listStylePosition; - DOMString listStyleType; - DOMString margin; - DOMString marginTop; - DOMString marginRight; - DOMString marginBottom; - DOMString marginLeft; - DOMString markerOffset; - DOMString marks; - DOMString maxHeight; - DOMString maxWidth; - DOMString minHeight; - DOMString minWidth; - DOMString orphans; - DOMString outline; - DOMString outlineColor; - DOMString outlineStyle; - DOMString outlineWidth; - DOMString overflow; - DOMString padding; - DOMString paddingTop; - DOMString paddingRight; - DOMString paddingBottom; - DOMString paddingLeft; - DOMString page; - DOMString pageBreakAfter; - DOMString pageBreakBefore; - DOMString pageBreakInside; - DOMString pause; - DOMString pauseAfter; - DOMString pauseBefore; - DOMString pitch; - DOMString pitchRange; - DOMString playDuring; - DOMString position; - DOMString quotes; - DOMString richness; - DOMString right; - DOMString size; - DOMString speak; - DOMString speakHeader; - DOMString speakNumeral; - DOMString speakPunctuation; - DOMString speechRate; - DOMString stress; - DOMString tableLayout; - DOMString textAlign; - DOMString textDecoration; - DOMString textIndent; - DOMString textShadow; - DOMString textTransform; - DOMString top; - DOMString unicodeBidi; - DOMString verticalAlign; - DOMString visibility; - DOMString voiceFamily; - DOMString volume; - DOMString whiteSpace; - DOMString widows; - DOMString width; - DOMString wordSpacing; - DOMString zIndex; - - -}; - - - - - - - - -/*######################################################################### -## ViewCSS -#########################################################################*/ - -/** - * This interface represents a CSS view. The getComputedStyle method provides a - * read only access to the computed values of an element. - * - * The expectation is that an instance of the ViewCSS interface can be obtained - * by using binding-specific casting methods on an instance of the AbstractView - * interface. - * - * Since a computed style is related to an Element node, if this element is - * removed from the document, the associated CSSStyleDeclaration and CSSValue - * related to this declaration are no longer valid. - */ -class ViewCSS : virtual public views::AbstractView -{ -public: - - /** - * This method is used to get the computed style as it is defined in [CSS2]. - */ - virtual CSSStyleDeclaration getComputedStyle(const Element &/*elt*/, - const DOMString &/*pseudoElt*/) - { - CSSStyleDeclaration style; - return style; - } - - //################## - //# Non-API methods - //################## - - /** - * - */ - ViewCSS() : views::AbstractView() - { - } - - /** - * - */ - ViewCSS(const ViewCSS &other) : views::AbstractView(other) - { - } - - /** - * - */ - ViewCSS &operator=(const ViewCSS &/*other*/) - { - return *this; - } - - /** - * - */ - virtual ~ViewCSS() {} -}; - - - - - -/*######################################################################### -## DocumentCSS -#########################################################################*/ - -/** - * This interface represents a document with a CSS view. - * - * The getOverrideStyle method provides a mechanism through which a DOM author - * could effect immediate change to the style of an element without modifying the - * explicitly linked style sheets of a document or the inline style of elements - * in the style sheets. This style sheet comes after the author style sheet in - * the cascade algorithm and is called override style sheet. The override style - * sheet takes precedence over author style sheets. An "!important" declaration - * still takes precedence over a normal declaration. Override, author, and user - * style sheets all may contain "!important" declarations. User "!important" - * rules take precedence over both override and author "!important" rules, and - * override "!important" rules take precedence over author "!important" rules. - * - * The expectation is that an instance of the DocumentCSS interface can be - * obtained by using binding-specific casting methods on an instance of the - * Document interface. - */ -class DocumentCSS : virtual public stylesheets::DocumentStyle -{ -public: - - /** - * This method is used to retrieve the override style declaration for a specified - * element and a specified pseudo-element. - */ - virtual CSSStyleDeclaration getOverrideStyle(const Element */*elt*/, - const DOMString &/*pseudoElt*/) - { - CSSStyleDeclaration style; - return style; - } - - //################## - //# Non-API methods - //################## - - /** - * - */ - DocumentCSS() : stylesheets::DocumentStyle() - { - } - - /** - * - */ - DocumentCSS(const DocumentCSS &other) : stylesheets::DocumentStyle(other) - { - } - - /** - * - */ - DocumentCSS &operator=(const DocumentCSS &/*other*/) - { - return *this; - } - - /** - * - */ - virtual ~DocumentCSS() {} -}; - - - - - - -/*######################################################################### -## DOMImplementationCSS -#########################################################################*/ - -/** - * This interface allows the DOM user to create a CSSStyleSheet outside the - * context of a document. There is no way to associate the new CSSStyleSheet with - * a document in DOM Level 2. - */ -class DOMImplementationCSS : virtual public DOMImplementation -{ -public: - - /** - * Creates a new CSSStyleSheet. - */ - virtual CSSStyleSheet createCSSStyleSheet(const DOMString &/*title*/, - const DOMString &/*media*/) - throw (dom::DOMException) - { - CSSStyleSheet sheet; - return sheet; - } - - //################## - //# Non-API methods - //################## - - /** - * - */ - DOMImplementationCSS() {} - - /** - * - */ - DOMImplementationCSS(const DOMImplementationCSS &other) - : DOMImplementation(other) - { - } - - /** - * - */ - DOMImplementationCSS &operator=(const DOMImplementationCSS &/*other*/) - { - return *this; - } - - /** - * - */ - virtual ~DOMImplementationCSS() {} -}; - - - - - - - - -} //namespace css -} //namespace dom -} //namespace w3c -} //namespace org - - -#endif // SEEN_CSS_H - -/*######################################################################### -## E N D O F F I L E -#########################################################################*/ diff --git a/src/dom/cssreader.cpp b/src/dom/cssreader.cpp deleted file mode 100644 index 93473b229..000000000 --- a/src/dom/cssreader.cpp +++ /dev/null @@ -1,1684 +0,0 @@ -/* - * Phoebe DOM Implementation. - * - * This is a C++ approximation of the W3C DOM model, which follows - * fairly closely the specifications in the various .idl files, copies of - * which are provided for reference. Most important is this one: - * - * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * - * Authors: - * Bob Jamison - * - * Copyright (C) 2005-2008 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "cssreader.h" -#include "ucd.h" - -#include -#include - -namespace org -{ -namespace w3c -{ -namespace dom -{ -namespace css -{ - -//######################################################################### -//# M E S S A G E S -//######################################################################### - -/** - * Get the column and row number of the given character position - */ -void CssReader::getColumnAndRow(int p, int &colResult, int &rowResult, int &lastNL) -{ - int col = 1; - int row = 1; - int lastnl = 0; - - for (int i=0 ; i

= parselen) - return 0; - XMLCh ch = parsebuf[p]; - //printf("%c", ch); - lastPosition = p; - return ch; -} - - - -/** - * Test if the given substring exists at the given position - * in parsebuf. Use get() in case of out-of-bounds - */ -bool CssReader::match(int pos, const char *str) -{ - while (*str) - { - if (get(pos++) != (XMLCh) *str++) - return false; - } - return true; -} - -/** - * - */ -int CssReader::skipwhite(int p) -{ - while (p < parselen) - { - //# XML COMMENT - if (match(p, "")) - { - p+=3; - done=true; - break; - } - p++; - } - lastPosition = p; - if (!done) - { - error("unterminated comment"); - return -1; - } - } - //# C comment - else if (match(p, "/*")) - { - p+=2; - bool done=false; - while (p'9') - break; - str.push_back(ch); - p++; - } - if (get(p) == '.' && get(p+1)>='0' && get(p+1)<='9') - { - p++; - str.push_back('.'); - while (p < parselen) - { - XMLCh ch = get(p); - if (ch<'0' || ch>'9') - break; - str.push_back(ch); - p++; - } - } - if (p>p0) - { - char *start = (char *)str.c_str(); - char *end = NULL; - double val = strtod(start, &end); - if (end > start) - { - result = val; - return p; - } - } - - //not a number - return p0; -} - - - -/** - * Assume that we are starting on a quote. Ends on the char - * after the final '"' - */ -int CssReader::getQuoted(int p0, DOMString &result) -{ - - int p = p0; - - XMLCh quoteChar = get(p); - if (quoteChar != '"' && quoteChar != '\'') - return p0; - - p++; - - DOMString buf; - - bool done = false; - while (pp) - { - p = p2; - continue; - } - - //Media - p2 = getMedia(p); - if (p2<0) - { - return -1; - } - if (p2>p) - { - p = p2; - continue; - } - - //Page - p2 = getPage(p); - if (p2<0) - { - return -1; - } - if (p2>p) - { - p = p2; - continue; - } - - //none of the above - break; - } - - return p; -} - -/** - * import - * : IMPORT_SYM S* - * [STRING|URI] S* [ medium [ COMMA S* medium]* ]? ';' S* - * ; - */ -int CssReader::getImport(int p0) -{ - int p = p0; - if (!match(p, "@import")) - return p0; - p+=7; - p = skipwhite(p); - - //# STRING | URI - DOMString str; - int p2 = getQuoted(p, str); - if (p2<0) - { - return -1; - } - if (p2<=p) - { - p2 = getUri(p, str); - if (p2<0) - { - return -1; - } - if (p2<=p) - { - error("quoted string or URI required after @import"); - return -1; - } - } - p = p2; - p2 = getMedium(p); - if (p2<0) - return -1; - - p = p2; - p = skipwhite(p); - XMLCh ch = get(p); - if (ch != ';') - { - error("@import must be terminated with ';'"); - return -1; - } - p++; - return p; -} - -/** - * media - * : MEDIA_SYM S* medium [ COMMA S* medium ]* LBRACE S* ruleset* '}' S* - * ; - */ -int CssReader::getMedia(int p0) -{ - int p = p0; - XMLCh ch; - if (!match(p, "@media")) - return p0; - p+=6; - p = skipwhite(p); - - //# MEDIUM LIST - int p2 = getMedium(p); - if (p2<0) - return -1; - if (p2<=p) - { - error("@media must be followed by medium"); - return -1; - } - p = p2; - while (true) - { - ch = get(p); - if (ch != ',') - break; - p2 = getMedium(p); - if (p2<0) - return -1; - if (p2<=p) - { - error("',' in medium list must be followed by medium"); - return -1; - } - p = p2; - } - - p = skipwhite(p); - ch = get(p); - if (ch!='{') - { - error("@media requires '{' for ruleset"); - return -1; - } - p++; - p2 = getRuleSet(p); - if (p2<0) - return -1; - if (p2<=p) - { - error("@media requires ruleset after '{'"); - return -1; - } - p = p2; - ch = get(p); - if (ch != '}') - { - error("@media requires '}' after ruleset"); - return -1; - } - p++; - return p0; -} - -/** - * medium - * : IDENT S* - * ; - */ -int CssReader::getMedium(int p0) -{ - int p = p0; - p = skipwhite(p); - - DOMString ident; - int p2 = getWord(p, ident); - if (p2<0) - return -1; - if (p2<=p) - return p0; - p = p2; - - return p; -} - -/** - * page - * : PAGE_SYM S* pseudo_page? S* - * LBRACE S* declaration [ ';' S* declaration ]* '}' S* - * ; - */ -int CssReader::getPage(int p0) -{ - int p = p0; - - //# @PAGE - p = skipwhite(p); - if (!match(p, "@page")) - return p0; - p+= 5; - - //#PSEUDO PAGE 0 or 1 - p = skipwhite(p); - int p2 = getPseudoPage(p); - if (p2<0) - return -1; - if (p2>p) - { - p = p2; - } - - //# { - p=skipwhite(p); - XMLCh ch = get(p); - if (p != '{') - { - error("@page requires '{' before declarations"); - } - p++; - - //# DECLARATION LIST - p = skipwhite(p); - CSSStyleDeclaration declarationList; - p2 = getDeclaration(p, declarationList); - if (p2<0) - return -1; - if (p2<=p) - { - error("@page requires declaration(s) after '{'"); - return -1; - } - while (true) - { - p = skipwhite(p2); - XMLCh ch = get(p); - if (ch != ';') - break; - p++; - p = skipwhite(p); - p2 = getDeclaration(p, declarationList); - if (p2<0) - return -1; - if (p2<= p) - { - error("@page requires declaration after ';'"); - return -1; - } - } - - //# } - p=skipwhite(p); - ch = get(p); - if (p != '}') - { - error("@page requires '}' after declarations"); - } - p++; - - return p; -} - -/** - * pseudo_page - * : ':' IDENT - * ; - */ -int CssReader::getPseudoPage(int p0) -{ - int p = p0; - if (!match(p, ":")) - return p0; - p++; - DOMString str; - int p2 = getWord(p, str); - if (p2<0) - return -1; - if (p2<=p) - { - error("pseudo-page requires identifier after ':'"); - return -1; - } - p = p2; - return p; -} - -/** - * ruleset - * : selector [ COMMA S* selector ]* - * LBRACE S* declaration [ ';' S* declaration ]* '}' S* - * ; - */ -int CssReader::getRuleSet(int p0) -{ - int p = p0; - XMLCh ch; - - //## SELECTOR - p = skipwhite(p); - int p2 = getSelector(p); - if (p2<0) - return -1; - if (p2<=p) //no selector - { - if (get(p) != '{')//check for selector-less rule - return p0;//not me - } - p = p2; - while (true) - { - p = skipwhite(p); - ch = get(p); - if (ch != ',') - break; - p++; - p = skipwhite(p); - int p2 = getSelector(p); - if (p2<0) - return -1; - if (p2<=p) - { - error("selector required after ',' in list"); - return -1; - } - p = p2; - } - - //## { - ch = get(p); - if (ch != '{') - { - error("'{' required before declarations of ruleset"); - return -1; - } - p++; - - //## DECLARATIONS ( 0 to many ) - CSSStyleDeclaration declarationList; - - p = skipwhite(p); - p2 = getDeclaration(p, declarationList); - if (p2<0) - return -1; - if (p2>p) - { - p = p2; - while (true) - { - p = skipwhite(p); - ch = get(p); - if (ch != ';') - break; - p++; - p = skipwhite(p); - p2 = getDeclaration(p, declarationList); - if (p2<0) - return -1; - if (p2<=p) - { - //apparently this is ok - //error("declaration required after ';' in ruleset"); - //return -1; - break; - } - p = p2; - } - } - //## } - ch = get(p); - if (ch != '}') - { - error("ruleset requires closing '}'"); - return -1; - } - p++; - p = skipwhite(p); - - return p; -} - -/** - * selector - * : simple_selector [ combinator simple_selector ]* - * ; - */ -int CssReader::getSelector(int p0) -{ - int p = p0; - - //## SIMPLE SELECTOR - p = skipwhite(p); - int p2 = getSimpleSelector(p); - if (p2<0) - return -1; - if (p2<=p) - return p0; //not me - p = p2; - - //## COMBINATORS + MORE SELECTORS - while (true) - { - XMLCh ch = get(p); - bool wasSpace = isspace(ch); - p = skipwhite(p); - ch = get(p); - //# Combinators - //easier to do here than have a getCombinator() - int visibleCombinator = false; - if (ch == '+') - { - visibleCombinator = true; - p++; - } - else if (ch == '>') - { - visibleCombinator = true; - p++; - } - else if (wasSpace) - { - } - else - { - break; - } - p = skipwhite(p); - p2 = getSimpleSelector(p); - if (p2<0) - return -1; - if (p2<=p) - { - if (visibleCombinator) - { - error("need simple selector after combinator"); - return -1; - } - else - { - break; - } - } - p = p2; - } - return p; -} - -/** - * simple_selector - * : element_name [ HASH | class | attrib | pseudo ]* - * | [ HASH | class | attrib | pseudo ]+ - * ; - */ -int CssReader::getSimpleSelector(int p0) -{ - int p = p0; - int p2; - - DOMString str; - - p = skipwhite(p); - - int selectorItems = 0; - - XMLCh ch = get(p); - - //###################### - //# Note: do NOT skipwhite between items. Only within the - //# pseudo function and attrib below - //###################### - - //#Element name 0 or 1 - if (uni_is_letter(ch)) - { - p2 = getWord(p, str); - if (p2<0) - return -1; - if (p2<=p) - { - error("null element name"); - return -1; - } - selectorItems++; - p = p2; - } - else if (ch == '*') - { - str = "*"; - p++; - selectorItems++; - } - - - - //## HASH, CLASS, ATTRIB, PSEUDO (0 to many with elem name, 1 to many without) - while (true) - { - XMLCh ch = get(p); - - //# HASH - if (ch == '#') - { - p++; - p2 = getWord(p, str); - if (p2<0) - return -1; - if (p2<=p) - { - error("no name for hash"); - return -1; - } - p = p2; - selectorItems++; - } - - //# CLASS - else if (ch == '.') - { - p++; - p2 = getWord(p, str); - if (p2<0) - return -1; - if (p2<=p) - { - error("no name for class"); - return -1; - } - p = p2; - selectorItems++; - } - - //# ATTRIB - else if (ch == '[') - { - p++; - p = skipwhite(p); - p2 = getWord(p, str); - if (p2<0) - return -1; - if (p2<=p) - { - error("no name for class"); - return -1; - } - p = skipwhite(p2); - bool getRHS=false; - if (match(p, "=")) - { - p++; - getRHS=true; - } - else if (match(p, "~=")) - { - p+=2; - getRHS=true; - } - else if (match(p, "|=")) - { - p+=2; - getRHS=true; - } - if (getRHS) - { - p = skipwhite(p); - ch = get(p); - if (uni_is_letter(ch)) - { - p2 = getWord(p, str); - if (p2<0) - return -1; - if (p2<=p) - { - error("null ident on rhs of attrib"); - return -1; - } - p = p2; - } - else if (ch == '\'' || ch =='"') - { - p2 = getQuoted(p, str); - if (p2<0) - return -1; - if (p2<=p) - { - error("null literal string on rhs of attrib"); - return -1; - } - p = p2; - } - }//getRHS - p = skipwhite(p); - ch = get(p); - if (ch != ']') - { - error("attrib needs closing ']'"); - //return -1; - p = skipBlock(p); - return p; - } - p++; - selectorItems++; - } - - //# PSEUDO - else if (ch == ':') - { - p++; - p2 = getWord(p, str); - if (p2<0) - return -1; - if (p2<=p) - { - error("no name for pseudo"); - return -1; - } - p = p2; - selectorItems++; - ch = get(p); - if (ch == '(') - { - p++; - p = skipwhite(p); - ch = get(p); - if (uni_is_letter(ch)) - { - p2 = getWord(p, str); - if (p2<0) - return -1; - if (p2<=p) - { - error("null function parameter in pseudo"); - return -1; - } - p = skipwhite(p2); - ch = get(p); - } - if (ch != ')') - { - error("function in pseudo needs ')'"); - return -1; - } - p++; - }// ch==( -function- - }//pseudo - - //# none of the above - else - { - break; - } - - }//while - - - if (selectorItems > 0) - return p; - return p0; -} - -/** - * declaration - * : property ':' S* expr prio? - * | {empty} - * ; - */ -int CssReader::getDeclaration(int p0, CSSStyleDeclaration &/*declarationList*/) -{ - int p = p0; - - //## PROPERTY - p = skipwhite(p); - XMLCh ch = get(p); - if (!uni_is_letter(ch)) - return p0; //not me - DOMString propName; - int p2 = getWord(p, propName); - if (p2<0) - return -1; - - //## ':' - p = skipwhite(p2); - ch = get(p); - if (ch != ':') - { - error("declaration requires ':' between name and value"); - return -1; - } - p++; - - //## EXPR - p = skipwhite(p); - p2 = getExpr(p); - if (p2<0) - return -1; - if (p2<=p) - { - error("declaration requires value after ':'"); - return -1; - } - DOMString propVal; - for (int i=p ; ip) - { - //do something - p = p2; - } - - return p; -} - -/** - * prio - * : IMPORTANT_SYM S* - * ; - */ -int CssReader::getPrio(int p0, DOMString &val) -{ - int p = p0; - - //## '!" - p = skipwhite(p); - XMLCh ch = get(p); - if (ch != '!') - return p0; - p++; - - //## "important" - p = skipwhite(p); - if (!match(p, "important")) - { - error("priority symbol is 'important'"); - return -1; - } - p += 9; - val = "important"; - return p; -} - -/** - * expr - * : term [ operator term ]* - * ; - */ -int CssReader::getExpr(int p0) -{ - int p = p0; - - //## TERM - p = skipwhite(p); - int p2 = getTerm(p); - if (p2<0) - return -1; - if (p2<=p) - return p0; //not me - p = p2; - while (p < parselen) - { - p = skipwhite(p); - //#Operator. do this instead of getOperator() - XMLCh ch = get(p); - int visibleTerm = false; - if (ch == '/') - { - visibleTerm = true; - p++; - } - else if (ch == ',') - { - visibleTerm = true; - p++; - } - else - { - //just space. this is allowable between terms, - // so we still need to check for another term - } - p = skipwhite(p); - p2 = getTerm(p); - if (p2<0) - return -1; - if (p2<=p) - { - if (visibleTerm) - { - error("expression requires term after operator"); - return -1; - } - else - { - break; - } - } - p = p2; - } - - return p; -} - -/** - * term - * : unary_operator? - * [ NUMBER S* | PERCENTAGE S* | LENGTH S* | EMS S* | EXS S* | ANGLE S* | - * TIME S* | FREQ S* | function ] - * | STRING S* | IDENT S* | URI S* | hexcolor - * ; - */ -int CssReader::getTerm(int p0) -{ - int p = p0; - p = skipwhite(p); - int unitType = CSSPrimitiveValue::CSS_UNKNOWN; /// \fixme Why is this variable never used? - //# Unary operator - XMLCh ch = get(p); - bool hasUnary = false; - if (ch == '-') - { - p++; - hasUnary = true; - } - else if (ch == '+') - { - p++; - hasUnary = true; - } - //# NUMERIC - double numVal; - int p2 = getNumber(p, numVal); - if (p2<0) - return -1; - if (p2>p) - { - p = p2; - if (match(p, "%")) - { - unitType = CSSPrimitiveValue::CSS_PERCENTAGE; - p++; - } - else if (match(p, "em")) - { - unitType = CSSPrimitiveValue::CSS_EMS; - p+=2; - } - else if (match(p, "ex")) - { - unitType = CSSPrimitiveValue::CSS_EXS; - p+=2; - } - else if (match(p, "px")) - { - unitType = CSSPrimitiveValue::CSS_PX; - p+=2; - } - else if (match(p, "cm")) - { - unitType = CSSPrimitiveValue::CSS_CM; - p+=2; - } - else if (match(p, "mm")) - { - unitType = CSSPrimitiveValue::CSS_MM; - p+=2; - } - else if (match(p, "in")) - { - unitType = CSSPrimitiveValue::CSS_IN; - p+=2; - } - else if (match(p, "pt")) - { - unitType = CSSPrimitiveValue::CSS_PT; - p+=2; - } - else if (match(p, "pc")) - { - unitType = CSSPrimitiveValue::CSS_PC; - p+=2; - } - else if (match(p, "deg")) - { - unitType = CSSPrimitiveValue::CSS_DEG; - p+=3; - } - else if (match(p, "rad")) - { - unitType = CSSPrimitiveValue::CSS_RAD; - p+=3; - } - else if (match(p, "grad")) - { - unitType = CSSPrimitiveValue::CSS_GRAD; - p+=4; - } - else if (match(p, "ms")) - { - unitType = CSSPrimitiveValue::CSS_MS; - p+=2; - } - else if (match(p, "s")) - { - unitType = CSSPrimitiveValue::CSS_S; - p+=1; - } - else if (match(p, "Hz")) - { - unitType = CSSPrimitiveValue::CSS_HZ; - p+=2; - } - else if (match(p, "kHz")) - { - unitType = CSSPrimitiveValue::CSS_KHZ; - p+=2; - } - else if (uni_is_letter(get(p)))//some other string - { - DOMString suffix; - p2 = getWord(p, suffix); - if (p2<0) - return -1; - unitType = CSSPrimitiveValue::CSS_DIMENSION; - p = p2; - } - else //plain number - { - unitType = CSSPrimitiveValue::CSS_NUMBER; - } - return p; - } - - DOMString str; - - //## URI --do before function, as syntax is similar - p2 = getUri(p, str); - if (p2<0) - return -1; - if (p2>p) - { - if (hasUnary) - { - error("+ or - not allowed on URI"); - return -1; - } - p = p2; - unitType = CSSPrimitiveValue::CSS_URI; - return p; - } - - //## FUNCTION - p2 = getFunction(p); - if (p2<0) - return -1; - if (p2>p) - { - p = p2; - return p; - } - - //## STRING - ch = get(p); - if (ch == '"' || ch == '\'') - { - p2 = getQuoted(p, str); - if (p2<0) - return -1; - if (p2>p) - { - if (hasUnary) - { - error("+ or - not allowed on a string"); - return -1; - } - p = p2; - unitType = CSSPrimitiveValue::CSS_STRING; - return p; - } - } - - //## IDENT - ch = get(p); - if (uni_is_letter(ch)) - { - p2 = getWord(p, str); - if (p2<0) - return -1; - if (p2>p) - { - if (hasUnary) - { - error("+ or - not allowed on an identifier"); - return -1; - } - p = p2; - unitType = CSSPrimitiveValue::CSS_IDENT; - return p; - } - } - - - //## HEXCOLOR - p2 = getHexColor(p); - if (p2<0) - return -1; - if (p2>p) - { - if (hasUnary) - { - error("+ or - not allowed on hex color"); - return -1; - } - p = p2; - unitType = CSSPrimitiveValue::CSS_RGBCOLOR; - return p; - } - - - return p0; -} - -/** - * function - * : FUNCTION S* expr ')' S* - * ; - */ -int CssReader::getFunction(int p0) -{ - int p = p0; - - //## IDENT + ( (both) - DOMString name; - p = skipwhite(p); - int p2 = getWord(p, name); - if (p2<0) - return -1; - if (p2<=p) - return p0; //not me - if (name == "uri" || name=="url") - return p0; //not me - p = skipwhite(p2); - XMLCh ch = get(p); - if (ch != '(') - return p0; //still not me - p++; - - //## EXPR - p = skipwhite(p); - p2 = getExpr(p); - if (p2<0) - return -1; - if (p2<=p) - { - error("function requires expression"); - return -1; - } - p = p2; - - //## ')' - p = skipwhite(p); - ch = get(p); - if (ch != ')') - { - error("function requires closing ')'"); - return -1; - } - p++; - p = skipwhite(p); - - return p; -} - -/** - * There is a constraint on the color that it must - * have either 3 or 6 hex-digits (i.e., [0-9a-fA-F]) - * after the "#"; e.g., "#000" is OK, but "#abcd" is not. - * hexcolor - * : HASH S* - * ; - */ -int CssReader::getHexColor(int p0) -{ - int p = p0; - - //## '#' - p = skipwhite(p); - if (!match(p, "#")) - return p0; - p++; - - //## HEX - DOMString hex; - long hexVal = 0; - while (p < parselen) - { - XMLCh b = get(p); - if (b>='0' && b<='9') - { - hexVal = (hexVal << 4) + (b - '0'); - hex.push_back(b); - p++; - } - else if (b>='a' && b<='f') - { - hexVal = (hexVal << 4) + (b - 'a' + 10); - hex.push_back(b); - p++; - } - else if (b>='A' && b<='F') - { - hexVal = (hexVal << 4) + (b - 'A' + 10); - hex.push_back(b); - p++; - } - else - { - break; - } - } - - if (hex.size() != 3 && hex.size() != 6) - { - error("exactly 3 or 6 hex digits are required after '#'"); - return -1; - } - - return p; -} - - - -/** - * - */ -bool CssReader::parse(const DOMString &str) -{ - /* - int len = str.size(); - for (int i=0 ; i - -#include "domptr.h" - - -/** - * What type of string do we want? Pick one of the following - * Then below, select one of the corresponding typedefs. - */ - -#ifdef DOM_STANDALONE -# include -#else -# include -#endif - -//# Unfortunate hack for a name collision -#ifdef SEVERITY_ERROR -#undef SEVERITY_ERROR -#endif - -#define XMLNSNAME "http://www.w3.org/2000/xmlns/" - -namespace org -{ -namespace w3c -{ -namespace dom -{ - - -/** - * This is the org::w3c::dom::DOMString definition. - * Which type do we want? - */ -#ifdef DOM_STANDALONE -typedef std::string DOMString; -typedef unsigned short XMLCh; -#else -typedef Glib::ustring DOMString; -typedef gunichar XMLCh; -#endif - -/** - * At least 64 bit time stamp value. - */ -typedef unsigned long long DOMTimeStamp; - -/** - * This is used for storing refs to user-supplied data. - */ -typedef void DOMUserData; - - - -/** - * This is used for opaque references to arbitrary objects from - * the DOM tree. - */ -typedef void DOMObject; - - -/** - * Forward references. These are needed because of extensive - * inter-referencing within the DOM tree. - */ -class NodeList; -class NamedNodeMap; -class DOMException; -class DOMStringList; -class NameList; -class DOMImplementationList; -class DOMImplementationSource; -class DOMImplementation; -class TypeInfo; -class UserDataHandler; -class DOMError; -class DOMErrorHandler; -class DOMLocator; -class DOMConfiguration; - -/** - * Smart pointer definitions. Most methods that return references to - * Nodes of various types, will return one of these smart pointers instead, - * to allow refcounting and GC. - */ -class Node; -typedef Ptr NodePtr; -class CharacterData; -typedef Ptr CharacterDataPtr; -class Attr; -typedef Ptr AttrPtr; -class Element; -typedef Ptr ElementPtr; -class Text; -typedef Ptr TextPtr; -class Comment; -typedef Ptr CommentPtr; -class DocumentType; -typedef Ptr DocumentTypePtr; -class CDATASection; -typedef Ptr CDATASectionPtr; -class Notation; -typedef Ptr NotationPtr; -class Entity; -typedef Ptr EntityPtr; -class EntityReference; -typedef Ptr EntityReferencePtr; -class ProcessingInstruction; -typedef Ptr ProcessingInstructionPtr; -class DocumentFragment; -typedef Ptr DocumentFragmentPtr; -class Document; -typedef Ptr DocumentPtr; - - - - -/** - * NOTE: We were originally intending to split ALL specifications into - * interface and implementation. After consideration, though, it behooves - * us to simplify things by implementing the base exception and - * container classes directly: - * - * DOMException - * DOMStringList - * NameList - * DOMImplementationList - * DOMImplementationSource - * DOMImplementation - * NodeList - * NamedNodeMap - */ - - -/*######################################################################### -## DOMException -#########################################################################*/ - -/** - * An Exception class. Not an interface, since this is something that - * all implementations must support. - */ -class DOMException -{ - -public: - - /** - * ExceptionCode - */ - typedef enum - { - INDEX_SIZE_ERR = 1, - DOMSTRING_SIZE_ERR = 2, - HIERARCHY_REQUEST_ERR = 3, - WRONG_DOCUMENT_ERR = 4, - INVALID_CHARACTER_ERR = 5, - NO_DATA_ALLOWED_ERR = 6, - NO_MODIFICATION_ALLOWED_ERR = 7, - NOT_FOUND_ERR = 8, - NOT_SUPPORTED_ERR = 9, - INUSE_ATTRIBUTE_ERR = 10, - INVALID_STATE_ERR = 11, - SYNTAX_ERR = 12, - INVALID_MODIFICATION_ERR = 13, - NAMESPACE_ERR = 14, - INVALID_ACCESS_ERR = 15, - VALIDATION_ERR = 16, - TYPE_MISMATCH_ERR = 17 - } ExceptionCode; - - - - DOMException(const DOMString &reasonMsg) - : msg (reasonMsg) - { } - - DOMException(short theCode) - { - code = theCode; - } - - virtual ~DOMException() throw() - {} - - /** - * What type of exception? One of the ExceptionCodes above. - */ - unsigned short code; - - /** - * Some text describing the context that generated this exception. - */ - DOMString msg; - - /** - * Get a string, translated from the code. - * Like std::exception. Not in spec. - */ - const char *what() - { return (const char *)msg.c_str(); } - - - -}; - - - - - - -/*######################################################################### -## DOMStringList -#########################################################################*/ - -/** - * This holds a list of DOMStrings. This is likely the response to a query, - * or the value of an attribute. - */ -class DOMStringList -{ -public: - - /** - * Get the nth string of the list - */ - virtual DOMString item(unsigned long index) - { - if (index>=strings.size()) - return ""; - return strings[index]; - } - - /** - * How many strings in this list? - */ - virtual unsigned long getLength() - { - return (unsigned long) strings.size(); - } - - /** - * Is the argument string present in this list? Lexically, not identically. - */ - virtual bool contains(const DOMString &str) - { - for (unsigned int i=0; istrings; - -}; - - - -/*######################################################################### -## NameList -#########################################################################*/ - - -/** - * Constains a list of namespaced names. - */ -class NameList -{ -private: - - class NamePair - { - public: - NamePair(const DOMString &theNamespaceURI, const DOMString &theName) - : namespaceURI (theNamespaceURI), - name (theName) - { - } - NamePair(const NamePair &other) - : namespaceURI (other.namespaceURI), - name (other.name) - { - } - NamePair &operator=(const NamePair &other) - { - namespaceURI = other.namespaceURI; - name = other.name; - return *this; - } - virtual ~NamePair() {} - - DOMString namespaceURI; - DOMString name; - }; - -public: - - /** - * Returns a name at the given index. If out of range, return -1. - */ - virtual DOMString getName(unsigned long index) - { - if (index>=namePairs.size()) - return ""; - return namePairs[index].name; - } - - /** - * Returns a namespace at the given index. If out of range, return -1. - */ - virtual DOMString getNamespaceURI(unsigned long index) - { - if (index>=namePairs.size()) - return ""; - return namePairs[index].namespaceURI; - } - - /** - * Return the number of entries in this list. - */ - virtual unsigned long getLength() - { - return (unsigned long)namePairs.size(); - } - - /** - * Return whether the name argument is present in the list. - * This is done lexically, not identically. - */ - virtual bool contains(const DOMString &name) - { - for (unsigned int i=0; i namePairs; - -}; - -/*######################################################################### -## DOMImplementationList -#########################################################################*/ - -/** - * Contains a list of DOMImplementations, with accessors. - */ -class DOMImplementationList -{ -public: - - /** - * Return a DOMImplementation at the given index. If - * out of range, return NULL. - */ - virtual DOMImplementation *item(unsigned long index) - { - if (index >implementations.size()) - return NULL; - return implementations[index]; - } - - /** - * Return the number of DOMImplementations in this list. - */ - virtual unsigned long getLength() - { - return (unsigned long) implementations.size(); - } - - - //################## - //# Non-API methods - //################## - - /** - * - */ - DOMImplementationList() {} - - - /** - * - */ - DOMImplementationList(const DOMImplementationList &other) - : implementations (other.implementations) - { - } - - /** - * - */ - DOMImplementationList &operator=(const DOMImplementationList &other) - { - implementations = other.implementations; - return *this; - } - - /** - * - */ - virtual ~DOMImplementationList() {} - -protected: - - std::vectorimplementations; - -}; - - -/*######################################################################### -## DOMImplementationSource -#########################################################################*/ - -/** - * This is usually the first item to be called when creating a Document. - * You will either find one DOMImplementation with a given set of features, - * or return a list that match. Using "" will get any implementation - * available. - */ -class DOMImplementationSource -{ -public: - - /** - * Return the first DOMImplementation with the given set of features. - * Use "" to fetch any implementation. - */ - virtual DOMImplementation *getDOMImplementation(const DOMString &features) = 0; - - /** - * Return a list of DOMImplementations with the given set of features. - * Use "" to fetch any implementation. - */ - virtual DOMImplementationList getDOMImplementationList(const DOMString &features) = 0; - - //################## - //# Non-API methods - //################## - - /** - * - */ - virtual ~DOMImplementationSource() {} - -}; - - - - - -/*######################################################################### -## DOMImplementation -#########################################################################*/ - -/** - * This is the class that actually creates a Document. - */ -class DOMImplementation -{ -public: - - /** - * Determine if this implementation has the given feature and version. - */ - virtual bool hasFeature(const DOMString& feature, const DOMString& version) = 0; - - - /** - * Create a document type to be used in creating documents. - */ - virtual DocumentTypePtr createDocumentType( - const DOMString& qualifiedName, - const DOMString& publicId, - const DOMString& systemId) - throw(DOMException) = 0; - - /** - * Create a DOM document. - */ - virtual DocumentPtr createDocument(const DOMString& namespaceURI, - const DOMString& qualifiedName, - DocumentTypePtr doctype) - throw(DOMException) = 0; - /** - * Return the thing which is the feature of this implementation. Since - * this is a "one size fits all" call, you will need to typecast the - * result to the expected type. - */ - virtual DOMObject *getFeature(const DOMString& feature, - const DOMString& version) = 0; - - - //################## - //# Non-API methods - //################## - - /** - * - */ - virtual ~DOMImplementation() {} - -}; - - - - - -/*######################################################################### -## Node -#########################################################################*/ - -/** - * The basic Node class, which is the root of most other - * classes in DOM. Thus it is by far the most important, and the one - * whose implementation we must perform correctly. - */ -class Node -{ -public: - - /** - * Which of the DOM Core node types is this node? - */ - typedef enum - { - ELEMENT_NODE = 1, - ATTRIBUTE_NODE = 2, - TEXT_NODE = 3, - CDATA_SECTION_NODE = 4, - ENTITY_REFERENCE_NODE = 5, - ENTITY_NODE = 6, - PROCESSING_INSTRUCTION_NODE = 7, - COMMENT_NODE = 8, - DOCUMENT_NODE = 9, - DOCUMENT_TYPE_NODE = 10, - DOCUMENT_FRAGMENT_NODE = 11, - NOTATION_NODE = 12 - } NodeType; - - /** - * Return the name of this node. - */ - virtual DOMString getNodeName() = 0; - - /** - * Return the value of this node. The interpretation of the - * value is type-specific. - */ - virtual DOMString getNodeValue() throw (DOMException) = 0; - - /** - * Set the value of this node. The interpretation of the - * value is type-specific. - */ - virtual void setNodeValue(const DOMString& val) throw (DOMException) = 0; - - /** - * Return the type of this Node. One of the NodeType values above. - */ - virtual unsigned short getNodeType() = 0; - - /** - * Return the parent which references this node as a child in the DOM - * tree. Return NULL if there is none. - */ - virtual NodePtr getParentNode() = 0; - - /** - * Return a list of the children of this Node. - * NOTE: the spec expects this to be a "live" list that always - * reflects an accurate list of what the Node current possesses, not - * a snapshot. How do we do this? - */ - virtual NodeList getChildNodes() = 0; - - /** - * Return the first sibling of the chidren of this node. Return - * null if there is none. - */ - virtual NodePtr getFirstChild() = 0; - - /** - * Return the last sibling of the children of this node. Return - * null if there is none. - */ - virtual NodePtr getLastChild() = 0; - - /** - * Return the node that is previous to this one in the parent's - * list of children. Return null if there is none. - */ - virtual NodePtr getPreviousSibling() = 0; - - /** - * Return the node that is after this one in the parent's list - * of children. Return null if there is none. - */ - virtual NodePtr getNextSibling() = 0; - - /** - * Get the list of all attributes of this node. - */ - virtual NamedNodeMap &getAttributes() = 0; - - - /** - * Return the document that created or inherited this node. - */ - virtual DocumentPtr getOwnerDocument() = 0; - - /** - * Insert a node as a new child. Place it before the referenced child. - * Place it at the end if the referenced child does not exist. - */ - virtual NodePtr insertBefore(const NodePtr newChild, - const NodePtr refChild) - throw(DOMException) = 0; - - /** - * Insert a node as a new child. Replace the referenced child with it. - * Place it at the end if the referenced child does not exist. - */ - virtual NodePtr replaceChild(const NodePtr newChild, - const NodePtr oldChild) - throw(DOMException) = 0; - - /** - * Remove a node from the list of children. Do nothing if the - * node is not a member of the child list. - */ - virtual NodePtr removeChild(const NodePtr oldChild) - throw(DOMException) = 0; - - /** - * Add the node to the end of this node's child list. - */ - virtual NodePtr appendChild(const NodePtr newChild) - throw(DOMException) = 0; - - /** - * Return true if this node has one or more children, else return false. - */ - virtual bool hasChildNodes() = 0; - - /** - * Return a new node which has the name, type, value, attributes, and - * child list as this one. - * If 'deep' is true, continue cloning recursively with this node's children, - * so that the child list also contains clones of their respective nodes. - */ - virtual NodePtr cloneNode(bool deep) = 0; - - /** - * Adjust this node and its children to have its namespaces and - * prefixes in "canonical" order. - */ - virtual void normalize() = 0; - - /** - * Return true if the named feature is supported by this node, - * else false. - */ - virtual bool isSupported(const DOMString& feature, - const DOMString& version) = 0; - - /** - * Return the namespace of this node. This would be whether the - * namespace were declared explicitly on this node, it has a namespace - * prefix, or it is inherits the namespace from an ancestor node. - */ - virtual DOMString getNamespaceURI() = 0; - - /** - * Return the namespace prefix of this node, if any. For example, if - * the tag were then the prefix would be "svg" - */ - virtual DOMString getPrefix() = 0; - - /** - * Sets the namespace prefix of this node to the given value. This - * does not change the namespaceURI value. - */ - virtual void setPrefix(const DOMString& val) throw(DOMException) = 0; - - /** - * Return the local name of this node. This is merely the name without - * any namespace or prefix. - */ - virtual DOMString getLocalName() = 0; - - /** - * Return true if this node has one or more attributes, else false. - */ - virtual bool hasAttributes() = 0; - - /** - * Return the base URI of this node. This is basically the "location" of this - * node, and is used in resolving the relative locations of other URIs. - */ - virtual DOMString getBaseURI() = 0; - - /** - * DocumentPosition. - * This is used to describe the position of one node relative - * to another in a document - */ - typedef enum - { - DOCUMENT_POSITION_DISCONNECTED = 0x01, - DOCUMENT_POSITION_PRECEDING = 0x02, - DOCUMENT_POSITION_FOLLOWING = 0x04, - DOCUMENT_POSITION_CONTAINS = 0x08, - DOCUMENT_POSITION_CONTAINED_BY = 0x10, - DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20 - } DocumentPosition; - - - /** - * Get the position of this node relative to the node argument. - */ - virtual unsigned short compareDocumentPosition( - const NodePtr other) = 0; - - /** - * This is a DOM L3 method. Return the text value of this node and its - * children. This is done by concatenating all of the TEXT_NODE and - * CDATA_SECTION nodes of this node and its children, in order, together. - * Very handy. - */ - virtual DOMString getTextContent() throw(DOMException) = 0; - - - /** - * This is a DOM L3 method. Remember, this is a destructive call. This - * will replace all of the child nodes of this node with a single TEXT_NODE - * with the given text value. - */ - virtual void setTextContent(const DOMString &val) throw(DOMException) = 0; - - - /** - * This will search the tree from this node up, for a prefix that - * has been assigned to the namespace argument. Return "" if not found. - */ - virtual DOMString lookupPrefix(const DOMString &namespaceURI) =0; - - - /** - * Return true if this node is in the namespace of the argument, without - * requiring an explicit namespace declaration or a suffix. - */ - virtual bool isDefaultNamespace(const DOMString &namespaceURI) =0; - - - /** - * This will search the tree from this node up, for a namespace that - * has been assigned the suffix in the argument. Return "" if not found. - */ - virtual DOMString lookupNamespaceURI(const DOMString &prefix) =0; - - - /** - * Return true if the argument node is equal to this one. Use W3C rules - * for equality. - */ - virtual bool isEqualNode(const NodePtr node) =0; - - - - /** - * Return an opaque reference to the named feature. Return null if - * not supported. Using other than "" for the version will look for - * a feature with the given version. - */ - virtual DOMObject *getFeature(const DOMString &feature, - const DOMString &version) =0; - - /** - * Store a user data reference in this node, using the given key. - * A handler is an optional function object that will be called during - * future settings of this value. See UserDataHandler for more info. - */ - virtual DOMUserData *setUserData(const DOMString &key, - const DOMUserData *data, - const UserDataHandler *handler) =0; - - - /** - * Return a reference to the named user data object. Return null - * if it does not exist. - */ - virtual DOMUserData *getUserData(const DOMString &key) =0; - - //################## - //# Non-API methods - //################## - - /** - * - */ - Node() : _refCnt(0) - {} - - /** - * - */ - virtual ~Node() {} - -protected: - - friend void incrementRefCount(Node *p); - friend void decrementRefCount(Node *p); - - /** - * For the Ptr smart pointer - */ - int _refCnt; - -}; - - - - -/*######################################################################### -## NodeList -#########################################################################*/ - -/** - * Contains a list of Nodes. This is the standard API container for Nodes, - * and is used in lieu of other lists, arrays, etc, in order to provide - * a consistent API and algorithm. - */ -class NodeList -{ -public: - - /** - * Retrieve the Node at the given index. Return NULL - * if out of range. - */ - virtual NodePtr item(unsigned long index) - { - if (index>=nodes.size()) - return NULL; - return nodes[index]; - } - - /** - * Get the number of nodes in this list - */ - virtual unsigned long getLength() - { - return (unsigned long) nodes.size(); - } - - - //################## - //# Non-API methods - //################## - - /** - * - */ - NodeList() {} - - /** - * - */ - NodeList(const NodeList &other) - : nodes (other.nodes) - { - } - - /** - * - */ - NodeList &operator=(const NodeList &other) - { - nodes = other.nodes; - return *this; - } - - /** - * - */ - virtual ~NodeList() {} - - /** - * - */ - virtual void clear() - { - nodes.clear(); - } - -protected: - -friend class NodeImpl; -friend class ElementImpl; - - /* - * - */ - virtual void add(const NodePtr node) - { - nodes.push_back(node); - } - -protected: - - std::vector nodes; - -}; - - - - -/*######################################################################### -## NamedNodeMap -#########################################################################*/ - -/** - * Contains a mapping from name->NodePtr. Used for various purposes. For - * example, a list of Attributes is a NamedNodeMap. - */ -class NamedNodeMap -{ -private: - - /** - * table entry. Not an API item - */ - class NamedNodeMapEntry - { - public: - NamedNodeMapEntry(const DOMString &theNamespaceURI, - const DOMString &theName, - const NodePtr theNode) - : namespaceURI (theNamespaceURI), - name (theName), - node (theNode) - { - } - NamedNodeMapEntry(const NamedNodeMapEntry &other) - { - assign(other); - } - NamedNodeMapEntry &operator=(const NamedNodeMapEntry &other) - { - assign(other); - return *this; - } - virtual ~NamedNodeMapEntry() - { - } - void assign(const NamedNodeMapEntry &other) - { - namespaceURI = other.namespaceURI; - name = other.name; - node = other.node; - } - DOMString namespaceURI; - DOMString name; - NodePtr node; - }; - - -public: - - /** - * Return the named node. Return nullptr if not found. - */ - virtual NodePtr getNamedItem(const DOMString& name) - { - std::vector::iterator iter; - for (iter = entries.begin() ; iter!=entries.end() ; ++iter) - { - if (iter->name == name) - { - NodePtr node = iter->node; - return node; - } - } - return NULL; - } - - /** - * Adds a node using its nodeName attribute. If a node with that name is already - * present in this map, it is replaced by the new one. Replacing a node by itself - * has no effect. - */ - virtual NodePtr setNamedItem(NodePtr arg) throw(DOMException) - { - if (!arg) - return NULL; - DOMString namespaceURI = arg->getNamespaceURI(); - DOMString name = arg->getNodeName(); - std::vector::iterator iter; - for (iter = entries.begin() ; iter!=entries.end() ; ++iter) - { - if (iter->name == name) - { - NodePtr node = iter->node; - iter->node = arg; - return node; - } - } - NamedNodeMapEntry entry(namespaceURI, name, arg); - entries.push_back(entry); - return arg; - } - - - /** - * Removes a node specified by name. - */ - virtual NodePtr removeNamedItem(const DOMString& name) throw(DOMException) - { - std::vector::iterator iter; - for (iter = entries.begin() ; iter!=entries.end() ; ++iter) - { - if (iter->name == name) - { - NodePtr node = iter->node; - entries.erase(iter); - return node; - } - } - return NULL; - } - - /** - * Retrieves an item at the given index. If out of bounds, return NULL - */ - virtual NodePtr item(unsigned long index) - { - if (index>=entries.size()) - return NULL; - return entries[index].node; - } - - /** - * Return the number of items in this map - */ - virtual unsigned long getLength() - { - return (unsigned long)entries.size(); - } - - /** - * Retrieves a node specified by local name and namespace URI. - */ - virtual NodePtr getNamedItemNS(const DOMString& namespaceURI, - const DOMString& localName) - { - std::vector::iterator iter; - for (iter = entries.begin() ; iter!=entries.end() ; ++iter) - { - if (iter->namespaceURI == namespaceURI && iter->name == localName) - { - NodePtr node = iter->node; - return node; - } - } - return NULL; - } - - /** - * Adds a node using its namespaceURI and localName. If a node with that - * namespace URI and that local name is already present in this map, it is - * replaced by the new one. Replacing a node by itself has no effect. - */ - virtual NodePtr setNamedItemNS(NodePtr arg) throw(DOMException) - { - if (!arg) - return NULL; - DOMString namespaceURI = arg->getNamespaceURI(); - DOMString name = arg->getNodeName(); - std::vector::iterator iter; - for (iter = entries.begin() ; iter!=entries.end() ; ++iter) - { - if (iter->namespaceURI == namespaceURI && iter->name == name) - { - NodePtr node = iter->node; - iter->node = arg; - return node; - } - } - NamedNodeMapEntry entry(namespaceURI, name, arg); - entries.push_back(entry); - return arg; - } - - /** - * Removes a node specified by local name and namespace URI. - */ - virtual NodePtr removeNamedItemNS(const DOMString& namespaceURI, - const DOMString& localName) - throw(DOMException) - { - std::vector::iterator iter; - for (iter = entries.begin() ; iter!=entries.end() ; ++iter) - { - if (iter->namespaceURI == namespaceURI && iter->name == localName) - { - NodePtr node = iter->node; - entries.erase(iter); - return node; - } - } - return NULL; - } - - - //################## - //# Non-API methods - //################## - - /** - * - */ - NamedNodeMap() {} - - - /** - * - */ - NamedNodeMap(const NamedNodeMap &other) - : entries (other.entries) - { - } - - /** - * - */ - NamedNodeMap &operator=(const NamedNodeMap &other) - { - entries = other.entries; - return *this; - } - - - /** - * - */ - virtual ~NamedNodeMap() {} - -protected: - - std::vector entries; - -}; - - - - -/*######################################################################### -## CharacterData -#########################################################################*/ - -/** - * This is the base class for other text-oriented Nodes, such as TEXT_NODE - * or CDATA_SECTION_NODE. No DOM objects correspond directly to CharacterData. - */ -class CharacterData : virtual public Node -{ -public: - - /** - * This is an alias for getNodeValue() - */ - virtual DOMString getData() throw(DOMException) = 0; - - /** - * This is an alias for setNodeValue() - */ - virtual void setData(const DOMString& val) throw(DOMException) = 0; - - /** - * Return the number of characters contained in this node's data - */ - virtual unsigned long getLength() = 0; - - /** - * Return a substring of this node's data, starting at offset, and - * continuing for 'count' characters. Throw an exception if this goes - * out of range. - */ - virtual DOMString substringData(unsigned long offset, - unsigned long count) - throw(DOMException) = 0; - - /** - * Append the argument string to the end of the node's current data. - */ - virtual void appendData(const DOMString& arg) throw(DOMException) = 0; - - /** - * Insert the argument string at the offset position into the node's - * current data. If the position is out of range, throw an Exception. - */ - virtual void insertData(unsigned long offset, - const DOMString& arg) - throw(DOMException) = 0; - - /** - * Delete 'count' characters from the node's data starting from the - * offset position. If this goes out of range, throw an Exception. - */ - virtual void deleteData(unsigned long offset, - unsigned long count) - throw(DOMException) = 0; - - /** - * Replace the 'count' characters at the offset position with the given - * argument string. If this goes out of range, throw an Exception. - */ - virtual void replaceData(unsigned long offset, - unsigned long count, - const DOMString& arg) - throw(DOMException) = 0; - - - //################## - //# Non-API methods - //################## - - - /** - * - */ - virtual ~CharacterData() {} - -}; - - - - -/*######################################################################### -## Attr -#########################################################################*/ - -/** - * The Attr interface represents an attribute in an Element object. - * Typically the allowable values for the attribute are defined in a - * schema associated with the document. - * Since Attrs are not considered to be part of the DOM tree, parent, - * previousSibling, and nextSibling are null. - */ -class Attr : virtual public Node -{ -public: - - /** - * Returns the name of this attribute. If Node.localName is different - * from null, this attribute is a qualified name. - */ - virtual DOMString getName() = 0; - - /** - * True if this attribute was explicitly given a value in the instance document, - * false otherwise. If the application changed the value of this attribute node - * (even if it ends up having the same value as the default value) then it is set - * to true. The implementation may handle attributes with default values from - * other schemas similarly but applications should use - * Document.normalizeDocument() to guarantee this information is up-to-date. - */ - virtual bool getSpecified() = 0; - - /** - * Returns the value of the attribute - */ - virtual DOMString getValue() = 0; - - /** - * Sets the value of the attribute - */ - virtual void setValue(const DOMString& val) throw(DOMException) = 0; - - /** - * Return the Element that possesses this attribute - */ - virtual ElementPtr getOwnerElement() = 0; - - - /** - * The type information associated with this attribute. - */ - virtual TypeInfo &getSchemaTypeInfo() = 0; - - - /** - * Returns whether this attribute is known to be of type ID (i.e. to contain an - * identifier for its owner element) or not. When it is and its value is unique, - * the ownerElement of this attribute can be retrieved using the method - * Document.getElementById. - */ - virtual bool getIsId() = 0; - - //################## - //# Non-API methods - //################## - - - /** - * - */ - virtual ~Attr() {} - -}; - - - - - -/*######################################################################### -## Element -#########################################################################*/ - -/** - * The Element interface represents an element in an XML document. - * Elements may have attributes associated with them; since the Element interface - * inherits from Node, the generic Node interface attribute attributes may be - * used to retrieve the set of all attributes for an element. There are methods - * on the Element interface to retrieve either an Attr object by name or an - * attribute value by name. In XML, where an attribute value may contain entity - * references, an Attr object should be retrieved to examine the possibly fairly - * complex sub-tree representing the attribute value. On the other hand, in HTML, - * where all attributes have simple string values, methods to directly access an - * attribute value can safely be used as a convenience. - */ -class Element : virtual public Node -{ -public: - - - /** - * The name of the element. If Node.localName is different from null, - * this attribute is a qualified name. - */ - virtual DOMString getTagName() = 0; - - /** - * Retrieves an attribute value by name. - */ - virtual DOMString getAttribute(const DOMString& name) = 0; - - /** - * Adds a new attribute. If an attribute with that name is already present in the - * element, its value is changed to be that of the value parameter. This value is - * a simple string; it is not parsed as it is being set. So any markup (such as - * syntax to be recognized as an entity reference) is treated as literal text, - * and needs to be appropriately escaped by the implementation when it is written - * out. In order to assign an attribute value that contains entity references, - * the user must create an Attr node plus any Text and EntityReference nodes, - * build the appropriate subtree, and use setAttributeNode to assign it as the - * value of an attribute. - */ - virtual void setAttribute(const DOMString& name, - const DOMString& value) - throw(DOMException) = 0; - - /** - * Removes an attribute by name. If no attribute with this name is found, - * this method has no effect. - */ - virtual void removeAttribute(const DOMString& name) - throw(DOMException) = 0; - - /** - * Retrieves an attribute node by name. - */ - virtual AttrPtr getAttributeNode(const DOMString& name) = 0; - - /** - * Adds a new attribute node. If an attribute with that name (nodeName) - * is already present in the element, it is replaced by the new one. - * Replacing an attribute node by itself has no effect. - */ - virtual AttrPtr setAttributeNode(AttrPtr newAttr) - throw(DOMException) = 0; - - /** - * Removes the specified attribute node. - */ - virtual AttrPtr removeAttributeNode(AttrPtr oldAttr) - throw(DOMException) = 0; - - /** - * Returns a NodeList of all descendant Elements with a given tag name, - * in document order. - */ - virtual NodeList getElementsByTagName(const DOMString& name) = 0; - - /** - * Retrieves an attribute value by local name and namespace URI. - * Per [XML Namespaces], applications must use the value null as the - * namespaceURI parameter for methods if they wish to have no namespace. - */ - virtual DOMString getAttributeNS(const DOMString& namespaceURI, - const DOMString& localName) = 0; - - /** - * Adds a new attribute. If an attribute with the same local name and namespace - * URI is already present on the element, its prefix is changed to be the prefix - * part of the qualifiedName, and its value is changed to be the value parameter. - * This value is a simple string; it is not parsed as it is being set. So any - * markup (such as syntax to be recognized as an entity reference) is treated as - * literal text, and needs to be appropriately escaped by the implementation when - * it is written out. In order to assign an attribute value that contains entity - * references, the user must create an Attr node plus any Text and - * EntityReference nodes, build the appropriate subtree, and use - * setAttributeNodeNS or setAttributeNode to assign it as the value of an - * attribute. - */ - virtual void setAttributeNS(const DOMString& namespaceURI, - const DOMString& qualifiedName, - const DOMString& value) - throw(DOMException) = 0; - - /** - * Removes an attribute by local name and namespace URI. - */ - virtual void removeAttributeNS(const DOMString& namespaceURI, - const DOMString& localName) - throw(DOMException) = 0; - - /** - * Retrieves an Attr node by local name and namespace URI. - */ - virtual AttrPtr getAttributeNodeNS(const DOMString& namespaceURI, - const DOMString& localName) = 0; - - /** - * Adds a new attribute. If an attribute with that local name and - * that namespace URI is already present in the element, it is - * replaced by the new one. Replacing an attribute node by itself has no effect. - */ - virtual AttrPtr setAttributeNodeNS(AttrPtr newAttr) - throw(DOMException) = 0; - - /** - * Returns a NodeList of all the descendant Elements with a given - * local name and namespace URI in document order. - */ - virtual NodeList getElementsByTagNameNS(const DOMString& namespaceURI, - const DOMString& localName) = 0; - - /** - * Returns true when an attribute with a given name is specified on - * this element or has a default value, false otherwise. - */ - virtual bool hasAttribute(const DOMString& name) = 0; - - /** - * Returns true when an attribute with a given local name and namespace - * URI is specified on this element or has a default value, false otherwise. - */ - virtual bool hasAttributeNS(const DOMString& namespaceURI, - const DOMString& localName) = 0; - - /** - * The type information associated with this element. - */ - virtual TypeInfo &getSchemaTypeInfo() = 0; - - - /** - * If the parameter isId is true, this method declares the specified - * attribute to be a user-determined ID attribute. - */ - virtual void setIdAttribute(const DOMString &name, - bool isId) throw (DOMException) = 0; - - /** - * If the parameter isId is true, this method declares the specified - * attribute to be a user-determined ID attribute. - */ - virtual void setIdAttributeNS(const DOMString &namespaceURI, - const DOMString &localName, - bool isId) throw (DOMException) = 0; - - /** - * If the parameter isId is true, this method declares the specified - * attribute to be a user-determined ID attribute. - */ - virtual void setIdAttributeNode(const AttrPtr idAttr, - bool isId) throw (DOMException) = 0; - - //################## - //# Non-API methods - //################## - - /** - * - */ - virtual ~Element() {} - -}; - - - - - -/*######################################################################### -## Text -#########################################################################*/ - -/** - * The Text interface inherits from CharacterData and represents the textual - * content (termed character data in XML) of an Element or Attr. If there is no - * markup inside an element's content, the text is contained in a single object - * implementing the Text interface that is the only child of the element. If - * there is markup, it is parsed into the information items (elements, comments, - * etc.) and Text nodes that form the list of children of the element. - */ -class Text : virtual public CharacterData -{ -public: - - /** - * Breaks this node into two nodes at the specified offset, keeping both in the - * tree as siblings. After being split, this node will contain all the content up - * to the offset point. A new node of the same type, which contains all the - * content at and after the offset point, is returned. If the original node had a - * parent node, the new node is inserted as the next sibling of the original - * node. When the offset is equal to the length of this node, the new node has no - * data. - */ - virtual TextPtr splitText(unsigned long offset) - throw(DOMException) = 0; - - /** - * Returns whether this text node contains element content whitespace, often - * abusively called "ignorable whitespace". The text node is determined to - * contain whitespace in element content during the load of the document or if - * validation occurs while using Document.normalizeDocument(). - */ - virtual bool getIsElementContentWhitespace()= 0; - - /** - * Returns all text of Text nodes logically-adjacent text nodes - * to this node, concatenated in document order. - */ - virtual DOMString getWholeText() = 0; - - - /** - * Replaces the text of the current node and all logically-adjacent text nodes - * with the specified text. All logically-adjacent text nodes are removed - * including the current node unless it was the recipient of the replacement text. - * - * This method returns the node which received the replacement text. The returned - * node is: - * o null, when the replacement text is the empty string; - * o the current node, except when the current node is read-only; - * o a new Text node of the same type (Text or CDATASection) as - * the current node inserted at the location of the replacement. - */ - virtual TextPtr replaceWholeText(const DOMString &content) - throw(DOMException) = 0; - - //################## - //# Non-API methods - //################## - - - /** - * - */ - virtual ~Text() {} - -}; - - - -/*######################################################################### -## Comment -#########################################################################*/ - -/** - * This interface inherits from CharacterData and represents the content of a - * comment, i.e., all the characters between the starting ''. - * Note that this is the definition of a comment in XML, and, in practice, - * HTML, although some HTML tools may implement the full SGML comment structure. - */ -class Comment : virtual public CharacterData -{ -public: - - //################## - //# Non-API methods - //################## - - - /** - * - */ - virtual ~Comment() {} - - -}; - - - -/*######################################################################### -## TypeInfo -#########################################################################*/ - -/** - * The TypeInfo interface represents a type referenced from Element or Attr nodes, - * specified in the schemas associated with the document. The type is a pair of - * a namespace URI and name properties, and depends on the document's schema. - */ -class TypeInfo -{ -public: - - /** - * The name of a type declared for the associated element or attribute, - * or null if unknown. - */ - virtual DOMString getTypeName() - { return typeName; } - - /** - * The namespace of the type declared for the associated element - * or attribute or null if the element does not have declaration or - * if no namespace information is available. - */ - virtual DOMString getTypeNamespace() - { return typeNameSpace; } - - /** - * These are the available values for the derivationMethod parameter used by the - * method TypeInfo.isDerivedFrom(). It is a set of possible types of derivation, - * and the values represent bit positions. If a bit in the derivationMethod - * parameter is set to 1, the corresponding type of derivation will be taken into - * account when evaluating the derivation between the reference type definition - * and the other type definition. When using the isDerivedFrom method, combining - * all of them in the derivationMethod parameter is equivalent to invoking the - * method for each of them separately and combining the results with the OR - * boolean function. This specification only defines the type of derivation for - * XML Schema. - */ - typedef enum - { - DERIVATION_RESTRICTION = 0x00000001, - DERIVATION_EXTENSION = 0x00000002, - DERIVATION_UNION = 0x00000004, - DERIVATION_LIST = 0x00000008 - } DerivationMethod; - - - /** - * This method returns if there is a derivation between the reference - * type definition, i.e. the TypeInfo on which the method is being called, - * and the other type definition, i.e. the one passed as parameters. - */ - virtual bool isDerivedFrom(const DOMString &/*typeNamespaceArg*/, - const DOMString &/*typeNameArg*/, - DerivationMethod /*derivationMethod*/) - { return false; } - - //################## - //# Non-API methods - //################## - - - /** - * - */ - TypeInfo() - {} - - /** - * - */ - TypeInfo(const TypeInfo &other) - { assign(other); } - - /** - * - */ - TypeInfo &operator=(const TypeInfo &other) - { assign(other); return *this; } - - /** - * - */ - virtual ~TypeInfo() {} - -private: - - void assign(const TypeInfo &other) - { - typeName = other.typeName; - typeNameSpace = other.typeNameSpace; - } - - DOMString typeName; - DOMString typeNameSpace; -}; - - - - -/*######################################################################### -## UserDataHandler -#########################################################################*/ - -/** - * When associating an object to a key on a node using Node.setUserData() the - * application can provide a handler that gets called when the node the object is - * associated to is being cloned, imported, or renamed. This can be used by the - * application to implement various behaviors regarding the data it associates to - * the DOM nodes. This interface defines that handler. - */ -class UserDataHandler -{ -public: - - /** - * An integer indicating the type of operation being performed on a node. - */ - typedef enum - { - NODE_CLONED = 1, - NODE_IMPORTED = 2, - NODE_DELETED = 3, - NODE_RENAMED = 4, - NODE_ADOPTED = 5 - } OperationType; - - - /** - * This method is called whenever the node for which this handler - * is registered is imported or cloned. - */ - virtual void handle(unsigned short operation, - const DOMString &key, - const DOMUserData *data, - const NodePtr src, - const NodePtr dst) =0; - - //################## - //# Non-API methods - //################## - - - /** - * - */ - virtual ~UserDataHandler() {} - -}; - - -/*######################################################################### -## DOMError -#########################################################################*/ - -/** - * DOMError is an interface that describes an error. - */ -class DOMError -{ -public: - - /** - * An integer indicating the severity of the error. - */ - typedef enum - { - SEVERITY_WARNING = 1, - SEVERITY_ERROR = 2, - SEVERITY_FATAL_ERROR = 3 - } ErrorSeverity; - - - /** - * The severity of the error, either SEVERITY_WARNING, SEVERITY_ERROR, - * or SEVERITY_FATAL_ERROR. - */ - virtual unsigned short getSeverity() =0; - - /** - * An implementation specific string describing the error that occurred. - */ - virtual DOMString getMessage() =0; - - /** - * A DOMString indicating which related data is expected in relatedData. - * Users should refer to the specification of the error in order to find - * its DOMString type and relatedData definitions if any. - */ - virtual DOMString getType() =0; - - /** - * The related platform dependent exception if any. - */ - virtual DOMObject *getRelatedException() =0; - - /** - * The related DOMError.type dependent data if any. - */ - virtual DOMObject *getRelatedData() =0; - - /** - * The location of the error. - */ - virtual DOMLocator *getLocation() =0; - - - //################## - //# Non-API methods - //################## - - - /** - * - */ - virtual ~DOMError() {} - -}; - - -/*######################################################################### -## DOMErrorHandler -#########################################################################*/ - -/** - * DOMErrorHandler is a callback interface that the DOM implementation can call - * when reporting errors that happens while processing XML data, or when doing - * some other processing (e.g. validating a document). A DOMErrorHandler object - * can be attached to a Document using the "error-handler" on the - * DOMConfiguration interface. If more than one error needs to be reported during - * an operation, the sequence and numbers of the errors passed to the error - * handler are implementation dependent. - */ -class DOMErrorHandler -{ -public: - - /** - * This method is called on the error handler when an error occurs. - * If an exception is thrown from this method, it is considered to be - * equivalent of returning true. - */ - virtual bool handleError(const DOMError *error) =0; - - - //################## - //# Non-API methods - //################## - - /** - * - */ - virtual ~DOMErrorHandler() {} - -}; - - - -/*######################################################################### -## DOMLocator -#########################################################################*/ - -/** - * DOMLocator is an interface that describes a location (e.g. where an error occurred). - */ -class DOMLocator -{ -public: - - /** - * The line number this locator is pointing to, or -1 if there is - * no column number available. - */ - virtual long getLineNumber() =0; - - /** - * The column number this locator is pointing to, or -1 if there is - * no column number available. - */ - virtual long getColumnNumber() =0; - - /** - * The byte offset into the input source this locator is pointing to - * or -1 if there is no byte offset available. - */ - virtual long getByteOffset() =0; - - /** - * The UTF-16, as defined in [Unicode] and Amendment 1 of [ISO/IEC 10646], - * offset into the input source this locator is pointing to or -1 - * if there is no UTF-16 offset available. - */ - virtual long getUtf16Offset() =0; - - - /** - * The node this locator is pointing to, or null if no node is available. - */ - virtual NodePtr getRelatedNode() =0; - - - /** - * The URI this locator is pointing to, or null if no URI is available. - */ - virtual DOMString getUri() =0; - - //################## - //# Non-API methods - //################## - - /** - * - */ - virtual ~DOMLocator() {} -}; - - -/*######################################################################### -## DOMConfiguration -#########################################################################*/ - -/** - * The DOMConfiguration interface represents the configuration of a document and - * maintains a table of recognized parameters. Using the configuration, it is - * possible to change Document.normalizeDocument() behavior, such as replacing - * the CDATASection nodes with Text nodes or specifying the type of the schema - * that must be used when the validation of the Document is requested. - * DOMConfiguration objects are also used in [DOM Level 3 Load and Save] in the - * DOMParser and DOMSerializer interfaces. - * - * Look here for a list of valid parameters: - * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#DOMConfiguration - */ -class DOMConfiguration -{ -public: - - /** - * Set the value of a parameter. - */ - virtual void setParameter(const DOMString &name, - const DOMUserData *value) - throw (DOMException) =0; - - /** - * Return the value of a parameter if known. - */ - virtual DOMUserData *getParameter(const DOMString &name) - throw (DOMException) =0; - - /** - * Check if setting a parameter to a specific value is supported. - */ - virtual bool canSetParameter(const DOMString &name, - const DOMUserData *data) =0; - - /** - * The list of the parameters supported by this DOMConfiguration - * object and for which at least one value can be set by the application. - * Note that this list can also contain parameter names defined outside - * this specification. - */ - virtual DOMStringList *getParameterNames() =0; - - //################## - //# Non-API methods - //################## - - - /** - * - */ - virtual ~DOMConfiguration() {} - -}; - - - - - - -/*######################################################################### -## CDATASection -#########################################################################*/ - -/** - * CDATA sections are used to escape blocks of text containing characters that - * would otherwise be regarded as markup. The only delimiter that is recognized - * in a CDATA section is the "]]>" string that ends the CDATA section. CDATA - * sections cannot be nested. Their primary purpose is for including material - * such as XML fragments, without needing to escape all the delimiters. - */ -class CDATASection : virtual public Text -{ -public: - - //################## - //# Non-API methods - //################## - - - /** - * - */ - virtual ~CDATASection() {} - -}; - - - - -/*######################################################################### -## DocumentType -#########################################################################*/ - -/** - * Each Document has a doctype attribute whose value is either null or a - * DocumentType object. The DocumentType interface in the DOM Core provides an - * interface to the list of entities that are defined for the document, and - * little else because the effect of namespaces and the various XML schema - * efforts on DTD representation are not clearly understood as of this writing. - */ -class DocumentType : virtual public Node -{ -public: - - /** - * The name of DTD; i.e., the name immediately following the DOCTYPE keyword. - */ - virtual DOMString getName() = 0; - - /** - * A NamedNodeMap containing the general entities, both external and - * internal, declared in the DTD. Parameter entities are not contained. - * Duplicates are discarded. - */ - virtual NamedNodeMap getEntities() = 0; - - /** - * A NamedNodeMap containing the notations declared in the DTD. Duplicates - * are discarded. Every node in this map also implements the - * Notation interface. - */ - virtual NamedNodeMap getNotations() = 0; - - /** - * The public identifier of the external subset. - */ - virtual DOMString getPublicId() = 0; - - /** - * The system identifier of the external subset. This may be an - * absolute URI or not. - */ - virtual DOMString getSystemId() = 0; - - /** - * The internal subset as a string, or null if there is none. This - * does not contain the delimiting square brackets. - */ - virtual DOMString getInternalSubset() = 0; - - //################## - //# Non-API methods - //################## - - /** - * - */ - virtual ~DocumentType() {} - -}; - - - - - -/*######################################################################### -## Notation -#########################################################################*/ - -/** - * This interface represents a notation declared in the DTD. A notation either - * declares, by name, the format of an unparsed entity (see section 4.7 of the - * XML 1.0 specification [XML 1.0]), or is used for formal declaration of - * processing instruction targets (see section 2.6 of the XML 1.0 specification - * [XML 1.0]). The nodeName attribute inherited from Node is set to the declared - * name of the notation. - */ -class Notation : virtual public Node -{ -public: - - /** - * The public identifier of this notation. If the public identifier was - * not specified, this is null. - */ - virtual DOMString getPublicId() = 0; - - /** - * The system identifier of this notation. If the system identifier was - * not specified, this is null. This may be an absolute URI or not. - */ - virtual DOMString getSystemId() = 0; - - //################## - //# Non-API methods - //################## - - - /** - * - */ - virtual ~Notation() {} -}; - - - - - - -/*######################################################################### -## Entity -#########################################################################*/ - -/** - * This interface represents a known entity, either parsed or unparsed, in an XML - * document. Note that this models the entity itself not the entity declaration. - */ -class Entity : virtual public Node -{ -public: - - /** - * The public identifier associated with the entity if specified, - * and null otherwise. - */ - virtual DOMString getPublicId() = 0; - - /** - * The system identifier associated with the entity if specified, - * and null otherwise. This may be an absolute URI or not. - */ - virtual DOMString getSystemId() = 0; - - /** - * For unparsed entities, the name of the notation for the entity. - * For parsed entities, this is null. - */ - virtual DOMString getNotationName() = 0; - - /** - * An attribute specifying the encoding used for this entity at the - * time of parsing, when it is an external parsed entity. This is null - * if it an entity from the internal subset or if it is not known. - */ - virtual DOMString getInputEncoding() = 0; - - /** - * An attribute specifying, as part of the text declaration, the encoding - * of this entity, when it is an external parsed entity. This is null otherwise. - */ - virtual DOMString getXmlEncoding() = 0; - - /** - * An attribute specifying, as part of the text declaration, the version - * number of this entity, when it is an external parsed entity. - * This is null otherwise. - */ - virtual DOMString getXmlVersion() = 0; - - //################## - //# Non-API methods - //################## - - - /** - * - */ - virtual ~Entity() {} -}; - - - - - -/*######################################################################### -## EntityReference -#########################################################################*/ - -/** - * EntityReference nodes may be used to represent an entity reference in the tree. - */ -class EntityReference : virtual public Node -{ -public: - - - //################## - //# Non-API methods - //################## - - /** - * - */ - virtual ~EntityReference() {} -}; - - - - - -/*######################################################################### -## ProcessingInstruction -#########################################################################*/ - -/** - * The ProcessingInstruction interface represents a "processing instruction", - * used in XML as a way to keep processor-specific information in the text of the - * document. - */ -class ProcessingInstruction : virtual public Node -{ -public: - - /** - * The target of this processing instruction. XML defines this as being - * the first token following the markup that begins the processing instruction. - */ - virtual DOMString getTarget() = 0; - - /** - * The content of this processing instruction. This is from the first non - * white space character after the target to the character immediately - * preceding the ?>. - */ - virtual DOMString getData() = 0; - - /** - * Sets the content above. - */ - virtual void setData(const DOMString& val) throw(DOMException) = 0; - - //################## - //# Non-API methods - //################## - - - /** - * - */ - virtual ~ProcessingInstruction() {} - -}; - - - - - -/*######################################################################### -## DocumentFragment -#########################################################################*/ - -/** - * DocumentFragment is a "lightweight" or "minimal" Document object. It is very - * common to want to be able to extract a portion of a document's tree or to - * create a new fragment of a document. Imagine implementing a user command like - * cut or rearranging a document by moving fragments around. It is desirable to - * have an object which can hold such fragments and it is quite natural to use a - * Node for this purpose. While it is true that a Document object could fulfill - * this role, a Document object can potentially be a heavyweight object, - * depending on the underlying implementation. What is really needed for this is - * a very lightweight object. DocumentFragment is such an object. - */ -class DocumentFragment : virtual public Node -{ -public: - - //################## - //# Non-API methods - //################## - - - /** - * - */ - virtual ~DocumentFragment() {} -}; - - - - - - -/*######################################################################### -## Document -#########################################################################*/ - -/** - * From the spec: - * - * The Document interface represents the entire HTML or XML document. - * Conceptually, it is the root of the document tree, and provides the primary - * access to the document's data. - * - * Since elements, text nodes, comments, processing instructions, etc. cannot - * exist outside the context of a Document, the Document interface also contains - * the factory methods needed to create these objects. The Node objects created - * have a ownerDocument attribute which associates them with the Document within - * whose context they were created. - * - */ -class Document : virtual public Node -{ -public: - - /** - * The Document Type Declaration (see DocumentType) associated with this document. - */ - virtual DocumentTypePtr getDoctype() = 0; - - /** - * The DOMImplementation object that handles this document. A DOM application - * may use objects from multiple implementations. - */ - virtual DOMImplementation *getImplementation() = 0; - - /** - * This is a convenience attribute that allows direct access to the child - * node that is the document element of the document. - */ - virtual ElementPtr getDocumentElement() = 0; - - /** - * Creates an element of the type specified. - */ - virtual ElementPtr createElement(const DOMString& tagName) - throw(DOMException) = 0; - - /** - * Creates a new, empty DocumentFragment - */ - virtual DocumentFragmentPtr createDocumentFragment() = 0; - - /** - * Creates an Text node with the text data specified. - */ - virtual TextPtr createTextNode(const DOMString& text) = 0; - - /** - * Creates a new Comment node with the argument text - */ - virtual CommentPtr createComment(const DOMString& text) = 0; - - /** - * Creates a new CDATASection node with the argument text - */ - virtual CDATASectionPtr createCDATASection(const DOMString& text) - throw(DOMException) = 0; - - /** - * Creates a new ProcessingInstruction - */ - virtual ProcessingInstructionPtr - createProcessingInstruction(const DOMString& target, - const DOMString& data) - throw(DOMException) = 0; - - /** - * Creates a new Attr with the given name, but no value. - */ - virtual AttrPtr createAttribute(const DOMString& name) - throw(DOMException) = 0; - - /** - * Creates a new EntityReference - */ - virtual EntityReferencePtr createEntityReference(const DOMString& name) - throw(DOMException) = 0; - - /** - * Searches the Document in document order for all elements with the given - * tag name - */ - virtual NodeList getElementsByTagName(const DOMString& tagname) = 0; - - - /** - * Imports a node from another document to this document, without altering or - * removing the source node from the original document; this method creates a new - * copy of the source node. The returned node has no parent; (parentNode is - * null). For all nodes, importing a node creates a node object owned by the - * importing document, with attribute values identical to the source node's - * nodeName and nodeType, plus the attributes related to namespaces (prefix, - * localName, and namespaceURI). As in the cloneNode operation, the source node - * is not altered. User data associated to the imported node is not carried over. - * However, if any UserDataHandlers has been specified along with the associated - * data these handlers will be called with the appropriate parameters before this - * method returns. Additional information is copied as appropriate to the - * nodeType, attempting to mirror the behavior expected if a fragment of XML or - * HTML source was copied from one document to another, recognizing that the two - * documents may have different DTDs in the XML case. The following list - * describes the specifics for each type of node. - */ - virtual NodePtr importNode(const NodePtr importedNode, - bool deep) - throw(DOMException) = 0; - - /** - * Creates a new Element with the given namespace and qualifiedName. - * Use "" for no namespace - */ - virtual ElementPtr createElementNS(const DOMString& namespaceURI, - const DOMString& qualifiedName) - throw(DOMException) = 0; - - /** - * Creates a new Attr with the given namespace and qualifiedName. - */ - virtual AttrPtr createAttributeNS(const DOMString& namespaceURI, - const DOMString& qualifiedName) - throw(DOMException) = 0; - - /** - * Searches the Document in document order for all elements with the given - * namespace and tag name - */ - virtual NodeList getElementsByTagNameNS(const DOMString& namespaceURI, - const DOMString& localName) = 0; - - /** - * Gets the element with the given id if it exists, else null. - */ - virtual ElementPtr getElementById(const DOMString& elementId) = 0; - - - /** - * Return the input encoding of this Document - */ - virtual DOMString getInputEncoding() = 0; - - - /** - * Return the XML encoding of this Document - */ - virtual DOMString getXmlEncoding() = 0; - - /** - * An attribute specifying, as part of the XML declaration, whether - * this document is standalone. This is false when unspecified. - */ - virtual bool getXmlStandalone() = 0; - - /** - * Sets whether this is a standalone XML document. No validation is - * done here. - */ - virtual void setXmlStandalone(bool val) throw (DOMException) = 0; - - /** - * Gets the version (1.0, 1.1, etc) of this document. - */ - virtual DOMString getXmlVersion() = 0; - - /** - * Sets the XML version of this document. - */ - virtual void setXmlVersion(const DOMString &version) - throw (DOMException) = 0; - - /** - * An attribute specifying whether error checking is enforced or not. When set to - * false, the implementation is free to not test every possible error case - * normally defined on DOM operations, and not raise any DOMException on DOM - * operations or report errors while using Document.normalizeDocument(). In case - * of error, the behavior is undefined. This attribute is true by default. - */ - virtual bool getStrictErrorChecking() = 0; - - /** - * Sets the value described above. - */ - virtual void setStrictErrorChecking(bool val) = 0; - - - /** - * Gets the document URI (the base location) of this Document. - */ - virtual DOMString getDocumentURI() = 0; - - /** - * Sets the document URI (the base location) of this Document to the - * argument uri. - */ - virtual void setDocumentURI(const DOMString &uri) = 0; - - /** - * Attempts to adopt a node from another document to this document. If supported, - * it changes the ownerDocument of the source node, its children, as well as the - * attached attribute nodes if there are any. If the source node has a parent it - * is first removed from the child list of its parent. This effectively allows - * moving a subtree from one document to another (unlike importNode() which - * create a copy of the source node instead of moving it). When it fails, - * applications should use Document.importNode() instead. Note that if the - * adopted node is already part of this document (i.e. the source and target - * document are the same), this method still has the effect of removing the - * source node from the child list of its parent, if any. - */ - virtual NodePtr adoptNode(const NodePtr source) throw (DOMException) = 0; - - /** - * Get the configuration item associated with this Document - */ - virtual DOMConfiguration *getDomConfig() = 0; - - /** - * This method acts as if the document was going through a save and load cycle, - * putting the document in a "normal" form. As a consequence, this method updates - * the replacement tree of EntityReference nodes and normalizes Text nodes, as - * defined in the method Node.normalize(). Otherwise, the actual result depends - * on the features being set on the Document.domConfig object and governing what - * operations actually take place. Noticeably this method could also make the - * document namespace well-formed according to the algorithm described in - * Namespace Normalization, check the character normalization, remove the - * CDATASection nodes, etc. See DOMConfiguration for details. - */ - virtual void normalizeDocument() = 0; - - /** - * - * Rename an existing node of type ELEMENT_NODE or ATTRIBUTE_NODE. When possible - * this simply changes the name of the given node, otherwise this creates a new - * node with the specified name and replaces the existing node with the new node - * as described below. If simply changing the name of the given node is not - * possible, the following operations are performed: a new node is created, any - * registered event listener is registered on the new node, any user data - * attached to the old node is removed from that node, the old node is removed - * from its parent if it has one, the children are moved to the new node, if the - * renamed node is an Element its attributes are moved to the new node, the new - * node is inserted at the position the old node used to have in its parent's - * child nodes list if it has one, the user data that was attached to the old - * node is attached to the new node. When the node being renamed is an Element - * only the specified attributes are moved, default attributes originated from - * the DTD are updated according to the new element name. In addition, the - * implementation may update default attributes from other schemas. Applications - * should use Document.normalizeDocument() to guarantee these attributes are - * up-to-date. When the node being renamed is an Attr that is attached to an - * Element, the node is first removed from the Element attributes map. Then, once - * renamed, either by modifying the existing node or creating a new one as - * described above, it is put back. - * - * In addition, - * a user data event NODE_RENAMED is fired, - * when the implementation supports the feature "MutationNameEvents", - * each mutation operation involved in this method fires the appropriate - * event, and in the end the event {http://www.w3.org/2001/xml-events, - * DOMElementNameChanged} or {http://www.w3.org/2001/xml-events, - * DOMAttributeNameChanged} is fired. - * - */ - virtual NodePtr renameNode(const NodePtr n, - const DOMString &namespaceURI, - const DOMString &qualifiedName) - throw (DOMException) = 0; - - - //################## - //# Non-API methods - //################## - - /** - * - */ - virtual ~Document() {} - -}; - - - - - - - - -} //namespace dom -} //namespace w3c -} //namespace org - - -#endif // SEEN_DOM_H - - -/*######################################################################### -## E N D O F F I L E -#########################################################################*/ - - - - diff --git a/src/dom/domimpl.cpp b/src/dom/domimpl.cpp deleted file mode 100644 index 3d9a29592..000000000 --- a/src/dom/domimpl.cpp +++ /dev/null @@ -1,3071 +0,0 @@ -/* - * Phoebe DOM Implementation. - * - * This is a C++ approximation of the W3C DOM model, which follows - * fairly closely the specifications in the various .idl files, copies of - * which are provided for reference. Most important is this one: - * - * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * - * Authors: - * Bob Jamison - * - * Copyright (C) 2005-2008 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -#include -#include "domimpl.h" - -namespace org -{ -namespace w3c -{ -namespace dom -{ - - -/** - * Test if the given substring exists for the length of the string - * in a given buffer - */ -/* -static bool match(const DOMString &buf, char *str) -{ - int pos = 0; - while (*str) - { - if (buf[pos++] != *str++) - return false; - } - return true; -} -*/ - - - -/*######################################################################### -## DOMImplementationSourceImpl -#########################################################################*/ - - -/** - * - */ -DOMImplementationSourceImpl::DOMImplementationSourceImpl() -{ - domImpl = new DOMImplementationImpl(); -} - -/** - * - */ -DOMImplementationSourceImpl::~DOMImplementationSourceImpl() -{ - delete domImpl; -} - -/** - * - */ -DOMImplementation *DOMImplementationSourceImpl::getDOMImplementation( - const DOMString &/*features*/) -{ - return domImpl; -} - -/** - * - */ -DOMImplementationList DOMImplementationSourceImpl::getDOMImplementationList( - const DOMString &/*features*/) -{ - return domImplList; -} - - - - - - - -/*######################################################################### -## DOMImplementationImpl -#########################################################################*/ - - -/** - * - */ -DOMImplementationImpl::DOMImplementationImpl() -{ -} - -/** - * - */ -DOMImplementationImpl::~DOMImplementationImpl() -{ -} - -/** - * - */ -bool DOMImplementationImpl::hasFeature(const DOMString& /*feature*/, - const DOMString& /*version*/) -{ - return false; -} - - -/** - * - */ -DocumentTypePtr DOMImplementationImpl::createDocumentType(const DOMString& qualifiedName, - const DOMString& publicId, - const DOMString& systemId) - throw(DOMException) -{ - DocumentTypePtr typeImpl = new DocumentTypeImpl(qualifiedName, - publicId, systemId); - return typeImpl; -} - -/** - * - */ -DocumentPtr DOMImplementationImpl::createDocument( - const DOMString& namespaceURI, - const DOMString& qualifiedName, - DocumentTypePtr doctype) - throw(DOMException) -{ - DocumentPtr doc = new DocumentImpl(this, - namespaceURI, - qualifiedName, - doctype); - return doc; -} - -/** - * - */ -DOMObject *DOMImplementationImpl::getFeature(const DOMString& /*feature*/, - const DOMString& /*version*/) - -{ - return NULL; -} - - - - - -/*######################################################################### -## NodeImpl -#########################################################################*/ - -/** - * Utility for finding the first Element above - * a given node. Used by several methods below - */ -static NodePtr getAncestorElement(NodePtr node) -{ - if (!node.get()) - return NULL; - node = node->getParentNode(); - //Either quit because I am an element, or because I am null - while (node.get()) - { - if (node->getNodeType() == Node::ELEMENT_NODE) - return node; - node = node->getParentNode(); - } - return node; -} - -/** - * - */ -DOMString NodeImpl::getNodeName() -{ - return nodeName; -} - -/** - * - */ -DOMString NodeImpl::getNodeValue() throw (DOMException) -{ - return nodeValue; -} - -/** - * - */ -void NodeImpl::setNodeValue(const DOMString& val) throw (DOMException) -{ - nodeValue = val; -} - -/** - * - */ -unsigned short NodeImpl::getNodeType() -{ - return nodeType; -} - -/** - * - */ -NodePtr NodeImpl::getParentNode() -{ - return parent; -} - -/** - * - */ -NodeList NodeImpl::getChildNodes() -{ - NodeList list; - for (NodeImplPtr node = firstChild ; node.get() ; node=node->next) - list.add(node); - return list; -} - -/** - * - */ -NodePtr NodeImpl::getFirstChild() -{ - return firstChild; -} - -/** - * - */ -NodePtr NodeImpl::getLastChild() -{ - return lastChild; -} - -/** - * - */ -NodePtr NodeImpl::getPreviousSibling() -{ - return prev; -} - -/** - * - */ -NodePtr NodeImpl::getNextSibling() -{ - return next; -} - -/** - * - */ -NamedNodeMap &NodeImpl::getAttributes() -{ - NamedNodeMap &attrs = attributes; - return attrs; -} - - -/** - * - */ -DocumentPtr NodeImpl::getOwnerDocument() -{ - return ownerDocument; -} - -/** - * - */ -NodePtr NodeImpl::insertBefore(const NodePtr newChild, - const NodePtr refChild) - throw(DOMException) -{ - if (!newChild) - return NULL; - - //if no ref, then just append - if (!refChild) - return appendChild(newChild); - - NodeImplPtr newChildImpl = reinterpret_cast(newChild.get()); - for (NodeImplPtr n = firstChild ; n.get() ; n=n->next) - { - if (n == refChild) - { - //link to new - if (n->prev.get()) - n->prev->next = newChildImpl; - else - firstChild = newChildImpl; - n->prev = newChildImpl; - //link from new - newChildImpl->next = n; - newChildImpl->prev = n->prev; - //reflect new location - newChildImpl->parent = this; - newChildImpl->ownerDocument = ownerDocument; - return n; - } - } - return NULL; -} - -/** - * - */ -NodePtr NodeImpl::replaceChild(const NodePtr newChild, - const NodePtr oldChild) - throw(DOMException) -{ - if (!oldChild) - return NULL; - - NodeImplPtr newChildImpl = reinterpret_cast(newChild.get()); - for (NodeImplPtr n = firstChild ; n.get() ; n=n->next) - { - if (n == oldChild) - { - //link to new - if (n->prev.get()) - n->prev->next = newChildImpl; - else - firstChild = newChildImpl; - if (n->next.get()) - n->next->prev = newChildImpl; - else - lastChild = newChildImpl; - //link from new - newChildImpl->next = n->next; - newChildImpl->prev = n->prev; - //reflect new location - newChildImpl->parent = this; - newChildImpl->ownerDocument = ownerDocument; - return n; - } - } - return NULL; -} - -/** - * - */ -NodePtr NodeImpl::removeChild(const NodePtr oldChild) - throw(DOMException) -{ - if (!oldChild) - return NULL; - - for (NodeImplPtr n = firstChild ; n.get() ; n=n->next) - { - if (n == oldChild) - { - if (n->prev.get()) - n->prev->next = n->next; - if (n->next.get()) - n->next->prev = n->prev; - return n; - } - } - return NULL; -} - -/** - * - */ -NodePtr NodeImpl::appendChild(const NodePtr newChild) - throw(DOMException) -{ - if (!newChild) - return NULL; - - NodeImplPtr newChildImpl = - reinterpret_cast (newChild.get()); - - newChildImpl->parent = this; - newChildImpl->ownerDocument = ownerDocument; - - if (!firstChild || !lastChild) - { - //Set up our first member - firstChild = newChildImpl; - lastChild = newChildImpl; - } - else - { - //link at the last position - lastChild->next = newChildImpl; - newChildImpl->prev = lastChild; - lastChild = newChildImpl; - } - - return newChild; -} - -/** - * - */ -bool NodeImpl::hasChildNodes() -{ - return (firstChild != (NodeImpl *)0); -} - -/** - * - */ -NodePtr NodeImpl::cloneNode(bool deep) -{ - NodeImplPtr node = new NodeImpl(ownerDocument, nodeName); - node->parent = parent; - node->prev = prev; - node->next = next; - node->userData = userData; - node->nodeValue = nodeValue; - - if (deep) - { - node->firstChild = node->lastChild = NULL; - for (NodeImplPtr child = firstChild ; child.get() ; child=child->next) - { - node->appendChild(child->cloneNode(deep)); - } - } - else - { - node->firstChild = firstChild; - node->lastChild = lastChild; - } - - return node; -} - -/** - * Concatenate adjoining text subnodes, remove null-length nodes - */ -void NodeImpl::normalize() -{ - //First, concatenate adjoining text nodes - NodeImplPtr next = (NodeImpl *)0; - for (NodeImplPtr child = firstChild ; child.get() ; child=next) - { - if (child->getNodeType() != Node::TEXT_NODE) - continue; - next = NULL; - DOMString sval = child->getNodeValue(); - for (NodeImplPtr sibling = child->next ; sibling.get() ; sibling=next) - { - next = sibling->next; - if (sibling->getNodeType() != Node::TEXT_NODE) - break; - sval.append(sibling->getNodeValue()); - //unlink and delete - child->next = sibling->next; - if (sibling->next.get()) - sibling->next->prev = child; - //delete sibling; - } - child->setNodeValue(sval); - } - - //Next, we remove zero-length text subnodes - next = NULL; - for (NodeImplPtr child = firstChild ; child.get() ; child=next) - { - next = child->next; - if (child->getNodeType() != Node::TEXT_NODE) - continue; - if (child->getNodeValue().size() == 0) - { - //unlink and delete - if (child->prev.get()) - child->prev->next = child->next; - if (child->next.get()) - child->next->prev = child->prev; - //delete child; - } - } - -} - -/** - * - */ -bool NodeImpl::isSupported(const DOMString& /*feature*/, - const DOMString& /*version*/) -{ - //again, no idea - return false; -} - -/** - * - */ -DOMString NodeImpl::getNamespaceURI() -{ - return namespaceURI; -} - -/** - * - */ -DOMString NodeImpl::getPrefix() -{ - return prefix; -} - -/** - * - */ -void NodeImpl::setPrefix(const DOMString& val) throw(DOMException) -{ - prefix = val; - if (prefix.size()>0) - nodeName = prefix + ":" + localName; - else - nodeName = localName; -} - -/** - * - */ -DOMString NodeImpl::getLocalName() -{ - return localName; -} - -/** - * - */ -bool NodeImpl::hasAttributes() -{ - return (attributes.getLength() > 0); -} - -/** - * - */ -DOMString NodeImpl::getBaseURI() -{ - return baseURI; -} - -/** - * - */ -unsigned short NodeImpl::compareDocumentPosition(const NodePtr otherArg) -{ - if (!otherArg || otherArg == (NodePtr )this) - return 0;//no flags - - NodePtr node; - NodePtr other = otherArg; - - //Look above me - for (node=getParentNode() ; node.get() ; node=node->getParentNode()) - if (node == other) - return DOCUMENT_POSITION_CONTAINED_BY; - - //Look above the other guy. See me? - for (node=other->getParentNode() ; node.get() ; node=node->getParentNode()) - if (node == (NodePtr )this) - return DOCUMENT_POSITION_CONTAINS; - - - return DOCUMENT_POSITION_DISCONNECTED | - DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC; -} - -/** - * - */ -DOMString NodeImpl::getTextContent() throw(DOMException) -{ - DOMString buf; - if (nodeType == TEXT_NODE || - nodeType == CDATA_SECTION_NODE || - nodeType == COMMENT_NODE || - nodeType == PROCESSING_INSTRUCTION_NODE) - buf = getNodeValue(); - else if (nodeType == ELEMENT_NODE || - nodeType == ATTRIBUTE_NODE || - nodeType == ENTITY_NODE || - nodeType == ENTITY_REFERENCE_NODE || - nodeType == DOCUMENT_FRAGMENT_NODE) - { - for (NodePtr n = getFirstChild() ; n.get() ; - n=n->getNextSibling() ) - { - if (n->getNodeType() != COMMENT_NODE && - n->getNodeType() != COMMENT_NODE) - buf.append(n->getTextContent()); - } - } - return buf; -} - - -/** - * - */ -void NodeImpl::setTextContent(const DOMString &val) throw(DOMException) -{ - //Delete children - /** Not necessary. Just let smart pointers to their work - for (NodePtr n = getFirstChild() ; n.get() ; - n=n->getNextSibling() ) - delete n; - */ - firstChild = lastChild = NULL; - - //Replace with a single text node - NodeImplPtr tnode = new NodeImpl(ownerDocument); - tnode->nodeType = Node::TEXT_NODE; - tnode->setNodeValue(val); - appendChild(tnode); -} - - -/** - * From DOM3 Namespace algorithms - */ -DOMString NodeImpl::lookupPrefix(const DOMString &theNamespaceURI) -{ - - if (theNamespaceURI.size()==0) - { - return DOMString(""); - } - - switch (nodeType) - { - case Node::ELEMENT_NODE: - { - ElementPtr elem = reinterpret_cast(this); - return lookupNamespacePrefix(theNamespaceURI, elem); - } - case Node::DOCUMENT_NODE: - { - DocumentPtr doc = reinterpret_cast(this); - ElementPtr elem = doc->getDocumentElement(); - return elem->lookupPrefix(theNamespaceURI); - } - case Node::ENTITY_NODE : - case Node::NOTATION_NODE: - case Node::DOCUMENT_FRAGMENT_NODE: - case Node::DOCUMENT_TYPE_NODE: - return DOMString(""); // type is unknown - case Node::ATTRIBUTE_NODE: - { - AttrPtr attr = reinterpret_cast(this); - ElementPtr elem = attr->getOwnerElement(); - if ( elem.get() ) - { - return elem->lookupPrefix(theNamespaceURI); - } - return DOMString(""); - } - default: - { - //Get ancestor element, if any - NodePtr ancestor = getAncestorElement(this); - if ( ancestor.get() ) - { - return ancestor->lookupPrefix(theNamespaceURI); - } - return DOMString(""); - } - }//switch - return DOMString(""); -} - - -/** - * - */ -bool NodeImpl::isDefaultNamespace(const DOMString &theNamespaceURI) -{ - switch (nodeType) - { - case ELEMENT_NODE: - { - if ( namespaceURI.size()>0 && prefix.size()==0 ) - { - return (namespaceURI == theNamespaceURI); - } - NodePtr attr = attributes.getNamedItem("xmlns"); - if ( attr.get() ) - { - return (attr->getNodeValue() == theNamespaceURI); - } - - NodePtr ancestor = getAncestorElement(this); - if ( ancestor.get() ) - { - return ancestor->isDefaultNamespace(theNamespaceURI); - } - else - { - return false; - } - } - case DOCUMENT_NODE: - { //just use braces for local declaration - DocumentPtr doc = reinterpret_cast(this); - ElementPtr elem = doc->getDocumentElement(); - return elem->isDefaultNamespace(theNamespaceURI); - } - case ENTITY_NODE: - case NOTATION_NODE: - case DOCUMENT_TYPE_NODE: - case DOCUMENT_FRAGMENT_NODE: - return false; - case ATTRIBUTE_NODE: - {//braces only for scope - AttrPtr attr = reinterpret_cast(this); - ElementPtr ownerElement = attr->getOwnerElement(); - if ( ownerElement.get() ) - { - return ownerElement->isDefaultNamespace(theNamespaceURI); - } - else - { - return false; - } - } - default: - { - NodePtr ancestor = getAncestorElement(this); - if ( ancestor.get() ) - { - return ancestor->isDefaultNamespace(theNamespaceURI); - } - else - { - return false; - } - } - }//switch - - return false; -} - - -/** - * - */ -DOMString NodeImpl::lookupNamespaceURI(const DOMString &thePrefix) -{ - switch (nodeType) - { - case ELEMENT_NODE: - { - if ( namespaceURI.size()>0 && prefix == thePrefix ) - { - DOMString nsURI = namespaceURI; - return (nsURI); - } - if ( hasAttributes() ) - { - NamedNodeMap attributes = getAttributes(); - int nrAttrs = attributes.getLength(); - for (int i=0 ; igetPrefix() == "xmlns" && attr->getLocalName() == thePrefix ) - { // non default namespace - if (attr->getNodeValue().size()>0) - { - return (attr->getNodeValue()); - } - return DOMString(""); - } - else if (attr->getLocalName() == "xmlns" && thePrefix.size()==0) - { // default namespace - if (attr->getNodeValue().size()>0) - { - return (attr->getNodeValue()); - } - return DOMString(""); - } - } - } - - NodePtr ancestor = getAncestorElement(this); - if ( ancestor.get() ) - { - return ancestor->lookupNamespaceURI(thePrefix); - } - return DOMString(""); - } - case DOCUMENT_NODE: - { - DocumentPtr doc = reinterpret_cast(this); - ElementPtr elem = doc->getDocumentElement(); - return elem->lookupNamespaceURI(thePrefix); - } - case ENTITY_NODE: - case NOTATION_NODE: - case DOCUMENT_TYPE_NODE: - case DOCUMENT_FRAGMENT_NODE: - return DOMString(""); - - case ATTRIBUTE_NODE: - { - ElementPtr ownerElement = (reinterpret_cast(this))->getOwnerElement(); - if ( ownerElement.get() ) - { - return ownerElement->lookupNamespaceURI(thePrefix); - } - else - { - return DOMString(""); - } - } - default: - { - NodePtr ancestor = getAncestorElement(this); - if ( ancestor.get() ) - { - return ancestor->lookupNamespaceURI(thePrefix); - } - else - { - return DOMString(""); - } - } - }//switch -} - - -/** - * - */ -bool NodeImpl::isEqualNode(const NodePtr nodeArg) -{ - if (!nodeArg) - return false; - - if (nodeArg == static_cast(this)) - return true; - - NodePtr node = nodeArg; - - if (getNodeType() != node->getNodeType() || - getNodeName() != node->getNodeName() || - getLocalName() != node->getLocalName() || - getNamespaceURI() != node->getNamespaceURI() || - getPrefix() != node->getPrefix() || - getNodeValue() != node->getNodeValue() || - getBaseURI() != node->getBaseURI() ) - return false; - - return true; -} - - - -/** - * - */ -DOMObject *NodeImpl::getFeature(const DOMString &/*feature*/, - const DOMString &/*version*/) -{ - //dont know - return NULL; -} - -/** - * - */ -DOMUserData *NodeImpl::setUserData(const DOMString &key, - const DOMUserData *data, - const UserDataHandler *handler) -{ - UserDataEntry *entry = userDataEntries; - UserDataEntry *prev = NULL; - while (entry) - { - if (entry->key == key) - { - DOMUserData *oldData = entry->data; - entry->data = const_cast(data); - entry->handler = const_cast(handler); - return oldData; - } - prev = entry; - entry = entry->next; - } - - //Make a new one - UserDataEntry *newEntry = new UserDataEntry(key, data, handler); - if (!prev) - userDataEntries = newEntry; - else - prev->next = newEntry; - - return NULL; -} - -/** - * - */ -DOMUserData *NodeImpl::getUserData(const DOMString &key) -{ - UserDataEntry *entry = userDataEntries; - while (entry) - { - if (entry->key == key) - return entry->data; - entry = entry->next; - } - return NULL; -} - - - -//################## -//# Non-API methods -//################## - -/** - * - */ -void NodeImpl::setNodeName(const DOMString &qualifiedName) -{ - nodeName = qualifiedName; - prefix = ""; - localName = ""; - for (unsigned int i=0 ; i0 && namespaceURI==theNamespaceURI && - prefix.size()>0 && - originalElement->lookupNamespaceURI(prefix) == theNamespaceURI) - { - return (prefix); - } - - if ( hasAttributes() ) - { - NamedNodeMap attributes = getAttributes(); - int nrAttrs = attributes.getLength(); - for (int i=0 ; igetLocalName(); - if (attr->getPrefix() == "xmlns" && - attr->getNodeValue() == theNamespaceURI && - originalElement->lookupNamespaceURI(attrLocalName) - == theNamespaceURI) - { - return (attrLocalName); - } - } - } - - //Get ancestor element, if any - NodeImplPtr ancestor = parent; - while (ancestor.get() && ancestor->getNodeType()!= Node::ELEMENT_NODE) - ancestor = ancestor->parent; - - if ( ancestor.get() ) - { - return ancestor->lookupNamespacePrefix(theNamespaceURI, originalElement); - } - - return DOMString(""); -} - - -/** - * - */ -NodeImpl::NodeImpl() : Node() -{ - init(); -} - - -/** - * - */ -NodeImpl::NodeImpl(const NodeImpl &other) : Node() -{ - init(); - assign(other); -} - -/** - * - */ -NodeImpl &NodeImpl::operator=(const NodeImpl &other) -{ - init(); - assign(other); - return *this; -} - - -/** - * - */ -NodeImpl::NodeImpl(DocumentImplPtr owner) : Node() -{ - init(); - ownerDocument = owner; -} - -/** - * - */ -NodeImpl::NodeImpl(DocumentImplPtr owner, const DOMString &nodeName) - : Node() -{ - init(); - ownerDocument = owner; - setNodeName(nodeName); -} - -/** - * - */ -NodeImpl::NodeImpl(DocumentImplPtr owner, const DOMString &/*theNamespaceURI*/, - const DOMString &qualifiedName) : Node() -{ - init(); - ownerDocument = owner; - //if (owner) - // namespaceURI = owner->stringCache(theNamespaceURI); - setNodeName(qualifiedName); -} - - - -/** - * - */ -void NodeImpl::init() -{ - nodeType = 0; //none yet - nodeValue = ""; - setNodeName(""); - namespaceURI = ""; - parent = NULL; - prev = NULL; - next = NULL; - userData = NULL; - firstChild = NULL; - lastChild = NULL; - ownerDocument = NULL; - userDataEntries = NULL; -} - -/** - * - */ -void NodeImpl::assign(const NodeImpl &other) -{ - ownerDocument = other.ownerDocument; - prefix = other.prefix; - localName = other.localName; - nodeName = other.nodeName; - nodeValue = other.nodeValue; - namespaceURI = other.namespaceURI; - attributes = other.attributes; -} - - -/** - * - */ -NodeImpl::~NodeImpl() -{ - if (userDataEntries) - delete userDataEntries; - //Delete children - /** Use smart pointers. do not delete explicitly - for (NodePtr n = getFirstChild() ; n.get() ; - n=n->getNextSibling() ) - delete n; - */ - firstChild = lastChild = (NodeImpl *)0; -} - - - -/*######################################################################### -## CharacterDataImpl -#########################################################################*/ - - -/** - * - */ -CharacterDataImpl::CharacterDataImpl() : NodeImpl() -{ -} - -/** - * - */ -CharacterDataImpl::CharacterDataImpl(DocumentImplPtr owner, - const DOMString &theValue) : NodeImpl() -{ - ownerDocument = owner; - nodeValue = theValue; -} - -/** - * - */ -CharacterDataImpl::~CharacterDataImpl() -{ -} - -/** - * - */ -DOMString CharacterDataImpl::getData() throw(DOMException) -{ - return nodeValue; -} - -/** - * - */ -void CharacterDataImpl::setData(const DOMString& val) throw(DOMException) -{ - nodeValue = val; -} - -/** - * - */ -unsigned long CharacterDataImpl::getLength() -{ - return nodeValue.size(); -} - -/** - * - */ -DOMString CharacterDataImpl::substringData(unsigned long offset, - unsigned long count) - throw(DOMException) -{ - return nodeValue.substr(offset, count); -} - -/** - * - */ -void CharacterDataImpl::appendData(const DOMString& arg) throw(DOMException) -{ - nodeValue += arg; -} - -/** - * - */ -void CharacterDataImpl::insertData(unsigned long offset, - const DOMString& arg) - throw(DOMException) -{ - nodeValue.insert(offset, arg); -} - -/** - * - */ -void CharacterDataImpl::deleteData(unsigned long offset, - unsigned long count) - throw(DOMException) -{ - nodeValue.erase(offset, count); -} - -/** - * - */ -void CharacterDataImpl::replaceData(unsigned long offset, - unsigned long count, - const DOMString& arg) - throw(DOMException) -{ - nodeValue.replace(offset, count, arg); -} - - - - - - -/*######################################################################### -## AttrImpl -#########################################################################*/ - -/** - * - */ -DOMString AttrImpl::getName() -{ - return nodeName; -} - -/** - * - */ -bool AttrImpl::getSpecified() -{ - return (nodeValue.size() > 0); -} - -/** - * - */ -DOMString AttrImpl::getValue() -{ - return nodeValue; -} - -/** - * - */ -void AttrImpl::setValue(const DOMString& val) throw(DOMException) -{ - nodeValue = val; -} - -/** - * - */ -ElementPtr AttrImpl::getOwnerElement() -{ - return ownerElement; -} - - -/** - * - */ -TypeInfo &AttrImpl::getSchemaTypeInfo() -{ - return typeInfo; -} - - -/** - * - */ -bool AttrImpl::getIsId() -{ - return (nodeName == "id"); -} - - - -//################## -//# Non-API methods -//################## - - -void AttrImpl::setOwnerElement(const ElementPtr elem) -{ - ownerElement = elem; -} - -/** - * - */ -AttrImpl::AttrImpl(DocumentImplPtr owner, const DOMString &theName) - : NodeImpl() -{ - nodeType = ATTRIBUTE_NODE; - ownerDocument = owner; - setNodeName(theName); -} - -/** - * - */ -AttrImpl::AttrImpl(DocumentImplPtr owner, - const DOMString &/*theNamespaceURI*/, - const DOMString &theQualifiedName) - : NodeImpl() -{ - nodeType = ATTRIBUTE_NODE; - ownerDocument = owner; - //if (owner) - // namespaceURI = owner->stringCache(theNamespaceURI); - setNodeName(theQualifiedName); -} - -/** - * - */ -AttrImpl::~AttrImpl() -{ -} - - - - - -/*######################################################################### -## ElementImpl -#########################################################################*/ - - -/** - * - */ -DOMString ElementImpl::getTagName() -{ - if (prefix.size() > 0) - return prefix + ":" + nodeName; - else - return nodeName; -} - -/** - * - */ -DOMString ElementImpl::getAttribute(const DOMString& name) -{ - NodePtr node = attributes.getNamedItem(name); - if (!node || node->getNodeType() != ATTRIBUTE_NODE) - return DOMString(""); - AttrPtr attr = reinterpret_cast(node.get()); - return attr->getValue(); -} - -/** - * - */ -void ElementImpl::setAttribute(const DOMString& name, - const DOMString& value) - throw(DOMException) -{ - AttrImplPtr attr = new AttrImpl(ownerDocument, name); - attr->setValue(value); - attr->setOwnerElement(this); - attributes.setNamedItem(attr); -} - -/** - * - */ -void ElementImpl::removeAttribute(const DOMString& name) - throw(DOMException) -{ - attributes.removeNamedItem(name); -} - -/** - * - */ -AttrPtr ElementImpl::getAttributeNode(const DOMString& name) -{ - NodePtr node = attributes.getNamedItem(name); - if (!node || node->getNodeType() != ATTRIBUTE_NODE) - return NULL; - AttrPtr attr = reinterpret_cast(node.get()); - return attr; -} - -/** - * - */ -AttrPtr ElementImpl::setAttributeNode(AttrPtr attr) - throw(DOMException) -{ - attributes.setNamedItem(attr); - return attr; -} - -/** - * - */ -AttrPtr ElementImpl::removeAttributeNode(AttrPtr attr) - throw(DOMException) -{ - attributes.removeNamedItem(attr->getName()); - return attr; -} - - -/** - * - */ -void ElementImpl::getElementsByTagNameRecursive(NodeList &list, - const DOMString& name, ElementPtr elem) -{ - if (!elem) - return; - - if (name == elem->getTagName()) - list.add(elem); - for (NodePtr node = elem->getFirstChild() ; node.get() ; - node=node->getNextSibling()) - { - if (node->getNodeType() != Node::ELEMENT_NODE) - continue; - ElementPtr childElem = reinterpret_cast(node.get()); - getElementsByTagNameRecursive(list, name, childElem); - } -} - - -/** - * - */ -NodeList ElementImpl::getElementsByTagName(const DOMString& tagName) -{ - NodeList list; - getElementsByTagNameRecursive(list, tagName, this); - return list; -} - -/** - * - */ -DOMString ElementImpl::getAttributeNS(const DOMString& namespaceURI, - const DOMString& localName) -{ - NodePtr node = attributes.getNamedItemNS(namespaceURI, localName); - if (!node || node->getNodeType()!=ATTRIBUTE_NODE) - return DOMString(""); - AttrPtr attr = reinterpret_cast(node.get()); - return attr->getValue(); -} - -/** - * - */ -void ElementImpl::setAttributeNS(const DOMString& namespaceURI, - const DOMString& qualifiedName, - const DOMString& value) - throw(DOMException) -{ - AttrImplPtr attr = new AttrImpl(ownerDocument, namespaceURI, qualifiedName); - attr->setValue(value); - attr->setOwnerElement(this); - attributes.setNamedItemNS(attr); -} - -/** - * - */ -void ElementImpl::removeAttributeNS(const DOMString& namespaceURI, - const DOMString& localName) - throw(DOMException) -{ - attributes.removeNamedItemNS(namespaceURI, localName); -} - -/** - * - */ - AttrPtr ElementImpl::getAttributeNodeNS(const DOMString& namespaceURI, - const DOMString& localName) -{ - NodePtr node = attributes.getNamedItemNS(namespaceURI, localName); - if (!node || node->getNodeType() != ATTRIBUTE_NODE) - return (Attr *)0; - AttrPtr attr = reinterpret_cast(node.get()); - return attr; -} - -/** - * - */ -AttrPtr ElementImpl::setAttributeNodeNS(AttrPtr attr) - throw(DOMException) -{ - attributes.setNamedItemNS(attr); - return attr; -} - - -/** - * - */ -void ElementImpl::getElementsByTagNameNSRecursive(NodeList &list, - const DOMString& namespaceURI, - const DOMString& tagName, ElementPtr elem) -{ - if (!elem) - return; - - if (namespaceURI == elem->getNamespaceURI() && tagName == elem->getTagName()) - list.add(elem); - for (NodePtr node = elem->getFirstChild() ; node.get() ; node=node->getNextSibling()) - { - if (node->getNodeType() != Node::ELEMENT_NODE) - continue; - ElementPtr childElem = reinterpret_cast(node.get()); - getElementsByTagNameNSRecursive(list, namespaceURI, tagName, childElem); - } -} - -/** - * - */ -NodeList ElementImpl::getElementsByTagNameNS(const DOMString& namespaceURI, - const DOMString& localName) -{ - NodeList list; - getElementsByTagNameNSRecursive(list, namespaceURI, localName, this); - return list; -} - -/** - * - */ -bool ElementImpl::hasAttribute(const DOMString& attrName) -{ - NodePtr node = attributes.getNamedItem(attrName); - if (!node || node->getNodeType() != ATTRIBUTE_NODE) - return false; - return true; -} - -/** - * - */ -bool ElementImpl::hasAttributeNS(const DOMString& namespaceURI, - const DOMString& localName) -{ - NodePtr node = attributes.getNamedItemNS(namespaceURI, localName); - if (!node || node->getNodeType() != ATTRIBUTE_NODE) - return false; - return true; -} - -/** - * - */ -TypeInfo &ElementImpl::getSchemaTypeInfo() -{ - return typeInfo; -} - - -/** - * - */ -void ElementImpl::setIdAttribute(const DOMString &/*name*/, - bool /*isId*/) throw (DOMException) -{ - //fixme -} - -/** - * - */ -void ElementImpl::setIdAttributeNS(const DOMString &/*namespaceURI*/, - const DOMString &/*localName*/, - bool /*isId*/) throw (DOMException) -{ - //fixme -} - -/** - * - */ -void ElementImpl::setIdAttributeNode(const AttrPtr /*idAttr*/, - bool /*isId*/) throw (DOMException) -{ - //fixme -} - - -//################## -//# Non-API methods -//################## - - -/** - * - */ -ElementImpl::ElementImpl() : NodeImpl() -{ - nodeType = ELEMENT_NODE; -} - -/** - * - */ -ElementImpl::ElementImpl(DocumentImplPtr owner, const DOMString &tagName) - : NodeImpl() -{ - nodeType = ELEMENT_NODE; - ownerDocument = owner; - setNodeName(tagName); -} - -/** - * - */ -ElementImpl::ElementImpl(DocumentImplPtr owner, - const DOMString &/*theNamespaceURI*/, - const DOMString &qualifiedName) : - NodeImpl() -{ - nodeType = ELEMENT_NODE; - ownerDocument = owner; - setNodeName(qualifiedName); -} - -/** - * - */ -ElementImpl::~ElementImpl() -{ -} - - -/** - * - */ -void ElementImpl::normalizeNamespaces() -{ - //printf("### NORMALIZE\n"); - - NamedNodeMap attrs = getAttributes(); - - //####################################### - //# Pick up local namespace declarations - //####################################### - bindingsClear(); //Reset bindings on this node - - int nrAttrs = attrs.getLength(); - for (int i=0; igetNodeType() != Node::ATTRIBUTE_NODE) - continue; - AttrImplPtr attr = reinterpret_cast(attrNode.get()); - DOMString attrName = attr->getLocalName(); - DOMString attrPrefix = attr->getPrefix(); - DOMString attrValue = attr->getNodeValue(); - if (attrName != "xmlns" && attrPrefix != "xmlns") - continue; - - //is the namespace declaration is invalid? - if (attrValue == XMLNSNAME || attrName == attrPrefix) - { - // Note: The prefix xmlns is used only to declare namespace bindings and - // is by definition bound to the namespace name http://www.w3.org/2000/xmlns/. - // It must not be declared. No other prefix may be bound to this namespace name. - - //==> Report an error. - printf("normalizeNamespaces() error: Namespace %s cannot be reassigned\n", - XMLNSNAME); - - } - else - { - //==> Record the namespace declaration - attr->setNamespaceURI(XMLNSNAME); - if (attrPrefix.size() > 0) - bindingsAdd(attrPrefix, attrValue); - else - bindingsAdd("*", attrValue);//default - - } - } - - - //####################################### - //# Fixup element's namespace - //####################################### - if ( namespaceURI.size() > 0 ) - { - DOMString key = prefix; - if (key.size() == 0) - key = "*"; - DOMString binding = bindingsFind(key); - //Element's prefix/namespace pair (or default namespace, if no prefix) - // are within the scope of a binding - if ( binding == namespaceURI ) - { - //==> do nothing, declaration in scope is inherited - - // See section "B.1.1: Scope of a binding" for an example - - } - else - { - - /* - ==> Create a local namespace declaration attr for this namespace, - with Element's current prefix (or a default namespace, if - no prefix). If there's a conflicting local declaration - already present, change its value to use this namespace. - - See section "B.1.2: Conflicting namespace declaration" for an example - */ - DOMString attrName = "xmlns"; - if (prefix.size() > 0) - { - attrName.append(":"); - attrName.append(prefix); - } - setAttribute(attrName, namespaceURI); - // NOTE that this may break other nodes within this Element's - // subtree, if they're already using this prefix. - // They will be repaired when we reach them. - } - } - else // Element has no namespace URI: - { - //############################################### - //# Bob -- alter this from the specs a bit. - //# Since the XmlReader does not set namespaces, - //# do it here - //############################################### - DOMString localName = getLocalName(); - if ( localName.size()==0 ) - { - // DOM Level 1 node - /* - ==> if in process of validation against a namespace aware schema - (i.e XML Schema) report a fatal error: the processor can not recover - in this situation. - Otherwise, report an error: no namespace fixup will be performed on this node. - */ - printf("normalizeNamespaces() error: no localName\n"); - } - else - { - // Element has no pseudo-prefix - //there's a conflicting local default namespace declaration already present - if ( prefix.size()==0 ) - { - //==> change its value to use this empty namespace. - namespaceURI = bindingsFind("*"); - //setAttribute("xmlns", ""); - } - else //#BOB . I added this. - { - namespaceURI = bindingsFind(prefix); - } - // NOTE that this may break other nodes within this Element's - // subtree, if they're already using the default namespaces. - // They will be repaired when we reach them. - } - } - - - //####################################### - //# Examine and polish the attributes - //####################################### - nrAttrs = attrs.getLength(); - for (int i=0; igetNodeType() != Node::ATTRIBUTE_NODE) - continue; - AttrPtr attr = reinterpret_cast(attrNode.get()); - DOMString attrNS = attr->getNamespaceURI(); - DOMString attrPrefix = attr->getPrefix(); - if (attrNS == XMLNSNAME) - continue; - - if ( attrNS.size()>0 ) //Attr[i] has a namespace URI - { - DOMString attrBinding = bindingsFind(attrPrefix); - /* - if attribute has no prefix (default namespace decl does not apply to attributes) - OR - attribute prefix is not declared - OR - conflict: attribute has a prefix that conflicts with a binding - already active in scope - */ - if ( attrPrefix.size() == 0 || attrBinding.size() == 0) - { - //namespaceURI matches an in scope declaration of one or more prefixes) - DOMString prefixForNS = lookupNamespacePrefix(attrNS, this); - if ( prefixForNS.size() > 0 ) - { - // pick the most local binding available; - // if there is more than one pick one arbitrarily - - //==> change attribute's prefix. - attr->setPrefix(prefixForNS); - } - else - { - // the current prefix is not null and it has no in scope declaration) - if ( attrPrefix.size() > 0 || attrBinding.size() == 0 ) - { - //==> declare this prefix - DOMString newAttrName = "xmlns:"; - newAttrName.append(attrPrefix); - setAttribute(newAttrName, attrNS); - bindingsAdd(attrPrefix, attrNS); - } - else - { - // find a prefix following the pattern "NS" +index (starting at 1) - // make sure this prefix is not declared in the current scope. - // create a local namespace declaration attribute - - //==> declare this prefix - char buf[16]; - sprintf(buf, "%d" , ownerDocument->namespaceIndex++); - DOMString newPrefix = "NS"; - newPrefix.append(buf); - DOMString newAttrName = "xmlns:"; - newAttrName.append(newPrefix); - setAttribute(newAttrName, attrNS); - bindingsAdd(newPrefix, attrNS); - //==> change attribute's prefix. - } - } - } - } - else // Attr has no namespace URI - { - // Attr has no localName - if ( attr->getLocalName().size() == 0 ) - { - // DOM Level 1 node - /* - ==> if in process of validation against a namespace aware schema - (i.e XML Schema) report a fatal error: the processor can not recover - in this situation. - Otherwise, report an error: no namespace fixup will be performed on this node. - */ - printf("normalizeNamespaces: no local name for attribute\n"); - } - else - { - // attr has no namespace URI and no prefix - // no action is required, since attrs don't use default - //==> do nothing - } - } - } // end for-all-Attrs - - - //####################################### - //# Recursively normalize children - //####################################### - for (NodePtr child=getFirstChild() ; child.get() ; child=child->getNextSibling()) - { - if (child->getNodeType() != Node::ELEMENT_NODE) - continue; - ElementImplPtr childElement = reinterpret_cast(child.get()); - childElement->normalizeNamespaces(); - } - -} - - -/*######################################################################### -## TextImpl -#########################################################################*/ - - -/** - * - */ -TextImpl::TextImpl() : CharacterDataImpl() -{ - nodeType = TEXT_NODE; - nodeName = "#text"; -} - - -/** - * - */ -TextImpl::TextImpl(DocumentImplPtr owner, const DOMString &value) - : CharacterDataImpl() -{ - nodeType = TEXT_NODE; - nodeName = "#text"; - ownerDocument = owner; - nodeValue = value; -} - - -/** - * - */ -TextImpl::~TextImpl() -{ -} - -/** - * - */ -TextPtr TextImpl::splitText(unsigned long /*offset*/) - throw(DOMException) -{ - return NULL; -} - -/** - * - */ -bool TextImpl::getIsElementContentWhitespace() -{ - return false; -} - -/** - * - */ -DOMString TextImpl::getWholeText() -{ - return nodeValue; -} - - -/** - * - */ -TextPtr TextImpl::replaceWholeText(const DOMString &/*content*/) - throw(DOMException) -{ - return NULL; -} - - -/*######################################################################### -## CommentImpl -#########################################################################*/ - -/** - * - */ -CommentImpl::CommentImpl() : CharacterDataImpl() -{ - nodeType = COMMENT_NODE; - nodeName = "#comment"; -} - - -/** - * - */ -CommentImpl::CommentImpl(DocumentImplPtr owner, const DOMString &value) - : CharacterDataImpl() -{ - nodeType = COMMENT_NODE; - nodeName = "#comment"; - ownerDocument = owner; - nodeValue = value; -} - - -/** - * - */ -CommentImpl::~CommentImpl() -{ -} - - - - - - - -/*######################################################################### -## UserDataHandlerImpl -#########################################################################*/ - - - -/** - * - */ -UserDataHandlerImpl::UserDataHandlerImpl() -{ -} - - -/** - * - */ -UserDataHandlerImpl::~UserDataHandlerImpl() -{ -} - -/** - * - */ -void UserDataHandlerImpl::handle(unsigned short /*operation*/, - const DOMString &/*key*/, - const DOMUserData */*data*/, - const NodePtr /*src*/, - const NodePtr /*dst*/) -{ - //do nothing. do we need anything here? -} - - - -/*######################################################################### -## DOMErrorImpl -#########################################################################*/ - - - -/** - * - */ -DOMErrorImpl::DOMErrorImpl() : - severity(0), - message(), - type() -{ -} - - -/** - * - */ -DOMErrorImpl::~DOMErrorImpl() -{ -} - -/** - * - */ -unsigned short DOMErrorImpl::getSeverity() -{ - return severity; -} - -/** - * - */ -DOMString DOMErrorImpl::getMessage() -{ - return message; -} - -/** - * - */ -DOMString DOMErrorImpl::getType() -{ - return type; -} - -/** - * - */ -DOMObject *DOMErrorImpl::getRelatedException() -{ - return NULL; -} - -/** - * - */ -DOMObject *DOMErrorImpl::getRelatedData() -{ - return NULL; -} - -/** - * - */ -DOMLocator *DOMErrorImpl::getLocation() -{ - //really should fill this in - return NULL; -} - - - - -/*######################################################################### -## DOMErrorHandlerImpl -#########################################################################*/ - - - -/** - * - */ -DOMErrorHandlerImpl::DOMErrorHandlerImpl() -{ -} - - -/** - * - */ -DOMErrorHandlerImpl::~DOMErrorHandlerImpl() -{ -} - -/** - * - */ -bool DOMErrorHandlerImpl::handleError(const DOMError *error) -{ - if (!error) - return false; - return true; -} - - - - -/*######################################################################### -## DOMLocatorImpl -#########################################################################*/ - - -/** - * - */ -DOMLocatorImpl::DOMLocatorImpl() : - lineNumber(0), - columnNumber(0), - byteOffset(0), - utf16Offset(0), - relatedNode(0), - uri() -{ -} - - -/** - * - */ -DOMLocatorImpl::~DOMLocatorImpl() -{ -} - - -/** - * - */ -long DOMLocatorImpl::getLineNumber() -{ - return lineNumber; -} - -/** - * - */ -long DOMLocatorImpl::getColumnNumber() -{ - return columnNumber; -} - -/** - * - */ -long DOMLocatorImpl::getByteOffset() -{ - return byteOffset; -} - -/** - * - */ -long DOMLocatorImpl::getUtf16Offset() -{ - return utf16Offset; -} - - -/** - * - */ -NodePtr DOMLocatorImpl::getRelatedNode() -{ - return relatedNode; -} - - -/** - * - */ -DOMString DOMLocatorImpl::getUri() -{ - return uri; -} - - - -/*######################################################################### -## DOMConfigurationImpl -#########################################################################*/ - - -/** - * - */ -DOMConfigurationImpl::DOMConfigurationImpl() -{ -} - - -/** - * - */ -DOMConfigurationImpl::~DOMConfigurationImpl() -{ -} - -/** - * - */ -void DOMConfigurationImpl::setParameter(const DOMString &/*name*/, - const DOMUserData */*value*/) throw (DOMException) -{ -} - -/** - * - */ -DOMUserData *DOMConfigurationImpl::getParameter(const DOMString &/*name*/) - throw (DOMException) -{ - return NULL; -} - -/** - * - */ -bool DOMConfigurationImpl::canSetParameter(const DOMString &/*name*/, - const DOMUserData */*data*/) -{ - return false; -} - -/** - * - */ -DOMStringList *DOMConfigurationImpl::getParameterNames() -{ - return NULL; -} - - - -/*######################################################################### -## CDATASectionImpl -#########################################################################*/ - -/** - * - */ -CDATASectionImpl::CDATASectionImpl() : TextImpl() -{ - nodeType = CDATA_SECTION_NODE; - nodeName = "#cdata-section"; -} - -/** - * - */ -CDATASectionImpl::CDATASectionImpl(DocumentImplPtr owner, const DOMString &theValue) - : TextImpl() -{ - nodeType = CDATA_SECTION_NODE; - nodeName = "#cdata-section"; - ownerDocument = owner; - nodeValue = theValue; -} - - -/** - * - */ -CDATASectionImpl::~CDATASectionImpl() -{ -} - - - - - -/*######################################################################### -## DocumentTypeImpl -#########################################################################*/ - -/** - * - */ -DocumentTypeImpl::DocumentTypeImpl(const DOMString& theName, - const DOMString& thePublicId, - const DOMString& theSystemId) - : NodeImpl(), - name(), //what with this variable? - publicId(thePublicId), - systemId(theSystemId), - entities(), - notations() -{ - nodeType = DOCUMENT_TYPE_NODE;//of class NodeImpl - nodeName = theName;//of class NodeImpl -} - -/** - * - */ -DocumentTypeImpl::~DocumentTypeImpl() -{ -} - -/** - * - */ -DOMString DocumentTypeImpl::getName() -{ - return nodeName; -} - -/** - * - */ -NamedNodeMap DocumentTypeImpl::getEntities() -{ - return entities; -} - -/** - * - */ -NamedNodeMap DocumentTypeImpl::getNotations() -{ - return notations; -} - -/** - * - */ -DOMString DocumentTypeImpl::getPublicId() -{ - return publicId; -} - -/** - * - */ -DOMString DocumentTypeImpl::getSystemId() -{ - return systemId; -} - -/** - * - */ -DOMString DocumentTypeImpl::getInternalSubset() -{ - return DOMString(""); -} - - - - - - -/*######################################################################### -## NotationImpl -#########################################################################*/ - - - -/** - * - */ -NotationImpl::NotationImpl(DocumentImplPtr owner) : NodeImpl() -{ - nodeType = NOTATION_NODE; - ownerDocument = owner; -} - - -/** - * - */ -NotationImpl::~NotationImpl() -{ -} - -/** - * - */ -DOMString NotationImpl::getPublicId() -{ - return publicId; -} - -/** - * - */ -DOMString NotationImpl::getSystemId() -{ - return systemId; -} - - - - - - - - -/*######################################################################### -## EntityImpl -#########################################################################*/ - - -/** - * - */ -EntityImpl::EntityImpl() : NodeImpl() -{ - nodeType = ENTITY_NODE; -} - - -/** - * - */ -EntityImpl::EntityImpl(DocumentImplPtr owner) : NodeImpl() -{ - nodeType = ENTITY_NODE; - ownerDocument = owner; -} - - -/** - * - */ -EntityImpl::~EntityImpl() -{ -} - -/** - * - */ -DOMString EntityImpl::getPublicId() -{ - return publicId; -} - -/** - * - */ -DOMString EntityImpl::getSystemId() -{ - return systemId; -} - -/** - * - */ -DOMString EntityImpl::getNotationName() -{ - return notationName; -} - -/** - * - */ -DOMString EntityImpl::getInputEncoding() -{ - return inputEncoding; -} - -/** - * - */ -DOMString EntityImpl::getXmlEncoding() -{ - return xmlEncoding; -} - -/** - * - */ -DOMString EntityImpl::getXmlVersion() -{ - return xmlVersion; -} - - - - - - -/*######################################################################### -## EntityReferenceImpl -#########################################################################*/ - - - -/** - * - */ -EntityReferenceImpl::EntityReferenceImpl() : NodeImpl() -{ - nodeType = ENTITY_REFERENCE_NODE; -} - - -/** - * - */ -EntityReferenceImpl::EntityReferenceImpl(DocumentImplPtr owner, - const DOMString &theName) - : NodeImpl() -{ - nodeType = ENTITY_REFERENCE_NODE; - nodeName = theName; - ownerDocument = owner; -} - - -/** - * - */ -EntityReferenceImpl::~EntityReferenceImpl() -{ -} - - - -/*######################################################################### -## ProcessingInstructionImpl -#########################################################################*/ - - - - -/** - * - */ -ProcessingInstructionImpl::ProcessingInstructionImpl(): NodeImpl() -{ - nodeType = PROCESSING_INSTRUCTION_NODE; -} - - - -/** - * - */ -ProcessingInstructionImpl::ProcessingInstructionImpl(DocumentImplPtr owner, - const DOMString &target, - const DOMString &data) - : NodeImpl() -{ - nodeType = PROCESSING_INSTRUCTION_NODE; - ownerDocument = owner; - nodeName = target; - nodeValue = data; -} - - -/** - * - */ -ProcessingInstructionImpl::~ProcessingInstructionImpl() -{ -} - - - - -/** - * - */ -DOMString ProcessingInstructionImpl::getTarget() -{ - return nodeName; -} - -/** - * - */ -DOMString ProcessingInstructionImpl::getData() -{ - return nodeValue; -} - -/** - * - */ -void ProcessingInstructionImpl::setData(const DOMString& /*val*/) throw(DOMException) -{ - //do something here -} - - - - - - - -/*######################################################################### -## DocumentFragmentImpl -#########################################################################*/ - -/** - * - */ -DocumentFragmentImpl::DocumentFragmentImpl() : NodeImpl() -{ - nodeType = DOCUMENT_FRAGMENT_NODE; - nodeName = "#document-fragment"; -} - - -/** - * - */ -DocumentFragmentImpl::DocumentFragmentImpl(DocumentImplPtr owner) : NodeImpl() -{ - nodeType = DOCUMENT_FRAGMENT_NODE; - nodeName = "#document-fragment"; - ownerDocument = owner; -} - - -/** - * - */ -DocumentFragmentImpl::~DocumentFragmentImpl() -{ -} - - - - - - -/*######################################################################### -## DocumentImpl -#########################################################################*/ - - - -/** - * - */ -DocumentTypePtr DocumentImpl::getDoctype() -{ - return doctype; -} - -/** - * - */ -DOMImplementation *DocumentImpl::getImplementation() -{ - return parent; -} - -/** - * - */ -ElementPtr DocumentImpl::getDocumentElement() -{ - return documentElement; -} - -/** - * - */ -ElementPtr DocumentImpl::createElement(const DOMString& tagName) - throw(DOMException) -{ - ElementPtr elem = new ElementImpl(this, tagName); - return elem; -} - -/** - * - */ -DocumentFragmentPtr DocumentImpl::createDocumentFragment() -{ - DocumentFragmentPtr frag = new DocumentFragmentImpl(this); - return frag; -} - -/** - * - */ -TextPtr DocumentImpl::createTextNode(const DOMString& data) -{ - TextPtr text = new TextImpl(this, data); - return text; -} - -/** - * - */ -CommentPtr DocumentImpl::createComment(const DOMString& data) -{ - CommentPtr comment = new CommentImpl(this, data); - return comment; -} - -/** - * - */ -CDATASectionPtr DocumentImpl::createCDATASection(const DOMString& data) - throw(DOMException) -{ - CDATASectionPtr cdata = new CDATASectionImpl(this, data); - return cdata; -} - -/** - * - */ -ProcessingInstructionPtr -DocumentImpl::createProcessingInstruction(const DOMString& target, - const DOMString& data) - throw(DOMException) -{ - ProcessingInstructionPtr pi = - new ProcessingInstructionImpl(this, target, data); - return pi; -} - -/** - * - */ -AttrPtr DocumentImpl::createAttribute(const DOMString& attrName) - throw(DOMException) -{ - AttrPtr attr = new AttrImpl(this, attrName); - return attr; -} - -/** - * - */ -EntityReferencePtr DocumentImpl::createEntityReference(const DOMString& erName) - throw(DOMException) -{ - EntityReferencePtr ref = new EntityReferenceImpl(this, erName); - return ref; -} - - -/** - * - */ -NodeList DocumentImpl::getElementsByTagName(const DOMString& tagname) -{ - NodeList list; - ElementImpl::getElementsByTagNameRecursive(list, - tagname, documentElement); - return list; -} - - -/** - * - */ -NodePtr DocumentImpl::importNode(const NodePtr /*importedNode*/, - bool /*deep*/) - throw(DOMException) -{ - return NULL; -} - -/** - * - */ -ElementPtr DocumentImpl::createElementNS(const DOMString& namespaceURI, - const DOMString& qualifiedName) - throw(DOMException) -{ - ElementPtr elem = new ElementImpl(this, namespaceURI, qualifiedName); - return elem; -} - -/** - * - */ -AttrPtr DocumentImpl::createAttributeNS(const DOMString& namespaceURI, - const DOMString& qualifiedName) - throw(DOMException) -{ - AttrPtr attr = new AttrImpl(this, namespaceURI, qualifiedName); - return attr; -} - - -/** - * - */ -NodeList DocumentImpl::getElementsByTagNameNS(const DOMString& namespaceURI, - const DOMString& localName) -{ - NodeList list; - ElementImpl::getElementsByTagNameNSRecursive(list, namespaceURI, - localName, documentElement); - return list; -} - -/** - * - */ -ElementPtr DocumentImpl::getElementById(const DOMString& elementId) -{ - for (NamedElementItem *entry = elementsById.next; entry ; entry=entry->next) - if (entry->name == elementId) - return entry->elem; - return NULL; -} - - -/** - * - */ -DOMString DocumentImpl::getInputEncoding() -{ - return inputEncoding; -} - - -/** - * - */ -DOMString DocumentImpl::getXmlEncoding() -{ - return xmlEncoding; -} - -/** - * - */ -bool DocumentImpl::getXmlStandalone() -{ - return xmlStandalone; -} - -/** - * - */ -void DocumentImpl::setXmlStandalone(bool val) throw (DOMException) -{ - xmlStandalone = val; -} - -/** - * - */ -DOMString DocumentImpl::getXmlVersion() -{ - return xmlVersion; -} - -/** - * - */ -void DocumentImpl::setXmlVersion(const DOMString &version) throw (DOMException) -{ - xmlVersion = version; -} - -/** - * - */ -bool DocumentImpl::getStrictErrorChecking() -{ - return strictErrorChecking; -} - -/** - * - */ -void DocumentImpl::setStrictErrorChecking(bool val) -{ - strictErrorChecking = val; -} - - -/** - * - */ -DOMString DocumentImpl::getDocumentURI() -{ - return documentURI; -} - -/** - * - */ -void DocumentImpl::setDocumentURI(const DOMString &/*uri*/) -{ - //documentURI = stringCache(uri); -} - -/** - * - */ -NodePtr DocumentImpl::adoptNode(const NodePtr source) throw (DOMException) -{ - return (NodePtr )source; -} - -/** - * - */ -DOMConfiguration *DocumentImpl::getDomConfig() -{ - return domConfig; -} - -/** - * - */ -void DocumentImpl::normalizeDocument() -{ - //i assume that this means adjusting namespaces & prefixes - if (documentElement.get()) - documentElement->normalizeNamespaces(); -} - -/** - * - */ -NodePtr DocumentImpl::renameNode(const NodePtr node, - const DOMString &/*namespaceURI*/, - const DOMString &qualifiedName) - throw (DOMException) -{ - NodeImplPtr nodeImpl = reinterpret_cast (node.get()); - nodeImpl->setNodeName(qualifiedName); - return node; -} - - - -//################## -//# Non-API methods -//################## - -/** - * - */ -DocumentImpl::DocumentImpl(const DOMImplementation *domImpl, - const DOMString &/*theNamespaceURI*/, - const DOMString &theQualifiedName, - const DocumentTypePtr theDoctype) - : NodeImpl(), - namespaceIndex(0), - parent(const_cast(domImpl)), - qualifiedName(theQualifiedName), - xmlStandalone(false), - strictErrorChecking(false), - domConfig(NULL) -{ - nodeType = DOCUMENT_NODE;//of class NodeImpl - nodeName = "#document";//of class NodeImpl - if (theDoctype.get()) //only assign if not null. - doctype = theDoctype; - else - doctype = new DocumentTypeImpl("", "", ""); - documentElement = new ElementImpl(this, "root"); -} - - -/** - * - */ -DocumentImpl::~DocumentImpl() -{ - documentElement = NULL; -} - - - - - - - - - - - - -} //namespace dom -} //namespace w3c -} //namespace org - - - -/*######################################################################### -## E N D O F F I L E -#########################################################################*/ - - - - diff --git a/src/dom/domimpl.h b/src/dom/domimpl.h deleted file mode 100644 index df586f35e..000000000 --- a/src/dom/domimpl.h +++ /dev/null @@ -1,2029 +0,0 @@ -#ifndef SEEN_DOMIMPL_H -#define SEEN_DOMIMPL_H -/** - * @file - * Phoebe DOM Implementation. - * - * This is a C++ approximation of the W3C DOM model, which follows - * fairly closely the specifications in the various .idl files, copies of - * which are provided for reference. Most important is this one: - * - * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - */ -/* - * Authors: - * Bob Jamison - * - * Copyright (C) 2005 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -#include "dom.h" - -#include - -namespace org -{ -namespace w3c -{ -namespace dom -{ - - - -class DOMImplementationSourceImpl; -class DOMImplementationImpl; -class NodeImpl; -typedef Ptr NodeImplPtr; -class CharacterDataImpl; -class AttrImpl; -typedef Ptr AttrImplPtr; -class ElementImpl; -typedef Ptr ElementImplPtr; -class TextImpl; -class CommentImpl; -class TypeInfoImpl; -class UserDataHandlerImpl; -class DOMErrorImpl; -class DOMErrorHandlerImpl; -class DOMLocatorImpl; -class DOMConfigurationImpl; -class CDATASectionImpl; -class DocumentTypeImpl; -typedef Ptr DocumentTypeImplPtr; -class NotationImpl; -class EntityImpl; -class EntityReferenceImpl; -class ProcessingInstructionImpl; -class DocumentFragmentImpl; -class DocumentImpl; -typedef Ptr DocumentImplPtr; - - - -/*######################################################################### -## DOMImplementationSourceImpl -#########################################################################*/ - -class DOMImplementationSourceImpl : public DOMImplementationSource -{ -public: - - /** - * - */ - virtual DOMImplementation *getDOMImplementation(const DOMString &features); - - /** - * - */ - virtual DOMImplementationList getDOMImplementationList(const DOMString &features); - - - //################## - //# Non-API methods - //################## - - /** - * - */ - DOMImplementationSourceImpl(); - - /** - * - */ - virtual ~DOMImplementationSourceImpl(); - -protected: - - - DOMImplementationImpl *domImpl; - DOMImplementationList domImplList; -}; - - - - - -/*######################################################################### -## DOMImplementationImpl -#########################################################################*/ -/** - * - */ -class DOMImplementationImpl : public DOMImplementation -{ -public: - - - /** - * - */ - DOMImplementationImpl(); - - /** - * - */ - virtual ~DOMImplementationImpl(); - - /** - * - */ - virtual bool hasFeature(const DOMString& feature, const DOMString& version); - - - /** - * - */ - virtual DocumentTypePtr createDocumentType(const DOMString& qualifiedName, - const DOMString& publicId, - const DOMString& systemId) - throw(DOMException); - - /** - * - */ - virtual DocumentPtr createDocument(const DOMString& namespaceURI, - const DOMString& qualifiedName, - DocumentTypePtr doctype) - throw(DOMException); - /** - * - */ - virtual DOMObject *getFeature(const DOMString& feature, - const DOMString& version); - - -protected: - -}; - - - - -/*######################################################################### -## NodeImpl -#########################################################################*/ - -/** - * - */ -class NodeImpl : virtual public Node -{ - - friend class DocumentImpl; - -public: - - /** - * - */ - virtual DOMString getNodeName(); - - /** - * - */ - virtual DOMString getNodeValue() throw (DOMException); - - /** - * - */ - virtual void setNodeValue(const DOMString& val) throw (DOMException); - - /** - * - */ - virtual unsigned short getNodeType(); - - /** - * - */ - virtual NodePtr getParentNode(); - - /** - * - */ - virtual NodeList getChildNodes(); - - /** - * - */ - virtual NodePtr getFirstChild(); - - /** - * - */ - virtual NodePtr getLastChild(); - - /** - * - */ - virtual NodePtr getPreviousSibling(); - - /** - * - */ - virtual NodePtr getNextSibling(); - - /** - * - */ - virtual NamedNodeMap &getAttributes(); - - - /** - * - */ - virtual DocumentPtr getOwnerDocument(); - - /** - * - */ - virtual NodePtr insertBefore(const NodePtr newChild, - const NodePtr refChild) - throw(DOMException); - - /** - * - */ - virtual NodePtr replaceChild(const NodePtr newChild, - const NodePtr oldChild) - throw(DOMException); - - /** - * - */ - virtual NodePtr removeChild(const NodePtr oldChild) - throw(DOMException); - - /** - * - */ - virtual NodePtr appendChild(const NodePtr newChild) - throw(DOMException); - - /** - * - */ - virtual bool hasChildNodes(); - - /** - * - */ - virtual NodePtr cloneNode(bool deep); - - /** - * - */ - virtual void normalize(); - - /** - * - */ - virtual bool isSupported(const DOMString& feature, - const DOMString& version); - - /** - * - */ - virtual DOMString getNamespaceURI(); - - /** - * - */ - virtual DOMString getPrefix(); - - /** - * - */ - virtual void setPrefix(const DOMString& val) throw(DOMException); - - /** - * - */ - virtual DOMString getLocalName(); - - /** - * - */ - virtual bool hasAttributes(); - - /** - * - */ - virtual DOMString getBaseURI(); - - /** - * - */ - virtual unsigned short compareDocumentPosition(const NodePtr other); - - /** - * - */ - virtual DOMString getTextContent() throw(DOMException); - - - /** - * - */ - virtual void setTextContent(const DOMString &val) throw(DOMException); - - - /** - * - */ - virtual DOMString lookupPrefix(const DOMString &namespaceURI); - - - /** - * - */ - virtual bool isDefaultNamespace(const DOMString &namespaceURI); - - - /** - * - */ - virtual DOMString lookupNamespaceURI(const DOMString &prefix); - - - /** - * - */ - virtual bool isEqualNode(const NodePtr node); - - - - /** - * - */ - virtual DOMObject *getFeature(const DOMString &feature, - const DOMString &version); - - /** - * - */ - virtual DOMUserData *setUserData(const DOMString &key, - const DOMUserData *data, - const UserDataHandler *handler); - - - /** - * - */ - virtual DOMUserData *getUserData(const DOMString &key); - - - //################## - //# Non-API methods - //################## - - /** - * - */ - virtual void bindingsAdd(const DOMString &prefix, const DOMString &namespaceURI) - { - bindings[prefix] = namespaceURI; - } - - /** - * - */ - virtual void bindingsClear() - { - bindings.clear(); - } - - DOMString bindingsFind(const DOMString &prefix) - { - std::map::iterator iter = - bindings.find(prefix); - if (iter != bindings.end()) - { - DOMString ret = iter->second; - return ret; - } - if (parent.get()) - { - DOMString ret = parent->bindingsFind(prefix); - if (ret.size() > 0) - return ret; - } - return ""; - } - - /** - * - */ - virtual void setNodeName(const DOMString &qualifiedName); - - /** - * - */ - virtual void setNamespaceURI(const DOMString &theNamespaceURI); - - /** - * - */ - DOMString lookupNamespacePrefix(const DOMString &namespaceURI, - NodePtr originalElement); - /** - * - */ - NodeImpl(); - - /** - * - */ - NodeImpl(const NodeImpl &other); - - /** - * - */ - NodeImpl &operator=(const NodeImpl &other); - - /** - * - */ - NodeImpl(DocumentImplPtr owner); - - /** - * - */ - NodeImpl(DocumentImplPtr owner, const DOMString &nodeName); - - /** - * - */ - NodeImpl(DocumentImplPtr owner, const DOMString &namespaceURI, - const DOMString &nodeName); - - /** - * - */ - virtual ~NodeImpl(); - - - /** - * - */ - void assign(const NodeImpl &other); - -protected: - - /** - * Set up the internal values - */ - void init(); - - unsigned short nodeType; - - NodeImplPtr parent; - - NodeImplPtr prev; - - NodeImplPtr next; - - DOMUserData *userData; - - DOMString prefix; - - DOMString localName; - - DOMString nodeName; - - DOMString namespaceURI; - - DOMString baseURI; - - DOMString nodeValue; - - NodeImplPtr firstChild; - NodeImplPtr lastChild; - - DocumentImplPtr ownerDocument; - - NamedNodeMap attributes; - - class UserDataEntry - { - public: - UserDataEntry(const DOMString &theKey, - const DOMUserData *theData, - const UserDataHandler *theHandler) - : next(NULL), - key(theKey), - data(const_cast(theData)), - handler(const_cast(theHandler)) - { - } - - virtual ~UserDataEntry() - { - //delete anything after me, too - if (next) - delete next; - } - - UserDataEntry *next; - DOMString key; - DOMUserData *data; - UserDataHandler *handler; - }; - - UserDataEntry *userDataEntries; - - TypeInfo typeInfo; - - //### Our prefix->namespaceURI bindings - - std::map bindings; - - -}; - - - -/*######################################################################### -## CharacterDataImpl -#########################################################################*/ - -/** - * - */ -class CharacterDataImpl : virtual public CharacterData, protected NodeImpl -{ -public: - - /** - * - */ - virtual DOMString getData() throw(DOMException); - - /** - * - */ - virtual void setData(const DOMString& val) throw(DOMException); - - /** - * - */ - virtual unsigned long getLength(); - - /** - * - */ - virtual DOMString substringData(unsigned long offset, - unsigned long count) - throw(DOMException); - - /** - * - */ - virtual void appendData(const DOMString& arg) throw(DOMException); - - /** - * - */ - virtual void insertData(unsigned long offset, - const DOMString& arg) - throw(DOMException); - - /** - * - */ - virtual void deleteData(unsigned long offset, - unsigned long count) - throw(DOMException); - - /** - * - */ - virtual void replaceData(unsigned long offset, - unsigned long count, - const DOMString& arg) - throw(DOMException); - - - //################## - //# Non-API methods - //################## - - /** - * - */ - CharacterDataImpl(); - - - /** - * - */ - CharacterDataImpl(DocumentImplPtr owner, const DOMString &value); - - /** - * - */ - virtual ~CharacterDataImpl(); - -protected: - - //'data' is the nodeValue - -}; - - - - - -/*######################################################################### -## AttrImpl -#########################################################################*/ - -/** - * - */ -class AttrImpl : virtual public Attr, public NodeImpl -{ -public: - - /** - * - */ - virtual DOMString getName(); - - /** - * - */ - virtual bool getSpecified(); - - /** - * - */ - virtual DOMString getValue(); - - /** - * - */ - virtual void setValue(const DOMString& val) throw(DOMException); - - /** - * - */ - virtual ElementPtr getOwnerElement(); - - - /** - * - */ - virtual TypeInfo &getSchemaTypeInfo(); - - - /** - * - */ - virtual bool getIsId(); - - - - //################## - //# Non-API methods - //################## - - /** - * - */ - virtual void setOwnerElement(const ElementPtr elem); - - /** - * - */ - AttrImpl(DocumentImplPtr owner, const DOMString &name); - - /** - * - */ - AttrImpl(DocumentImplPtr owner, const DOMString &namespaceURI, - const DOMString &name); - - /** - * - */ - virtual ~AttrImpl(); - -protected: - - - ElementPtr ownerElement; - - -}; - - - - - -/*######################################################################### -## ElementImpl -#########################################################################*/ - -/** - * - */ -class ElementImpl : virtual public Element, public NodeImpl -{ -public: - - /** - * - */ - virtual DOMString getTagName(); - - /** - * - */ - virtual DOMString getAttribute(const DOMString& name); - - /** - * - */ - virtual void setAttribute(const DOMString& name, - const DOMString& value) - throw(DOMException); - - /** - * - */ - virtual void removeAttribute(const DOMString& name) - throw(DOMException); - - /** - * - */ - virtual AttrPtr getAttributeNode(const DOMString& name); - - /** - * - */ - virtual AttrPtr setAttributeNode(AttrPtr newAttr) - throw(DOMException); - - /** - * - */ - virtual AttrPtr removeAttributeNode(AttrPtr oldAttr) - throw(DOMException); - - /** - * - */ - virtual NodeList getElementsByTagName(const DOMString& name); - - /** - * - */ - virtual DOMString getAttributeNS(const DOMString& namespaceURI, - const DOMString& localName); - - /** - * - */ - virtual void setAttributeNS(const DOMString& namespaceURI, - const DOMString& qualifiedName, - const DOMString& value) - throw(DOMException); - - /** - * - */ - virtual void removeAttributeNS(const DOMString& namespaceURI, - const DOMString& localName) - throw(DOMException); - - /** - * - */ - virtual AttrPtr getAttributeNodeNS(const DOMString& namespaceURI, - const DOMString& localName); - - /** - * - */ - virtual AttrPtr setAttributeNodeNS(AttrPtr newAttr) - throw(DOMException); - - /** - * - */ - virtual NodeList getElementsByTagNameNS(const DOMString& namespaceURI, - const DOMString& localName); - - /** - * - */ - virtual bool hasAttribute(const DOMString& name); - - /** - * - */ - virtual bool hasAttributeNS(const DOMString& namespaceURI, - const DOMString& localName); - - /** - * - */ - virtual TypeInfo &getSchemaTypeInfo(); - - - /** - * - */ - virtual void setIdAttribute(const DOMString &name, - bool isId) throw (DOMException); - - /** - * - */ - virtual void setIdAttributeNS(const DOMString &namespaceURI, - const DOMString &localName, - bool isId) throw (DOMException); - - /** - * - */ - virtual void setIdAttributeNode(const AttrPtr idAttr, - bool isId) throw (DOMException); - - - - //################## - //# Non-API methods - //################## - - - /** - * - */ - ElementImpl(); - - /** - * - */ - ElementImpl(DocumentImplPtr owner, const DOMString &tagName); - - /** - * - */ - ElementImpl(DocumentImplPtr owner, const DOMString &namespaceURI, - const DOMString &tagName); - - /** - * - */ - virtual ~ElementImpl(); - - /** - * - */ - void normalizeNamespaces(); - -protected: - -friend class DocumentImpl; - - static void getElementsByTagNameRecursive(NodeList &list, - const DOMString& name, ElementPtr elem); - static void getElementsByTagNameNSRecursive(NodeList &list, - const DOMString& namespaceURI, const DOMString& tagName, - ElementPtr elem); -}; - - - - - -/*######################################################################### -## TextImpl -#########################################################################*/ - -/** - * - */ -class TextImpl : virtual public Text, protected CharacterDataImpl -{ -public: - - /** - * - */ - virtual TextPtr splitText(unsigned long offset) - throw(DOMException); - - /** - * - */ - virtual bool getIsElementContentWhitespace(); - - /** - * - */ - virtual DOMString getWholeText(); - - - /** - * - */ - virtual TextPtr replaceWholeText(const DOMString &content) - throw(DOMException); - - //################## - //# Non-API methods - //################## - - /** - * - */ - TextImpl(); - - - /** - * - */ - TextImpl(DocumentImplPtr owner, const DOMString &val); - - /** - * - */ - virtual ~TextImpl(); - -protected: - -}; - - - -/*######################################################################### -## CommentImpl -#########################################################################*/ - -/** - * - */ -class CommentImpl : virtual public Comment, protected CharacterDataImpl -{ -public: - - //################## - //# Non-API methods - //################## - - /** - * - */ - CommentImpl(); - - /** - * - */ - CommentImpl(DocumentImplPtr owner, const DOMString &theValue); - - /** - * - */ - virtual ~CommentImpl(); -}; - - - -/*######################################################################### -## TypeInfoImpl -#########################################################################*/ - -/** - * - */ -class TypeInfoImpl : public TypeInfo -{ -public: - - /** - * - */ - virtual DOMString getTypeName(); - - /** - * - */ - virtual DOMString getTypeNamespace(); - - /** - * - */ - virtual bool isDerivedFrom(const DOMString &typeNamespaceArg, - const DOMString &typeNameArg, - const DerivationMethod derivationMethod); - - - //################## - //# Non-API methods - //################## - - - /** - * - */ - TypeInfoImpl(const DOMString &typeNamespaceArg, - const DOMString &typeNameArg, - const DerivationMethod derivationMethod); - - /** - * - */ - virtual ~TypeInfoImpl(); - -protected: - - DOMString typeName; - - DOMString typeNamespace; - - unsigned short derivationMethod; - -}; - - - - -/*######################################################################### -## UserDataHandlerImpl -#########################################################################*/ - -/** - * - */ -class UserDataHandlerImpl : public UserDataHandler -{ -public: - - /** - * - */ - virtual void handle(unsigned short operation, - const DOMString &key, - const DOMUserData *data, - const NodePtr src, - const NodePtr dst); - - //################## - //# Non-API methods - //################## - - -protected: - - /** - * - */ - UserDataHandlerImpl(); - - /** - * - */ - virtual ~UserDataHandlerImpl(); -}; - - -/*######################################################################### -## DOMErrorImpl -#########################################################################*/ - -/** - * - */ -class DOMErrorImpl : public DOMError -{ -public: - - /** - * - */ - virtual unsigned short getSeverity(); - - /** - * - */ - virtual DOMString getMessage(); - - /** - * - */ - virtual DOMString getType(); - - /** - * - */ - virtual DOMObject *getRelatedException(); - - /** - * - */ - virtual DOMObject *getRelatedData(); - - /** - * - */ - virtual DOMLocator *getLocation(); - - - //################## - //# Non-API methods - //################## - - -protected: - - /** - * - */ - DOMErrorImpl(); - - /** - * - */ - virtual ~DOMErrorImpl(); - - unsigned short severity; - - DOMString message; - - DOMString type; - - -}; - - -/*######################################################################### -## DOMErrorHandlerImpl -#########################################################################*/ - -/** - * - */ -class DOMErrorHandlerImpl : public DOMErrorHandler -{ -public: - - /** - * - */ - virtual bool handleError(const DOMError *error); - - - - //################## - //# Non-API methods - //################## - - - -protected: - - /** - * - */ - DOMErrorHandlerImpl(); - - /** - * - */ - virtual ~DOMErrorHandlerImpl(); - - -}; - - - -/*######################################################################### -## DOMLocatorImpl -#########################################################################*/ - -/** - * - */ -class DOMLocatorImpl : public DOMLocator -{ -public: - - /** - * - */ - virtual long getLineNumber(); - - /** - * - */ - virtual long getColumnNumber(); - - /** - * - */ - virtual long getByteOffset(); - - /** - * - */ - virtual long getUtf16Offset(); - - - /** - * - */ - virtual NodePtr getRelatedNode(); - - - /** - * - */ - virtual DOMString getUri(); - - - - //################## - //# Non-API methods - //################## - - - /** - * - */ - DOMLocatorImpl(); - - /** - * - */ - virtual ~DOMLocatorImpl(); - -protected: - - - long lineNumber; - - long columnNumber; - - long byteOffset; - - long utf16Offset; - - NodePtr relatedNode; - - DOMString uri; -}; - - -/*######################################################################### -## DOMConfigurationImpl -#########################################################################*/ - -/** - * - */ -class DOMConfigurationImpl : public DOMConfiguration -{ -public: - - /** - * - */ - virtual void setParameter(const DOMString &name, - const DOMUserData *value) throw (DOMException); - - /** - * - */ - virtual DOMUserData *getParameter(const DOMString &name) - throw (DOMException); - - /** - * - */ - virtual bool canSetParameter(const DOMString &name, - const DOMUserData *data); - - /** - * - */ - virtual DOMStringList *getParameterNames(); - - - //################## - //# Non-API methods - //################## - - /** - * - */ - DOMConfigurationImpl(); - - /** - * - */ - virtual ~DOMConfigurationImpl(); - -protected: - -}; - - - - - - -/*######################################################################### -## CDATASectionImpl -#########################################################################*/ -/** - * - */ -class CDATASectionImpl : public CDATASection, public TextImpl -{ -public: - - //################## - //# Non-API methods - //################## - - /** - * - */ - CDATASectionImpl(); - - - /** - * - */ - CDATASectionImpl(DocumentImplPtr owner, const DOMString &value); - - /** - * - */ - virtual ~CDATASectionImpl(); - -}; - - - - -/*######################################################################### -## DocumentTypeImpl -#########################################################################*/ - -/** - * - */ -class DocumentTypeImpl : public DocumentType, public NodeImpl -{ -public: - - /** - * - */ - virtual DOMString getName(); - - /** - * - */ - virtual NamedNodeMap getEntities(); - - /** - * - */ - virtual NamedNodeMap getNotations(); - - /** - * - */ - virtual DOMString getPublicId(); - - /** - * - */ - virtual DOMString getSystemId(); - - /** - * - */ - virtual DOMString getInternalSubset(); - - //################## - //# Non-API methods - //################## - - /** - * - */ - DocumentTypeImpl(); - - /** - * - */ - DocumentTypeImpl(const DOMString& name, - const DOMString& publicId, - const DOMString& systemId); - /** - * - */ - virtual ~DocumentTypeImpl(); - - -protected: - DOMString name; - DOMString publicId; - DOMString systemId; - - NamedNodeMap entities; - NamedNodeMap notations; - -}; - - - - - -/*######################################################################### -## NotationImpl -#########################################################################*/ - -/** - * - */ -class NotationImpl : public Notation, public NodeImpl -{ -public: - - /** - * - */ - virtual DOMString getPublicId(); - - /** - * - */ - virtual DOMString getSystemId(); - - - //################## - //# Non-API methods - //################## - - /** - * - */ - NotationImpl(); - - /** - * - */ - NotationImpl(DocumentImplPtr owner); - - /** - * - */ - virtual ~NotationImpl(); - - -protected: - - - - DOMString publicId; - - DOMString systemId; -}; - - - - - - -/*######################################################################### -## EntityImpl -#########################################################################*/ - -/** - * - */ -class EntityImpl : public Entity, public NodeImpl -{ -public: - - /** - * - */ - virtual DOMString getPublicId(); - - /** - * - */ - virtual DOMString getSystemId(); - - /** - * - */ - virtual DOMString getNotationName(); - - /** - * - */ - virtual DOMString getInputEncoding(); - - /** - * - */ - virtual DOMString getXmlEncoding(); - - /** - * - */ - virtual DOMString getXmlVersion(); - - - //################## - //# Non-API methods - //################## - - /** - * - */ - EntityImpl(); - - - /** - * - */ - EntityImpl(DocumentImplPtr owner); - - /** - * - */ - virtual ~EntityImpl(); - -protected: - - - - DOMString publicId; - - DOMString systemId; - - DOMString notationName; - - DOMString inputEncoding; - - DOMString xmlEncoding; - - DOMString xmlVersion; - -}; - - - - - -/*######################################################################### -## EntityReferenceImpl -#########################################################################*/ -/** - * - */ -class EntityReferenceImpl : public EntityReference, public NodeImpl -{ -public: - - //################## - //# Non-API methods - //################## - - /** - * - */ - EntityReferenceImpl(); - - - /** - * - */ - EntityReferenceImpl(DocumentImplPtr owner, const DOMString &theName); - - /** - * - */ - virtual ~EntityReferenceImpl(); - -}; - - - - - -/*######################################################################### -## ProcessingInstructionImpl -#########################################################################*/ - -/** - * - */ -class ProcessingInstructionImpl : - public ProcessingInstruction, - public NodeImpl -{ -public: - - /** - * - */ - virtual DOMString getTarget(); - - /** - * - */ - virtual DOMString getData(); - - /** - * - */ - virtual void setData(const DOMString& val) throw(DOMException); - - - //################## - //# Non-API methods - //################## - - - /** - * - */ - ProcessingInstructionImpl(); - - - /** - * - */ - ProcessingInstructionImpl(DocumentImplPtr owner, - const DOMString &target, - const DOMString &data); - - /** - * - */ - virtual ~ProcessingInstructionImpl(); - - -protected: - - - //'target' is nodeName - - //'data' is nodeValue - - -}; - - - - - -/*######################################################################### -## DocumentFragmentImpl -#########################################################################*/ -/** - * - */ -class DocumentFragmentImpl : public DocumentFragment, public NodeImpl -{ - -public: - - //################## - //# Non-API methods - //################## - - /** - * - */ - DocumentFragmentImpl(); - - /** - * - */ - DocumentFragmentImpl(DocumentImplPtr owner); - - /** - * - */ - virtual ~DocumentFragmentImpl(); - -}; - - - - - - -/*######################################################################### -## DocumentImpl -#########################################################################*/ - -/** - * - */ -class DocumentImpl : virtual public Document, public NodeImpl -{ -public: - - /** - * - */ - virtual DocumentTypePtr getDoctype(); - - /** - * - */ - virtual DOMImplementation *getImplementation(); - - /** - * - */ - virtual ElementPtr getDocumentElement(); - - /** - * - */ - virtual ElementPtr createElement(const DOMString& tagName) - throw(DOMException); - - /** - * - */ - virtual DocumentFragmentPtr createDocumentFragment(); - - /** - * - */ - virtual TextPtr createTextNode(const DOMString& data); - - /** - * - */ - virtual CommentPtr createComment(const DOMString& data); - - /** - * - */ - virtual CDATASectionPtr createCDATASection(const DOMString& data) - throw(DOMException); - - /** - * - */ - virtual ProcessingInstructionPtr createProcessingInstruction( - const DOMString& target, - const DOMString& data) - throw(DOMException); - - /** - * - */ - virtual AttrPtr createAttribute(const DOMString& name) - throw(DOMException); - - /** - * - */ - virtual EntityReferencePtr createEntityReference(const DOMString& name) - throw(DOMException); - - /** - * - */ - virtual NodeList getElementsByTagName(const DOMString& tagname); - - - /** - * - */ - virtual NodePtr importNode(const NodePtr importedNode, - bool deep) - throw(DOMException); - - /** - * - */ - virtual ElementPtr createElementNS(const DOMString& namespaceURI, - const DOMString& qualifiedName) - throw(DOMException); - - /** - * - */ - virtual AttrPtr createAttributeNS(const DOMString& namespaceURI, - const DOMString& qualifiedName) - throw(DOMException); - - /** - * - */ - virtual NodeList getElementsByTagNameNS(const DOMString& namespaceURI, - const DOMString& localName); - - /** - * - */ - virtual ElementPtr getElementById(const DOMString& elementId); - - - /** - * - */ - virtual DOMString getInputEncoding(); - - - /** - * - */ - virtual DOMString getXmlEncoding(); - - /** - * - */ - virtual bool getXmlStandalone(); - - /** - * - */ - virtual void setXmlStandalone(bool val) throw (DOMException); - - /** - * - */ - virtual DOMString getXmlVersion(); - - /** - * - */ - virtual void setXmlVersion(const DOMString &version) throw (DOMException); - - /** - * - */ - virtual bool getStrictErrorChecking(); - - /** - * - */ - virtual void setStrictErrorChecking(bool val); - - - /** - * - */ - virtual DOMString getDocumentURI(); - - /** - * - */ - virtual void setDocumentURI(const DOMString &uri); - - /** - * - */ - virtual NodePtr adoptNode(const NodePtr source) throw (DOMException); - - /** - * - */ - virtual DOMConfiguration *getDomConfig(); - - /** - * - */ - virtual void normalizeDocument(); - - /** - * - */ - virtual NodePtr renameNode(const NodePtr n, - const DOMString &name, - const DOMString &qualifiedName) - throw (DOMException); - - - //################## - //# Non-API methods - //################## - - DocumentImpl(const DOMImplementation *domImpl, - const DOMString &namespaceURI, - const DOMString &qualifiedName, - const DocumentTypePtr doctype); - - virtual ~DocumentImpl(); - - - DOMString *stringCache(const DOMString &val); - - int namespaceIndex; - -protected: - - DOMImplementation *parent; - - DOMString documentURI; - - DOMString qualifiedName; - - DocumentTypePtr doctype; - - ElementImplPtr documentElement; - - class NamedElementItem - { - public: - NamedElementItem() - { - next = NULL; - } - NamedElementItem(const DOMString &nameArg, ElementPtr elemArg) - : next (NULL), - name (nameArg), - elem (elemArg) - { - } - ~NamedElementItem() - { - if (next) - delete next; - } - NamedElementItem *next; - DOMString name; - ElementPtr elem; - }; - - NamedElementItem elementsById; - - - DOMString xmlEncoding; - - DOMString inputEncoding; - - DOMString xmlVersion; - - bool xmlStandalone; - - bool strictErrorChecking; - - DOMConfiguration *domConfig; - - NamedNodeMap namespaceURIs; - - -}; - - - - - - - - - - - -} //namespace dom -} //namespace w3c -} //namespace org - - -#endif // SEEN_DOMIMPL_H - - -/*######################################################################### -## E N D O F F I L E -#########################################################################*/ - - - - diff --git a/src/dom/domptr.cpp b/src/dom/domptr.cpp deleted file mode 100644 index 73999e100..000000000 --- a/src/dom/domptr.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Phoebe DOM Implementation. - * - * This is a C++ approximation of the W3C DOM model, which follows - * fairly closely the specifications in the various .idl files, copies of - * which are provided for reference. Most important is this one: - * - * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * - * Authors: - * Bob Jamison - * - * Copyright (C) 2006-2008 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "dom.h" -#include "domptr.h" - - -namespace org -{ -namespace w3c -{ -namespace dom -{ - - - - -/*######################################################################### -## NodePtr -#########################################################################*/ - - - -/** - * Increment the ref counter of the wrapped class instance - */ -void incrementRefCount(Node *p) -{ - if (p) - p->_refCnt++; -} - -/** - * Decrement the ref counter of the wrapped class instance. Delete - * the object if the reference count goes to zero - */ -void decrementRefCount(Node *p) -{ - if (p) - { - if (--(p->_refCnt) < 1) - delete p; - } -} - - - - -} //namespace dom -} //namespace w3c -} //namespace org - - - -/*######################################################################### -## E N D O F F I L E -#########################################################################*/ - - - - diff --git a/src/dom/domptr.h b/src/dom/domptr.h deleted file mode 100644 index aa9d4c208..000000000 --- a/src/dom/domptr.h +++ /dev/null @@ -1,339 +0,0 @@ -#ifndef SEEN_DOMPTR_H -#define SEEN_DOMPTR_H -/** - * @file - * Phoebe DOM Implementation. - * - * This is a C++ approximation of the W3C DOM model, which follows - * fairly closely the specifications in the various .idl files, copies of - * which are provided for reference. Most important is this one: - * - * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * - * More thorough explanations of the various classes and their algorithms - * can be found there. - * - */ -/* - * Authors: - * Bob Jamison - * - * Copyright (C) 2006-2008 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * ======================================================================= - * NOTES: - * - * Notice that many of the classes defined here are pure virtual. In other - * words, they are purely unimplemented interfaces. For the implementations - * of them, look in domimpl.h and domimpl.cpp. - * - * Also, note that there is a domptr.cpp file that has a couple of necessary - * functions which cannot be in a .h file - * - */ - -#include - -namespace org -{ -namespace w3c -{ -namespace dom -{ - - - -/*######################################################################### -## NodePtr -#########################################################################*/ - -/** - * A simple Smart Pointer class that handles Nodes and all of its - * descendants. This is very similar to shared_ptr, but it is customized - * to handle our needs. - */ -template class Ptr -{ -public: - - /** - * Simple constructor - */ - Ptr() - { _ref = 0; } - - /** - * Constructor upon a reference - */ - template Ptr(const Ptr &other) - { - _ref = other._ref; - incrementRefCount(_ref); - } - - /** - * Constructor upon a reference - */ - Ptr(T * refArg, bool addRef = true) - { - _ref = refArg; - if(addRef) - incrementRefCount(_ref); - } - - - /** - * Copy constructor - */ - Ptr(const Ptr &other) - { - _ref = other._ref; - incrementRefCount(_ref); - } - - /** - * Destructor - */ - virtual ~Ptr() - { - decrementRefCount(_ref); - } - - - /** - * Assignment operator - */ - template Ptr &operator=(const Ptr &other) - { - decrementRefCount(_ref); - _ref = other._ref; - incrementRefCount(_ref); - return *this; - } - - /** - * Assignment operator - */ - Ptr &operator=(const Ptr &other) - { - decrementRefCount(_ref); - _ref = other._ref; - incrementRefCount(_ref); - return *this; - } - - /** - * Assignment operator - */ - template Ptr &operator=(Y * ref) - { - decrementRefCount(_ref); - _ref = ref; - incrementRefCount(_ref); - return *this; - } - - /** - * Assignment operator - */ - template Ptr &operator=(const Y * ref) - { - decrementRefCount(_ref); - _ref = const_cast(ref); - incrementRefCount(_ref); - return *this; - } - - /** - * Return the reference - */ - T * get() const - { - return _ref; - } - - /** - * Dereference operator - */ - T &operator*() const - { - return *_ref; - } - - /** - * Point-to operator - */ - T *operator->() const - { - return _ref; - } - - /** - * NOT bool operator. How to check if we are null without a comparison - */ - bool operator! () const - { - return (_ref == 0); - } - - /** - * Swap what I reference with the other guy - */ - void swap(Ptr &other) - { - T *tmp = _ref; - _ref = other._ref; - other._ref = tmp; - } - - //The referenced item - T *_ref; -}; - - -/** - * Global definitions. Many of these are used to mimic behaviour of - * a real pointer - */ - -/** - * Equality - */ -template inline bool - operator==(const Ptr &a, const Ptr &b) -{ - return a.get() == b.get(); -} - -/** - * Inequality - */ -template inline bool - operator!=(const Ptr &a, const Ptr &b) -{ - return a.get() != b.get(); -} - -/** - * Equality - */ -template inline bool - operator==(const Ptr &a, T * b) -{ - return a.get() == b; -} - -/** - * Inequality - */ -template inline bool - operator!=(const Ptr &a, T * b) -{ - return a.get() != b; -} - -/** - * Equality - */ -template inline bool - operator==(T * a, const Ptr &b) -{ - return a == b.get(); -} - -/** - * Inequality - */ -template inline bool - operator!=(T * a, const Ptr &b) -{ - return a != b.get(); -} - - -/** - * Less than - */ -template inline bool - operator<(const Ptr &a, const Ptr &b) -{ - return std::less()(a.get(), b.get()); -} - -/** - * Swap - */ -template void - swap(Ptr &a, Ptr &b) -{ - a.swap(b); -} - - -/** - * Get the pointer globally, for - */ -template T * - get_pointer(const Ptr &p) -{ - return p.get(); -} - -/** - * Static cast - */ -template Ptr - static_pointer_cast(const Ptr &p) -{ - return static_cast(p.get()); -} - -/** - * Const cast - */ -template Ptr - const_pointer_cast(const Ptr &p) -{ - return const_cast(p.get()); -} - -/** - * Dynamic cast - */ -template Ptr - dynamic_pointer_cast(const Ptr &p) -{ - return dynamic_cast(p.get()); -} - - - -} //namespace dom -} //namespace w3c -} //namespace org - - -#endif // SEEN_DOMPTR_H - - -/*######################################################################### -## E N D O F F I L E -#########################################################################*/ - - - - diff --git a/src/dom/domstring.cpp b/src/dom/domstring.cpp deleted file mode 100644 index 32e3c078f..000000000 --- a/src/dom/domstring.cpp +++ /dev/null @@ -1,423 +0,0 @@ -/* - * Phoebe DOM Implementation. - * - * This is a C++ approximation of the W3C DOM model, which follows - * fairly closely the specifications in the various .idl files, copies of - * which are provided for reference. Most important is this one: - * - * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * - * Authors: - * Bob Jamison - * - * Copyright (C) 2005 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include - -#include "domstring.h" - -namespace org -{ -namespace w3c -{ -namespace dom -{ - - -//######################################################################### -//# C O N S T R U C T O R S -//######################################################################### - -DOMString::DOMString() -{ - init(); -} - -DOMString::DOMString(const DOMString &other) -{ - init(); - chars = other.chars; -} - -DOMString::DOMString(const char *str) -{ - init(); - append(str); -} - - -DOMString::~DOMString() -{ - if (cstring) - delete[] cstring; -} - - -/** - * Called only by Constructors - */ -void DOMString::init() -{ - cstring = NULL; - chars.clear(); -} - -//######################################################################### -//# M O D I F Y -//######################################################################### - -DOMString &DOMString::append(const DOMString &str) -{ - unsigned int len = str.size(); - for (unsigned int i=0 ; i::iterator iter = chars.begin(); - chars.erase(iter, iter + count); -} - -DOMString &DOMString::insert(unsigned long pos, const DOMString &str) -{ - DOMString a = substr(0, pos); - DOMString b = substr(pos, size()); - clear(); - append(a); - append(str); - append(b); - return *this; -} - -DOMString &DOMString::insert(unsigned long pos, const char *str) -{ - DOMString a = substr(0, pos); - DOMString b = substr(pos, size()); - clear(); - append(a); - append(str); - append(b); - return *this; -} - -DOMString &DOMString::insert(unsigned long pos, const std::string &str) -{ - DOMString a = substr(0, pos); - DOMString b = substr(pos, size()); - clear(); - append(a); - append(str); - append(b); - return *this; -} - - -DOMString &DOMString::prepend(const DOMString &str) -{ - DOMString tmp = *this; - clear(); - append(str); - append(tmp); - return *this; -} - -DOMString &DOMString::prepend(const char *str) -{ - DOMString tmp = *this; - clear(); - append(str); - append(tmp); - return *this; -} - -DOMString &DOMString::prepend(const std::string &str) -{ - DOMString tmp = *this; - clear(); - append(str); - append(tmp); - return *this; -} - -DOMString &DOMString::replace(unsigned long pos, unsigned long count, - const DOMString &str) -{ - DOMString a = substr(0, pos); - DOMString b = substr(pos+count, size()); - clear(); - append(a); - append(str); - append(b); - return *this; -} - -DOMString &DOMString::replace(unsigned long pos, unsigned long count, - const char *str) -{ - DOMString a = substr(0, pos); - DOMString b = substr(pos+count, size()); - clear(); - append(a); - append(str); - append(b); - return *this; -} - -DOMString &DOMString::replace(unsigned long pos, unsigned long count, - const std::string &str) -{ - DOMString a = substr(0, pos); - DOMString b = substr(pos+count, size()); - clear(); - append(a); - append(str); - append(b); - return *this; -} - - -DOMString &DOMString::push_back(XMLCh ch) -{ - chars.push_back(ch); - return *this; -} - - - -void DOMString::clear() -{ - chars.clear(); - if (cstring) - { - delete[] cstring; - cstring = NULL; - } -} - -//######################################################################### -//# Q U E R Y -//######################################################################### - -XMLCh DOMString::charAt(unsigned long index) const -{ - return chars[index]; -} - -XMLCh DOMString::operator[](unsigned long index) const -{ - return chars[index]; -} - -DOMString DOMString::substr(unsigned long start, unsigned long end) const -{ - DOMString ret; - for (unsigned long i = start; i -#include - -namespace org -{ -namespace w3c -{ -namespace dom -{ - -/** - * - */ -typedef unsigned short XMLCh; - -class DOMString -{ -public: - - //############################### - //# C O N S T R U C T O R S - //############################### - - /** - * - */ - DOMString(); - - /** - * - */ - DOMString(const char *str); - - - /** - * - */ - DOMString(const DOMString &str); - - - /** - * - */ - DOMString(const std::string &str); - - /** - * - */ - virtual ~DOMString(); - - - //############################### - //# M O D I F Y - //############################### - - - - /** - * - */ - virtual DOMString &append(const DOMString &str); - virtual DOMString &operator +(const DOMString &str) - { return append(str); } - virtual DOMString &operator +=(const DOMString &str) - { return append(str); } - - /** - * - */ - virtual DOMString &append(const char *str); - - /** - * - */ - virtual DOMString &append(const std::string &str); - - - /** - * - */ - virtual DOMString &assign(const DOMString &str); - - /** - * - */ - DOMString &operator =(const DOMString &a); - - /** - * - */ - virtual DOMString &assign(const char *str); - - /** - * - */ - virtual DOMString &assign(const std::string &str); - - /** - * - */ - virtual void erase(unsigned long pos, unsigned long count); - - /** - * - */ - virtual DOMString &insert(unsigned long pos, const DOMString &str); - - /** - * - */ - virtual DOMString &insert(unsigned long pos, const char *str); - - /** - * - */ - virtual DOMString &insert(unsigned long pos, const std::string &str); - - - /** - * - */ - virtual DOMString &prepend(const DOMString &str); - - /** - * - */ - virtual DOMString &prepend(const char *str); - - /** - * - */ - virtual DOMString &prepend(const std::string &str); - - - /** - * - */ - virtual DOMString &replace(unsigned long pos, unsigned long count, - const DOMString &str); - - /** - * - */ - virtual DOMString &replace(unsigned long pos, unsigned long count, - const char *str); - - /** - * - */ - virtual DOMString &replace(unsigned long pos, unsigned long count, - const std::string &str); - - /** - * - */ - virtual DOMString &push_back(XMLCh ch); - - /** - * - */ - virtual void clear(); - - //############################### - //# Q U E R Y - //############################### - - /** - * - */ - virtual DOMString substr(unsigned long start, unsigned long end) const; - - /** - * - */ - virtual XMLCh charAt(unsigned long index) const; - - /** - * - */ - virtual XMLCh operator[](unsigned long index) const; - - /** - * - */ - virtual unsigned long size() const; - - /** - * - */ - virtual const char *c_str(); - - //############################### - //# C O M P A R I S O N - //############################### - - /** - * - */ - virtual int compare(const DOMString &str) const; - virtual bool operator <(const DOMString &str) const - { return (compare(str)<0) ; } - virtual bool operator <=(const DOMString &str) const - { return (compare(str)<=0) ; } - virtual bool operator >(const DOMString &str) const - { return (compare(str)>0) ; } - virtual bool operator >=(const DOMString &str) const - { return (compare(str)>=0) ; } - virtual bool operator !=(const DOMString &str) const - { return (compare(str)!=0) ; } - virtual bool operator ==(const DOMString &str) const - { return (compare(str)==0) ; } - - /** - * - */ - virtual int compare(const char *str) const; - virtual bool operator <(const char *str) const - { return (compare(str)<0) ; } - virtual bool operator <=(const char *str) const - { return (compare(str)<=0) ; } - virtual bool operator >(const char *str) const - { return (compare(str)>0) ; } - virtual bool operator >=(const char *str) const - { return (compare(str)>=0) ; } - virtual bool operator !=(const char *str) const - { return (compare(str)!=0) ; } - virtual bool operator ==(const char *str) const - { return (compare(str)==0) ; } - - /** - * - */ - virtual int compare(const std::string &str) const; - virtual bool operator <(const std::string &str) const - { return (compare(str)<0) ; } - virtual bool operator <=(const std::string &str) const - { return (compare(str)<=0) ; } - virtual bool operator >(const std::string &str) const - { return (compare(str)>0) ; } - virtual bool operator >=(const std::string &str) const - { return (compare(str)>=0) ; } - virtual bool operator !=(const std::string &str) const - { return (compare(str)!=0) ; } - virtual bool operator ==(const std::string &str) const - { return (compare(str)==0) ; } - - - - -protected: - - void init(); - - char *cstring; - - std::vector chars; - -}; // class DOMString - - - - -//############################### -//# O P E R A T O R S -//############################### - -DOMString &operator +(DOMString &a, const char *b); - -DOMString &operator +(const char *b, DOMString &a); - - - -} //namespace dom -} //namespace w3c -} //namespace org - -#endif // SEEN_DOMSTRING_H -//######################################################################### -//## E N D O F F I L E -//######################################################################### - - diff --git a/src/dom/events.h b/src/dom/events.h deleted file mode 100644 index e62c5d420..000000000 --- a/src/dom/events.h +++ /dev/null @@ -1,1644 +0,0 @@ -#ifndef SEEN_EVENTS_H -#define SEEN_EVENTS_H - -/** - * @file - * Phoebe DOM Implementation. - * - * This is a C++ approximation of the W3C DOM model, which follows - * fairly closely the specifications in the various .idl files, copies of - * which are provided for reference. Most important is this one: - * - * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - */ -/* - * Authors: - * Bob Jamison - * - * Copyright (C) 2005-2008 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * ======================================================================== - * NOTES - * - * This Events API follows somewhat this specification: - * http://www.w3.org/TR/2003/NOTE-DOM-Level-3-Events-20031107/events.html - * - * Some of the comments are excerpted from that document. - * - * - */ - - -#include "dom.h" -#include "views.h" - - - - -namespace org { -namespace w3c { -namespace dom { -namespace events { - - - - -//Local definitions -typedef dom::DOMString DOMString; -typedef dom::DOMTimeStamp DOMTimeStamp; -typedef dom::NodePtr NodePtr ; - - - - -//forward declarations -class EventTarget; -class EventListener; -class DocumentEvent; -class CustomEvent; -class UIEvent; -class TextEvent; -class MouseEvent; -class KeyboardEvent; -class MutationEvent; -class MutationNameEvent; - - - -/*######################################################################### -## EventException -#########################################################################*/ - -/** - * Event operations may throw an EventException as specified in their - * method descriptions. - */ -class EventException -{ -public: - - /** - * An integer indicating the type of error generated. - */ - typedef enum - { - UNSPECIFIED_EVENT_TYPE_ERR = 0, - DISPATCH_REQUEST_ERR = 1 - } EventExceptionCode; - - unsigned short code; - - - //################## - //# Non-API methods - //################## - - EventException(short theCode) - { - code = theCode; - } - - virtual ~EventException() throw() - {} - -}; - - - - -/*######################################################################### -## Event -#########################################################################*/ - -/** - * The Event interface is used to provide contextual information about an event - * to the listener processing the event. An object which implements the Event - * interface is passed as the parameter to an EventListener. More specific - * context information is passed to event listeners by deriving additional - * interfaces from Event which contain information directly relating to the type - * of event they represent. These derived interfaces are also implemented by the - * object passed to the event listener. - * - * To create an instance of the Event interface, use the - * DocumentEvent.createEvent("Event") method call. - */ -class Event -{ -public: - - /** - * An integer indicating which phase of the event flow is being processed - * as defined in DOM event flow. - */ - typedef enum - { - CAPTURING_PHASE = 1, - AT_TARGET = 2, - BUBBLING_PHASE = 3 - } PhaseType; - - /** - * The name should be an NCName as defined in [XML Namespaces] and is - * case-sensitive. - * If the attribute Event.namespaceURI is different from null, this - * attribute represents a local name. - */ - virtual DOMString getType() const - { return eventType; } - - /** - * Used to indicate the event target. This attribute contains the target - * node when used with the DOM event flow. - */ - virtual EventTarget *getTarget() - { return target; } - - /** - * Used to indicate the EventTarget whose EventListeners are currently - * being processed. This is particularly useful during the capture and - * bubbling phases. This attribute could contain the target node or a - * target ancestor when used with the DOM event flow. - */ - virtual EventTarget *getCurrentTarget() - { return currentTarget; } - - /** - * Used to indicate which phase of event flow is currently being accomplished. - */ - virtual unsigned short getEventPhase() - { return eventPhase; } - - /** - * Used to indicate whether or not an event is a bubbling event. If the - * event can bubble the value is true, otherwise the value is false. - */ - virtual bool getBubbles() - { return canBubble; } - - /** - * Used to indicate whether or not an event can have its default action - * prevented (see also Default actions and cancelable events). If the - * default action can be prevented the value is true, otherwise the - * value is false. - */ - virtual bool getCancelable() - { return cancelable; } - - /** - * Used to specify the time (in milliseconds relative to the epoch) at which the - * event was created. Due to the fact that some systems may not provide this - * information the value of timeStamp may be not available for all events. When - * not available, a value of 0 will be returned. Examples of epoch time are the - * time of the system start or 0:0:0 UTC 1st January 1970. - */ - virtual DOMTimeStamp getTimeStamp() - { return timeStamp; } - - /** - * This method is used to prevent event listeners of the same group to be - * triggered but its effect is deferred until all event listeners attached on the - * currentTarget have been triggered (see Event propagation and event groups). - * Once it has been called, further calls to that method have no additional effect. - */ - virtual void stopPropagation() - { - } - - /** - * If an event is cancelable, the preventDefault method is used to signify that - * the event is to be canceled, meaning any default action normally taken by the - * implementation as a result of the event will not occur (see also Default - * actions and cancelable events), and thus independently of event groups. - * Calling this method for a non-cancelable event has no effect. - */ - virtual void preventDefault() - { - } - - /** - * The initEvent method is used to initialize the value of an Event created - * through the DocumentEvent.createEvent method. This method may only be called - * before the Event has been dispatched via the EventTarget.dispatchEvent() - * method. If the method is called several times before invoking - * EventTarget.dispatchEvent, only the final invocation takes precedence. This - * method has no effect if called after the event has been dispatched. If called - * from a subclass of the Event interface only the values specified in this - * method are modified, all other attributes are left unchanged. - * - * This method sets the Event.type attribute to eventTypeArg, and - * Event.namespaceURI to null. To initialize an event with a namespace URI, use - * the Event.initEventNS(namespaceURIArg, eventTypeArg, ...) method. - */ - virtual void initEvent(const DOMString &eventTypeArg, - bool canBubbleArg, - bool cancelableArg) - { - namespaceURI = ""; - eventType = eventTypeArg; - canBubble = canBubbleArg; - cancelable = cancelableArg; - } - - - /** - * The namespace URI associated with this event at creation time, or - * null if it is unspecified. - */ - virtual DOMString getNamespaceURI() const - { return namespaceURI; } - - /** - * This method will always return false, unless the event implements - * the CustomEvent interface. - */ - virtual bool isCustom() - { return custom; } - - /** - * This method is used to prevent event listeners of the same group to be - * triggered and, unlike stopPropagation its effect is immediate (see Event - * propagation and event groups). Once it has been called, further calls to that - * method have no additional effect. - * - * Note: This method does not prevent the default action from being invoked; use - * Event.preventDefault() for that effect. - */ - virtual void stopImmediatePropagation() - { - } - - /** - * This method will return true if the method Event.preventDefault() - * has been called for this event, false otherwise. - */ - virtual bool isDefaultPrevented() - { return defaultPrevented; } - - /** - * The initEventNS method is used to initialize the value of an Event - * object and has the same behavior as Event.initEvent(). - */ - virtual void initEventNS(const DOMString &namespaceURIArg, - const DOMString &eventTypeArg, - bool canBubbleArg, - bool cancelableArg) - { - namespaceURI = namespaceURIArg; - eventType = eventTypeArg; - canBubble = canBubbleArg; - cancelable = cancelableArg; - } - - //################## - //# Non-API methods - //################## - - /** - * - */ - Event() - { - init(); - } - - /** - * - */ - Event(const DOMString &eventTypeArg) - { - init(); - eventType = eventTypeArg; - } - - - /** - * - */ - Event(const Event &other) - { - eventType = other.eventType; - target = other.target; - currentTarget = other.currentTarget; - eventPhase = other.eventPhase; - canBubble = other.canBubble; - cancelable = other.cancelable; - timeStamp = other.timeStamp; - namespaceURI = other.namespaceURI; - custom = other.custom; - defaultPrevented = other.defaultPrevented; - } - - /** - * - */ - virtual ~Event() {} - -protected: - - /** - * - */ - void init() - { - eventType = ""; - target = NULL; - currentTarget = NULL; - eventPhase = 0; - canBubble = false; - cancelable = false; - //timeStamp = other.timeStamp; - namespaceURI = ""; - custom = false; - defaultPrevented = false; - } - - DOMString eventType; - EventTarget *target; - EventTarget *currentTarget; - unsigned short eventPhase; - bool canBubble; - bool cancelable; - DOMTimeStamp timeStamp; - DOMString namespaceURI; - bool custom; - bool defaultPrevented; - -}; - - - - -/*######################################################################### -## EventListener -#########################################################################*/ - -/** - * The EventListener interface is the primary way for handling events. Users - * implement the EventListener interface and register their event listener on an - * EventTarget. The users should also remove their EventListener from its - * EventTarget after they have completed using the listener. - * - * Copying a Node, with methods such as Node.cloneNode or Range.cloneContents, - * does not copy the event listeners attached to it. Event listeners must be - * attached to the newly created Node afterwards if so desired. - * - * Moving a Node, with methods Document.adoptNode, Node.appendChild, or - * Range.extractContents, does not affect the event listeners attached to it. - */ -class EventListener -{ -public: - - /** - * This method is called whenever an event occurs of the event type - * for which the EventListener interface was registered. - */ - virtual void handleEvent(const Event &/*evt*/) - {} - - //################## - //# Non-API methods - //################## - - /** - * - */ - virtual ~EventListener() {} -}; - - - - - - -/*######################################################################### -## EventTarget -#########################################################################*/ - - -/** - * The EventTarget interface is implemented by all the objects which could be - * event targets in an implementation which supports the Event flows. The - * interface allows registration, removal or query of event listeners, and - * dispatch of events to an event target. - * - * When used with DOM event flow, this interface is implemented by all target - * nodes and target ancestors, i.e. all DOM Nodes of the tree support this - * interface when the implementation conforms to DOM Level 3 Events and, - * therefore, this interface can be obtained by using binding-specific casting - * methods on an instance of the Node interface. - * - * Invoking addEventListener or addEventListenerNS multiple times on the same - * EventTarget with the same parameters (namespaceURI, type, listener, and - * useCapture) is considered to be a no-op and thus independently of the event - * group. They do not cause the EventListener to be called more than once and do - * not cause a change in the triggering order. In order to guarantee that an - * event listener will be added to the event target for the specified event group, - * one needs to invoke removeEventListener or removeEventListenerNS first. - */ -class EventTarget -{ -private: - - class EventListenerEntry - { - public: - EventListenerEntry(const DOMString &namespaceURIArg, - const DOMString &eventTypeArg, - const EventListener *listenerArg, - bool useCaptureArg) - { - namespaceURI = namespaceURIArg; - eventType = eventTypeArg; - listener = const_cast(listenerArg); - useCapture = useCaptureArg; - } - - EventListenerEntry(const EventListenerEntry &other) - { - namespaceURI = other.namespaceURI; - eventType = other.eventType; - listener = other.listener; - useCapture = other.useCapture; - } - - virtual ~EventListenerEntry() {} - - DOMString namespaceURI; - DOMString eventType; - EventListener *listener; - bool useCapture; - }; - - - -public: - - /** - * This method allows the registration of an event listener in the default group - * and, depending on the useCapture parameter, on the capture phase of the DOM - * event flow or its target and bubbling phases. - */ - virtual void addEventListener(const DOMString &type, - const EventListener *listener, - bool useCapture) - { - EventListenerEntry entry("", type, listener, useCapture); - listeners.push_back(entry); - } - - /** - * This method allows the removal of event listeners from the default group. - * Calling removeEventListener with arguments which do not identify any currently - * registered EventListener on the EventTarget has no effect. - */ - virtual void removeEventListener(const DOMString &type, - const EventListener *listener, - bool useCapture) - { - std::vector::iterator iter; - for (iter = listeners.begin() ; iter != listeners.end() ; ){ - EventListenerEntry entry = *iter; - if (entry.eventType == type && - entry.listener == listener && - useCapture && entry.useCapture){ - iter = listeners.erase(iter); - } - else{ - ++iter; - } - } - } - - /** - * This method allows the dispatch of events into the implementation's event - * model. The event target of the event is the EventTarget object on which - * dispatchEvent is called. - */ - virtual bool dispatchEvent(const Event &evt) throw(EventException) - { - - for (unsigned int i=0 ; ihandleEvent(evt); - } - } - return true; - } - - - /** - * This method allows the registration of an event listener in a specified group - * or the default group and, depending on the useCapture parameter, on the - * capture phase of the DOM event flow or its target and bubbling phases. - */ - virtual void addEventListenerNS(const DOMString &namespaceURI, - const DOMString &type, - const EventListener *listener, - bool useCapture) - { - EventListenerEntry entry(namespaceURI, type, listener, useCapture); - listeners.push_back(entry); - } - - /** - * This method allows the removal of an event listener, independently of the - * associated event group. - * Calling removeEventListenerNS with arguments which do not identify any - * currently registered EventListener on the EventTarget has no effect. - */ - virtual void removeEventListenerNS(const DOMString &namespaceURI, - const DOMString &type, - const EventListener *listener, - bool useCapture) - { - std::vector::iterator iter; - for (iter = listeners.begin() ; iter != listeners.end() ; ){ - EventListenerEntry entry = *iter; - if (entry.namespaceURI == namespaceURI && - entry.eventType == type && - entry.listener == listener && - useCapture && entry.useCapture){ - iter = listeners.erase(iter); - } - else { - ++iter; - } - } - } - - /** - * This method allows the DOM application to know if an event listener, attached - * to this EventTarget or one of its ancestors, will be triggered by the - * specified event type during the dispatch of the event to this event target or - * one of its descendants. - */ - virtual bool willTriggerNS(const DOMString &namespaceURI, - const DOMString &type) - { - std::vector::iterator iter; - for (iter = listeners.begin() ; iter != listeners.end() ; ++iter) - { - EventListenerEntry entry = *iter; - if (entry.namespaceURI == namespaceURI && - entry.eventType == type) - return true; - } - return false; - } - - /** - * This method allows the DOM application to know if this EventTarget contains an - * event listener registered for the specified event type. This is useful for - * determining at which nodes within a hierarchy altered handling of specific - * event types has been introduced, but should not be used to determine whether - * the specified event type triggers an event listener (see - * EventTarget.willTriggerNS()). - */ - virtual bool hasEventListenerNS(const DOMString &namespaceURI, - const DOMString &type) - { - std::vector::iterator iter; - for (iter = listeners.begin() ; iter != listeners.end() ; ++iter) - { - EventListenerEntry entry = *iter; - if (entry.namespaceURI == namespaceURI && - entry.eventType == type) - return true; - } - return false; - } - - - //################## - //# Non-API methods - //################## - - /** - * - */ - EventTarget() {} - - /** - * - */ - EventTarget(const EventTarget &other) - : listeners (other.listeners) - { - } - - /** - * - */ - virtual ~EventTarget() {} - -protected: - - std::vector listeners; - -}; - - - - -/*######################################################################### -## DocumentEvent -#########################################################################*/ - -/** - * The DocumentEvent interface provides a mechanism by which the user can create - * an Event object of a type supported by the implementation. If the feature - * "Events" is supported by the Document object, the DocumentEvent interface must - * be implemented on the same object. If the feature "+Events" is supported by - * the Document object, an object that supports the DocumentEvent interface must - * be returned by invoking the method Node.getFeature("+Events", "3.0") on the - * Document object. - */ -class DocumentEvent : virtual public Event -{ -public: - - /** - * Create an event with the current document - */ - virtual Event createEvent(const DOMString &/*eventType*/) - throw (dom::DOMException) - { - Event event; - return event; - } - - /** - * Test if the implementation can generate events of a specified type. - */ - virtual bool canDispatch(const DOMString &/*namespaceURI*/, - const DOMString &/*type*/) - { - return dispatchable; - } - - //################## - //# Non-API methods - //################## - - /** - * - */ - DocumentEvent() - : dispatchable(false) - {} - - /** - * - */ - DocumentEvent(const DocumentEvent &other) : Event(other) - { - dispatchable = other.dispatchable; - } - - /** - * - */ - virtual ~DocumentEvent() {} - -protected: - - bool dispatchable; - - -}; - - -/*######################################################################### -## CustomEvent -#########################################################################*/ - -/** - * The CustomEvent interface gives access to the attributes Event.currentTarget - * and Event.eventPhase. It is intended to be used by the DOM Events - * implementation to access the underlying current target and event phase while - * dispatching a custom Event in the tree; it is also intended to be implemented, - * and not used, by DOM applications. - * - * The methods contained in this interface are not intended to be used by a DOM - * application, especially during the dispatch on the Event object. Changing the - * current target or the current phase may result in unpredictable results of the - * event flow. The DOM Events implementation should ensure that both methods - * return the appropriate current target and phase before invoking each event - * listener on the current target to protect DOM applications from malicious - * event listeners. - * - * Note: If this interface is supported by the event object, Event.isCustom() - * must return true. -*/ -class CustomEvent : virtual public Event -{ -public: - - /** - * The setDispatchState method is used by the DOM Events implementation to set - * the values of Event.currentTarget and Event.eventPhase. It also reset the - * states of isPropagationStopped and isImmediatePropagationStopped. - */ - virtual void setDispatchState(const EventTarget */*target*/, - unsigned short /*phase*/) - { - } - - /** - * This method will return true if the method stopPropagation() has been - * called for this event, false in any other cases. - */ - virtual bool isPropagationStopped() - { - return propagationStopped; - } - - /** - * The isImmediatePropagationStopped method is used by the DOM Events - * implementation to know if the method stopImmediatePropagation() has been - * called for this event. It returns true if the method has been called, false - * otherwise. - */ - virtual bool isImmediatePropagationStopped() - { - return immediatePropagationStopped; - } - - - //################## - //# Non-API methods - //################## - - /** - * - */ - CustomEvent() - : propagationStopped(false), - immediatePropagationStopped(false) - {} - - /** - * - */ - CustomEvent(const CustomEvent &other) : Event(other) - { - propagationStopped = other.propagationStopped; - immediatePropagationStopped = other.immediatePropagationStopped; - } - - /** - * - */ - virtual ~CustomEvent() {} - -protected: - - bool propagationStopped; - bool immediatePropagationStopped; - - - -}; - - - - -/*######################################################################### -## UIEvent -#########################################################################*/ - -/** - * The UIEvent interface provides specific contextual information associated with - * User Interface events. - * - * To create an instance of the UIEvent interface, use the - * DocumentEvent.createEvent("UIEvent") method call. - * - * NOTE: - * For dom level 2 and 3, note that views.idl and events.idl disagree on the - * name of Views. We are using level -2- Views - */ -class UIEvent : virtual public Event -{ -public: - - /** - * The view attribute identifies the AbstractView from which the - * event was generated. - */ - virtual views::AbstractView getView() - { return view; } - - /** - * Specifies some detail information about the Event, depending on - * the type of event. - */ - virtual long getDetail() - { return detail; } - - /** - * The initUIEvent method is used to initialize the value of a UIEvent object and - * has the same behavior as Event.initEvent(). - */ - virtual void initUIEvent(const DOMString &/*typeArg*/, - bool /*canBubbleArg*/, - bool /*cancelableArg*/, - const views::AbstractView */*viewArg*/, - long /*detailArg*/) - { - } - - /** - * The initUIEventNS method is used to initialize the value of a UIEvent object - * and has the same behavior as Event.initEventNS(). - */ - virtual void initUIEventNS(const DOMString &/*namespaceURI*/, - const DOMString &/*typeArg*/, - bool /*canBubbleArg*/, - bool /*cancelableArg*/, - const views::AbstractView */*viewArg*/, - long /*detailArg*/) - { - } - - //################## - //# Non-API methods - //################## - - /** - * - */ - UIEvent() - : view(), - detail(0) - {} - - /** - * - */ - UIEvent(const UIEvent &other) - : Event(other), - view(other.view), - detail(other.detail) - { - } - - /** - * - */ - virtual ~UIEvent() {} - -protected: - - views::AbstractView view; - long detail; -}; - - - - -/*######################################################################### -## TextEvent -#########################################################################*/ - -/** - * The TextEvent interface provides specific contextual information associated - * with Text Events. - * - * To create an instance of the TextEvent interface, use the - * DocumentEvent.createEvent("TextEvent") method call. - */ -class TextEvent : virtual public UIEvent -{ -public: - - /** - * data holds the value of the characters generated by the character device. This - * may be a single Unicode character or a non-empty sequence of Unicode - * characters [Unicode]. Characters should be normalized as defined by the - * Unicode normalization form NFC, defined in [UTR #15]. This attribute cannot be - * null or contain the empty string. - */ - virtual DOMString getData() - { return data; } - - /** - * The initTextEvent method is used to initialize the value of a TextEvent object - * and has the same behavior as UIEvent.initUIEvent(). The value of - * UIEvent.detail remains undefined. - */ - virtual void initTextEvent(const DOMString &/*typeArg*/, - bool /*canBubbleArg*/, - bool /*cancelableArg*/, - const views::AbstractView */*viewArg*/, - long /*detailArg*/) - { - } - - /** - * The initTextEventNS method is used to initialize the value of a TextEvent - * object and has the same behavior as UIEvent.initUIEventNS(). The value of - * UIEvent.detail remains undefined. - */ - virtual void initTextEventNS(const DOMString &/*namespaceURI*/, - const DOMString &/*typeArg*/, - bool /*canBubbleArg*/, - bool /*cancelableArg*/, - const views::AbstractView */*viewArg*/, - long /*detailArg*/) - { - } - - //################## - //# Non-API methods - //################## - - /** - * - */ - TextEvent() {} - - /** - * - */ - TextEvent(const TextEvent &other) : Event(other), UIEvent(other) - { - data = other.data; - } - - /** - * - */ - virtual ~TextEvent() {} - -protected: - - DOMString data; - -}; - - - - - - - - -/*######################################################################### -## MouseEvent -#########################################################################*/ - -/** - * The MouseEvent interface provides specific contextual information associated - * with Mouse events. - * - * In the case of nested elements mouse events are always targeted at the most - * deeply nested element. Ancestors of the targeted element may use bubbling to - * obtain notification of mouse events which occur within theirs descendent - * elements. - * - * To create an instance of the MouseEvent interface, use the - * DocumentEvent.createEvent("MouseEvent") method call. - */ -class MouseEvent : virtual public UIEvent -{ -public: - - /** - * The horizontal coordinate at which the event occurred relative to the - * origin of the screen coordinate system. - */ - virtual long getScreenX() - { return screenX; } - - /** - * The vertical coordinate at which the event occurred relative to the - * origin of the screen coordinate system. - */ - virtual long getScreenY() - { return screenY; } - - /** - * The horizontal coordinate at which the event occurred relative to the - * DOM implementation's client area. - */ - virtual long getClientX() - { return clientX; } - - /** - * The vertical coordinate at which the event occurred relative to the - * DOM implementation's client area. - */ - virtual long getClientY() - { return clientY; } - - /** - * true if the control (Ctrl) key modifier is activated. - */ - virtual bool getCtrlKey() - { return ctrlKey; } - - /** - * true if the shift (Shift) key modifier is activated. - */ - virtual bool getShiftKey() - { return shiftKey; } - - /** - * true if the alt (alternative) key modifier is activated. - */ - virtual bool getAltKey() - { return altKey; } - - /** - * true if the meta (Meta) key modifier is activated. - */ - virtual bool getMetaKey() - { return metaKey; } - - /** - * During mouse events caused by the depression or release of a mouse button, - * button is used to indicate which mouse button changed state. 0 indicates the - * normal button of the mouse (in general on the left or the one button on - * Macintosh mice, used to activate a button or select text). 2 indicates the - * contextual property (in general on the right, used to display a context menu) - * button of the mouse if present. 1 indicates the extra (in general in the - * middle and often combined with the mouse wheel) button. Some mice may provide - * or simulate more buttons, and values higher than 2 can be used to represent - * such buttons. - */ - virtual unsigned short getButton() - { return button; } - - /** - * Used to identify a secondary EventTarget related to a UI event. Currently this - * attribute is used with the mouseover event to indicate the EventTarget which - * the pointing device exited and with the mouseout event to indicate the - * EventTarget which the pointing device entered. - */ - virtual EventTarget *getRelatedTarget() - { return relatedTarget; } - - - /** - * This methods queries the state of a modifier using a key identifier. - * The argument is a modifier key identifier, as defined by the - * KeyboardEvent.keyIdentifier attribute. Common modifier keys are "Alt", - * "AltGraph", "CapsLock", "Control", "Meta", "NumLock", "Scroll", or "Shift". - */ - virtual bool getModifierState(const DOMString &/*id*/) - { return false; } - - /** - * The initMouseEvent method is used to initialize the value of a MouseEvent - * object and has the same behavior as UIEvent.initUIEvent(). - */ - virtual void initMouseEvent(const DOMString &/*typeArg*/, - bool /*canBubbleArg*/, - bool /*cancelableArg*/, - const views::AbstractView */*viewArg*/, - long /*detailArg*/, - long /*screenXArg*/, - long /*screenYArg*/, - long /*clientXArg*/, - long /*clientYArg*/, - bool /*ctrlKeyArg*/, - bool /*altKeyArg*/, - bool /*shiftKeyArg*/, - bool /*metaKeyArg*/, - unsigned short /*buttonArg*/, - const EventTarget */*relatedTargetArg*/) - { - } - - - /** - * The initMouseEventNS method is used to initialize the value of a - * MouseEvent object and has the same behavior as UIEvent.initUIEventNS(). - */ - virtual void initMouseEventNS(const DOMString &/*namespaceURI*/, - const DOMString &/*typeArg*/, - bool /*canBubbleArg*/, - bool /*cancelableArg*/, - const views::AbstractView */*viewArg*/, - long /*detailArg*/, - long /*screenXArg*/, - long /*screenYArg*/, - long /*clientXArg*/, - long /*clientYArg*/, - unsigned short /*buttonArg*/, - const EventTarget */*relatedTargetArg*/, - const DOMString &/*modifiersList*/) - { - } - - - //################## - //# Non-API methods - //################## - - /** - * - */ - MouseEvent() - : screenX(0), - screenY(0), - clientX(0), - clientY(0), - ctrlKey(false), - shiftKey(false), - altKey(false), - metaKey(false), - button(0), - relatedTarget(NULL) - {} - - /** - * - */ - MouseEvent(const MouseEvent &other) : Event(other), UIEvent(other) - { - screenX = other.screenX; - screenY = other.screenY; - clientX = other.clientX; - clientY = other.clientY; - ctrlKey = other.ctrlKey; - shiftKey = other.shiftKey; - altKey = other.altKey; - metaKey = other.metaKey; - button = other.button; - relatedTarget = other.relatedTarget; - } - - /** - * - */ - virtual ~MouseEvent() {} - -protected: - - long screenX; - long screenY; - long clientX; - long clientY; - bool ctrlKey; - bool shiftKey; - bool altKey; - bool metaKey; - unsigned short button; - EventTarget *relatedTarget; -}; - - - - -/*######################################################################### -## KeyboardEvent -#########################################################################*/ - -/** - * The KeyboardEvent interface provides specific contextual information - * associated with keyboard devices. Each keyboard event references a key using - * an identifier. Keyboard events are commonly directed at the element that has - * the focus. - * - * The KeyboardEvent interface provides convenient attributes for some common - * modifiers keys: KeyboardEvent.ctrlKey, KeyboardEvent.shiftKey, - * KeyboardEvent.altKey, KeyboardEvent.metaKey. These attributes are equivalent - * to use the method KeyboardEvent.getModifierState(keyIdentifierArg) with - * "Control", "Shift", "Alt", or "Meta" respectively. - * - * To create an instance of the KeyboardEvent interface, use the - * DocumentEvent.createEvent("KeyboardEvent") method call. - */ -class KeyboardEvent : virtual public UIEvent -{ -public: - - /** - * This set of constants is used to indicate the location of a key on - * the device. In case a DOM implementation wishes to provide a new - * location information, a value different from the following constant - * values must be used. - */ - typedef enum - { - DOM_KEY_LOCATION_STANDARD = 0x00, - DOM_KEY_LOCATION_LEFT = 0x01, - DOM_KEY_LOCATION_RIGHT = 0x02, - DOM_KEY_LOCATION_NUMPAD = 0x03 - } KeyLocationCode; - - /** - * keyIdentifier holds the identifier of the key. - * Key identifiers can be found here: - * http://www.w3.org/TR/2003/NOTE-DOM-Level-3-Events-20031107/keyset.html#KeySet-Set - * Implementations that are unable to identify a key must use the key - * identifier "Unidentified". - */ - virtual DOMString getKeyIdentifier() - { return keyIdentifier; } - - /** - * The keyLocation attribute contains an indication of the location of - * they key on the device, as described in: - * http://www.w3.org/TR/2003/NOTE-DOM-Level-3-Events-20031107/events.html#ID-KeyboardEvent-KeyLocationCode - */ - virtual unsigned long getKeyLocation() - { return keyLocation; } - - /** - * true if the control (Ctrl) key modifier is activated. - */ - virtual bool getCtrlKey() - { return ctrlKey; } - - /** - * true if the shift (Shift) key modifier is activated. - */ - virtual bool getShiftKey() - { return shiftKey; } - - /** - * true if the alternative (Alt) key modifier is activated. - */ - virtual bool getAltKey() - { return altKey; } - - /** - * true if the meta (Meta) key modifier is activated. - */ - virtual bool getMetaKey() - { return metaKey; } - - /** - * This methods queries the state of a modifier using a key identifier. - * The argument is a modifier key identifier. Common modifier keys are "Alt", - * "AltGraph", "CapsLock", "Control", "Meta", "NumLock", "Scroll", or "Shift". - */ - virtual bool getModifierState(const DOMString &/*id*/) - { return false; } - - /** - * The initKeyboardEvent method is used to initialize the value of a - * KeyboardEvent object and has the same behavior as UIEvent.initUIEvent(). The - * value of UIEvent.detail remains undefined. - */ - virtual void initKeyboardEvent(const DOMString &/*typeArg*/, - bool /*canBubbleArg*/, - bool /*cancelableArg*/, - const views::AbstractView */*viewArg*/, - const DOMString &/*keyIdentifier*/, - unsigned long /*keyLocation*/, - const DOMString /*modifiersList*/) - { - } - - - - /** - * The initKeyboardEventNS method is used to initialize the value of a - * KeyboardEvent object and has the same behavior as UIEvent.initUIEventNS(). The - * value of UIEvent.detail remains undefined. - */ - virtual void initKeyboardEventNS(const DOMString &/*namespaceURI*/, - const DOMString &/*typeArg*/, - bool /*canBubbleArg*/, - bool /*cancelableArg*/, - const views::AbstractView */*viewArg*/, - const DOMString &/*keyIdentifier*/, - unsigned long /*keyLocation*/, - const DOMString /*modifiersList*/) - { - } - - - - //################## - //# Non-API methods - //################## - - /** - * - */ - KeyboardEvent() - : keyIdentifier(), - keyLocation(0), - ctrlKey(false), - shiftKey(false), - altKey(false), - metaKey(false) - {} - - /** - * - */ - KeyboardEvent(const KeyboardEvent &other) : Event(other), UIEvent(other) - { - keyIdentifier = other.keyIdentifier; - keyLocation = other.keyLocation; - ctrlKey = other.ctrlKey; - shiftKey = other.shiftKey; - altKey = other.altKey; - metaKey = other.metaKey; - } - - /** - * - */ - virtual ~KeyboardEvent() {} - -protected: - - DOMString keyIdentifier; - unsigned long keyLocation; - bool ctrlKey; - bool shiftKey; - bool altKey; - bool metaKey; -}; - - - - - - - - - -/*######################################################################### -## MutationEvent -#########################################################################*/ - -/** - * The MutationEvent interface provides specific contextual information - * associated with Mutation events. - * - * To create an instance of the MutationEvent interface, use the - * DocumentEvent.createEvent("MutationEvent") method call. - */ -class MutationEvent : virtual public Event -{ -public: - - /** - * An integer indicating in which way the Attr was changed. - */ - typedef enum - { - MODIFICATION = 1, - ADDITION = 2, - REMOVAL = 3 - } AttrChangeType; - - /** - * relatedNode is used to identify a secondary node related to a mutation event. - * For example, if a mutation event is dispatched to a node indicating that its - * parent has changed, the relatedNode is the changed parent. If an event is - * instead dispatched to a subtree indicating a node was changed within it, the - * relatedNode is the changed node. In the case of the - * {"http://www.w3.org/2001/xml-events", "DOMAttrModified"} event it indicates - * the Attr node which was modified, added, or removed. - */ - virtual NodePtr getRelatedNode() - { return relatedNodePtr ; } - - /** - * prevValue indicates the previous value of the Attr node in - * {"http://www.w3.org/2001/xml-events", "DOMAttrModified"} events, and of the - * CharacterData node in {"http://www.w3.org/2001/xml-events", - * "DOMCharacterDataModified"} events. - */ - virtual DOMString getPrevValue() - { return prevValue; } - - /** - * newValue indicates the new value of the Attr node in - * {"http://www.w3.org/2001/xml-events", "DOMAttrModified"} events, and of the - * CharacterData node in {"http://www.w3.org/2001/xml-events", - * "DOMCharacterDataModified"} events. - */ - virtual DOMString getNewValue() - { return newValue; } - - /** - * attrName indicates the name of the changed Attr node in a - * {"http://www.w3.org/2001/xml-events", "DOMAttrModified"} event. - */ - virtual DOMString getAttrName() - { return attrName; } - - /** - * attrChange indicates the type of change which triggered the - * {"http://www.w3.org/2001/xml-events", "DOMAttrModified"} event. The values can - * be MODIFICATION, ADDITION, or REMOVAL. - */ - virtual unsigned short getAttrChange() - { - return attrChange; - } - - /** - * The initMutationEvent method is used to initialize the value of a - * MutationEvent object and has the same behavior as Event.initEvent(). - */ - virtual void initMutationEvent(const DOMString &/*typeArg*/, - bool /*canBubbleArg*/, - bool /*cancelableArg*/, - const NodePtr /*relatedNodeArg*/, - const DOMString &/*prevValueArg*/, - const DOMString &/*newValueArg*/, - const DOMString &/*attrNameArg*/, - unsigned short /*attrChangeArg*/) - { - } - - /** - * The initMutationEventNS method is used to initialize the value of a - * MutationEvent object and has the same behavior as Event.initEventNS(). - */ - virtual void initMutationEventNS(const DOMString &/*namespaceURI*/, - const DOMString &/*typeArg*/, - bool /*canBubbleArg*/, - bool /*cancelableArg*/, - const NodePtr /*relatedNodeArg*/, - const DOMString &/*prevValueArg*/, - const DOMString &/*newValueArg*/, - const DOMString &/*attrNameArg*/, - unsigned short /*attrChangeArg*/) - { - } - - - //################## - //# Non-API methods - //################## - - /** - * - */ - MutationEvent() - : relatedNodePtr (NULL), - attrChange(0) - { - } - - /** - * - */ - MutationEvent(const MutationEvent &other) : Event(other) - { - relatedNodePtr = other.relatedNodePtr ; - prevValue = other.prevValue; - newValue = other.newValue; - attrName = other.attrName; - attrChange = other.attrChange; - } - - /** - * - */ - virtual ~MutationEvent() {} - -protected: - - NodePtr relatedNodePtr ; - DOMString prevValue; - DOMString newValue; - DOMString attrName; - unsigned short attrChange; - -}; - - - - -/*######################################################################### -## MutationNameEvent -#########################################################################*/ - -/** - * The MutationNameEvent interface provides specific contextual information - * associated with Mutation name event types. - * - * To create an instance of the MutationNameEvent interface, use the - * Document.createEvent("MutationNameEvent") method call. - */ -class MutationNameEvent : virtual public MutationEvent -{ -public: - - /** - * The previous value of the relatedNode's namespaceURI. - */ - virtual DOMString getPrevNamespaceURI() - { return prevNamespaceURI; } - - /** - * The previous value of the relatedNode's nodeName. - */ - virtual DOMString getPrevNodeName() - { return prevNodeName; } - - /** - * The initMutationNameEvent method is used to initialize the value of a - * MutationNameEvent object and has the same behavior as - * MutationEvent.initMutationEvent(). - */ - virtual void initMutationNameEvent(const DOMString &/*typeArg*/, - bool /*canBubbleArg*/, - bool /*cancelableArg*/, - const NodePtr /*relatedNodeArg*/, - const DOMString &/*prevNamespaceURIArg*/, - const DOMString &/*prevNodeNameArg*/) - { - } - - - /** - * The initMutationNameEventNS method is used to initialize the value of a - * MutationNameEvent object and has the same behavior as - * MutationEvent.initMutationEventNS(). - */ - virtual void initMutationNameEventNS(const DOMString &/*namespaceURI*/, - const DOMString &/*typeArg*/, - bool /*canBubbleArg*/, - bool /*cancelableArg*/, - const NodePtr /*relatedNodeArg*/, - const DOMString &/*prevNamespaceURIArg*/, - const DOMString &/*prevNodeNameArg*/) - { - } - - - - //################## - //# Non-API methods - //################## - - /** - * - */ - MutationNameEvent() {} - - - /** - * - */ - MutationNameEvent(const MutationNameEvent &other) - : Event(other), MutationEvent(other) - { - prevNamespaceURI = other.prevNamespaceURI; - prevNodeName = other.prevNodeName; - } - - - /** - * - */ - virtual ~MutationNameEvent() {} - -protected: - - DOMString prevNamespaceURI; - DOMString prevNodeName; - - -}; - - - - - - -} //namespace events -} //namespace dom -} //namespace w3c -} //namespace org - -#endif // SEEN_EVENTS_H - -/*######################################################################### -## E N D O F F I L E -#########################################################################*/ - diff --git a/src/dom/io/domstream.cpp b/src/dom/io/domstream.cpp deleted file mode 100644 index 1f08c0eee..000000000 --- a/src/dom/io/domstream.cpp +++ /dev/null @@ -1,1228 +0,0 @@ -/* - * Phoebe DOM Implementation. - * - * This is a C++ approximation of the W3C DOM model, which follows - * fairly closely the specifications in the various .idl files, copies of - * which are provided for reference. Most important is this one: - * - * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * - * Authors: - * Bob Jamison - * - * Copyright (C) 2006-2008 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * Our base input/output stream classes. These are is directly - * inherited from iostreams, and includes any extra - * functionality that we might need. - * - */ - -#include -#include -#include -#include - -#include "domstream.h" -#include "dom/ucd.h" - -namespace org -{ -namespace w3c -{ -namespace dom -{ -namespace io -{ - - -//######################################################################### -//# U T I L I T Y -//######################################################################### - -void pipeStream(InputStream &source, OutputStream &dest) -{ - for (;;) - { - int ch = source.get(); - if (ch<0) - break; - dest.put(ch); - } - dest.flush(); -} -/* - - -//######################################################################### -//# F O R M A T T E D P R I N T I N G -//######################################################################### - -static char const *digits = "0123456789abcdefghijklmnopqrstuvwxyz"; -*/ -// static int dprintInt(Writer &outs, - // long arg, int base, - // int flag, int width, int /*precision*/) -/*{ - - DOMString buf; - - //### Get the digits - while (arg > 0) - { - int ch = arg % base; - buf.insert(buf.begin(), digits[ch]); - arg /= base; - } - - if (flag == '#' && base == 16) - { - buf.insert(buf.begin(), 'x'); - buf.insert(buf.begin(), '0'); - } - - if (buf.size() == 0) - buf = "0"; - - int pad = width - (int)buf.size(); - for (int i=0 ; i 0) - pad -= precision + 1; - else if (flag == '#') - pad--; - - - //### Signs - if (negative) - buf.push_back('-'); - else if (flag == '+') - buf.push_back('+'); - - //### Prefix pad - if (pad > 0 && flag == '0') - { - while (pad--) - buf.push_back('0'); - } - - //### Integer digits - intPart = (intPart + 0.1 ) / scale; // turn 12345.678 to .12345678 - while (intDigits--) - { - intPart *= 10.0; - double dig; - intPart = modf(intPart, &dig); - char ch = '0' + (int)dig; - buf.push_back(ch); - } - if (buf.size() == 0) - buf = "0"; - - //### Decimal point - if (flag == '#' || precision > 0) - { - buf.push_back('.'); - } - - //### Fractional digits - while (precision--) - { - fracPart *= 10.0; - double dig; - fracPart = modf(fracPart, &dig); - char ch = '0' + (int)dig; - buf.push_back(ch); - } - - //### Left justify if requested - if (pad > 0 && flag == '-') - { - while (pad--) - buf.push_back(' '); - } - - //### Output the result - for (unsigned int i=0 ; i') - outs.writeString(">"); - else if (ch == '"') - outs.writeString("""); - else if (ch == '\'') - outs.writeString("'"); - else - outs.put(ch); - } - } - else - { - outs.writeString(str); - } - - return 1; -} - - - -static int getint(const DOMString &buf, int pos, int *ret) -{ - int len = buf.size(); - if (!len) - { - *ret = 0; - return pos; - } - - bool has_sign = false; - int val = 0; - if (buf[pos] == '-') - { - has_sign = true; - pos++; - } - while (pos < len) - { - XMLCh ch = buf[pos]; - if (ch >= '0' && ch <= '9') - val = val * 10 + (ch - '0'); - else - break; - pos++; - } - if (has_sign) - val = -val; - - *ret = val; - - return pos; -} - - - -static int dprintf(Writer &outs, const DOMString &fmt, va_list ap) -{ - - int len = fmt.size(); - - for (int pos=0 ; pos < len ; pos++) - { - XMLCh ch = fmt[pos]; - - //## normal character - if (ch != '%') - { - if (outs.put(ch)<0) - { - return -1; - } - continue; - } - - if (++pos >= len) - { - return -1; - } - - ch = fmt[pos]; - - //## is this %% ? - if (ch == '%') // escaped '%' - { - if (outs.put('%')<0) - { - return -1; - } - continue; - } - - //## flag - char flag = '\0'; - if (ch == '-' || ch == '+' || ch == ' ' || - ch == '#' || ch == '0') - { - flag = ch; - if (++pos >= len) - { - return -1; - } - ch = fmt[pos]; - } - - //## width.precision - int width = 0; - int precision = 0; - pos = getint(fmt, pos, &width); - if (pos >= len) - { - return -1; - } - ch = fmt[pos]; - if (ch == '.') - { - if (++pos >= len) - { - return -1; - } - pos = getint(fmt, pos, &precision); - if (pos >= len) - { - return -1; - } - ch = fmt[pos]; - } - - //## length - char length = '\0'; - if (ch == 'l' || ch == 'h') - { - length = ch; - if (++pos >= len) - { - return -1; - } - ch = fmt[pos]; - } - - //## data type - switch (ch) - { - case 'f': - case 'g': - { - double val = va_arg(ap, double); - dprintDouble(outs, val, flag, width, precision); - break; - } - case 'd': - { - long val = 0; - if (length == 'l') - val = va_arg(ap, long); - else if (length == 'h') - val = (long)va_arg(ap, int); - else - val = (long)va_arg(ap, int); - dprintInt(outs, val, 10, flag, width, precision); - break; - } - case 'x': - { - long val = 0; - if (length == 'l') - val = va_arg(ap, long); - else if (length == 'h') - val = (long)va_arg(ap, int); - else - val = (long)va_arg(ap, int); - dprintInt(outs, val, 16, flag, width, precision); - break; - } - case 's': - { - DOMString val = va_arg(ap, char *); - dprintString(outs, val, flag, width, precision); - break; - } - default: - { - break; - } - } - } - - return 1; -} -*/ - -//######################################################################### -//# B A S I C I N P U T S T R E A M -//######################################################################### - -/** - * - */ -BasicInputStream::BasicInputStream(InputStream &sourceStream) - : source(sourceStream) -{ - closed = false; -} - -/** - * Returns the number of bytes that can be read (or skipped over) from - * this input stream without blocking by the next caller of a method for - * this input stream. - */ -int BasicInputStream::available() -{ - if (closed) - return 0; - return source.available(); -} - - -/** - * Closes this input stream and releases any system resources - * associated with the stream. - */ -void BasicInputStream::close() -{ - if (closed) - return; - source.close(); - closed = true; -} - -/** - * Reads the next byte of data from the input stream. -1 if EOF - */ -int BasicInputStream::get() -{ - if (closed) - return -1; - return source.get(); -} - - - -//######################################################################### -//# B A S I C O U T P U T S T R E A M -//######################################################################### - -/** - * - */ -BasicOutputStream::BasicOutputStream(OutputStream &destinationStream) - : destination(destinationStream) -{ - closed = false; -} - -/** - * Closes this output stream and releases any system resources - * associated with this stream. - */ -void BasicOutputStream::close() -{ - if (closed) - return; - destination.close(); - closed = true; -} - -/** - * Flushes this output stream and forces any buffered output - * bytes to be written out. - */ -void BasicOutputStream::flush() -{ - if (closed) - return; - destination.flush(); -} - -/** - * Writes the specified byte to this output stream. - */ -int BasicOutputStream::put(gunichar ch) -{ - if (closed) - return -1; - destination.put(ch); - return 1; -} - - -//######################################################################### -//# B A S I C R E A D E R -//######################################################################### -BasicReader::BasicReader(Reader &sourceReader) -{ - source = &sourceReader; -} - -/** - * Returns the number of bytes that can be read (or skipped over) from - * this reader without blocking by the next caller of a method for - * this reader. - */ -int BasicReader::available() -{ - if (source) - return source->available(); - else - return 0; -} - - -/** - * Closes this reader and releases any system resources - * associated with the reader. - */ -void BasicReader::close() -{ - if (source) - source->close(); -} - -/** - * Reads the next byte of data from the reader. - */ -gunichar BasicReader::get() -{ - if (source) - return source->get(); - else - return (gunichar)-1; -} - - -/** - * Reads a line of data from the reader. - */ -Glib::ustring BasicReader::readLine() -{ - Glib::ustring str; - while (available() > 0) - { - gunichar ch = get(); - if (ch == '\n') - break; - str.push_back(ch); - } - return str; -} - -/** - * Reads a line of data from the reader. - */ -Glib::ustring BasicReader::readWord() -{ - Glib::ustring str; - while (available() > 0) - { - gunichar ch = get(); - if (!g_unichar_isprint(ch)) - break; - str.push_back(ch); - } - return str; -} - - -static bool getLong(Glib::ustring &str, long *val) -{ - const char *begin = str.raw().c_str(); - char *end; - long ival = strtol(begin, &end, 10); - if (str == end) - return false; - *val = ival; - return true; -} - -static bool getULong(Glib::ustring &str, unsigned long *val) -{ - const char *begin = str.raw().c_str(); - char *end; - unsigned long ival = strtoul(begin, &end, 10); - if (str == end) - return false; - *val = ival; - return true; -} - -static bool getDouble(Glib::ustring &str, double *val) -{ - const char *begin = str.raw().c_str(); - char *end; - double ival = strtod(begin, &end); - if (str == end) - return false; - *val = ival; - return true; -} - - - -const Reader &BasicReader::readBool (bool& val ) -{ - Glib::ustring buf = readWord(); - if (buf == "true") - val = true; - else - val = false; - return *this; -} - -const Reader &BasicReader::readShort (short& val ) -{ - Glib::ustring buf = readWord(); - long ival; - if (getLong(buf, &ival)) - val = (short) ival; - return *this; -} - -const Reader &BasicReader::readUnsignedShort (unsigned short& val ) -{ - Glib::ustring buf = readWord(); - unsigned long ival; - if (getULong(buf, &ival)) - val = (unsigned short) ival; - return *this; -} - -const Reader &BasicReader::readInt (int& val ) -{ - Glib::ustring buf = readWord(); - long ival; - if (getLong(buf, &ival)) - val = (int) ival; - return *this; -} - -const Reader &BasicReader::readUnsignedInt (unsigned int& val ) -{ - Glib::ustring buf = readWord(); - unsigned long ival; - if (getULong(buf, &ival)) - val = (unsigned int) ival; - return *this; -} - -const Reader &BasicReader::readLong (long& val ) -{ - Glib::ustring buf = readWord(); - long ival; - if (getLong(buf, &ival)) - val = ival; - return *this; -} - -const Reader &BasicReader::readUnsignedLong (unsigned long& val ) -{ - Glib::ustring buf = readWord(); - unsigned long ival; - if (getULong(buf, &ival)) - val = ival; - return *this; -} - -const Reader &BasicReader::readFloat (float& val ) -{ - Glib::ustring buf = readWord(); - double ival; - if (getDouble(buf, &ival)) - val = (float)ival; - return *this; -} - -const Reader &BasicReader::readDouble (double& val ) -{ - Glib::ustring buf = readWord(); - double ival; - if (getDouble(buf, &ival)) - val = ival; - return *this; -} - - - -//######################################################################### -//# I N P U T S T R E A M R E A D E R -//######################################################################### - - -InputStreamReader::InputStreamReader(InputStream &inputStreamSource) - : inputStream(inputStreamSource) -{ -} - - - -/** - * Close the underlying OutputStream - */ -void InputStreamReader::close() -{ - inputStream.close(); -} - -/** - * Flush the underlying OutputStream - */ -int InputStreamReader::available() -{ - return inputStream.available(); -} - -/** - * Overloaded to receive its bytes from an InputStream - * rather than a Reader - */ -gunichar InputStreamReader::get() -{ - //Do we need conversions here? - gunichar ch = (gunichar)inputStream.get(); - return ch; -} - - - -//######################################################################### -//# S T D R E A D E R -//######################################################################### - - -/** - * - */ -StdReader::StdReader() -{ - inputStream = new StdInputStream(); -} - -/** - * - */ -StdReader::~StdReader() -{ - delete inputStream; -} - - - -/** - * Close the underlying OutputStream - */ -void StdReader::close() -{ - inputStream->close(); -} - -/** - * Flush the underlying OutputStream - */ -int StdReader::available() -{ - return inputStream->available(); -} - -/** - * Overloaded to receive its bytes from an InputStream - * rather than a Reader - */ -gunichar StdReader::get() -{ - //Do we need conversions here? - gunichar ch = (gunichar)inputStream->get(); - return ch; -} - - - - -//######################################################################### -//# B A S I C W R I T E R -//######################################################################### -/** - * - */ -BasicWriter::BasicWriter(const Writer &destinationWriter) -{ - destination = (Writer*) &destinationWriter; -} - -/** - * Closes this writer and releases any system resources - * associated with this writer. - */ -void BasicWriter::close() -{ - if (destination) - destination->close(); -} - -/** - * Flushes this output stream and forces any buffered output - * bytes to be written out. - */ -void BasicWriter::flush() -{ - if (destination) - destination->flush(); -} - -/** - * Writes the specified byte to this output writer. - */ -int BasicWriter::put(gunichar ch) -{ - if (destination && destination->put(ch)>=0) - return 1; - return -1; -} - -/** - * Provide printf()-like formatting - */ -Writer &BasicWriter::printf(char const *fmt, ...) -{ - va_list args; - va_start(args, fmt); - gchar *buf = g_strdup_vprintf(fmt, args); - va_end(args); - if (buf) { - writeString(buf); - g_free(buf); - } - return *this; -} -/** - * Writes the specified character to this output writer. - */ -Writer &BasicWriter::writeChar(char ch) -{ - gunichar uch = ch; - put(uch); - return *this; -} - - -/** - * Writes the specified unicode string to this output writer. - */ -Writer &BasicWriter::writeUString(Glib::ustring &str) -{ - for (int i=0; i< (int)str.size(); i++) - put(str[i]); - return *this; -} - -/** - * Writes the specified standard string to this output writer. - */ -Writer &BasicWriter::writeStdString(std::string &str) -{ - Glib::ustring tmp(str); - writeUString(tmp); - return *this; -} - -/** - * Writes the specified character string to this output writer. - */ -Writer &BasicWriter::writeString(const char *str) -{ - Glib::ustring tmp; - if (str) - tmp = str; - else - tmp = "null"; - writeUString(tmp); - return *this; -} - - - - -/** - * - */ -Writer &BasicWriter::writeBool (bool val ) -{ - if (val) - writeString("true"); - else - writeString("false"); - return *this; -} - - -/** - * - */ -Writer &BasicWriter::writeShort (short val ) -{ - gchar *buf = g_strdup_printf("%d", val); - if (buf) { - writeString(buf); - g_free(buf); - } - return *this; -} - - - -/** - * - */ -Writer &BasicWriter::writeUnsignedShort (unsigned short val ) -{ - gchar *buf = g_strdup_printf("%u", val); - if (buf) { - writeString(buf); - g_free(buf); - } - return *this; -} - -/** - * - */ -Writer &BasicWriter::writeInt (int val) -{ - gchar *buf = g_strdup_printf("%d", val); - if (buf) { - writeString(buf); - g_free(buf); - } - return *this; -} - -/** - * - */ -Writer &BasicWriter::writeUnsignedInt (unsigned int val) -{ - gchar *buf = g_strdup_printf("%u", val); - if (buf) { - writeString(buf); - g_free(buf); - } - return *this; -} - -/** - * - */ -Writer &BasicWriter::writeLong (long val) -{ - gchar *buf = g_strdup_printf("%ld", val); - if (buf) { - writeString(buf); - g_free(buf); - } - return *this; -} - -/** - * - */ -Writer &BasicWriter::writeUnsignedLong(unsigned long val) -{ - gchar *buf = g_strdup_printf("%lu", val); - if (buf) { - writeString(buf); - g_free(buf); - } - return *this; -} - -/** - * - */ -Writer &BasicWriter::writeFloat(float val) -{ -#if 1 - gchar *buf = g_strdup_printf("%8.3f", val); - if (buf) { - writeString(buf); - g_free(buf); - } -#else - std::string tmp = ftos(val, 'g', 8, 3, 0); - writeStdString(tmp); -#endif - return *this; -} - -/** - * - */ -Writer &BasicWriter::writeDouble(double val) -{ -#if 1 - gchar *buf = g_strdup_printf("%8.3f", val); - if (buf) { - writeString(buf); - g_free(buf); - } -#else - std::string tmp = ftos(val, 'g', 8, 3, 0); - writeStdString(tmp); -#endif - return *this; -} - - - - -//######################################################################### -//# O U T P U T S T R E A M W R I T E R -//######################################################################### - - -OutputStreamWriter::OutputStreamWriter(OutputStream &outputStreamDest) - : outputStream(outputStreamDest) -{ -} - - - -/** - * Close the underlying OutputStream - */ -void OutputStreamWriter::close() -{ - flush(); - outputStream.close(); -} - -/** - * Flush the underlying OutputStream - */ -void OutputStreamWriter::flush() -{ - outputStream.flush(); -} - -/** - * Overloaded to redirect the output chars from the next Writer - * in the chain to an OutputStream instead. - */ -int OutputStreamWriter::put(gunichar ch) -{ - if (outputStream.put(ch)>=0) - return 1; - return -1; -} - -//######################################################################### -//# S T D W R I T E R -//######################################################################### - - -/** - * - */ -StdWriter::StdWriter() -{ - outputStream = new StdOutputStream(); -} - -/** - * - */ -StdWriter::~StdWriter() -{ - delete outputStream; -} - -/** - * Close the underlying OutputStream - */ -void StdWriter::close() -{ - flush(); - outputStream->close(); -} - -/** - * Flush the underlying OutputStream - */ -void StdWriter::flush() -{ - outputStream->flush(); -} - -/** - * Overloaded to redirect the output chars from the next Writer - * in the chain to an OutputStream instead. - */ -int StdWriter::put(gunichar ch) -{ - if (outputStream && (outputStream->put(ch)>=0)) - return 1; - return -1; -} - - - -//############################################### -//# O P E R A T O R S -//############################################### -//# Normally these would be in the .h, but we -//# just want to be absolutely certain that these -//# are never multiply defined. Easy to maintain, -//# though. Just occasionally copy/paste these -//# into the .h , and replace the {} with a ; -//############################################### - - - - -const Reader& operator>> (Reader &reader, bool& val ) - { return reader.readBool(val); } - -const Reader& operator>> (Reader &reader, short &val) - { return reader.readShort(val); } - -const Reader& operator>> (Reader &reader, unsigned short &val) - { return reader.readUnsignedShort(val); } - -const Reader& operator>> (Reader &reader, int &val) - { return reader.readInt(val); } - -const Reader& operator>> (Reader &reader, unsigned int &val) - { return reader.readUnsignedInt(val); } - -const Reader& operator>> (Reader &reader, long &val) - { return reader.readLong(val); } - -const Reader& operator>> (Reader &reader, unsigned long &val) - { return reader.readUnsignedLong(val); } - -const Reader& operator>> (Reader &reader, float &val) - { return reader.readFloat(val); } - -const Reader& operator>> (Reader &reader, double &val) - { return reader.readDouble(val); } - - - -Writer& operator<< (Writer &writer, char val) - { return writer.writeChar(val); } - -Writer& operator<< (Writer &writer, Glib::ustring &val) - { return writer.writeUString(val); } - -Writer& operator<< (Writer &writer, std::string &val) - { return writer.writeStdString(val); } - -Writer& operator<< (Writer &writer, char const *val) - { return writer.writeString(val); } - -Writer& operator<< (Writer &writer, bool val) - { return writer.writeBool(val); } - -Writer& operator<< (Writer &writer, short val) - { return writer.writeShort(val); } - -Writer& operator<< (Writer &writer, unsigned short val) - { return writer.writeUnsignedShort(val); } - -Writer& operator<< (Writer &writer, int val) - { return writer.writeInt(val); } - -Writer& operator<< (Writer &writer, unsigned int val) - { return writer.writeUnsignedInt(val); } - -Writer& operator<< (Writer &writer, long val) - { return writer.writeLong(val); } - -Writer& operator<< (Writer &writer, unsigned long val) - { return writer.writeUnsignedLong(val); } - -Writer& operator<< (Writer &writer, float val) - { return writer.writeFloat(val); } - -Writer& operator<< (Writer &writer, double val) - { return writer.writeDouble(val); } - -} //namespace io -} //namespace dom -} //namespace w3c -} //namespace org - - -//######################################################################### -//# E N D O F F I L E -//######################################################################### diff --git a/src/dom/io/domstream.h b/src/dom/io/domstream.h deleted file mode 100644 index edd180b83..000000000 --- a/src/dom/io/domstream.h +++ /dev/null @@ -1,684 +0,0 @@ -#ifndef SEEN_DOMSTREAM_H -#define SEEN_DOMSTREAM_H -/** - * @file - * Phoebe DOM Implementation. - * - * This is a C++ approximation of the W3C DOM model, which follows - * fairly closely the specifications in the various .idl files, copies of - * which are provided for reference. Most important is this one: - * - * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - */ -/* - * Authors: - * Bob Jamison - * - * Copyright (C) 2006-2007 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -#include -#include - -namespace org -{ -namespace w3c -{ -namespace dom -{ -namespace io -{ - -class StreamException : public std::exception -{ -public: - - StreamException(const char *theReason) throw() - { reason = theReason; } - StreamException(Glib::ustring &theReason) throw() - { reason = theReason; } - virtual ~StreamException() throw() - { } - char const *what() const throw() - { return reason.c_str(); } - -private: - Glib::ustring reason; - -}; - -//######################################################################### -//# I N P U T S T R E A M -//######################################################################### - -/** - * This interface is the base of all input stream classes. Users who wish - * to make an InputStream that is part of a chain should inherit from - * BasicInputStream. Inherit from this class to make a source endpoint, - * such as a URI or buffer. - * - */ -class InputStream -{ - -public: - - /** - * Constructor. - */ - InputStream() {} - - /** - * Destructor - */ - virtual ~InputStream() {} - - /** - * Return the number of bytes that are currently available - * to be read - */ - virtual int available() = 0; - - /** - * Do whatever it takes to 'close' this input stream - * The most likely implementation of this method will be - * for endpoints that use a resource for their data. - */ - virtual void close() = 0; - - /** - * Read one byte from this input stream. This is a blocking - * call. If no data is currently available, this call will - * not return until it exists. If the user does not want - * their code to block, then the usual solution is: - * if (available() > 0) - * myChar = get(); - * This call returns -1 on end-of-file. - */ - virtual int get() = 0; - -}; // class InputStream - - - - -/** - * This is the class that most users should inherit, to provide - * their own streams. - * - */ -class BasicInputStream : public InputStream -{ - -public: - - BasicInputStream(InputStream &sourceStream); - - virtual ~BasicInputStream() {} - - virtual int available(); - - virtual void close(); - - virtual int get(); - -protected: - - bool closed; - - InputStream &source; - -private: - - -}; // class BasicInputStream - - - -/** - * Convenience class for reading from standard input - */ -class StdInputStream : public InputStream -{ -public: - - int available() - { return 0; } - - void close() - { /* do nothing */ } - - int get() - { return getchar(); } - -}; - - - - - -//######################################################################### -//# O U T P U T S T R E A M -//######################################################################### - -/** - * This interface is the base of all input stream classes. Users who wish - * to make an OutputStream that is part of a chain should inherit from - * BasicOutputStream. Inherit from this class to make a destination endpoint, - * such as a URI or buffer. - */ -class OutputStream -{ - -public: - - /** - * Constructor. - */ - OutputStream() {} - - /** - * Destructor - */ - virtual ~OutputStream() {} - - /** - * This call should - * 1. flush itself - * 2. close itself - * 3. close the destination stream - */ - virtual void close() = 0; - - /** - * This call should push any pending data it might have to - * the destination stream. It should NOT call flush() on - * the destination stream. - */ - virtual void flush() = 0; - - /** - * Send one byte to the destination stream. - */ - virtual int put(gunichar ch) = 0; - - -}; // class OutputStream - - -/** - * This is the class that most users should inherit, to provide - * their own output streams. - */ -class BasicOutputStream : public OutputStream -{ - -public: - - BasicOutputStream(OutputStream &destinationStream); - - virtual ~BasicOutputStream() {} - - virtual void close(); - - virtual void flush(); - - virtual int put(gunichar ch); - -protected: - - bool closed; - - OutputStream &destination; - - -}; // class BasicOutputStream - - - -/** - * Convenience class for writing to standard output - */ -class StdOutputStream : public OutputStream -{ -public: - - void close() - { } - - void flush() - { } - - int put(gunichar ch) - { return putchar(ch); } - -}; - - - - -//######################################################################### -//# R E A D E R -//######################################################################### - -/** - * This interface and its descendants are for unicode character-oriented input - * - */ -class Reader -{ - -public: - - /** - * Constructor. - */ - Reader() {} - - /** - * Destructor - */ - virtual ~Reader() {} - - - virtual int available() = 0; - - virtual void close() = 0; - - virtual gunichar get() = 0; - - virtual Glib::ustring readLine() = 0; - - virtual Glib::ustring readWord() = 0; - - /* Input formatting */ - virtual const Reader& readBool (bool& val ) = 0; - virtual const Reader& operator>> (bool& val ) = 0; - - virtual const Reader& readShort (short &val) = 0; - virtual const Reader& operator>> (short &val) = 0; - - virtual const Reader& readUnsignedShort (unsigned short &val) = 0; - virtual const Reader& operator>> (unsigned short &val) = 0; - - virtual const Reader& readInt (int &val) = 0; - virtual const Reader& operator>> (int &val) = 0; - - virtual const Reader& readUnsignedInt (unsigned int &val) = 0; - virtual const Reader& operator>> (unsigned int &val) = 0; - - virtual const Reader& readLong (long &val) = 0; - virtual const Reader& operator>> (long &val) = 0; - - virtual const Reader& readUnsignedLong (unsigned long &val) = 0; - virtual const Reader& operator>> (unsigned long &val) = 0; - - virtual const Reader& readFloat (float &val) = 0; - virtual const Reader& operator>> (float &val) = 0; - - virtual const Reader& readDouble (double &val) = 0; - virtual const Reader& operator>> (double &val) = 0; - -}; // interface Reader - - - -/** - * This class and its descendants are for unicode character-oriented input - * - */ -class BasicReader : public Reader -{ - -public: - - BasicReader(Reader &sourceStream); - - virtual ~BasicReader() {} - - virtual int available(); - - virtual void close(); - - virtual gunichar get(); - - virtual Glib::ustring readLine(); - - virtual Glib::ustring readWord(); - - /* Input formatting */ - virtual const Reader& readBool (bool& val ); - virtual const Reader& operator>> (bool& val ) - { return readBool(val); } - - virtual const Reader& readShort (short &val); - virtual const Reader& operator>> (short &val) - { return readShort(val); } - - virtual const Reader& readUnsignedShort (unsigned short &val); - virtual const Reader& operator>> (unsigned short &val) - { return readUnsignedShort(val); } - - virtual const Reader& readInt (int &val); - virtual const Reader& operator>> (int &val) - { return readInt(val); } - - virtual const Reader& readUnsignedInt (unsigned int &val); - virtual const Reader& operator>> (unsigned int &val) - { return readUnsignedInt(val); } - - virtual const Reader& readLong (long &val); - virtual const Reader& operator>> (long &val) - { return readLong(val); } - - virtual const Reader& readUnsignedLong (unsigned long &val); - virtual const Reader& operator>> (unsigned long &val) - { return readUnsignedLong(val); } - - virtual const Reader& readFloat (float &val); - virtual const Reader& operator>> (float &val) - { return readFloat(val); } - - virtual const Reader& readDouble (double &val); - virtual const Reader& operator>> (double &val) - { return readDouble(val); } - - -protected: - - Reader *source; - - BasicReader() - { source = NULL; } - -private: - -}; // class BasicReader - - - -/** - * Class for placing a Reader on an open InputStream - * - */ -class InputStreamReader : public BasicReader -{ -public: - - InputStreamReader(InputStream &inputStreamSource); - - /*Overload these 3 for your implementation*/ - virtual int available(); - - virtual void close(); - - virtual gunichar get(); - - -private: - - InputStream &inputStream; - - -}; - -/** - * Convenience class for reading formatted from standard input - * - */ -class StdReader : public BasicReader -{ -public: - - StdReader(); - - virtual ~StdReader(); - - /*Overload these 3 for your implementation*/ - virtual int available(); - - virtual void close(); - - virtual gunichar get(); - - -private: - - InputStream *inputStream; - - -}; - - - -//######################################################################### -//# W R I T E R -//######################################################################### - -/** - * This interface and its descendants are for unicode character-oriented output - * - */ -class Writer -{ - -public: - - /** - * Constructor. - */ - Writer() {} - - /** - * Destructor - */ - virtual ~Writer() {} - - virtual void close() = 0; - - virtual void flush() = 0; - - virtual int put(gunichar ch) = 0; - - /* Formatted output */ - virtual Writer& printf(char const *fmt, ...) G_GNUC_PRINTF(2,3) = 0; - - virtual Writer& writeChar(char val) = 0; - - virtual Writer& writeUString(Glib::ustring &val) = 0; - - virtual Writer& writeStdString(std::string &val) = 0; - - virtual Writer& writeString(const char *str) = 0; - - virtual Writer& writeBool (bool val ) = 0; - - virtual Writer& writeShort (short val ) = 0; - - virtual Writer& writeUnsignedShort (unsigned short val ) = 0; - - virtual Writer& writeInt (int val ) = 0; - - virtual Writer& writeUnsignedInt (unsigned int val ) = 0; - - virtual Writer& writeLong (long val ) = 0; - - virtual Writer& writeUnsignedLong (unsigned long val ) = 0; - - virtual Writer& writeFloat (float val ) = 0; - - virtual Writer& writeDouble (double val ) = 0; - - - -}; // interface Writer - - -/** - * This class and its descendants are for unicode character-oriented output - * - */ -class BasicWriter : public Writer -{ - -public: - - BasicWriter(const Writer &destinationWriter); - - virtual ~BasicWriter() {} - - /*Overload these 3 for your implementation*/ - virtual void close(); - - virtual void flush(); - - virtual int put(gunichar ch); - - - - /* Formatted output */ - virtual Writer &printf(char const *fmt, ...) G_GNUC_PRINTF(2,3); - - virtual Writer& writeChar(char val); - - virtual Writer& writeUString(Glib::ustring &val); - - virtual Writer& writeStdString(std::string &val); - - virtual Writer& writeString(const char *str); - - virtual Writer& writeBool (bool val ); - - virtual Writer& writeShort (short val ); - - virtual Writer& writeUnsignedShort (unsigned short val ); - - virtual Writer& writeInt (int val ); - - virtual Writer& writeUnsignedInt (unsigned int val ); - - virtual Writer& writeLong (long val ); - - virtual Writer& writeUnsignedLong (unsigned long val ); - - virtual Writer& writeFloat (float val ); - - virtual Writer& writeDouble (double val ); - - -protected: - - Writer *destination; - - BasicWriter() - { destination = NULL; } - -private: - -}; // class BasicWriter - - -Writer& operator<< (Writer &writer, char val); - -Writer& operator<< (Writer &writer, Glib::ustring &val); - -Writer& operator<< (Writer &writer, std::string &val); - -Writer& operator<< (Writer &writer, char const *val); - -Writer& operator<< (Writer &writer, bool val); - -Writer& operator<< (Writer &writer, short val); - -Writer& operator<< (Writer &writer, unsigned short val); - -Writer& operator<< (Writer &writer, int val); - -Writer& operator<< (Writer &writer, unsigned int val); - -Writer& operator<< (Writer &writer, long val); - -Writer& operator<< (Writer &writer, unsigned long val); - -Writer& operator<< (Writer &writer, float val); - -Writer& operator<< (Writer &writer, double val); - - -/** - * Class for placing a Writer on an open OutputStream - * - */ -class OutputStreamWriter : public BasicWriter -{ -public: - - OutputStreamWriter(OutputStream &outputStreamDest); - - /*Overload these 3 for your implementation*/ - virtual void close(); - virtual void flush(); - virtual int put(gunichar ch); - - -private: - - OutputStream &outputStream; - - -}; - - -/** - * Convenience class for writing to standard output - */ -class StdWriter : public BasicWriter -{ -public: - StdWriter(); - - virtual ~StdWriter(); - virtual void close(); - virtual void flush(); - virtual int put(gunichar ch); - - -private: - - OutputStream *outputStream; - -}; - -//######################################################################### -//# U T I L I T Y -//######################################################################### - -void pipeStream(InputStream &source, OutputStream &dest); - - -} //namespace io -} //namespace dom -} //namespace w3c -} //namespace org - - -#endif // SEEN_DOMSTREAM_H - -//######################################################################### -//# E N D O F F I L E -//######################################################################### diff --git a/src/dom/ls.h b/src/dom/ls.h deleted file mode 100644 index 6e9a940f7..000000000 --- a/src/dom/ls.h +++ /dev/null @@ -1,947 +0,0 @@ -#ifndef SEEN_LS_H -#define SEEN_LS_H -/** - * @file - * Phoebe DOM Implementation. - * - * This is a C++ approximation of the W3C DOM model, which follows - * fairly closely the specifications in the various .idl files, copies of - * which are provided for reference. Most important is this one: - * - * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - */ -/* - * Authors: - * Bob Jamison - * - * Copyright (C) 2005 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -#include "dom.h" -#include "events.h" -#include "traversal.h" - -#include "io/domstream.h" - -namespace org -{ -namespace w3c -{ -namespace dom -{ -namespace ls -{ - - - -//Local definitions -//The idl said Object. Since this is undefined, we will -//use our own class which is designed to be a bit similar to -//java.io streams - -typedef dom::io::InputStream LSInputStream; -typedef dom::io::OutputStream LSOutputStream; -typedef dom::io::Reader LSReader; -typedef dom::io::Writer LSWriter; - - -//local definitions -typedef dom::DOMString DOMString; -typedef dom::DOMConfiguration DOMConfiguration; -typedef dom::Node Node; -typedef dom::NodePtr NodePtr; -typedef dom::Document Document; -typedef dom::DocumentPtr DocumentPtr; -typedef dom::Element Element; -typedef dom::ElementPtr ElementPtr; - - -//forward declarations -class LSParser; -class LSSerializer; -class LSInput; -class LSOutput; -class LSParserFilter; -class LSSerializerFilter; - - - -/*######################################################################### -## LSException -#########################################################################*/ - -/** - * Maybe this should inherit from DOMException? - */ -class LSException -{ - -public: - - LSException(const DOMString &reasonMsg) - { msg = reasonMsg; } - - LSException(short theCode) - { - code = theCode; - } - - virtual ~LSException() throw() - {} - - /** - * - */ - unsigned short code; - - /** - * - */ - DOMString msg; - - /** - * Get a string, translated from the code. - * Like std::exception. Not in spec. - */ - const char *what() - { return msg.c_str(); } - - - -}; - - -/** - * LSExceptionCode - */ -typedef enum - { - PARSE_ERR = 81, - SERIALIZE_ERR = 82 - } XPathExceptionCode; - - -/*######################################################################### -## LSParserFilter -#########################################################################*/ - -/** - * - */ -class LSParserFilter -{ -public: - - // Constants returned by startElement and acceptNode - typedef enum - { - FILTER_ACCEPT = 1, - FILTER_REJECT = 2, - FILTER_SKIP = 3, - FILTER_INTERRUPT = 4 - } ReturnValues; - - - /** - * - */ - virtual unsigned short startElement(const ElementPtr elementArg) =0; - - /** - * - */ - virtual unsigned short acceptNode(const NodePtr nodeArg) =0; - - /** - * - */ - virtual unsigned long getWhatToShow() =0; - - //################## - //# Non-API methods - //################## - - /** - * - */ - virtual ~LSParserFilter() {} - - - -}; - -/*######################################################################### -## LSInput -#########################################################################*/ - -/** - * - */ -class LSInput -{ -public: - - /** - * - */ - virtual LSReader *getCharacterStream() const - { return characterStream; } - - /** - * - */ - virtual void setCharacterStream(const LSReader *val) - { characterStream = (LSReader *)val; } - - /** - * - */ - virtual LSInputStream *getByteStream() const - { return byteStream; } - - /** - * - */ - virtual void setByteStream(const LSInputStream *val) - { byteStream = (LSInputStream *)val; } - - /** - * - */ - virtual DOMString getStringData() const - { return stringData; } - - /** - * - */ - virtual void setStringData(const DOMString &val) - { stringData = val; } - - /** - * - */ - virtual DOMString getSystemId() const - { return systemId; } - - /** - * - */ - virtual void setSystemId(const DOMString &val) - { systemId = val; } - - /** - * - */ - virtual DOMString getPublicId() const - { return publicId; } - - /** - * - */ - virtual void setPublicId(const DOMString &val) - { publicId = val; } - - /** - * - */ - virtual DOMString getBaseURI() const - { return baseURI; } - - /** - * - */ - virtual void setBaseURI(const DOMString &val) - { baseURI = val; } - - /** - * - */ - virtual DOMString getEncoding() const - { return encoding; } - - /** - * - */ - virtual void setEncoding(const DOMString &val) - { encoding = val; } - - /** - * - */ - virtual bool getCertifiedText() const - { return certifiedText; } - - /** - * - */ - virtual void setCertifiedText(bool val) - { certifiedText = val; } - - //################## - //# Non-API methods - //################## - - - /** - * - */ - LSInput() - { - characterStream = NULL; - byteStream = NULL; - stringData = ""; - systemId = ""; - publicId = ""; - baseURI = ""; - encoding = ""; - certifiedText = false; - } - - - - /** - * - */ - LSInput(const LSInput &other) - { - characterStream = other.characterStream; - byteStream = other.byteStream; - stringData = other.stringData; - systemId = other.systemId; - publicId = other.publicId; - baseURI = other.baseURI; - encoding = other.encoding; - certifiedText = other.certifiedText; - } - - /** - * - */ - virtual ~LSInput() - {} - -private: - - LSReader *characterStream; - LSInputStream *byteStream; - DOMString stringData; - DOMString systemId; - DOMString publicId; - DOMString baseURI; - DOMString encoding; - bool certifiedText; - - -}; - - -/*######################################################################### -## LSParser -#########################################################################*/ - -/** - * - */ -class LSParser -{ -public: - - - /** - * - */ - virtual DOMConfiguration *getDomConfig() - { return NULL; } - - /** - * - */ - virtual LSParserFilter *getFilter() - { return filter; } - - /** - * - */ - virtual void setFilter(const LSParserFilter *val) - { filter = const_cast(val); } - - /** - * - */ - virtual bool getAsync() - { return false; } - - /** - * - */ - virtual bool getBusy() - { return false; } - - /** - * - */ - virtual DocumentPtr parse(const LSInput &/*input*/) - throw(dom::DOMException, LSException) - { return NULL; } - - - /** - * - */ - virtual DocumentPtr parseURI(const DOMString &/*uri*/) - throw(dom::DOMException, LSException) - { return NULL; } - - typedef enum - { - ACTION_APPEND_AS_CHILDREN = 1, - ACTION_REPLACE_CHILDREN = 2, - ACTION_INSERT_BEFORE = 3, - ACTION_INSERT_AFTER = 4, - ACTION_REPLACE = 5 - } ActionTypes; - - - /** - * - */ - virtual NodePtr parseWithContext(const LSInput &/*input*/, - const NodePtr /*contextArg*/, - unsigned short /*action*/) - throw(dom::DOMException, LSException) - { return NULL; } - - /** - * - */ - virtual void abort() - {} - - - - //################## - //# Non-API methods - //################## - - /** - * - */ - LSParser() - { - filter = NULL; - } - - /** - * - */ - LSParser(const LSParser &other) - { - filter = other.filter; - } - - /** - * - */ - virtual ~LSParser() {} - -protected: - - LSParserFilter *filter; -}; - - - -/*######################################################################### -## LSResourceResolver -#########################################################################*/ - -/** - * - */ -class LSResourceResolver -{ -public: - - /** - * - */ - virtual LSInput resolveResource(const DOMString &/*type*/, - const DOMString &/*namespaceURI*/, - const DOMString &/*publicId*/, - const DOMString &/*systemId*/, - const DOMString &/*baseURI*/) - { - LSInput input; - //do something - return input; - } - - //################## - //# Non-API methods - //################## - - /** - * - */ - LSResourceResolver() {} - - /** - * - */ - LSResourceResolver(const LSResourceResolver &/*other*/) - { - } - - /** - * - */ - virtual ~LSResourceResolver() {} - - - -}; - -/*######################################################################### -## LSOutput -#########################################################################*/ - -/** - * - */ -class LSOutput -{ -public: - - /** - * - */ - virtual LSWriter *getCharacterStream() const - { return characterStream; } - - /** - * - */ - virtual void setCharacterStream(const LSWriter *val) - { characterStream = (LSWriter *)val; } - - /** - * - */ - virtual LSOutputStream *getByteStream() const - { return byteStream; } - - /** - * - */ - virtual void setByteStream(const LSOutputStream *val) - { byteStream = (LSOutputStream *) val; } - - /** - * - */ - virtual DOMString getSystemId() const - { return systemId; } - - /** - * - */ - virtual void setSystemId(const DOMString &val) - { systemId = val; } - - /** - * - */ - virtual DOMString getEncoding() const - { return encoding; } - - /** - * - */ - virtual void setEncoding(const DOMString &val) - { encoding = val; } - - - //################## - //# Non-API methods - //################## - - /** - * - */ - LSOutput() - { - characterStream = NULL; - byteStream = NULL; - systemId = ""; - encoding = ""; - } - - - /** - * - */ - LSOutput(const LSOutput &other) - { - characterStream = other.characterStream; - byteStream = other.byteStream; - systemId = other.systemId; - encoding = other.encoding; - } - - /** - * - */ - virtual ~LSOutput() - {} - -private: - - LSWriter *characterStream; - LSOutputStream *byteStream; - DOMString systemId; - DOMString encoding; - -}; - - -/*######################################################################### -## LSSerializer -#########################################################################*/ - -/** - * - */ -class LSSerializer -{ -public: - - /** - * - */ - virtual DOMConfiguration *getDomConfig() - { return NULL; } - - /** - * - */ - virtual DOMString getNewLine() - { return newLine; } - /** - * - */ - virtual void setNewLine(const DOMString &val) - { newLine = val; } - - /** - * - */ - virtual LSSerializerFilter *getFilter() - { return filter; } - - /** - * - */ - virtual void setFilter(const LSSerializerFilter *val) - { filter = const_cast(val); } - - /** - * - */ - virtual bool write(const NodePtr /*nodeArg*/, - const LSOutput &/*destination*/) - throw (LSException) - { return false; } - - /** - * - */ - virtual bool writeToURI(const NodePtr /*nodeArg*/, - const DOMString &/*uri*/) - throw(LSException) - { return false; } - - /** - * - */ - virtual DOMString writeToString(const NodePtr /*nodeArg*/) - throw(dom::DOMException, LSException) - { - DOMString str; - return str; - } - - //################## - //# Non-API methods - //################## - - /** - * - */ - LSSerializer() - { - filter = NULL; - newLine = "\n"; - } - - /** - * - */ - LSSerializer(const LSSerializer &other) - { - filter = other.filter; - newLine = other.newLine; - } - - /** - * - */ - virtual ~LSSerializer() {} - -protected: - - LSSerializerFilter *filter; - DOMString newLine; - -}; - -/*######################################################################### -## LSProgressEvent -#########################################################################*/ - -/** - * - */ -class LSProgressEvent : virtual public events::Event -{ -public: - - /** - * - */ - virtual LSInput &getInput() - { - return input; - } - - /** - * - */ - virtual unsigned long getPosition() - { return position; } - - /** - * - */ - virtual unsigned long getTotalSize() - { return totalSize; } - - //################## - //# Non-API methods - //################## - - /** - * - */ - LSProgressEvent(const LSInput &inputArg, unsigned long positionArg, - unsigned long totalSizeArg) : input((LSInput &)inputArg) - { - position = positionArg; - totalSize = totalSizeArg; - } - - - /** - * - */ - LSProgressEvent(const LSProgressEvent &other) - : events::Event(other) , input(other.input) - { - position = other.position; - totalSize = other.totalSize; - } - - - /** - * - */ - virtual ~LSProgressEvent() {} - -protected: - - LSInput &input; - unsigned long position; - unsigned long totalSize; - -}; - -/*######################################################################### -## LSLoadEvent -#########################################################################*/ - -/** - * - */ -class LSLoadEvent : public events::Event -{ -public: - - /** - * - */ - virtual DocumentPtr getNewDocument() - { return newDocument; } - - /** - * - */ - virtual LSInput &getInput() - { return input; } - - //################## - //# Non-API methods - //################## - - /** - * - */ - LSLoadEvent(const LSInput &inputArg, - const DocumentPtr docArg) - : input((LSInput &)inputArg) - { newDocument = docArg; } - - /** - * - */ - LSLoadEvent(const LSLoadEvent &other) - : events::Event(other) , input(other.input) - { - newDocument = other.newDocument; - } - - /** - * - */ - virtual ~LSLoadEvent() {} - -protected: - - DocumentPtr newDocument; - - LSInput &input; - - -}; - - - -/*######################################################################### -## LSSerializerFilter -#########################################################################*/ - -/** - * - */ -class LSSerializerFilter : virtual public traversal::NodeFilter -{ -public: - - /** - * - */ - virtual unsigned long getWhatToShow() =0; - - //################## - //# Non-API methods - //################## - - /** - * - */ - virtual ~LSSerializerFilter() {} -}; - - - - -/*######################################################################### -## DOMImplementationLS -#########################################################################*/ - -/** - * - */ -class DOMImplementationLS -{ -public: - - typedef enum - { - MODE_SYNCHRONOUS = 1, - MODE_ASYNCHRONOUS = 2 - } DOMImplementationLSMode; - - /** - * To use, for this and subclasses: - * LSParser &parser = myImplementation.createLSParser(mode, schemaType); - */ - virtual LSParser &createLSParser(unsigned short mode, - const DOMString &schemaType) - throw (dom::DOMException) =0; - - /** - * To use, for this and subclasses: - * LSSerializer &serializer = myImplementation.createLSSerializer(); - * - */ - virtual LSSerializer &createLSSerializer() =0; - - /** - * - */ - virtual LSInput createLSInput() =0; - - /** - * - */ - virtual LSOutput createLSOutput() =0; - - //################## - //# Non-API methods - //################## - - /** - * - */ - virtual ~DOMImplementationLS() {} -}; - - - - -} //namespace ls -} //namespace dom -} //namespace w3c -} //namespace org - - -#endif // SEEN_LS_H - -/*######################################################################### -## E N D O F F I L E -#########################################################################*/ - diff --git a/src/dom/lsimpl.cpp b/src/dom/lsimpl.cpp deleted file mode 100644 index d4da0d5ce..000000000 --- a/src/dom/lsimpl.cpp +++ /dev/null @@ -1,441 +0,0 @@ -/* - * Phoebe DOM Implementation. - * - * This is a C++ approximation of the W3C DOM model, which follows - * fairly closely the specifications in the various .idl files, copies of - * which are provided for reference. Most important is this one: - * - * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * - * Authors: - * Bob Jamison - * - * Copyright (C) 2005-2007 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "domimpl.h" -#include "events.h" -#include "traversal.h" -#include "lsimpl.h" - -#include -#include - -namespace org -{ -namespace w3c -{ -namespace dom -{ -namespace ls -{ - - - -/*######################################################################### -## LSParserImpl -#########################################################################*/ - - -/** - * - */ -bool LSParserImpl::getBusy() -{ - return false; -} - -/** - * - */ -DocumentPtr LSParserImpl::parse(const LSInput &input) - throw(dom::DOMException, LSException) -{ - - //#### Check the various inputs of 'input' in order, according - //# to the L&S spec - LSReader *lsreader = input.getCharacterStream(); - if (lsreader) - { - DOMString buf; - while (true) - { - int ch = lsreader->get(); - if (ch < 0) - break; - buf.push_back((XMLCh)ch); - } - XmlReader reader; - DocumentPtr doc = reader.parse(buf); - return doc; - } - - LSInputStream *inputStream = input.getByteStream(); - if (inputStream) - { - DOMString buf; - while (true) - { - int ch = inputStream->get(); - if (ch < 0) - break; - buf.push_back((XMLCh)ch); - } - XmlReader reader; - DocumentPtr doc = reader.parse(buf); - return doc; - } - - DOMString stringData = input.getStringData(); - if (stringData.size() > 0) - { - XmlReader reader; - DocumentPtr doc = reader.parse(stringData); - return doc; - } - - DOMString systemId = input.getSystemId(); - if (systemId.size() > 0) - { - //lets not do this yet - return NULL; - } - - DOMString publicId = input.getPublicId(); - if (publicId.size() > 0) - { - //lets not do this yet - return NULL; - } - - return NULL; -} - - -/** - * - */ -DocumentPtr LSParserImpl::parseURI(const DOMString &/*uri*/) - throw(dom::DOMException, LSException) -{ - return NULL; -} - - /** - * - */ -NodePtr LSParserImpl::parseWithContext(const LSInput &/*input*/, - const NodePtr /*contextArg*/, - unsigned short /*action*/) - throw(dom::DOMException, LSException) -{ - return NULL; -} - - - -//################## -//# Non-API methods -//################## - - - - - - - - - - - -/*######################################################################### -## LSSerializerImpl -#########################################################################*/ - - -/** - * - */ -bool LSSerializerImpl::write( - const NodePtr nodeArg, - const LSOutput &destination) - throw (LSException) -{ - outbuf = ""; - indent = 0; - - writeNode(nodeArg); - - //## Check in order specified in the L&S specs - LSWriter *writer = destination.getCharacterStream(); - if (writer) - { - for (unsigned int i=0 ; iput(ch); - } - return true; - } - - LSOutputStream *outputStream = destination.getByteStream(); - if (outputStream) - { - for (unsigned int i=0 ; iput(ch); - } - return true; - } - - DOMString systemId = destination.getSystemId(); - if (systemId.size() > 0) - { - //DO SOMETHING - return true; - } - - return false; -} - -/** - * - */ -bool LSSerializerImpl::writeToURI(const NodePtr nodeArg, - const DOMString &uriArg) - throw(LSException) -{ - outbuf = ""; - indent = 0; - - writeNode(nodeArg); - - DOMString uri = uriArg; - char *fileName = (char *) uri.c_str(); //temporary hack - FILE *f = fopen(fileName, "wb"); - if (!f) - return false; - for (unsigned int i=0 ; i') - outbuf.append(">"); - else if (ch == '"') - outbuf.append("""); - else if (ch == '\'') - outbuf.append("'"); - else - outbuf.push_back(ch); - } -} - -/** - * - */ -void LSSerializerImpl::writeNode(const NodePtr nodeArg) -{ - NodePtr node = nodeArg; - - int type = node->getNodeType(); - - switch (type) - { - - //############# - //# DOCUMENT - //############# - case Node::DOCUMENT_NODE: - { - DocumentPtr doc = dynamic_cast(node.get()); - writeNode(doc->getDocumentElement()); - } - break; - - //############# - //# TEXT - //############# - case Node::TEXT_NODE: - { - poxml(node->getNodeValue()); - } - break; - - - //############# - //# CDATA - //############# - case Node::CDATA_SECTION_NODE: - { - pos("getNodeValue()); - pos("]]>"); - } - break; - - - //############# - //# ELEMENT - //############# - case Node::ELEMENT_NODE: - { - - indent+=2; - - NamedNodeMap attributes = node->getAttributes(); - int nrAttrs = attributes.getLength(); - - //### Start open tag - spaces(); - po("<"); - pos(node->getNodeName()); - //if (nrAttrs>0) - // pos(newLine); - - //### Attributes - for (int i=0 ; igetNodeName()); - po("=\""); - pos(attr->getNodeValue()); - po("\""); - //pos(newLine); - } - - //### Finish open tag - //if (nrAttrs>0) - // spaces(); - po(">"); - //pos(newLine); - - //### Contents - //spaces(); - pos(node->getNodeValue()); - - //### Children - for (NodePtr child = node->getFirstChild() ; - child.get() ; - child=child->getNextSibling()) - { - writeNode(child); - } - - //### Close tag - //spaces(); - po("getNodeName()); - po(">"); - pos(newLine); - - indent-=2; - } - break; - - }//switch - -} - - - - - - - - - - -} //namespace ls -} //namespace dom -} //namespace w3c -} //namespace org - - - - - -/*######################################################################### -## E N D O F F I L E -#########################################################################*/ - diff --git a/src/dom/lsimpl.h b/src/dom/lsimpl.h deleted file mode 100644 index fcfd42a4b..000000000 --- a/src/dom/lsimpl.h +++ /dev/null @@ -1,390 +0,0 @@ -#ifndef SEEN_LSIMPL_H -#define SEEN_LSIMPL_H -/** - * @file - * Phoebe DOM Implementation. - * - * This is a C++ approximation of the W3C DOM model, which follows - * fairly closely the specifications in the various .idl files, copies of - * which are provided for reference. Most important is this one: - * - * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - */ -/* - * Authors: - * Bob Jamison - * - * Copyright (C) 2005-2007 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "domimpl.h" -#include "events.h" -#include "traversal.h" -#include "ls.h" - - -#include "xmlreader.h" - -namespace org -{ -namespace w3c -{ -namespace dom -{ -namespace ls -{ - - -/*######################################################################### -## LSParserImpl -#########################################################################*/ - -/** - * - */ -class LSParserImpl : virtual public LSParser -{ -public: - - typedef enum - { - PARSE_AS_DATA = 0, - PARSE_AS_DOCUMENT = 1 - } ParsingModes; - - /** - * - */ - virtual bool getBusy(); - - /** - * - */ - virtual DocumentPtr parse(const LSInput &input) - throw(dom::DOMException, LSException); - - - /** - * - */ - virtual DocumentPtr parseURI(const DOMString &uri) - throw(dom::DOMException, LSException); - - /** - * - */ - virtual NodePtr parseWithContext(const LSInput &input, - const NodePtr contextArg, - unsigned short action) - throw(dom::DOMException, LSException); - - - //################## - //# Non-API methods - //################## - - /** - * - */ - LSParserImpl() : - reader(), - filter(0) - {} - - /** - * - */ - LSParserImpl(const LSParserImpl &other) : - LSParser(other), - reader(), - filter(0) - {} - - /** - * - */ - virtual ~LSParserImpl() - {} - - - - //################## - //# Internals - //################## - - -protected: - - XmlReader reader; - LSParserFilter *filter; - -}; - - - - -/*######################################################################### -## LSParserFilterImpl -#########################################################################*/ - -/** - * - */ -class LSParserFilterImpl : virtual public LSParserFilter -{ -public: - - /** - * - */ - virtual unsigned short startElement(const ElementPtr /*elementArg*/) - { return 0; } - - /** - * - */ - virtual unsigned short acceptNode(const NodePtr /*nodeArg*/) - { return 0; } - - /** - * - */ - virtual unsigned long getWhatToShow() - { return 0; } - - //################## - //# Non-API methods - //################## - - /** - * - */ - virtual ~LSParserFilterImpl() - {} - - - -}; - -/*######################################################################### -## LSSerializerImpl -#########################################################################*/ - -/** - * - */ -class LSSerializerImpl : virtual public LSSerializer -{ -public: - - - /** - * - */ - virtual bool write(const NodePtr nodeArg, - const LSOutput &destination) - throw (LSException); - - /** - * - */ - virtual bool writeToURI(const NodePtr nodeArg, - const DOMString &uri) - throw(LSException); - - /** - * - */ - virtual DOMString writeToString(const NodePtr nodeArg) - throw(dom::DOMException, LSException); - - //################## - //# Non-API methods - //################## - - /** - * - */ - LSSerializerImpl() : - outbuf(), - indent(0), - domConfig(0), - filter(0) - { - } - - /** - * - */ - virtual ~LSSerializerImpl() - {} - - - -protected: - - /** - * - */ - void writeNode(const NodePtr nodeArg); - -private: - - void spaces(); - - void po(char const *fmt, ...) - #ifdef G_GNUC_PRINTF - G_GNUC_PRINTF(2, 3) - #endif - ; - - void pos(const DOMString &str); - - void poxml(const DOMString &str); - - DOMString outbuf; - - int indent; - - DOMConfiguration *domConfig; - - LSSerializerFilter *filter; - - - -}; - - - - -/*######################################################################### -## LSSerializerFilterImpl -#########################################################################*/ - -/** - * - */ -class LSSerializerFilterImpl : virtual public LSSerializerFilter -{ -public: - - /** - * - */ - virtual unsigned long getWhatToShow() - { return 0; } - - //################## - //# Non-API methods - //################## - - /** - * - */ - virtual ~LSSerializerFilterImpl() - {} -}; - - - -/*######################################################################### -## DOMImplementationLSImpl -#########################################################################*/ - -/** - * - */ -class DOMImplementationLSImpl : virtual public DOMImplementationLS -{ -public: - - /** - * - */ - virtual LSParser &createLSParser(unsigned short /*mode*/, - const DOMString &/*schemaType*/) - throw (dom::DOMException) - { - LSParserImpl newParser; - parser = newParser; - return parser; - } - - - /** - * - */ - virtual LSSerializer &createLSSerializer() - { - LSSerializerImpl newSerializer; - serializer = newSerializer; - return serializer; - } - - - /** - * - */ - virtual LSInput createLSInput() - { - LSInput input; - return input; - } - - /** - * - */ - virtual LSOutput createLSOutput() - { - LSOutput output; - return output; - } - - //################## - //# Non-API methods - //################## - - /** - * - */ - virtual ~DOMImplementationLSImpl() {} - -protected: - - LSParserImpl parser; - LSSerializerImpl serializer; -}; - - - - - - -} //namespace ls -} //namespace dom -} //namespace w3c -} //namespace org - - - - -#endif // SEEN_LSIMPL_H - -/*######################################################################### -## E N D O F F I L E -#########################################################################*/ - diff --git a/src/dom/makefile.in b/src/dom/makefile.in deleted file mode 100644 index b505975a6..000000000 --- a/src/dom/makefile.in +++ /dev/null @@ -1,17 +0,0 @@ -# Convenience stub makefile to call the real Makefile. - -@SET_MAKE@ - -OBJEXT = @OBJEXT@ - -# Explicit so that it's the default rule. -all: - cd .. && $(MAKE) dom/all - -clean %.a %.$(OBJEXT): - cd .. && $(MAKE) dom/$@ - -.PHONY: all clean - -.SUFFIXES: -.SUFFIXES: .a .$(OBJEXT) diff --git a/src/dom/mingwenv.bat b/src/dom/mingwenv.bat deleted file mode 100644 index 48e8bf096..000000000 --- a/src/dom/mingwenv.bat +++ /dev/null @@ -1,2 +0,0 @@ -set PATH=c:\mingw\bin;%PATH% -set RM=del diff --git a/src/dom/prop-css.cpp b/src/dom/prop-css.cpp deleted file mode 100644 index 9922b4935..000000000 --- a/src/dom/prop-css.cpp +++ /dev/null @@ -1,1161 +0,0 @@ -/* - * Phoebe DOM Implementation. - * - * This is a C++ approximation of the W3C DOM model, which follows - * fairly closely the specifications in the various .idl files, copies of - * which are provided for reference. Most important is this one: - * - * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html - * - * Authors: - * Bob Jamison - * - * Copyright (C) 2005 Bob Jamison - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ -#include - - -struct CssProp_def -{ - const char *name; - const char *values; - const char *defaultValue; - const char *appliesTo; - bool inherited; - const char *percentages; - const char *mediaGroups; -}; - -typedef struct CssProp_def CssProp; - -static CssProp cssProps[] = -{ - -{ -"azimuth", -" | [[ left-side | far-left | left | center-left | center | center-right | right | far-right | right-side ] || behind ] | leftwards | rightwards | inherit", -"center", -"", -true, -"", -"aural" -}, - - -{ -"background-attachment", -"scroll | fixed | inherit", -"scroll", -"", -false, -"", -"visual" -}, - - -{ -"background-color", -" | transparent | inherit", -"transparent", -"", -false, -"", -"visual" -}, - - -{ -"background-image", -" | none | inherit", -"none", -"", -false, -"", -"visual" -}, - - -{ -"background-position", -"[ [ | | left | center | right ] [ | | top | center | bottom ]? ] | [ [ left | center | right ] || [ top | center | bottom ] ] | inherit", -"0% 0%", -"", -false, -"refer to the size of the box itself", -"visual" -}, - - -{ -"background-repeat", -"repeat | repeat-x | repeat-y | no-repeat | inherit", -"repeat", -"", -false, -"", -"visual" -}, - - -{ -"background", -"['background-color' || 'background-image' || 'background-repeat' || 'background-attachment' || 'background-position'] | inherit", -"see individual properties", -"", -false, -"allowed on 'background-position", -"visual" -}, - - -{ -"border-collapse", -"collapse | separate | inherit", -"separate", -"table' and 'inline-table' elements", -true, -"", -"visual" -}, - - -{ -"border-color", -"[ | transparent ]{1,4} | inherit", -"see individual properties", -"", -false, -"", -"visual" -}, - - -{ -"border-spacing", -" ? | inherit", -"0", -"table' and 'inline-table' elements", -true, -"", -"visual" -}, - - -{ -"border-style", -"{1,4} | inherit", -"see individual properties", -"", -false, -"", -"visual" -}, - - -{ -"border-top' 'border-right' 'border-bottom' 'border-left", -"[ || || 'border-top-color' ] | inherit", -"see individual properties", -"", -false, -"", -"visual" -}, - - -{ -"border-top-color' 'border-right-color' 'border-bottom-color' 'border-left-color", -" | transparent | inherit", -"the value of the 'color' property", -"", -false, -"", -"visual" -}, - - -{ -"border-top-style' 'border-right-style' 'border-bottom-style' 'border-left-style", -" | inherit", -"none", -"", -false, -"", -"visual" -}, - - -{ -"border-top-width' 'border-right-width' 'border-bottom-width' 'border-left-width", -" | inherit", -"medium", -"", -false, -"", -"visual" -}, - - -{ -"border-width", -"{1,4} | inherit", -"see individual properties", -"", -false, -"", -"visual" -}, - - -{ -"border", -"[ || || 'border-top-color' ] | inherit", -"see individual properties", -"", -false, -"", -"visual" -}, - - -{ -"bottom", -" | | auto | inherit", -"auto", -"positioned elements", -false, -"refer to height of containing block", -"visual" -}, - - -{ -"caption-side", -"top | bottom | inherit", -"top", -"table-caption' elements", -true, -"", -"visual" -}, - - -{ -"clear", -"none | left | right | both | inherit", -"none", -"block-level elements", -false, -"", -"visual" -}, - - -{ -"clip", -" | auto | inherit", -"auto", -"absolutely positioned elements", -false, -"", -"visual" -}, - - -{ -"color", -" | inherit", -"depends on user agent", -"", -true, -"", -"visual" -}, - - -{ -"content", -"normal | [ | | | attr() | open-quote | close-quote | no-open-quote | no-close-quote ]+ | inherit", -"normal", -":before and :after pseudo-elements", -false, -"", -"all " -}, - - -{ -"counter-increment", -"[ ? ]+ | none | inherit", -"none", -"", -false, -"", -"all " -}, - - -{ -"counter-reset", -"[ ? ]+ | none | inherit", -"none", -"", -false, -"", -"all " -}, - - -{ -"cue-after", -" | none | inherit", -"none", -"", -false, -"", -"aural" -}, - - -{ -"cue-before", -" | none | inherit", -"none", -"", -false, -"", -"aural" -}, - - -{ -"cue", -"[ 'cue-before' || 'cue-after' ] | inherit", -"see individual properties", -"", -false, -"", -"aural" -}, - - -{ -"cursor", -"[ [ ,]* [ auto | crosshair | default | pointer | move | e-resize | ne-resize | nw-resize | n-resize | se-resize | sw-resize | s-resize | w-resize | text | wait | help | progress ] ] | inherit", -"auto", -"", -true, -"", -"visual, interactive " -}, - - -{ -"direction", -"ltr | rtl | inherit", -"ltr", -"all elements, but see prose", -true, -"", -"visual" -}, - - -{ -"display", -"inline | block | list-item | run-in | inline-block | table | inline-table | table-row-group | table-header-group | table-footer-group | table-row | table-column-group | table-column | table-cell | table-caption | none | inherit", -"inline", -"", -false, -"", -"all " -}, - - -{ -"elevation", -" | below | level | above | higher | lower | inherit", -"level", -"", -true, -"", -"aural" -}, - - -{ -"empty-cells", -"show | hide | inherit", -"show", -"table-cell' elements", -true, -"", -"visual" -}, - - -{ -"float", -"left | right | none | inherit", -"none", -"all, but see 9.7", -false, -"", -"visual" -}, - - -{ -"font-family", -"[[ | ] [, | ]* ] | inherit", -"depends on user agent", -"", -true, -"", -"visual" -}, - - -{ -"font-size", -" | | | | inherit", -"medium", -"", -true, -"refer to parent element's font size", -"visual" -}, - - -{ -"font-style", -"normal | italic | oblique | inherit", -"normal", -"", -true, -"", -"visual" -}, - - -{ -"font-variant", -"normal | small-caps | inherit", -"normal", -"", -true, -"", -"visual" -}, - - -{ -"font-weight", -"normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | inherit", -"normal", -"", -true, -"", -"visual" -}, - - -{ -"font", -"[ [ 'font-style' || 'font-variant' || 'font-weight' ]? 'font-size' [ / 'line-height' ]? 'font-family' ] | caption | icon | menu | message-box | small-caption | status-bar | inherit", -"see individual properties", -"", -true, -"see individual properties", -"visual" -}, - - -{ -"height", -" | | auto | inherit", -"auto", -"all elements but non-replaced inline elements, table columns, and column groups", -false, -"see prose", -"visual" -}, - - -{ -"left", -" | | auto | inherit", -"auto", -"positioned elements", -false, -"refer to width of containing block", -"visual" -}, - - -{ -"letter-spacing", -"normal | | inherit", -"normal", -"", -true, -"", -"visual" -}, - - -{ -"line-height", -"normal | | | | inherit", -"normal", -"", -true, -"refer to the font size of the element itself", -"visual" -}, - - -{ -"list-style-image", -" | none | inherit", -"none", -"elements with 'display: list-item", -true, -"", -"visual" -}, - - -{ -"list-style-position", -"inside | outside | inherit", -"outside", -"elements with 'display: list-item", -true, -"", -"visual" -}, - - -{ -"list-style-type", -"disc | circle | square | decimal | decimal-leading-zero | lower-roman | upper-roman | lower-greek | lower-latin | upper-latin | armenian | georgian | none | inherit", -"disc", -"elements with 'display: list-item", -true, -"", -"visual" -}, - - -{ -"list-style", -"[ 'list-style-type' || 'list-style-position' || 'list-style-image' ] | inherit", -"see individual properties", -"elements with 'display: list-item", -true, -"", -"visual" -}, - - -{ -"margin-right' 'margin-left", -" | inherit", -"0", -"all elements except elements with table display types other than table and inline-table", -false, -"refer to width of containing block", -"visual" -}, - - -{ -"margin-top' 'margin-bottom", -" | inherit", -"0", -"all elements except elements with table display types other than table and inline-table", -false, -"refer to width of containing block", -"visual" -}, - - -{ -"margin", -"{1,4} | inherit", -"see individual properties", -"all elements except elements with table display types other than table and inline-table", -false, -"refer to width of containing block", -"visual" -}, - - -{ -"max-height", -" | | none | inherit", -"none", -"all elements except non-replaced inline elements and table elements", -false, -"see prose", -"visual" -}, - - -{ -"max-width", -" | | none | inherit", -"none", -"all elements except non-replaced inline elements and table elements", -false, -"refer to width of containing block", -"visual" -}, - - -{ -"min-height", -" | | inherit", -"0", -"all elements except non-replaced inline elements and table elements", -false, -"see prose", -"visual" -}, - - -{ -"min-width", -" | | inherit", -"0", -"all elements except non-replaced inline elements and table elements", -false, -"refer to width of containing block", -"visual" -}, - - -{ -"orphans", -" | inherit", -"2", -"block-level elements", -true, -"", -"visual, paged " -}, - - -{ -"outline-color", -" | invert | inherit", -"invert", -"", -false, -"", -"visual, interactive " -}, - - -{ -"outline-style", -" | inherit", -"none", -"", -false, -"", -"visual, interactive " -}, - - -{ -"outline-width", -" | inherit", -"medium", -"", -false, -"", -"visual, interactive " -}, - - -{ -"outline", -"[ 'outline-color' || 'outline-style' || 'outline-width' ] | inherit", -"see individual properties", -"", -false, -"", -"visual, interactive " -}, - - -{ -"overflow", -"visible | hidden | scroll | auto | inherit", -"visible", -"block-level and replaced elements, table cells, inline blocks", -false, -"", -"visual" -}, - - -{ -"padding-top' 'padding-right' 'padding-bottom' 'padding-left", -" | inherit", -"0", -"all elements except elements with table display types other than table, inline-table, and table-cell", -false, -"refer to width of containing block", -"visual" -}, - - -{ -"padding", -"{1,4} | inherit", -"see individual properties", -"all elements except elements with table display types other than table, inline-table, and table-cell", -false, -"refer to width of containing block", -"visual" -}, - - -{ -"page-break-after", -"auto | always | avoid | left | right | inherit", -"auto", -"block-level elements", -false, -"", -"visual, paged " -}, - - -{ -"page-break-before", -"auto | always | avoid | left | right | inherit", -"auto", -"block-level elements", -false, -"", -"visual, paged " -}, - - -{ -"page-break-inside", -"avoid | auto | inherit", -"auto", -"block-level elements", -true, -"", -"visual, paged " -}, - - -{ -"pause-after", -"\n" //# VALUES HERE - "\n\n"; - - //if (!Glib::get_charset()) //If we are not utf8 + // wrap a rectangle around the image + gint rectX = imgX - 1; + gint rectY = imgY - 1; + gint rectWidth = scaledImgWidth + 2; + gint rectHeight = scaledImgHeight + 2; + + // Our template. Modify to taste + gchar const *xformat = "\n" + "\n" //# VALUES HERE + "\n" + "\n" + "\n" + "%d x %d\n" //# VALUES HERE + "\n\n"; + + // if (!Glib::get_charset()) //If we are not utf8 fileName = Glib::filename_to_utf8(fileName); - //Fill in the template + // Fill in the template /* FIXME: Do proper XML quoting for fileName. */ - gchar *xmlBuffer = g_strdup_printf(xformat, - previewWidth, previewHeight, - imgX, imgY, scaledImgWidth, scaledImgHeight, - fileName.c_str(), - rectX, rectY, rectWidth, rectHeight, - imgWidth, imgHeight); + gchar *xmlBuffer = + g_strdup_printf(xformat, previewWidth, previewHeight, imgX, imgY, scaledImgWidth, scaledImgHeight, + fileName.c_str(), rectX, rectY, rectWidth, rectHeight, imgWidth, imgHeight); - //g_message("%s\n", xmlBuffer); + // g_message("%s\n", xmlBuffer); - //now show it! + // now show it! setFromMem(xmlBuffer); g_free(xmlBuffer); } @@ -313,97 +292,95 @@ void SVGPreview::showImage(Glib::ustring &theFileName) void SVGPreview::showNoPreview() { - //Are we already showing it? + // Are we already showing it? if (showingNoPreview) return; - //Arbitrary size of svg doc -- rather 'portrait' shaped - gint previewWidth = 300; + // Arbitrary size of svg doc -- rather 'portrait' shaped + gint previewWidth = 300; gint previewHeight = 600; - //Our template. Modify to taste + // Our template. Modify to taste gchar const *xformat = - "\n" - "\n" //# VALUES HERE - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - " \n" - "%s\n" //# VALUE HERE - "\n\n"; - - //Fill in the template - gchar *xmlBuffer = g_strdup_printf(xformat, - previewWidth, previewHeight, _("No preview")); - - //g_message("%s\n", xmlBuffer); - - //now show it! + "\n" + "\n" //# VALUES HERE + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + " \n" + "%s\n" //# VALUE HERE + "\n\n"; + + // Fill in the template + gchar *xmlBuffer = g_strdup_printf(xformat, previewWidth, previewHeight, _("No preview")); + + // g_message("%s\n", xmlBuffer); + + // now show it! setFromMem(xmlBuffer); g_free(xmlBuffer); showingNoPreview = true; - } @@ -414,101 +391,99 @@ void SVGPreview::showNoPreview() void SVGPreview::showTooLarge(long fileLength) { - //Arbitrary size of svg doc -- rather 'portrait' shaped - gint previewWidth = 300; + // Arbitrary size of svg doc -- rather 'portrait' shaped + gint previewWidth = 300; gint previewHeight = 600; - //Our template. Modify to taste + // Our template. Modify to taste gchar const *xformat = - "\n" - "\n" //# VALUES HERE - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "%5.1f MB\n" //# VALUE HERE - "%s\n" //# VALUE HERE - "\n\n"; - - //Fill in the template + "\n" + "\n" //# VALUES HERE + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "%5.1f MB\n" //# VALUE HERE + "%s\n" //# VALUE HERE + "\n\n"; + + // Fill in the template double floatFileLength = ((double)fileLength) / 1048576.0; - //printf("%ld %f\n", fileLength, floatFileLength); - gchar *xmlBuffer = g_strdup_printf(xformat, - previewWidth, previewHeight, floatFileLength, - _("too large for preview")); + // printf("%ld %f\n", fileLength, floatFileLength); + gchar *xmlBuffer = + g_strdup_printf(xformat, previewWidth, previewHeight, floatFileLength, _("too large for preview")); - //g_message("%s\n", xmlBuffer); + // g_message("%s\n", xmlBuffer); - //now show it! + // now show it! setFromMem(xmlBuffer); g_free(xmlBuffer); - } bool SVGPreview::set(Glib::ustring &fileName, int dialogType) @@ -525,18 +500,17 @@ bool SVGPreview::set(Glib::ustring &fileName, int dialogType) return false; } - if (Glib::file_test(fileName, Glib::FILE_TEST_IS_REGULAR)) - { + if (Glib::file_test(fileName, Glib::FILE_TEST_IS_REGULAR)) { Glib::ustring fileNameUtf8 = Glib::filename_to_utf8(fileName); - gchar *fName = const_cast(fileNameUtf8.c_str()); // const-cast probably not necessary? (not necessary on Windows version of stat()) + gchar *fName = const_cast( + fileNameUtf8.c_str()); // const-cast probably not necessary? (not necessary on Windows version of stat()) struct stat info; if (g_stat(fName, &info)) // stat returns 0 upon success { g_warning("SVGPreview::set() : %s : %s", fName, strerror(errno)); return false; } - if (info.st_size > 0xA00000L) - { + if (info.st_size > 0xA00000L) { showingNoPreview = false; showTooLarge(info.st_size); return false; @@ -547,8 +521,7 @@ bool SVGPreview::set(Glib::ustring &fileName, int dialogType) Glib::ustring svgz = ".svgz"; if ((dialogType == SVG_TYPES || dialogType == IMPORT_TYPES) && - (hasSuffix(fileName, svg) || hasSuffix(fileName, svgz) ) - ) { + (hasSuffix(fileName, svg) || hasSuffix(fileName, svgz))) { bool retval = setFileName(fileName); showingNoPreview = false; return retval; @@ -566,16 +539,15 @@ bool SVGPreview::set(Glib::ustring &fileName, int dialogType) SVGPreview::SVGPreview() { if (!INKSCAPE) - inkscape_application_init("",false); + inkscape_application_init("", false); document = NULL; viewerGtk = NULL; - set_size_request(150,150); + set_size_request(150, 150); showingNoPreview = false; } SVGPreview::~SVGPreview() { - } @@ -588,32 +560,30 @@ void FileDialogBaseGtk::internalSetup() // Open executable file dialogs don't need the preview panel if (_dialogType != EXE_TYPES) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - bool enablePreview = prefs->getBool( preferenceBase + "/enable_preview", true); + bool enablePreview = prefs->getBool(preferenceBase + "/enable_preview", true); - previewCheckbox.set_label( Glib::ustring(_("Enable preview")) ); - previewCheckbox.set_active( enablePreview ); + previewCheckbox.set_label(Glib::ustring(_("Enable preview"))); + previewCheckbox.set_active(enablePreview); - previewCheckbox.signal_toggled().connect( - sigc::mem_fun(*this, &FileDialogBaseGtk::_previewEnabledCB) ); + previewCheckbox.signal_toggled().connect(sigc::mem_fun(*this, &FileDialogBaseGtk::_previewEnabledCB)); - //Catch selection-changed events, so we can adjust the text widget - signal_update_preview().connect( - sigc::mem_fun(*this, &FileDialogBaseGtk::_updatePreviewCallback) ); + // Catch selection-changed events, so we can adjust the text widget + signal_update_preview().connect(sigc::mem_fun(*this, &FileDialogBaseGtk::_updatePreviewCallback)); //###### Add a preview widget set_preview_widget(svgPreview); - set_preview_widget_active( enablePreview ); - set_use_preview_label (false); + set_preview_widget_active(enablePreview); + set_use_preview_label(false); } } -void FileDialogBaseGtk::cleanup( bool showConfirmed ) +void FileDialogBaseGtk::cleanup(bool showConfirmed) { if (_dialogType != EXE_TYPES) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - if ( showConfirmed ) { - prefs->setBool( preferenceBase + "/enable_preview", previewCheckbox.get_active() ); + if (showConfirmed) { + prefs->setBool(preferenceBase + "/enable_preview", previewCheckbox.get_active()); } } } @@ -623,7 +593,7 @@ void FileDialogBaseGtk::_previewEnabledCB() { bool enabled = previewCheckbox.get_active(); set_preview_widget_active(enabled); - if ( enabled ) { + if (enabled) { _updatePreviewCallback(); } else { // Clears out any current preview image. @@ -642,12 +612,12 @@ void FileDialogBaseGtk::_updatePreviewCallback() bool enabled = previewCheckbox.get_active(); #ifdef WITH_GNOME_VFS - if ( fileName.empty() && gnome_vfs_initialized() ) { + if (fileName.empty() && gnome_vfs_initialized()) { fileName = get_preview_uri(); } #endif - if ( enabled && !fileName.empty() ) { + if (enabled && !fileName.empty()) { svgPreview.set(fileName, _dialogType); } else { svgPreview.showNoPreview(); @@ -662,11 +632,9 @@ void FileDialogBaseGtk::_updatePreviewCallback() /** * Constructor. Not called directly. Use the factory. */ -FileOpenDialogImplGtk::FileOpenDialogImplGtk(Gtk::Window& parentWindow, - const Glib::ustring &dir, - FileDialogType fileTypes, - const Glib::ustring &title) : - FileDialogBaseGtk(parentWindow, title, Gtk::FILE_CHOOSER_ACTION_OPEN, fileTypes, "/dialogs/open") +FileOpenDialogImplGtk::FileOpenDialogImplGtk(Gtk::Window &parentWindow, const Glib::ustring &dir, + FileDialogType fileTypes, const Glib::ustring &title) + : FileDialogBaseGtk(parentWindow, title, Gtk::FILE_CHOOSER_ACTION_OPEN, fileTypes, "/dialogs/open") { @@ -699,7 +667,8 @@ FileOpenDialogImplGtk::FileOpenDialogImplGtk(Gtk::Window& parentWindow, Glib::ustring::size_type len = udir.length(); // leaving a trailing backslash on the directory name leads to the infamous // double-directory bug on win32 - if (len != 0 && udir[len - 1] == '\\') udir.erase(len - 1); + if (len != 0 && udir[len - 1] == '\\') + udir.erase(len - 1); if (_dialogType == EXE_TYPES) { set_filename(udir.c_str()); } else { @@ -708,21 +677,18 @@ FileOpenDialogImplGtk::FileOpenDialogImplGtk(Gtk::Window& parentWindow, } if (_dialogType != EXE_TYPES) { - set_extra_widget( previewCheckbox ); + set_extra_widget(previewCheckbox); } //###### Add the file types menu createFilterMenu(); add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); - set_default(*add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK)); + set_default(*add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK)); //###### Allow easy access to our examples folder - if ( Inkscape::IO::file_test(INKSCAPE_EXAMPLESDIR, G_FILE_TEST_EXISTS) - && Inkscape::IO::file_test(INKSCAPE_EXAMPLESDIR, G_FILE_TEST_IS_DIR) - && g_path_is_absolute(INKSCAPE_EXAMPLESDIR) - ) - { + if (Inkscape::IO::file_test(INKSCAPE_EXAMPLESDIR, G_FILE_TEST_EXISTS) && + Inkscape::IO::file_test(INKSCAPE_EXAMPLESDIR, G_FILE_TEST_IS_DIR) && g_path_is_absolute(INKSCAPE_EXAMPLESDIR)) { add_shortcut_folder(INKSCAPE_EXAMPLESDIR); } } @@ -732,23 +698,22 @@ FileOpenDialogImplGtk::FileOpenDialogImplGtk(Gtk::Window& parentWindow, */ FileOpenDialogImplGtk::~FileOpenDialogImplGtk() { - } void FileOpenDialogImplGtk::addFilterMenu(Glib::ustring name, Glib::ustring pattern) { #if WITH_GTKMM_3_0 - Glib::RefPtr allFilter = Gtk::FileFilter::create(); - allFilter->set_name(_(name.c_str())); - allFilter->add_pattern(pattern); + Glib::RefPtr allFilter = Gtk::FileFilter::create(); + allFilter->set_name(_(name.c_str())); + allFilter->add_pattern(pattern); #else - Gtk::FileFilter allFilter; - allFilter.set_name(_(name.c_str())); - allFilter.add_pattern(pattern); + Gtk::FileFilter allFilter; + allFilter.set_name(_(name.c_str())); + allFilter.add_pattern(pattern); #endif - extensionMap[Glib::ustring(_("All Files"))]=NULL; - add_filter(allFilter); + extensionMap[Glib::ustring(_("All Files"))] = NULL; + add_filter(allFilter); } void FileOpenDialogImplGtk::createFilterMenu() @@ -767,68 +732,69 @@ void FileOpenDialogImplGtk::createFilterMenu() allFilter.set_name(_("All Files")); allFilter.add_pattern("*"); #endif - extensionMap[Glib::ustring(_("All Files"))]=NULL; + extensionMap[Glib::ustring(_("All Files"))] = NULL; add_filter(allFilter); } else { #if WITH_GTKMM_3_0 Glib::RefPtr allInkscapeFilter = Gtk::FileFilter::create(); allInkscapeFilter->set_name(_("All Inkscape Files")); - - Glib::RefPtr allFilter = Gtk::FileFilter::create(); + + Glib::RefPtr allFilter = Gtk::FileFilter::create(); allFilter->set_name(_("All Files")); allFilter->add_pattern("*"); - - Glib::RefPtr allImageFilter = Gtk::FileFilter::create(); + + Glib::RefPtr allImageFilter = Gtk::FileFilter::create(); allImageFilter->set_name(_("All Images")); - - Glib::RefPtr allVectorFilter = Gtk::FileFilter::create(); + + Glib::RefPtr allVectorFilter = Gtk::FileFilter::create(); allVectorFilter->set_name(_("All Vectors")); - - Glib::RefPtr allBitmapFilter = Gtk::FileFilter::create(); + + Glib::RefPtr allBitmapFilter = Gtk::FileFilter::create(); allBitmapFilter->set_name(_("All Bitmaps")); #else Gtk::FileFilter allInkscapeFilter; allInkscapeFilter.set_name(_("All Inkscape Files")); - - Gtk::FileFilter allFilter; + + Gtk::FileFilter allFilter; allFilter.set_name(_("All Files")); allFilter.add_pattern("*"); - - Gtk::FileFilter allImageFilter; + + Gtk::FileFilter allImageFilter; allImageFilter.set_name(_("All Images")); - - Gtk::FileFilter allVectorFilter; + + Gtk::FileFilter allVectorFilter; allVectorFilter.set_name(_("All Vectors")); - - Gtk::FileFilter allBitmapFilter; + + Gtk::FileFilter allBitmapFilter; allBitmapFilter.set_name(_("All Bitmaps")); #endif - extensionMap[Glib::ustring(_("All Inkscape Files"))]=NULL; + extensionMap[Glib::ustring(_("All Inkscape Files"))] = NULL; add_filter(allInkscapeFilter); - extensionMap[Glib::ustring(_("All Files"))]=NULL; + extensionMap[Glib::ustring(_("All Files"))] = NULL; add_filter(allFilter); - - extensionMap[Glib::ustring(_("All Images"))]=NULL; + + extensionMap[Glib::ustring(_("All Images"))] = NULL; add_filter(allImageFilter); - extensionMap[Glib::ustring(_("All Vectors"))]=NULL; + extensionMap[Glib::ustring(_("All Vectors"))] = NULL; add_filter(allVectorFilter); - extensionMap[Glib::ustring(_("All Bitmaps"))]=NULL; + extensionMap[Glib::ustring(_("All Bitmaps"))] = NULL; add_filter(allBitmapFilter); - //patterns added dynamically below + // patterns added dynamically below Inkscape::Extension::DB::InputList extension_list; Inkscape::Extension::db.get_input_list(extension_list); for (Inkscape::Extension::DB::InputList::iterator current_item = extension_list.begin(); current_item != extension_list.end(); ++current_item) { - Inkscape::Extension::Input * imod = *current_item; + Inkscape::Extension::Input *imod = *current_item; // FIXME: would be nice to grey them out instead of not listing them - if (imod->deactivated()) continue; + if (imod->deactivated()) + continue; Glib::ustring upattern("*"); Glib::ustring extension = imod->get_extension(); @@ -837,7 +803,7 @@ void FileOpenDialogImplGtk::createFilterMenu() Glib::ustring uname(_(imod->get_filetypename())); #if WITH_GTKMM_3_0 - Glib::RefPtr filter = Gtk::FileFilter::create(); + Glib::RefPtr filter = Gtk::FileFilter::create(); filter->set_name(uname); filter->add_pattern(upattern); #else @@ -849,14 +815,14 @@ void FileOpenDialogImplGtk::createFilterMenu() add_filter(filter); extensionMap[uname] = imod; - //g_message("ext %s:%s '%s'\n", ioext->name, ioext->mimetype, upattern.c_str()); +// g_message("ext %s:%s '%s'\n", ioext->name, ioext->mimetype, upattern.c_str()); #if WITH_GTKMM_3_0 allInkscapeFilter->add_pattern(upattern); - if ( strncmp("image", imod->get_mimetype(), 5)==0 ) + if (strncmp("image", imod->get_mimetype(), 5) == 0) allImageFilter->add_pattern(upattern); #else allInkscapeFilter.add_pattern(upattern); - if ( strncmp("image", imod->get_mimetype(), 5)==0 ) + if (strncmp("image", imod->get_mimetype(), 5) == 0) allImageFilter.add_pattern(upattern); #endif @@ -864,32 +830,32 @@ void FileOpenDialogImplGtk::createFilterMenu() // g_print ("%s\n", imod->get_mimetype()); // I don't know of any other way to define "bitmap" formats other than by listing them - if ( - strncmp("image/png", imod->get_mimetype(), 9)==0 || - strncmp("image/jpeg", imod->get_mimetype(), 10)==0 || - strncmp("image/gif", imod->get_mimetype(), 9)==0 || - strncmp("image/x-icon", imod->get_mimetype(), 12)==0 || - strncmp("image/x-navi-animation", imod->get_mimetype(), 22)==0 || - strncmp("image/x-cmu-raster", imod->get_mimetype(), 18)==0 || - strncmp("image/x-xpixmap", imod->get_mimetype(), 15)==0 || - strncmp("image/bmp", imod->get_mimetype(), 9)==0 || - strncmp("image/vnd.wap.wbmp", imod->get_mimetype(), 18)==0 || - strncmp("image/tiff", imod->get_mimetype(), 10)==0 || - strncmp("image/x-xbitmap", imod->get_mimetype(), 15)==0 || - strncmp("image/x-tga", imod->get_mimetype(), 11)==0 || - strncmp("image/x-pcx", imod->get_mimetype(), 11)==0 - ) + if (strncmp("image/png", imod->get_mimetype(), 9) == 0 || + strncmp("image/jpeg", imod->get_mimetype(), 10) == 0 || + strncmp("image/gif", imod->get_mimetype(), 9) == 0 || + strncmp("image/x-icon", imod->get_mimetype(), 12) == 0 || + strncmp("image/x-navi-animation", imod->get_mimetype(), 22) == 0 || + strncmp("image/x-cmu-raster", imod->get_mimetype(), 18) == 0 || + strncmp("image/x-xpixmap", imod->get_mimetype(), 15) == 0 || + strncmp("image/bmp", imod->get_mimetype(), 9) == 0 || + strncmp("image/vnd.wap.wbmp", imod->get_mimetype(), 18) == 0 || + strncmp("image/tiff", imod->get_mimetype(), 10) == 0 || + strncmp("image/x-xbitmap", imod->get_mimetype(), 15) == 0 || + strncmp("image/x-tga", imod->get_mimetype(), 11) == 0 || + strncmp("image/x-pcx", imod->get_mimetype(), 11) == 0) + { #if WITH_GTKMM_3_0 allBitmapFilter->add_pattern(upattern); #else allBitmapFilter.add_pattern(upattern); #endif - else + } else { #if WITH_GTKMM_3_0 allVectorFilter->add_pattern(upattern); #else allVectorFilter.add_pattern(upattern); #endif + } } } return; @@ -898,50 +864,43 @@ void FileOpenDialogImplGtk::createFilterMenu() /** * Show this dialog modally. Return true if user hits [OK] */ -bool -FileOpenDialogImplGtk::show() +bool FileOpenDialogImplGtk::show() { - set_modal (TRUE); //Window - sp_transientize(GTK_WIDGET(gobj())); //Make transient - gint b = run(); //Dialog + set_modal(TRUE); // Window + sp_transientize(GTK_WIDGET(gobj())); // Make transient + gint b = run(); // Dialog svgPreview.showNoPreview(); hide(); - if (b == Gtk::RESPONSE_OK) - { - //This is a hack, to avoid the warning messages that - //Gtk::FileChooser::get_filter() returns - //should be: Gtk::FileFilter *filter = get_filter(); + if (b == Gtk::RESPONSE_OK) { + // This is a hack, to avoid the warning messages that + // Gtk::FileChooser::get_filter() returns + // should be: Gtk::FileFilter *filter = get_filter(); GtkFileChooser *gtkFileChooser = Gtk::FileChooser::gobj(); GtkFileFilter *filter = gtk_file_chooser_get_filter(gtkFileChooser); - if (filter) - { - //Get which extension was chosen, if any + if (filter) { + // Get which extension was chosen, if any extension = extensionMap[gtk_file_filter_get_name(filter)]; - } + } myFilename = get_filename(); #ifdef WITH_GNOME_VFS if (myFilename.empty() && gnome_vfs_initialized()) myFilename = get_uri(); #endif - cleanup( true ); - return TRUE; - } - else - { - cleanup( false ); - return FALSE; - } + cleanup(true); + return true; + } else { + cleanup(false); + return false; + } } - /** * Get the file extension type that was selected by the user. Valid after an [OK] */ -Inkscape::Extension::Extension * -FileOpenDialogImplGtk::getSelectionType() +Inkscape::Extension::Extension *FileOpenDialogImplGtk::getSelectionType() { return extension; } @@ -950,8 +909,7 @@ FileOpenDialogImplGtk::getSelectionType() /** * Get the file name chosen by the user. Valid after an [OK] */ -Glib::ustring -FileOpenDialogImplGtk::getFilename (void) +Glib::ustring FileOpenDialogImplGtk::getFilename(void) { return myFilename; } @@ -960,7 +918,7 @@ FileOpenDialogImplGtk::getFilename (void) /** * To Get Multiple filenames selected at-once. */ -std::vectorFileOpenDialogImplGtk::getFilenames() +std::vector FileOpenDialogImplGtk::getFilenames() { #if WITH_GTKMM_3_0 std::vector result_tmp = get_filenames(); @@ -968,9 +926,8 @@ std::vectorFileOpenDialogImplGtk::getFilenames() // Copy filenames to a vector of type Glib::ustring std::vector result; - for (std::vector::iterator it = result_tmp.begin(); - it != result_tmp.end(); ++it) - result.push_back(*it); + for (std::vector::iterator it = result_tmp.begin(); it != result_tmp.end(); ++it) + result.push_back(*it); #else std::vector result = get_filenames(); @@ -990,7 +947,6 @@ Glib::ustring FileOpenDialogImplGtk::getCurrentDirectory() - //######################################################################## //# F I L E S A V E //######################################################################## @@ -998,16 +954,14 @@ Glib::ustring FileOpenDialogImplGtk::getCurrentDirectory() /** * Constructor */ -FileSaveDialogImplGtk::FileSaveDialogImplGtk( Gtk::Window &parentWindow, - const Glib::ustring &dir, - FileDialogType fileTypes, - const Glib::ustring &title, - const Glib::ustring &/*default_key*/, - const gchar* docTitle, - const Inkscape::Extension::FileSaveMethod save_method) : - FileDialogBaseGtk(parentWindow, title, Gtk::FILE_CHOOSER_ACTION_SAVE, fileTypes, - (save_method == Inkscape::Extension::FILE_SAVE_METHOD_SAVE_COPY) ? "/dialogs/save_copy" : "/dialogs/save_as"), - save_method(save_method) +FileSaveDialogImplGtk::FileSaveDialogImplGtk(Gtk::Window &parentWindow, const Glib::ustring &dir, + FileDialogType fileTypes, const Glib::ustring &title, + const Glib::ustring & /*default_key*/, const gchar *docTitle, + const Inkscape::Extension::FileSaveMethod save_method) + : FileDialogBaseGtk(parentWindow, title, Gtk::FILE_CHOOSER_ACTION_SAVE, fileTypes, + (save_method == Inkscape::Extension::FILE_SAVE_METHOD_SAVE_COPY) ? "/dialogs/save_copy" + : "/dialogs/save_as") + , save_method(save_method) { FileSaveDialog::myDocTitle = docTitle; @@ -1029,18 +983,19 @@ FileSaveDialogImplGtk::FileSaveDialogImplGtk( Gtk::Window &parentWindow, _dialogType = fileTypes; /* Set the pwd and/or the filename */ - if (dir.size() > 0) - { + if (dir.size() > 0) { Glib::ustring udir(dir); Glib::ustring::size_type len = udir.length(); // leaving a trailing backslash on the directory name leads to the infamous // double-directory bug on win32 - if (len != 0 && udir[len - 1] == '\\') udir.erase(len - 1); - myFilename = udir; + if ((len != 0) && (udir[len - 1] == '\\')) { + udir.erase(len - 1); } + myFilename = udir; + } //###### Add the file types menu - //createFilterMenu(); + // createFilterMenu(); //###### Do we want the .xxx extension automatically added? Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -1054,60 +1009,54 @@ FileSaveDialogImplGtk::FileSaveDialogImplGtk( Gtk::Window &parentWindow, if (_dialogType != CUSTOM_TYPE) createFileTypeMenu(); - fileTypeComboBox.set_size_request(200,40); - fileTypeComboBox.signal_changed().connect( - sigc::mem_fun(*this, &FileSaveDialogImplGtk::fileTypeChangedCallback) ); + fileTypeComboBox.set_size_request(200, 40); + fileTypeComboBox.signal_changed().connect(sigc::mem_fun(*this, &FileSaveDialogImplGtk::fileTypeChangedCallback)); - childBox.pack_start( checksBox ); - childBox.pack_end( fileTypeComboBox ); - checksBox.pack_start( fileTypeCheckbox ); - checksBox.pack_start( previewCheckbox ); + childBox.pack_start(checksBox); + childBox.pack_end(fileTypeComboBox); + checksBox.pack_start(fileTypeCheckbox); + checksBox.pack_start(previewCheckbox); - set_extra_widget( childBox ); + set_extra_widget(childBox); - //Let's do some customization + // Let's do some customization fileNameEntry = NULL; Gtk::Container *cont = get_toplevel(); std::vector entries; findEntryWidgets(cont, entries); - //g_message("Found %d entry widgets\n", entries.size()); - if (!entries.empty()) - { - //Catch when user hits [return] on the text field + // g_message("Found %d entry widgets\n", entries.size()); + if (!entries.empty()) { + // Catch when user hits [return] on the text field fileNameEntry = entries[0]; fileNameEntry->signal_activate().connect( - sigc::mem_fun(*this, &FileSaveDialogImplGtk::fileNameEntryChangedCallback) ); - } + sigc::mem_fun(*this, &FileSaveDialogImplGtk::fileNameEntryChangedCallback)); + } - //Let's do more customization + // Let's do more customization std::vector expanders; findExpanderWidgets(cont, expanders); - //g_message("Found %d expander widgets\n", expanders.size()); - if (!expanders.empty()) - { - //Always show the file list + // g_message("Found %d expander widgets\n", expanders.size()); + if (!expanders.empty()) { + // Always show the file list Gtk::Expander *expander = expanders[0]; expander->set_expanded(true); - } + } // allow easy access to the user's own templates folder - gchar *templates = profile_path ("templates"); - if ( Inkscape::IO::file_test(templates, G_FILE_TEST_EXISTS) - && Inkscape::IO::file_test(templates, G_FILE_TEST_IS_DIR) - && g_path_is_absolute(templates) - ) - { + gchar *templates = profile_path("templates"); + if (Inkscape::IO::file_test(templates, G_FILE_TEST_EXISTS) && + Inkscape::IO::file_test(templates, G_FILE_TEST_IS_DIR) && g_path_is_absolute(templates)) { add_shortcut_folder(templates); } - g_free (templates); + g_free(templates); - //if (extension == NULL) + // if (extension == NULL) // checkbox.set_sensitive(FALSE); add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); - set_default(*add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK)); + set_default(*add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK)); show_all_children(); } @@ -1128,27 +1077,27 @@ void FileSaveDialogImplGtk::fileNameEntryChangedCallback() return; Glib::ustring fileName = fileNameEntry->get_text(); - if (!Glib::get_charset()) //If we are not utf8 + if (!Glib::get_charset()) // If we are not utf8 fileName = Glib::filename_to_utf8(fileName); - //g_message("User hit return. Text is '%s'\n", fileName.c_str()); + // g_message("User hit return. Text is '%s'\n", fileName.c_str()); if (!Glib::path_is_absolute(fileName)) { - //try appending to the current path + // try appending to the current path // not this way: fileName = get_current_folder() + "/" + fileName; std::vector pathSegments; - pathSegments.push_back( get_current_folder() ); - pathSegments.push_back( fileName ); + pathSegments.push_back(get_current_folder()); + pathSegments.push_back(fileName); fileName = Glib::build_filename(pathSegments); } - //g_message("path:'%s'\n", fileName.c_str()); + // g_message("path:'%s'\n", fileName.c_str()); if (Glib::file_test(fileName, Glib::FILE_TEST_IS_DIR)) { set_current_folder(fileName); - } else if (/*Glib::file_test(fileName, Glib::FILE_TEST_IS_REGULAR)*/1) { - //dialog with either (1) select a regular file or (2) cd to dir - //simulate an 'OK' + } else if (/*Glib::file_test(fileName, Glib::FILE_TEST_IS_REGULAR)*/ 1) { + // dialog with either (1) select a regular file or (2) cd to dir + // simulate an 'OK' set_filename(fileName); response(Gtk::RESPONSE_OK); } @@ -1162,10 +1111,11 @@ void FileSaveDialogImplGtk::fileNameEntryChangedCallback() void FileSaveDialogImplGtk::fileTypeChangedCallback() { int sel = fileTypeComboBox.get_active_row_number(); - if (sel<0 || sel >= (int)fileTypes.size()) + if ((sel < 0) || (sel >= (int)fileTypes.size())) return; + FileType type = fileTypes[sel]; - //g_message("selected: %s\n", type.name.c_str()); + // g_message("selected: %s\n", type.name.c_str()); extension = type.extension; #if WITH_GTKMM_3_0 @@ -1192,7 +1142,7 @@ void FileSaveDialogImplGtk::addFileType(Glib::ustring name, Glib::ustring patter fileTypeComboBox.set_active(0); - fileTypeChangedCallback(); //call at least once to set the filter + fileTypeChangedCallback(); // call at least once to set the filter } void FileSaveDialogImplGtk::createFileTypeMenu() @@ -1202,20 +1152,20 @@ void FileSaveDialogImplGtk::createFileTypeMenu() knownExtensions.clear(); for (Inkscape::Extension::DB::OutputList::iterator current_item = extension_list.begin(); - current_item != extension_list.end(); ++current_item) - { - Inkscape::Extension::Output * omod = *current_item; + current_item != extension_list.end(); ++current_item) { + Inkscape::Extension::Output *omod = *current_item; // FIXME: would be nice to grey them out instead of not listing them - if (omod->deactivated()) continue; + if (omod->deactivated()) + continue; FileType type; - type.name = (_(omod->get_filetypename())); - type.pattern = "*"; + type.name = (_(omod->get_filetypename())); + type.pattern = "*"; Glib::ustring extension = omod->get_extension(); - knownExtensions.insert( extension.casefold() ); - fileDialogExtensionToPattern (type.pattern, extension); - type.extension= omod; + knownExtensions.insert(extension.casefold()); + fileDialogExtensionToPattern(type.pattern, extension); + type.extension = omod; fileTypeComboBox.append(type.name); fileTypes.push_back(type); } @@ -1230,23 +1180,20 @@ void FileSaveDialogImplGtk::createFileTypeMenu() fileTypeComboBox.set_active(0); - fileTypeChangedCallback(); //call at least once to set the filter + fileTypeChangedCallback(); // call at least once to set the filter } - - /** * Show this dialog modally. Return true if user hits [OK] */ -bool -FileSaveDialogImplGtk::show() +bool FileSaveDialogImplGtk::show() { change_path(myFilename); - set_modal (TRUE); //Window - sp_transientize(GTK_WIDGET(gobj())); //Make transient - gint b = run(); //Dialog + set_modal(TRUE); // Window + sp_transientize(GTK_WIDGET(gobj())); // Make transient + gint b = run(); // Dialog svgPreview.showNoPreview(); set_preview_widget_active(false); hide(); @@ -1254,7 +1201,7 @@ FileSaveDialogImplGtk::show() if (b == Gtk::RESPONSE_OK) { updateNameAndExtension(); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - + // Store changes of the "Append filename automatically" checkbox back to preferences. if (save_method == Inkscape::Extension::FILE_SAVE_METHOD_SAVE_COPY) { prefs->setBool("/dialogs/save_copy/append_extension", fileTypeCheckbox.get_active()); @@ -1262,14 +1209,14 @@ FileSaveDialogImplGtk::show() prefs->setBool("/dialogs/save_as/append_extension", fileTypeCheckbox.get_active()); } - Inkscape::Extension::store_file_extension_in_prefs ((extension != NULL ? extension->get_id() : "" ), save_method); + Inkscape::Extension::store_file_extension_in_prefs((extension != NULL ? extension->get_id() : ""), save_method); - cleanup( true ); + cleanup(true); - return TRUE; + return true; } else { - cleanup( false ); - return FALSE; + cleanup(false); + return false; } } @@ -1277,23 +1224,22 @@ FileSaveDialogImplGtk::show() /** * Get the file extension type that was selected by the user. Valid after an [OK] */ -Inkscape::Extension::Extension * -FileSaveDialogImplGtk::getSelectionType() +Inkscape::Extension::Extension *FileSaveDialogImplGtk::getSelectionType() { return extension; } -void FileSaveDialogImplGtk::setSelectionType( Inkscape::Extension::Extension * key ) +void FileSaveDialogImplGtk::setSelectionType(Inkscape::Extension::Extension *key) { // If no pointer to extension is passed in, look up based on filename extension. - if ( !key ) { + if (!key) { // Not quite UTF-8 here. gchar *filenameLower = g_ascii_strdown(myFilename.c_str(), -1); - for ( int i = 0; !key && (i < (int)fileTypes.size()); i++ ) { - Inkscape::Extension::Output *ext = dynamic_cast(fileTypes[i].extension); - if ( ext && ext->get_extension() ) { - gchar *extensionLower = g_ascii_strdown( ext->get_extension(), -1 ); - if ( g_str_has_suffix(filenameLower, extensionLower) ) { + for (int i = 0; !key && (i < (int)fileTypes.size()); i++) { + Inkscape::Extension::Output *ext = dynamic_cast(fileTypes[i].extension); + if (ext && ext->get_extension()) { + gchar *extensionLower = g_ascii_strdown(ext->get_extension(), -1); + if (g_str_has_suffix(filenameLower, extensionLower)) { key = fileTypes[i].extension; } g_free(extensionLower); @@ -1303,17 +1249,17 @@ void FileSaveDialogImplGtk::setSelectionType( Inkscape::Extension::Extension * k } // Ensure the proper entry in the combo box is selected. - if ( key ) { + if (key) { extension = key; - gchar const * extensionID = extension->get_id(); - if ( extensionID ) { - for ( int i = 0; i < (int)fileTypes.size(); i++ ) { + gchar const *extensionID = extension->get_id(); + if (extensionID) { + for (int i = 0; i < (int)fileTypes.size(); i++) { Inkscape::Extension::Extension *ext = fileTypes[i].extension; - if ( ext ) { - gchar const * id = ext->get_id(); - if ( id && ( strcmp(extensionID, id) == 0) ) { + if (ext) { + gchar const *id = ext->get_id(); + if (id && (strcmp(extensionID, id) == 0)) { int oldSel = fileTypeComboBox.get_active_row_number(); - if ( i != oldSel ) { + if (i != oldSel) { fileTypeComboBox.set_active(i); } break; @@ -1339,32 +1285,34 @@ FileSaveDialogImplGtk::change_title(const Glib::ustring& title) /** * Change the default save path location. */ -void -FileSaveDialogImplGtk::change_path(const Glib::ustring& path) +void FileSaveDialogImplGtk::change_path(const Glib::ustring &path) { myFilename = path; if (Glib::file_test(myFilename, Glib::FILE_TEST_IS_DIR)) { - //fprintf(stderr,"set_current_folder(%s)\n",myFilename.c_str()); + // fprintf(stderr,"set_current_folder(%s)\n",myFilename.c_str()); set_current_folder(myFilename); } else { - //fprintf(stderr,"set_filename(%s)\n",myFilename.c_str()); - if ( Glib::file_test( myFilename, Glib::FILE_TEST_EXISTS ) ) { + // fprintf(stderr,"set_filename(%s)\n",myFilename.c_str()); + if (Glib::file_test(myFilename, Glib::FILE_TEST_EXISTS)) { set_filename(myFilename); } else { - std::string dirName = Glib::path_get_dirname( myFilename ); - if ( dirName != get_current_folder() ) { + std::string dirName = Glib::path_get_dirname(myFilename); + if (dirName != get_current_folder()) { set_current_folder(dirName); } } Glib::ustring basename = Glib::path_get_basename(myFilename); - //fprintf(stderr,"set_current_name(%s)\n",basename.c_str()); - try { - set_current_name( Glib::filename_to_utf8(basename) ); - } catch ( Glib::ConvertError& e ) { - g_warning( "Error converting save filename to UTF-8." ); + // fprintf(stderr,"set_current_name(%s)\n",basename.c_str()); + try + { + set_current_name(Glib::filename_to_utf8(basename)); + } + catch (Glib::ConvertError &e) + { + g_warning("Error converting save filename to UTF-8."); // try a fallback. - set_current_name( basename ); + set_current_name(basename); } } } @@ -1374,16 +1322,16 @@ void FileSaveDialogImplGtk::updateNameAndExtension() // Pick up any changes the user has typed in. Glib::ustring tmp = get_filename(); #ifdef WITH_GNOME_VFS - if ( tmp.empty() && gnome_vfs_initialized() ) { + if (tmp.empty() && gnome_vfs_initialized()) { tmp = get_uri(); } #endif - if ( !tmp.empty() ) { + if (!tmp.empty()) { myFilename = tmp; } - Inkscape::Extension::Output* newOut = extension ? dynamic_cast(extension) : 0; - if ( fileTypeCheckbox.get_active() && newOut ) { + Inkscape::Extension::Output *newOut = extension ? dynamic_cast(extension) : 0; + if (fileTypeCheckbox.get_active() && newOut) { // Append the file extension if it's not already present and display it in the file name entry field appendExtension(myFilename, newOut); change_path(myFilename); @@ -1406,27 +1354,27 @@ void FileExportDialogImpl::fileNameEntryChangedCallback() return; Glib::ustring fileName = fileNameEntry->get_text(); - if (!Glib::get_charset()) //If we are not utf8 + if (!Glib::get_charset()) // If we are not utf8 fileName = Glib::filename_to_utf8(fileName); - //g_message("User hit return. Text is '%s'\n", fileName.c_str()); + // g_message("User hit return. Text is '%s'\n", fileName.c_str()); if (!Glib::path_is_absolute(fileName)) { - //try appending to the current path + // try appending to the current path // not this way: fileName = get_current_folder() + "/" + fileName; std::vector pathSegments; - pathSegments.push_back( get_current_folder() ); - pathSegments.push_back( fileName ); + pathSegments.push_back(get_current_folder()); + pathSegments.push_back(fileName); fileName = Glib::build_filename(pathSegments); } - //g_message("path:'%s'\n", fileName.c_str()); + // g_message("path:'%s'\n", fileName.c_str()); if (Glib::file_test(fileName, Glib::FILE_TEST_IS_DIR)) { set_current_folder(fileName); - } else if (/*Glib::file_test(fileName, Glib::FILE_TEST_IS_REGULAR)*/1) { - //dialog with either (1) select a regular file or (2) cd to dir - //simulate an 'OK' + } else if (/*Glib::file_test(fileName, Glib::FILE_TEST_IS_REGULAR)*/ 1) { + // dialog with either (1) select a regular file or (2) cd to dir + // simulate an 'OK' set_filename(fileName); response(Gtk::RESPONSE_OK); } @@ -1440,10 +1388,11 @@ void FileExportDialogImpl::fileNameEntryChangedCallback() void FileExportDialogImpl::fileTypeChangedCallback() { int sel = fileTypeComboBox.get_active_row_number(); - if (sel<0 || sel >= (int)fileTypes.size()) + if ((sel < 0) || (sel >= (int)fileTypes.size())) return; + FileType type = fileTypes[sel]; - //g_message("selected: %s\n", type.name.c_str()); + // g_message("selected: %s\n", type.name.c_str()); Gtk::FileFilter filter; filter.add_pattern(type.pattern); set_filter(filter); @@ -1457,19 +1406,19 @@ void FileExportDialogImpl::createFileTypeMenu() Inkscape::Extension::db.get_output_list(extension_list); for (Inkscape::Extension::DB::OutputList::iterator current_item = extension_list.begin(); - current_item != extension_list.end(); ++current_item) - { - Inkscape::Extension::Output * omod = *current_item; + current_item != extension_list.end(); ++current_item) { + Inkscape::Extension::Output *omod = *current_item; // FIXME: would be nice to grey them out instead of not listing them - if (omod->deactivated()) continue; + if (omod->deactivated()) + continue; FileType type; - type.name = (_(omod->get_filetypename())); - type.pattern = "*"; + type.name = (_(omod->get_filetypename())); + type.pattern = "*"; Glib::ustring extension = omod->get_extension(); - fileDialogExtensionToPattern (type.pattern, extension); - type.extension= omod; + fileDialogExtensionToPattern(type.pattern, extension); + type.extension = omod; fileTypeComboBox.append_text(type.name); fileTypes.push_back(type); } @@ -1484,28 +1433,26 @@ void FileExportDialogImpl::createFileTypeMenu() fileTypeComboBox.set_active(0); - fileTypeChangedCallback(); //call at least once to set the filter + fileTypeChangedCallback(); // call at least once to set the filter } /** * Constructor */ -FileExportDialogImpl::FileExportDialogImpl( Gtk::Window& parentWindow, - const Glib::ustring &dir, - FileDialogType fileTypes, - const Glib::ustring &title, - const Glib::ustring &/*default_key*/ ) : - FileDialogBaseGtk(parentWindow, title, Gtk::FILE_CHOOSER_ACTION_SAVE, fileTypes, "/dialogs/export"), - sourceX0Spinner("X0", _("Left edge of source")), - sourceY0Spinner("Y0", _("Top edge of source")), - sourceX1Spinner("X1", _("Right edge of source")), - sourceY1Spinner("Y1", _("Bottom edge of source")), - sourceWidthSpinner("Width", _("Source width")), - sourceHeightSpinner("Height", _("Source height")), - destWidthSpinner("Width", _("Destination width")), - destHeightSpinner("Height", _("Destination height")), - destDPISpinner("DPI", _("Resolution (dots per inch)")) +FileExportDialogImpl::FileExportDialogImpl(Gtk::Window &parentWindow, const Glib::ustring &dir, + FileDialogType fileTypes, const Glib::ustring &title, + const Glib::ustring & /*default_key*/) + : FileDialogBaseGtk(parentWindow, title, Gtk::FILE_CHOOSER_ACTION_SAVE, fileTypes, "/dialogs/export") + , sourceX0Spinner("X0", _("Left edge of source")) + , sourceY0Spinner("Y0", _("Top edge of source")) + , sourceX1Spinner("X1", _("Right edge of source")) + , sourceY1Spinner("Y1", _("Bottom edge of source")) + , sourceWidthSpinner("Width", _("Source width")) + , sourceHeightSpinner("Height", _("Source height")) + , destWidthSpinner("Width", _("Destination width")) + , destHeightSpinner("Height", _("Destination height")) + , destDPISpinner("DPI", _("Resolution (dots per inch)")) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); append_extension = prefs->getBool("/dialogs/save_export/append_extension", true); @@ -1528,15 +1475,15 @@ FileExportDialogImpl::FileExportDialogImpl( Gtk::Window& parentWindow, _dialogType = fileTypes; /* Set the pwd and/or the filename */ - if (dir.size()>0) - { + if (dir.size() > 0) { Glib::ustring udir(dir); Glib::ustring::size_type len = udir.length(); // leaving a trailing backslash on the directory name leads to the infamous // double-directory bug on win32 - if (len != 0 && udir[len - 1] == '\\') udir.erase(len - 1); + if ((len != 0) && (udir[len - 1] == '\\')) + udir.erase(len - 1); set_current_folder(udir.c_str()); - } + } //######################################### //## EXTRA WIDGET -- SOURCE SIDE @@ -1563,16 +1510,16 @@ FileExportDialogImpl::FileExportDialogImpl( Gtk::Window& parentWindow, - //dimension buttons - sourceTable.resize(3,3); - sourceTable.attach(sourceX0Spinner, 0,1,0,1); - sourceTable.attach(sourceY0Spinner, 1,2,0,1); + // dimension buttons + sourceTable.resize(3, 3); + sourceTable.attach(sourceX0Spinner, 0, 1, 0, 1); + sourceTable.attach(sourceY0Spinner, 1, 2, 0, 1); sourceUnitsSpinner.setUnitType(UNIT_TYPE_LINEAR); - sourceTable.attach(sourceUnitsSpinner, 2,3,0,1); - sourceTable.attach(sourceX1Spinner, 0,1,1,2); - sourceTable.attach(sourceY1Spinner, 1,2,1,2); - sourceTable.attach(sourceWidthSpinner, 0,1,2,3); - sourceTable.attach(sourceHeightSpinner, 1,2,2,3); + sourceTable.attach(sourceUnitsSpinner, 2, 3, 0, 1); + sourceTable.attach(sourceX1Spinner, 0, 1, 1, 2); + sourceTable.attach(sourceY1Spinner, 1, 2, 1, 2); + sourceTable.attach(sourceWidthSpinner, 0, 1, 2, 3); + sourceTable.attach(sourceHeightSpinner, 1, 2, 2, 3); sourceBox.pack_start(sourceTable); sourceFrame.set_label(_("Source")); @@ -1585,12 +1532,12 @@ FileExportDialogImpl::FileExportDialogImpl( Gtk::Window& parentWindow, //######################################### - destTable.resize(3,3); - destTable.attach(destWidthSpinner, 0,1,0,1); - destTable.attach(destHeightSpinner, 1,2,0,1); + destTable.resize(3, 3); + destTable.attach(destWidthSpinner, 0, 1, 0, 1); + destTable.attach(destHeightSpinner, 1, 2, 0, 1); destUnitsSpinner.setUnitType(UNIT_TYPE_LINEAR); - destTable.attach(destUnitsSpinner, 2,3,0,1); - destTable.attach(destDPISpinner, 0,1,1,2); + destTable.attach(destUnitsSpinner, 2, 3, 0, 1); + destTable.attach(destDPISpinner, 0, 1, 1, 2); destBox.pack_start(destTable); @@ -1608,8 +1555,6 @@ FileExportDialogImpl::FileExportDialogImpl( Gtk::Window& parentWindow, - - //###### File options //###### Do we want the .xxx extension automatically added? fileTypeCheckbox.set_label(Glib::ustring(_("Append filename extension automatically"))); @@ -1618,9 +1563,8 @@ FileExportDialogImpl::FileExportDialogImpl( Gtk::Window& parentWindow, //###### File type menu createFileTypeMenu(); - fileTypeComboBox.set_size_request(200,40); - fileTypeComboBox.signal_changed().connect( - sigc::mem_fun(*this, &FileExportDialogImpl::fileTypeChangedCallback) ); + fileTypeComboBox.set_size_request(200, 40); + fileTypeComboBox.signal_changed().connect(sigc::mem_fun(*this, &FileExportDialogImpl::fileTypeChangedCallback)); destBox.pack_start(fileTypeComboBox); @@ -1636,38 +1580,35 @@ FileExportDialogImpl::FileExportDialogImpl( Gtk::Window& parentWindow, - - //Let's do some customization + // Let's do some customization fileNameEntry = NULL; Gtk::Container *cont = get_toplevel(); std::vector entries; findEntryWidgets(cont, entries); - //g_message("Found %d entry widgets\n", entries.size()); - if (!entries.empty()) - { - //Catch when user hits [return] on the text field + // g_message("Found %d entry widgets\n", entries.size()); + if (!entries.empty()) { + // Catch when user hits [return] on the text field fileNameEntry = entries[0]; fileNameEntry->signal_activate().connect( - sigc::mem_fun(*this, &FileExportDialogImpl::fileNameEntryChangedCallback) ); - } + sigc::mem_fun(*this, &FileExportDialogImpl::fileNameEntryChangedCallback)); + } - //Let's do more customization + // Let's do more customization std::vector expanders; findExpanderWidgets(cont, expanders); - //g_message("Found %d expander widgets\n", expanders.size()); - if (!expanders.empty()) - { - //Always show the file list + // g_message("Found %d expander widgets\n", expanders.size()); + if (!expanders.empty()) { + // Always show the file list Gtk::Expander *expander = expanders[0]; expander->set_expanded(true); - } + } - //if (extension == NULL) + // if (extension == NULL) // checkbox.set_sensitive(FALSE); add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); - set_default(*add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK)); + set_default(*add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK)); show_all_children(); } @@ -1684,30 +1625,28 @@ FileExportDialogImpl::~FileExportDialogImpl() /** * Show this dialog modally. Return true if user hits [OK] */ -bool -FileExportDialogImpl::show() +bool FileExportDialogImpl::show() { - Glib::ustring s = Glib::filename_to_utf8 (get_current_folder()); - if (s.length() == 0) - s = getcwd (NULL, 0); - set_current_folder(Glib::filename_from_utf8(s)); //hack to force initial dir listing - set_modal (TRUE); //Window - sp_transientize(GTK_WIDGET(gobj())); //Make transient - gint b = run(); //Dialog + Glib::ustring s = Glib::filename_to_utf8(get_current_folder()); + if (s.length() == 0) { + s = getcwd(NULL, 0); + } + set_current_folder(Glib::filename_from_utf8(s)); // hack to force initial dir listing + set_modal(TRUE); // Window + sp_transientize(GTK_WIDGET(gobj())); // Make transient + gint b = run(); // Dialog svgPreview.showNoPreview(); hide(); - if (b == Gtk::RESPONSE_OK) - { - int sel = fileTypeComboBox.get_active_row_number (); - if (sel>=0 && sel< (int)fileTypes.size()) - { + if (b == Gtk::RESPONSE_OK) { + int sel = fileTypeComboBox.get_active_row_number(); + if (sel >= 0 && sel < (int)fileTypes.size()) { FileType &type = fileTypes[sel]; extension = type.extension; - } + } myFilename = get_filename(); #ifdef WITH_GNOME_VFS - if ( myFilename.empty() && gnome_vfs_initialized() ) { + if (myFilename.empty() && gnome_vfs_initialized()) { myFilename = get_uri(); } #endif @@ -1721,20 +1660,17 @@ FileExportDialogImpl::show() prefs->setBool("/dialogs/save_export/append_extension", append_extension); prefs->setBool("/dialogs/save_export/default", ( extension != NULL ? extension->get_id() : "" )); */ - return TRUE; - } - else - { - return FALSE; - } + return true; + } else { + return false; + } } /** * Get the file extension type that was selected by the user. Valid after an [OK] */ -Inkscape::Extension::Extension * -FileExportDialogImpl::getSelectionType() +Inkscape::Extension::Extension *FileExportDialogImpl::getSelectionType() { return extension; } @@ -1743,8 +1679,7 @@ FileExportDialogImpl::getSelectionType() /** * Get the file name chosen by the user. Valid after an [OK] */ -Glib::ustring -FileExportDialogImpl::getFilename() +Glib::ustring FileExportDialogImpl::getFilename() { return myFilename; } @@ -1752,9 +1687,9 @@ FileExportDialogImpl::getFilename() #endif // NEW_EXPORT_DIALOG -} //namespace Dialog -} //namespace UI -} //namespace Inkscape +} // namespace Dialog +} // namespace UI +} // namespace Inkscape /* Local Variables: -- cgit v1.2.3 From 08692dea2a2b45f0358a70db8e7d08fd73c6e3e4 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Mon, 31 Mar 2014 11:10:00 +0100 Subject: Fix Gtkmm 3.8 build issues on systems with Gtk+ 3.10 (bzr r13242) --- src/ui/dialog/document-properties.cpp | 12 ++++++------ src/ui/dialog/livepatheffect-editor.cpp | 8 ++++---- src/ui/dialog/polar-arrange-tab.h | 3 +-- 3 files changed, 11 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 508fc52b1..67e788e21 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -613,7 +613,7 @@ void DocumentProperties::build_cms() label_avail->set_markup (_("Available Color Profiles:")); _link_btn.set_tooltip_text(_("Link Profile")); -#if GTK_CHECK_VERSION(3,10,0) +#if WITH_GTKMM_3_10 _link_btn.set_image_from_icon_name(INKSCAPE_ICON("list-add"), Gtk::ICON_SIZE_SMALL_TOOLBAR); #else Gtk::Image *image_link = Gtk::manage(new Gtk::Image()); @@ -622,7 +622,7 @@ void DocumentProperties::build_cms() #endif _unlink_btn.set_tooltip_text(_("Unlink Profile")); -#if GTK_CHECK_VERSION(3,10,0) +#if WITH_GTKMM_3_10 _unlink_btn.set_image_from_icon_name(INKSCAPE_ICON("list-remove"), Gtk::ICON_SIZE_SMALL_TOOLBAR); #else Gtk::Image *image_unlink = Gtk::manage(new Gtk::Image()); @@ -750,7 +750,7 @@ void DocumentProperties::build_scripting() label_external->set_markup (_("External script files:")); _external_add_btn.set_tooltip_text(_("Add the current file name or browse for a file")); -#if GTK_CHECK_VERSION(3,10,0) +#if WITH_GTKMM_3_10 _external_add_btn.set_image_from_icon_name(INKSCAPE_ICON("list-add"), Gtk::ICON_SIZE_SMALL_TOOLBAR); #else Gtk::Image *image_ext_add = Gtk::manage(new Gtk::Image()); @@ -759,7 +759,7 @@ void DocumentProperties::build_scripting() #endif _external_remove_btn.set_tooltip_text(_("Remove")); -#if GTK_CHECK_VERSION(3,10,0) +#if WITH_GTKMM_3_10 _external_remove_btn.set_image_from_icon_name(INKSCAPE_ICON("list-remove"), Gtk::ICON_SIZE_SMALL_TOOLBAR); #else Gtk::Image *image_ext_rm = Gtk::manage(new Gtk::Image()); @@ -839,7 +839,7 @@ void DocumentProperties::build_scripting() label_embedded->set_markup (_("Embedded script files:")); _embed_new_btn.set_tooltip_text(_("New")); -#if GTK_CHECK_VERSION(3,10,0) +#if WITH_GTKMM_3_10 _embed_new_btn.set_image_from_icon_name(INKSCAPE_ICON("list-add"), Gtk::ICON_SIZE_SMALL_TOOLBAR); #else Gtk::Image *image_embed_new = Gtk::manage(new Gtk::Image()); @@ -848,7 +848,7 @@ void DocumentProperties::build_scripting() #endif _embed_remove_btn.set_tooltip_text(_("Remove")); -#if GTK_CHECK_VERSION(3,10,0) +#if WITH_GTKMM_3_10 _embed_remove_btn.set_image_from_icon_name(INKSCAPE_ICON("list-remove"), Gtk::ICON_SIZE_SMALL_TOOLBAR); #else Gtk::Image *image_embed_rm = Gtk::manage(new Gtk::Image()); diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp index 0ab2fc9f7..9a569725c 100644 --- a/src/ui/dialog/livepatheffect-editor.cpp +++ b/src/ui/dialog/livepatheffect-editor.cpp @@ -107,7 +107,7 @@ LivePathEffectEditor::LivePathEffectEditor() effectcontrol_frame.add(effectcontrol_vbox); button_add.set_tooltip_text(_("Add path effect")); -#if GTK_CHECK_VERSION(3,10,0) +#if WITH_GTKMM_3_10 button_add.set_image_from_icon_name(INKSCAPE_ICON("list-add"), Gtk::ICON_SIZE_SMALL_TOOLBAR); #else Gtk::Image *image_add = Gtk::manage(new Gtk::Image()); @@ -117,7 +117,7 @@ LivePathEffectEditor::LivePathEffectEditor() button_add.set_relief(Gtk::RELIEF_NONE); button_remove.set_tooltip_text(_("Delete current path effect")); -#if GTK_CHECK_VERSION(3,10,0) +#if WITH_GTKMM_3_10 button_remove.set_image_from_icon_name(INKSCAPE_ICON("list-remove"), Gtk::ICON_SIZE_SMALL_TOOLBAR); #else Gtk::Image *image_remove = Gtk::manage(new Gtk::Image()); @@ -127,7 +127,7 @@ LivePathEffectEditor::LivePathEffectEditor() button_remove.set_relief(Gtk::RELIEF_NONE); button_up.set_tooltip_text(_("Raise the current path effect")); -#if GTK_CHECK_VERSION(3,10,0) +#if WITH_GTKMM_3_10 button_up.set_image_from_icon_name(INKSCAPE_ICON("go-up"), Gtk::ICON_SIZE_SMALL_TOOLBAR); #else Gtk::Image *image_up = Gtk::manage(new Gtk::Image()); @@ -137,7 +137,7 @@ LivePathEffectEditor::LivePathEffectEditor() button_up.set_relief(Gtk::RELIEF_NONE); button_down.set_tooltip_text(_("Lower the current path effect")); -#if GTK_CHECK_VERSION(3,10,0) +#if WITH_GTKMM_3_10 button_down.set_image_from_icon_name(INKSCAPE_ICON("go-down"), Gtk::ICON_SIZE_SMALL_TOOLBAR); #else Gtk::Image *image_down = Gtk::manage(new Gtk::Image()); diff --git a/src/ui/dialog/polar-arrange-tab.h b/src/ui/dialog/polar-arrange-tab.h index bfed40bbd..f6c3b2906 100644 --- a/src/ui/dialog/polar-arrange-tab.h +++ b/src/ui/dialog/polar-arrange-tab.h @@ -10,9 +10,8 @@ #ifndef INKSCAPE_UI_DIALOG_POLAR_ARRANGE_TAB_H #define INKSCAPE_UI_DIALOG_POLAR_ARRANGE_TAB_H -#include "ui/dialog/arrange-tab.h" - #include "ui/widget/anchor-selector.h" +#include "ui/dialog/arrange-tab.h" #include "ui/widget/scalar-unit.h" namespace Inkscape { -- cgit v1.2.3 From 7f76e57b71213ded4ffc75f42af0f19ece24e04c Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Mon, 31 Mar 2014 22:50:32 +0200 Subject: partial 2geom update: fix compiler error on some platforms (mavericks in any case) (bzr r13244) --- src/2geom/sbasis-roots.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/2geom/sbasis-roots.cpp b/src/2geom/sbasis-roots.cpp index 813e471e8..acf4e1abc 100644 --- a/src/2geom/sbasis-roots.cpp +++ b/src/2geom/sbasis-roots.cpp @@ -114,7 +114,7 @@ OptInterval bounds_fast(const SBasis &sb, int order) { res[1]=lerp(t, a+v*t, b); } } - if (order>0) res*=pow(.25,order); + if (order>0) res*=std::pow(.25,order); return res; } @@ -151,7 +151,7 @@ OptInterval bounds_local(const SBasis &sb, const OptInterval &i, int order) { } } Interval res = Interval(lo,hi); - if (order>0) res*=pow(.25,order); + if (order>0) res*=std::pow(.25,order); return res; } -- cgit v1.2.3 From 24335d0da5da0df3e7ee0f235d04e57807c97a69 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Mon, 31 Mar 2014 22:55:53 +0200 Subject: fix windows build (bzr r13245) --- src/ui/dialog/pixelartdialog.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/pixelartdialog.cpp b/src/ui/dialog/pixelartdialog.cpp index 31449d4e7..2d25f54d7 100644 --- a/src/ui/dialog/pixelartdialog.cpp +++ b/src/ui/dialog/pixelartdialog.cpp @@ -410,8 +410,8 @@ void PixelArtDialogImpl::vectorize() lastOptions = options(); g_atomic_int_set(&abortThread, false); - thread = Glib::Thread::create( - sigc::mem_fun(*this, &PixelArtDialogImpl::workerThread) ); + thread = Glib::Thread::create(sigc::mem_fun(*this, &PixelArtDialogImpl::workerThread), + /*joinable =*/true); } void PixelArtDialogImpl::processLibdepixelize(const Input &input) -- cgit v1.2.3 From 3394f340295af7b454b27250cdce1d845ad4b64d Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Tue, 1 Apr 2014 01:09:09 +0200 Subject: partial 2geom update (fixes warning) (bzr r13246) --- src/2geom/recursive-bezier-intersection.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/2geom/recursive-bezier-intersection.cpp b/src/2geom/recursive-bezier-intersection.cpp index 0c7977970..548065196 100644 --- a/src/2geom/recursive-bezier-intersection.cpp +++ b/src/2geom/recursive-bezier-intersection.cpp @@ -13,6 +13,8 @@ unsigned intersect_steps = 0; using std::vector; +using std::swap; + namespace Geom { class OldBezier { @@ -31,7 +33,7 @@ public: minax = p[0][X]; // These are the most likely to be extremal maxax = p.back()[X]; if( minax > maxax ) - std::swap(minax, maxax); + swap(minax, maxax); for(unsigned i = 1; i < p.size()-1; i++) { if( p[i][X] < minax ) minax = p[i][X]; @@ -42,7 +44,7 @@ public: minay = p[0][Y]; // These are the most likely to be extremal maxay = p.back()[Y]; if( minay > maxay ) - std::swap(minay, maxay); + swap(minay, maxay); for(unsigned i = 1; i < p.size()-1; i++) { if( p[i][Y] < minay ) minay = p[i][Y]; @@ -71,9 +73,6 @@ find_intersections_bezier_recursive( std::vector > &xs } -/* The value of 1.0 / (1L<<14) is enough for most applications */ -const double INV_EPS = (1L<<14); - /* * split the curve at the midpoint, returning an array with the two parts * Temporary storage is minimized by using part of the storage for the result @@ -318,9 +317,14 @@ double Lmax(Point p) { return std::max(fabs(p[X]), fabs(p[Y])); } + unsigned wangs_theorem(OldBezier /*a*/) { return 6; // seems a good approximation! - /*double la1 = Lmax( ( a.p[2] - a.p[1] ) - (a.p[1] - a.p[0]) ); + + /* + const double INV_EPS = (1L<<14); // The value of 1.0 / (1L<<14) is enough for most applications + + double la1 = Lmax( ( a.p[2] - a.p[1] ) - (a.p[1] - a.p[0]) ); double la2 = Lmax( ( a.p[3] - a.p[2] ) - (a.p[2] - a.p[1]) ); double l0 = std::max(la1, la2); unsigned ra; -- cgit v1.2.3 From a8809d5d4f115dc1f4415a41f1feb5828e4201c9 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Tue, 1 Apr 2014 01:11:37 +0200 Subject: 2geom: silence warning (bzr r13247) --- src/2geom/svg-path-parser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/2geom/svg-path-parser.cpp b/src/2geom/svg-path-parser.cpp index fa31b57b5..ccc383920 100644 --- a/src/2geom/svg-path-parser.cpp +++ b/src/2geom/svg-path-parser.cpp @@ -1144,7 +1144,7 @@ static const char _svg_path_trans_actions[] = { static const int svg_path_start = 1; static const int svg_path_first_final = 270; -static const int svg_path_en_main = 1; +//static const int svg_path_en_main = 1; #line 144 "/home/tweenk/src/lib2geom/src/2geom/svg-path-parser.rl" -- cgit v1.2.3 From 04b06fe3ed0824c37cf65b425bf820d8b6f226a2 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Tue, 1 Apr 2014 01:25:06 +0200 Subject: partial 2geom update: - main reason for update: better swap for Path (fixes C++11 warning/error) - faster implementation for Path * Translate (~6x), Inkscape's code has to be modified to use it though (bzr r13248) --- src/2geom/bezier-curve.h | 11 +++++++++++ src/2geom/bezier.h | 12 ++++++++++++ src/2geom/curve.h | 16 ++++++++++++++++ src/2geom/elliptical-arc.h | 7 +++++++ src/2geom/path.cpp | 34 +++++++++++++++++++++++++++++++--- src/2geom/path.h | 24 +++++++++++++----------- src/2geom/sbasis-curve.h | 7 +++++++ 7 files changed, 97 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/2geom/bezier-curve.h b/src/2geom/bezier-curve.h index c0224e850..d379526fa 100644 --- a/src/2geom/bezier-curve.h +++ b/src/2geom/bezier-curve.h @@ -39,6 +39,7 @@ #include <2geom/curve.h> #include <2geom/sbasis-curve.h> // for non-native winding method #include <2geom/bezier.h> +#include <2geom/transforms.h> namespace Geom { @@ -118,6 +119,7 @@ public: virtual Curve *reverse() const { return new BezierCurve(Geom::reverse(inner)); } + virtual Curve *transformed(Affine const &m) const { BezierCurve *ret = new BezierCurve(); std::vector ps = points(); @@ -127,6 +129,11 @@ public: ret->setPoints(ps); return ret; } + virtual Curve &operator*=(Translate const &m) { + inner += m.vector(); + return *this; + }; + virtual Curve *derivative() const { return new BezierCurve(Geom::derivative(inner[X]), Geom::derivative(inner[Y])); } @@ -248,6 +255,10 @@ public: return ret; } } + virtual Curve &operator*=(Translate const &m) { + inner += m.vector(); + return *this; + } virtual Curve *derivative() const; // the method below is defined so that LineSegment can specialize it diff --git a/src/2geom/bezier.h b/src/2geom/bezier.h index 176128328..51d5211d9 100644 --- a/src/2geom/bezier.h +++ b/src/2geom/bezier.h @@ -391,6 +391,18 @@ inline Bezier operator-(const Bezier & a, double v) { return result; } +inline Bezier& operator+=(Bezier & a, double v) { + for(unsigned i = 0; i <= a.order(); ++i) + a[i] = a[i] + v; + return a; +} + +inline Bezier& operator-=(Bezier & a, double v) { + for(unsigned i = 0; i <= a.order(); ++i) + a[i] = a[i] - v; + return a; +} + inline Bezier operator*(const Bezier & a, double v) { Bezier result = Bezier(Bezier::Order(a)); for(unsigned i = 0; i <= a.order(); i++) diff --git a/src/2geom/curve.h b/src/2geom/curve.h index 77f6808e1..172fd7ddc 100644 --- a/src/2geom/curve.h +++ b/src/2geom/curve.h @@ -162,6 +162,7 @@ public: /** @brief Create an exact copy of this curve. * @return Pointer to a newly allocated curve, identical to the original */ virtual Curve *duplicate() const = 0; + /** @brief Create a curve transformed by an affine transformation. * This method returns a new curve instead modifying the existing one, because some curve * types are not closed under affine transformations. The returned curve may be of different @@ -169,6 +170,15 @@ public: * @param m Affine describing the affine transformation * @return Pointer to a new, transformed curve */ virtual Curve *transformed(Affine const &m) const = 0; + + /** @brief Translate the curve (i.e. displace by Point) + * This method modifies the curve; all curve types are closed under + * translations (the result can be expressed in its own curve type). + * This function yields the same result as transformed(m). + * @param p Point by which to translate the curve + * @return reference to self */ + virtual Curve &operator*=(Translate const &m) = 0; + /** @brief Create a curve that corresponds to a part of this curve. * For \f$a > b\f$, the returned portion will be reversed with respect to the original. * The returned curve will always be of the same type. @@ -282,6 +292,12 @@ Coord nearest_point(Point const& p, Curve const& c) { return c.nearestPoint(p); } +// for make benefit glorious library of Boost Pointer Container +inline +Curve *new_clone(Curve const &c) { + return c.duplicate(); +} + } // end namespace Geom diff --git a/src/2geom/elliptical-arc.h b/src/2geom/elliptical-arc.h index e1e757207..5527aa6bc 100644 --- a/src/2geom/elliptical-arc.h +++ b/src/2geom/elliptical-arc.h @@ -229,6 +229,13 @@ public: virtual int degreesOfFreedom() const { return 7; } virtual Curve *derivative() const; virtual Curve *transformed(Affine const &m) const; + virtual Curve &operator*=(Translate const &m) { + _initial_point += m.vector(); + _final_point += m.vector(); + _center += m.vector(); + return *this; + } + /** * The size of the returned vector equals n+1. diff --git a/src/2geom/path.cpp b/src/2geom/path.cpp index 93def6c55..5797f475c 100644 --- a/src/2geom/path.cpp +++ b/src/2geom/path.cpp @@ -35,9 +35,10 @@ #include <2geom/path.h> +#include <2geom/transforms.h> #include - +using std::swap; using namespace Geom::PathInternal; namespace Geom @@ -102,10 +103,35 @@ Path &Path::operator*=(Affine const &m) { return *this; } +Path &Path::operator*=(Translate const &m) { + unshare(); + Sequence::iterator last = get_curves().end() - 1; + Sequence::iterator it; + Point prev; + for (it = get_curves().begin() ; it != last ; ++it) { + *(const_cast(&**it)) *= m; + if ( it != get_curves().begin() && (*it)->initialPoint() != prev ) { + THROW_CONTINUITYERROR(); + } + prev = (*it)->finalPoint(); + } + for ( int i = 0 ; i < 2 ; ++i ) { + final_->setPoint(i, (*final_)[i] + m.vector()); + } + if (get_curves().size() > 1) { + if ( front().initialPoint() != initialPoint() || back().finalPoint() != finalPoint() ) { + THROW_CONTINUITYERROR(); + } + } + return *this; +} + std::vector Path::allNearestPoints(Point const& _point, double from, double to) const { - if ( from > to ) std::swap(from, to); + using std::swap; + + if ( from > to ) swap(from, to); const Path& _path = *this; unsigned int sz = _path.size(); if ( _path.closed() ) ++sz; @@ -215,7 +241,9 @@ Path::nearestPointPerCurve(Point const& _point) const double Path::nearestPoint(Point const &_point, double from, double to, double *distance_squared) const { - if ( from > to ) std::swap(from, to); + using std::swap; + + if ( from > to ) swap(from, to); const Path& _path = *this; unsigned int sz = _path.size(); if ( _path.closed() ) ++sz; diff --git a/src/2geom/path.h b/src/2geom/path.h index 48d7acaaf..28d2a25e4 100644 --- a/src/2geom/path.h +++ b/src/2geom/path.h @@ -40,6 +40,7 @@ #include #include <2geom/curve.h> #include <2geom/bezier-curve.h> +#include <2geom/transforms.h> namespace Geom { @@ -205,11 +206,14 @@ public: // Path &operator=(Path const &other) - use default assignment operator + /// \todo Add noexcept specifiers for C++11 void swap(Path &other) { - std::swap(other.curves_, curves_); - std::swap(other.final_, final_); - std::swap(other.closed_, closed_); + using std::swap; + swap(other.curves_, curves_); + swap(other.final_, final_); + swap(other.closed_, closed_); } + friend inline void swap(Path &a, Path &b) { a.swap(b); } Curve const &operator[](unsigned i) const { return *get_curves()[i]; } Curve const &at_index(unsigned i) const { return *get_curves()[i]; } @@ -289,8 +293,14 @@ public: ret *= m; return ret; } + Path operator*(Translate const &m) const { // specialization over Affine, for faster computation + Path ret(*this); + ret *= m; + return ret; + } Path &operator*=(Affine const &m); + Path &operator*=(Translate const &m); // specialization over Affine, for faster computation Point pointAt(double t) const { @@ -686,14 +696,6 @@ Coord nearest_point(Point const& p, Path const& c) } // end namespace Geom -namespace std { - -template <> -inline void swap(Geom::Path &a, Geom::Path &b) { - a.swap(b); -} - -} // end namespace std #endif // LIB2GEOM_SEEN_PATH_H diff --git a/src/2geom/sbasis-curve.h b/src/2geom/sbasis-curve.h index 554b702e6..a5c3f2ca7 100644 --- a/src/2geom/sbasis-curve.h +++ b/src/2geom/sbasis-curve.h @@ -39,6 +39,7 @@ #include <2geom/curve.h> #include <2geom/nearest-point.h> #include <2geom/sbasis-geometric.h> +#include <2geom/transforms.h> namespace Geom { @@ -117,7 +118,13 @@ public: virtual Curve *portion(Coord f, Coord t) const { return new SBasisCurve(Geom::portion(inner, f, t)); } + virtual Curve *transformed(Affine const &m) const { return new SBasisCurve(inner * m); } + virtual Curve &operator*=(Translate const &m) { + inner += m.vector(); + return *this; + }; + virtual Curve *derivative() const { return new SBasisCurve(Geom::derivative(inner)); } -- cgit v1.2.3