summaryrefslogtreecommitdiffstats
path: root/src/extension
diff options
context:
space:
mode:
authorMarkus Engel <markus.engel@tum.de>2013-03-29 23:52:42 +0000
committerMarkus Engel <markus.engel@tum.de>2013-03-29 23:52:42 +0000
commita168040d5a452544328a1e6ad35aaac351f94d44 (patch)
treefae1ba829f543a473da281bd5fa6e4deabbf6912 /src/extension
parentRemoved function pointers from SPObject and subclasses. (diff)
parentDutch translation update (diff)
downloadinkscape-a168040d5a452544328a1e6ad35aaac351f94d44.tar.gz
inkscape-a168040d5a452544328a1e6ad35aaac351f94d44.zip
merged from trunk
(bzr r11608.1.56)
Diffstat (limited to 'src/extension')
-rw-r--r--src/extension/CMakeLists.txt17
-rw-r--r--src/extension/Makefile_insert1
-rw-r--r--src/extension/dbus/application-interface.cpp41
-rw-r--r--src/extension/dbus/application-interface.h17
-rw-r--r--src/extension/dbus/dbus-init.cpp3
-rw-r--r--src/extension/dbus/dbus-init.h1
-rw-r--r--src/extension/dbus/document-interface.cpp57
-rw-r--r--src/extension/dbus/document-interface.h14
-rw-r--r--src/extension/dependency.cpp6
-rw-r--r--src/extension/dxf2svg/GPL.txt340
-rw-r--r--src/extension/dxf2svg/LGPL.txt504
-rw-r--r--src/extension/dxf2svg/Makefile21
-rw-r--r--src/extension/dxf2svg/README41
-rw-r--r--src/extension/dxf2svg/aci2rgb.cpp114
-rw-r--r--src/extension/dxf2svg/blocks.cpp83
-rw-r--r--src/extension/dxf2svg/blocks.h38
-rw-r--r--src/extension/dxf2svg/dxf2svg.cpp99
-rw-r--r--src/extension/dxf2svg/dxf_input.inx16
-rw-r--r--src/extension/dxf2svg/dxf_input_windows.inx17
-rw-r--r--src/extension/dxf2svg/entities.cpp996
-rw-r--r--src/extension/dxf2svg/entities.h256
-rw-r--r--src/extension/dxf2svg/entities2elements.cpp678
-rw-r--r--src/extension/dxf2svg/entities2elements.h53
-rw-r--r--src/extension/dxf2svg/read_dxf.cpp275
-rw-r--r--src/extension/dxf2svg/read_dxf.h32
-rw-r--r--src/extension/dxf2svg/tables.cpp211
-rw-r--r--src/extension/dxf2svg/tables.h71
-rw-r--r--src/extension/dxf2svg/tables2svg_info.cpp37
-rw-r--r--src/extension/dxf2svg/tables2svg_info.h9
-rw-r--r--src/extension/dxf2svg/test_dxf.cpp99
-rw-r--r--src/extension/effect.h4
-rw-r--r--src/extension/error-file.cpp9
-rw-r--r--src/extension/extension.cpp28
-rw-r--r--src/extension/extension.h13
-rw-r--r--src/extension/implementation/implementation.h3
-rw-r--r--src/extension/implementation/script.cpp15
-rw-r--r--src/extension/implementation/script.h3
-rw-r--r--src/extension/init.cpp18
-rw-r--r--src/extension/input.cpp7
-rw-r--r--src/extension/input.h4
-rw-r--r--src/extension/internal/Makefile_insert27
-rw-r--r--src/extension/internal/cairo-png-out.cpp2
-rw-r--r--src/extension/internal/cairo-ps-out.cpp112
-rw-r--r--src/extension/internal/cairo-render-context.cpp2
-rw-r--r--src/extension/internal/cairo-render-context.h6
-rw-r--r--src/extension/internal/cairo-renderer-pdf-out.cpp75
-rw-r--r--src/extension/internal/cairo-renderer.cpp28
-rw-r--r--src/extension/internal/cairo-renderer.h4
-rw-r--r--src/extension/internal/cdr-input.cpp332
-rw-r--r--src/extension/internal/cdr-input.h54
-rw-r--r--src/extension/internal/emf-win32-inout.cpp72
-rw-r--r--src/extension/internal/filter/bumps.h3
-rw-r--r--src/extension/internal/filter/color.h260
-rwxr-xr-xsrc/extension/internal/filter/filter-all.cpp3
-rw-r--r--src/extension/internal/filter/filter-file.cpp1
-rw-r--r--src/extension/internal/filter/filter.cpp4
-rw-r--r--src/extension/internal/filter/filter.h2
-rw-r--r--src/extension/internal/filter/paint.h54
-rw-r--r--src/extension/internal/filter/shadows.h13
-rw-r--r--src/extension/internal/gdkpixbuf-input.cpp13
-rw-r--r--src/extension/internal/image-resolution.cpp371
-rw-r--r--src/extension/internal/javafx-out.cpp2
-rw-r--r--src/extension/internal/latex-text-renderer.cpp7
-rw-r--r--src/extension/internal/latex-text-renderer.h4
-rw-r--r--src/extension/internal/odf.cpp236
-rw-r--r--src/extension/internal/odf.h10
-rw-r--r--src/extension/internal/pdf-input-cairo.cpp26
-rw-r--r--src/extension/internal/pdf-input-cairo.h11
-rw-r--r--src/extension/internal/pdfinput/pdf-input.cpp33
-rw-r--r--src/extension/internal/pdfinput/pdf-input.h11
-rw-r--r--src/extension/internal/pdfinput/pdf-parser.cpp565
-rw-r--r--src/extension/internal/pdfinput/svg-builder.cpp7
-rw-r--r--src/extension/internal/pdfinput/svg-builder.h8
-rw-r--r--src/extension/internal/svg.cpp2
-rw-r--r--src/extension/internal/vsd-input.cpp332
-rw-r--r--src/extension/internal/vsd-input.h54
-rw-r--r--src/extension/output.h2
-rw-r--r--src/extension/param/enum.cpp4
-rw-r--r--src/extension/param/float.cpp25
-rw-r--r--src/extension/param/int.cpp25
-rw-r--r--src/extension/param/notebook.cpp18
-rw-r--r--src/extension/param/radiobutton.cpp4
-rw-r--r--src/extension/param/string.cpp3
-rw-r--r--src/extension/prefdialog.cpp35
-rw-r--r--src/extension/prefdialog.h2
-rw-r--r--src/extension/script/InkscapeScript.h4
-rw-r--r--src/extension/system.cpp40
-rw-r--r--src/extension/timer.cpp2
88 files changed, 2116 insertions, 5045 deletions
diff --git a/src/extension/CMakeLists.txt b/src/extension/CMakeLists.txt
index 5761b1e8b..fa4fdd740 100644
--- a/src/extension/CMakeLists.txt
+++ b/src/extension/CMakeLists.txt
@@ -36,11 +36,13 @@ set(extension_SRC
internal/cairo-render-context.cpp
internal/cairo-renderer.cpp
internal/cairo-renderer-pdf-out.cpp
+ internal/cdr-input.cpp
internal/emf-win32-inout.cpp
internal/emf-win32-print.cpp
internal/gdkpixbuf-input.cpp
internal/gimpgrad.cpp
internal/grid.cpp
+ internal/image-resolution.cpp
internal/latex-pstricks.cpp
internal/latex-pstricks-out.cpp
internal/odf.cpp
@@ -50,6 +52,7 @@ set(extension_SRC
internal/javafx-out.cpp
internal/svg.cpp
internal/svgz.cpp
+ internal/vsd-input.cpp
internal/filter/filter-all.cpp
internal/filter/filter-file.cpp
@@ -61,17 +64,6 @@ set(extension_SRC
script/InkscapeScript.cpp
- # dxf2svg/aci2rgb.cpp
- # dxf2svg/entities2elements.cpp
- # dxf2svg/tables2svg_info.cpp
- # dxf2svg/blocks.cpp
- # dxf2svg/entities.cpp
- # dxf2svg/tables.cpp
- # dxf2svg/dxf2svg.cpp
- # dxf2svg/read_dxf.cpp
- # dxf2svg/test_dxf.cpp
-
-
# ------
# Header
db.h
@@ -109,6 +101,7 @@ set(extension_SRC
internal/cairo-render-context.h
internal/cairo-renderer-pdf-out.h
internal/cairo-renderer.h
+ internal/cdr-input.h
internal/clear-n_.h
internal/emf-win32-inout.h
internal/emf-win32-print.h
@@ -129,6 +122,7 @@ set(extension_SRC
internal/gdkpixbuf-input.h
internal/gimpgrad.h
internal/grid.h
+ internal/image-resolution.h
internal/javafx-out.h
internal/latex-pstricks-out.h
internal/latex-pstricks.h
@@ -141,6 +135,7 @@ set(extension_SRC
internal/pov-out.h
internal/svg.h
internal/svgz.h
+ internal/vsd-input.h
script/InkscapeScript.h
)
diff --git a/src/extension/Makefile_insert b/src/extension/Makefile_insert
index ffcee5f9a..4e75de13a 100644
--- a/src/extension/Makefile_insert
+++ b/src/extension/Makefile_insert
@@ -3,7 +3,6 @@
ink_common_sources += \
extension/extension.cpp \
extension/extension.h \
- extension/extension-forward.h \
extension/db.cpp \
extension/db.h \
extension/dependency.cpp \
diff --git a/src/extension/dbus/application-interface.cpp b/src/extension/dbus/application-interface.cpp
index a652b7c96..8ee7bd12f 100644
--- a/src/extension/dbus/application-interface.cpp
+++ b/src/extension/dbus/application-interface.cpp
@@ -39,6 +39,9 @@ application_interface_class_init (ApplicationInterfaceClass *klass)
static void
application_interface_init (ApplicationInterface *object)
{
+ dbus_g_error_domain_register (INKSCAPE_ERROR,
+ NULL,
+ INKSCAPE_TYPE_ERROR);
}
@@ -48,6 +51,44 @@ application_interface_new (void)
return (ApplicationInterface*)g_object_new (TYPE_APPLICATION_INTERFACE, NULL);
}
+/*
+ * Error stuff...
+ *
+ * To add a new error type, edit here and in the .h InkscapeError enum.
+ */
+GQuark
+inkscape_error_quark (void)
+{
+ static GQuark quark = 0;
+ if (!quark)
+ quark = g_quark_from_static_string ("inkscape_error");
+
+ return quark;
+}
+
+#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC }
+
+GType inkscape_error_get_type(void)
+{
+ static GType etype = 0;
+
+ if (etype == 0) {
+ static const GEnumValue values[] =
+ {
+
+ ENUM_ENTRY(INKSCAPE_ERROR_SELECTION, "Incompatible_Selection"),
+ ENUM_ENTRY(INKSCAPE_ERROR_OBJECT, "Incompatible_Object"),
+ ENUM_ENTRY(INKSCAPE_ERROR_VERB, "Failed_Verb"),
+ ENUM_ENTRY(INKSCAPE_ERROR_OTHER, "Generic_Error"),
+ { 0, 0, 0 }
+ };
+
+ etype = g_enum_register_static("InkscapeError", values);
+ }
+
+ return etype;
+}
+
/****************************************************************************
DESKTOP FUNCTIONS
****************************************************************************/
diff --git a/src/extension/dbus/application-interface.h b/src/extension/dbus/application-interface.h
index e782bd1ad..88219a6b0 100644
--- a/src/extension/dbus/application-interface.h
+++ b/src/extension/dbus/application-interface.h
@@ -45,6 +45,23 @@ struct _ApplicationInterfaceClass {
GObjectClass parent;
};
+
+typedef enum
+{
+ INKSCAPE_ERROR_SELECTION,
+ INKSCAPE_ERROR_OBJECT,
+ INKSCAPE_ERROR_VERB,
+ INKSCAPE_ERROR_OTHER
+} InkscapeError;
+
+
+
+#define INKSCAPE_ERROR (inkscape_error_quark ())
+#define INKSCAPE_TYPE_ERROR (inkscape_error_get_type ())
+
+GQuark inkscape_error_quark (void);
+GType inkscape_error_get_type (void);
+
/****************************************************************************
DESKTOP FUNCTIONS
****************************************************************************/
diff --git a/src/extension/dbus/dbus-init.cpp b/src/extension/dbus/dbus-init.cpp
index 1b6baa979..9ff6897e5 100644
--- a/src/extension/dbus/dbus-init.cpp
+++ b/src/extension/dbus/dbus-init.cpp
@@ -128,9 +128,6 @@ dbus_init_desktop_interface (SPDesktop * dt)
DBusGConnection *connection;
DBusGProxy *proxy;
DocumentInterface *obj;
- dbus_g_error_domain_register (INKSCAPE_ERROR,
- NULL,
- INKSCAPE_TYPE_ERROR);
std::string name("/org/inkscape/desktop_");
std::stringstream out;
diff --git a/src/extension/dbus/dbus-init.h b/src/extension/dbus/dbus-init.h
index 4b07acfb4..025011f28 100644
--- a/src/extension/dbus/dbus-init.h
+++ b/src/extension/dbus/dbus-init.h
@@ -12,6 +12,7 @@
#include "desktop.h"
+
namespace Inkscape {
namespace Extension {
namespace Dbus {
diff --git a/src/extension/dbus/document-interface.cpp b/src/extension/dbus/document-interface.cpp
index c67234b34..56d1dfdbd 100644
--- a/src/extension/dbus/document-interface.cpp
+++ b/src/extension/dbus/document-interface.cpp
@@ -17,6 +17,7 @@
#include "file.h" //IO
#include "document-interface.h"
+#include "application-interface.h"
#include <string.h>
#include <dbus/dbus-glib.h>
#include "desktop-handles.h" //sp_desktop_document()
@@ -222,11 +223,12 @@ dbus_create_node (SPDesktop *desk, const gchar *type)
*/
gchar *finish_create_shape (DocumentInterface *object, GError ** /*error*/, Inkscape::XML::Node *newNode, gchar *desc)
{
-
SPCSSAttr *style = sp_desktop_get_style(object->desk, TRUE);
if (style) {
- newNode->setAttribute("style", sp_repr_css_write_string(style), TRUE);
+ Glib::ustring str;
+ sp_repr_css_write_string(style, str);
+ newNode->setAttribute("style", str.c_str(), TRUE);
}
else {
newNode->setAttribute("style", "fill:#0000ff;fill-opacity:1;stroke:#c900b9;stroke-width:0;stroke-miterlimit:0;stroke-opacity:1;stroke-dasharray:none", TRUE);
@@ -320,43 +322,7 @@ document_interface_new (void)
return (DocumentInterface*)g_object_new (TYPE_DOCUMENT_INTERFACE, NULL);
}
-/*
- * Error stuff...
- *
- * To add a new error type, edit here and in the .h InkscapeError enum.
- */
-GQuark
-inkscape_error_quark (void)
-{
- static GQuark quark = 0;
- if (!quark)
- quark = g_quark_from_static_string ("inkscape_error");
-
- return quark;
-}
-
-#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC }
-GType inkscape_error_get_type(void)
-{
- static GType etype = 0;
-
- if (etype == 0) {
- static const GEnumValue values[] =
- {
-
- ENUM_ENTRY(INKSCAPE_ERROR_SELECTION, "Incompatible_Selection"),
- ENUM_ENTRY(INKSCAPE_ERROR_OBJECT, "Incompatible_Object"),
- ENUM_ENTRY(INKSCAPE_ERROR_VERB, "Failed_Verb"),
- ENUM_ENTRY(INKSCAPE_ERROR_OTHER, "Generic_Error"),
- { 0, 0, 0 }
- };
-
- etype = g_enum_register_static("InkscapeError", values);
- }
-
- return etype;
-}
/****************************************************************************
MISC FUNCTIONS
@@ -565,7 +531,7 @@ gchar *document_interface_node(DocumentInterface *object, gchar *type, GError **
}
/****************************************************************************
- ENVIORNMENT FUNCTIONS
+ ENVIRONMENT FUNCTIONS
****************************************************************************/
gdouble
document_interface_document_get_width (DocumentInterface *object)
@@ -582,7 +548,9 @@ document_interface_document_get_height (DocumentInterface *object)
gchar *document_interface_document_get_css(DocumentInterface *object, GError ** /*error*/)
{
SPCSSAttr *current = (object->desk)->current;
- return sp_repr_css_write_string(current);
+ Glib::ustring str;
+ sp_repr_css_write_string(current, str);
+ return (str.empty() ? NULL : g_strdup (str.c_str()));
}
gboolean document_interface_document_merge_css(DocumentInterface *object,
@@ -803,7 +771,9 @@ document_interface_modify_css (DocumentInterface *object, gchar *shape,
SPCSSAttr * oldstyle = sp_repr_css_attr (node, style);
sp_repr_css_set_property(oldstyle, cssattrb, newval);
- node->setAttribute (style, sp_repr_css_write_string (oldstyle), TRUE);
+ Glib::ustring str;
+ sp_repr_css_write_string (oldstyle, str);
+ node->setAttribute (style, str.c_str(), TRUE);
return TRUE;
}
@@ -826,7 +796,10 @@ document_interface_merge_css (DocumentInterface *object, gchar *shape,
SPCSSAttr * oldstyle = sp_repr_css_attr (node, style);
sp_repr_css_merge(oldstyle, newstyle);
- node->setAttribute (style, sp_repr_css_write_string (oldstyle), TRUE);
+ Glib::ustring str;
+ sp_repr_css_write_string (oldstyle, str);
+ node->setAttribute (style, str.c_str(), TRUE);
+
return TRUE;
}
diff --git a/src/extension/dbus/document-interface.h b/src/extension/dbus/document-interface.h
index e7e55cb7d..5fcbb919b 100644
--- a/src/extension/dbus/document-interface.h
+++ b/src/extension/dbus/document-interface.h
@@ -56,19 +56,7 @@ struct _DocumentInterfaceClass {
GObjectClass parent;
};
-typedef enum
-{
- INKSCAPE_ERROR_SELECTION,
- INKSCAPE_ERROR_OBJECT,
- INKSCAPE_ERROR_VERB,
- INKSCAPE_ERROR_OTHER
-} InkscapeError;
-
-#define INKSCAPE_ERROR (inkscape_error_quark ())
-#define INKSCAPE_TYPE_ERROR (inkscape_error_get_type ())
-
-GQuark inkscape_error_quark (void);
-GType inkscape_error_get_type (void);
+
struct DBUSPoint {
int x;
diff --git a/src/extension/dependency.cpp b/src/extension/dependency.cpp
index f53dc93b4..78012ccc8 100644
--- a/src/extension/dependency.cpp
+++ b/src/extension/dependency.cpp
@@ -13,6 +13,8 @@
#endif
#include <glibmm/i18n.h>
+#include <glibmm/fileutils.h>
+#include <glibmm/miscutils.h>
#include "config.h"
#include "path-prefix.h"
#include "dependency.h"
@@ -120,8 +122,7 @@ Dependency::~Dependency (void)
found then a TRUE is returned. If we get all the way through the
path then a FALSE is returned, the command could not be found.
*/
-bool
-Dependency::check (void) const
+bool Dependency::check (void) const
{
// std::cout << "Checking: " << *this << std::endl;
@@ -214,7 +215,6 @@ Dependency::check (void) const
g_free(orig_path);
return FALSE; /* Reverse logic in this one */
- break;
}
} /* switch _location */
break;
diff --git a/src/extension/dxf2svg/GPL.txt b/src/extension/dxf2svg/GPL.txt
deleted file mode 100644
index 3912109b5..000000000
--- a/src/extension/dxf2svg/GPL.txt
+++ /dev/null
@@ -1,340 +0,0 @@
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users. This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it. (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.) You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
- To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have. You must make sure that they, too, receive or can get the
-source code. And you must show them these terms so they know their
-rights.
-
- We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
- Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software. If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary. To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- GNU GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License. The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language. (Hereinafter, translation is included without limitation in
-the term "modification".) Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
- 1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
- 2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) You must cause the modified files to carry prominent notices
- stating that you changed the files and the date of any change.
-
- b) You must cause any work that you distribute or publish, that in
- whole or in part contains or is derived from the Program or any
- part thereof, to be licensed as a whole at no charge to all third
- parties under the terms of this License.
-
- c) If the modified program normally reads commands interactively
- when run, you must cause it, when started running for such
- interactive use in the most ordinary way, to print or display an
- announcement including an appropriate copyright notice and a
- notice that there is no warranty (or else, saying that you provide
- a warranty) and that users may redistribute the program under
- these conditions, and telling the user how to view a copy of this
- License. (Exception: if the Program itself is interactive but
- does not normally print such an announcement, your work based on
- the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
- a) Accompany it with the complete corresponding machine-readable
- source code, which must be distributed under the terms of Sections
- 1 and 2 above on a medium customarily used for software interchange; or,
-
- b) Accompany it with a written offer, valid for at least three
- years, to give any third party, for a charge no more than your
- cost of physically performing source distribution, a complete
- machine-readable copy of the corresponding source code, to be
- distributed under the terms of Sections 1 and 2 above on a medium
- customarily used for software interchange; or,
-
- c) Accompany it with the information you received as to the offer
- to distribute corresponding source code. (This alternative is
- allowed only for noncommercial distribution and only if you
- received the program in object code or executable form with such
- an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it. For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable. However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License. Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
- 5. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Program or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
- 6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
- 7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all. For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded. In such case, this License incorporates
-the limitation as if written in the body of this License.
-
- 9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation. If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
- 10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission. For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this. Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
- NO WARRANTY
-
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program 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 General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
- Gnomovision version 69, Copyright (C) year name of author
- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
- This is free software, and you are welcome to redistribute it
- under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the program
- `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
- <signature of Ty Coon>, 1 April 1989
- Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs. If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library. If this is what you want to do, use the GNU Library General
-Public License instead of this License.
diff --git a/src/extension/dxf2svg/LGPL.txt b/src/extension/dxf2svg/LGPL.txt
deleted file mode 100644
index 8add30ad5..000000000
--- a/src/extension/dxf2svg/LGPL.txt
+++ /dev/null
@@ -1,504 +0,0 @@
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 2.1, February 1999
-
- Copyright (C) 1991, 1999 Free Software Foundation, Inc.
- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the Lesser GPL. It also counts
- as the successor of the GNU Library Public License, version 2, hence
- the version number 2.1.]
-
- Preamble
-
- The licenses for most software are designed to take away your
-freedom to share and change it. By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
- This license, the Lesser General Public License, applies to some
-specially designated software packages--typically libraries--of the
-Free Software Foundation and other authors who decide to use it. You
-can use it too, but we suggest you first think carefully about whether
-this license or the ordinary General Public License is the better
-strategy to use in any particular case, based on the explanations below.
-
- When we speak of free software, we are referring to freedom of use,
-not price. Our General Public Licenses are designed to make sure that
-you have the freedom to distribute copies of free software (and charge
-for this service if you wish); that you receive source code or can get
-it if you want it; that you can change the software and use pieces of
-it in new free programs; and that you are informed that you can do
-these things.
-
- To protect your rights, we need to make restrictions that forbid
-distributors to deny you these rights or to ask you to surrender these
-rights. These restrictions translate to certain responsibilities for
-you if you distribute copies of the library or if you modify it.
-
- For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you. You must make sure that they, too, receive or can get the source
-code. If you link other code with the library, you must provide
-complete object files to the recipients, so that they can relink them
-with the library after making changes to the library and recompiling
-it. And you must show them these terms so they know their rights.
-
- We protect your rights with a two-step method: (1) we copyright the
-library, and (2) we offer you this license, which gives you legal
-permission to copy, distribute and/or modify the library.
-
- To protect each distributor, we want to make it very clear that
-there is no warranty for the free library. Also, if the library is
-modified by someone else and passed on, the recipients should know
-that what they have is not the original version, so that the original
-author's reputation will not be affected by problems that might be
-introduced by others.
-
- Finally, software patents pose a constant threat to the existence of
-any free program. We wish to make sure that a company cannot
-effectively restrict the users of a free program by obtaining a
-restrictive license from a patent holder. Therefore, we insist that
-any patent license obtained for a version of the library must be
-consistent with the full freedom of use specified in this license.
-
- Most GNU software, including some libraries, is covered by the
-ordinary GNU General Public License. This license, the GNU Lesser
-General Public License, applies to certain designated libraries, and
-is quite different from the ordinary General Public License. We use
-this license for certain libraries in order to permit linking those
-libraries into non-free programs.
-
- When a program is linked with a library, whether statically or using
-a shared library, the combination of the two is legally speaking a
-combined work, a derivative of the original library. The ordinary
-General Public License therefore permits such linking only if the
-entire combination fits its criteria of freedom. The Lesser General
-Public License permits more lax criteria for linking other code with
-the library.
-
- We call this license the "Lesser" General Public License because it
-does Less to protect the user's freedom than the ordinary General
-Public License. It also provides other free software developers Less
-of an advantage over competing non-free programs. These disadvantages
-are the reason we use the ordinary General Public License for many
-libraries. However, the Lesser license provides advantages in certain
-special circumstances.
-
- For example, on rare occasions, there may be a special need to
-encourage the widest possible use of a certain library, so that it becomes
-a de-facto standard. To achieve this, non-free programs must be
-allowed to use the library. A more frequent case is that a free
-library does the same job as widely used non-free libraries. In this
-case, there is little to gain by limiting the free library to free
-software only, so we use the Lesser General Public License.
-
- In other cases, permission to use a particular library in non-free
-programs enables a greater number of people to use a large body of
-free software. For example, permission to use the GNU C Library in
-non-free programs enables many more people to use the whole GNU
-operating system, as well as its variant, the GNU/Linux operating
-system.
-
- Although the Lesser General Public License is Less protective of the
-users' freedom, it does ensure that the user of a program that is
-linked with the Library has the freedom and the wherewithal to run
-that program using a modified version of the Library.
-
- The precise terms and conditions for copying, distribution and
-modification follow. Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library". The
-former contains code derived from the library, whereas the latter must
-be combined with the library in order to run.
-
- GNU LESSER GENERAL PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. This License Agreement applies to any software library or other
-program which contains a notice placed by the copyright holder or
-other authorized party saying it may be distributed under the terms of
-this Lesser General Public License (also called "this License").
-Each licensee is addressed as "you".
-
- A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
- The "Library", below, refers to any such software library or work
-which has been distributed under these terms. A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language. (Hereinafter, translation is
-included without limitation in the term "modification".)
-
- "Source code" for a work means the preferred form of the work for
-making modifications to it. For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control compilation
-and installation of the library.
-
- Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope. The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it). Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-
- 1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
- You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-
- 2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
- a) The modified work must itself be a software library.
-
- b) You must cause the files modified to carry prominent notices
- stating that you changed the files and the date of any change.
-
- c) You must cause the whole of the work to be licensed at no
- charge to all third parties under the terms of this License.
-
- d) If a facility in the modified Library refers to a function or a
- table of data to be supplied by an application program that uses
- the facility, other than as an argument passed when the facility
- is invoked, then you must make a good faith effort to ensure that,
- in the event an application does not supply such function or
- table, the facility still operates, and performs whatever part of
- its purpose remains meaningful.
-
- (For example, a function in a library to compute square roots has
- a purpose that is entirely well-defined independent of the
- application. Therefore, Subsection 2d requires that any
- application-supplied function or table used by this function must
- be optional: if the application does not supply it, the square
- root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole. If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works. But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
- 3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library. To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License. (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.) Do not make any other change in
-these notices.
-
- Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
- This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
- 4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
- If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
- 5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library". Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
- However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library". The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
- When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library. The
-threshold for this to be true is not precisely defined by law.
-
- If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work. (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
- Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-
- 6. As an exception to the Sections above, you may also combine or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
- You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License. You must supply a copy of this License. If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License. Also, you must do one
-of these things:
-
- a) Accompany the work with the complete corresponding
- machine-readable source code for the Library including whatever
- changes were used in the work (which must be distributed under
- Sections 1 and 2 above); and, if the work is an executable linked
- with the Library, with the complete machine-readable "work that
- uses the Library", as object code and/or source code, so that the
- user can modify the Library and then relink to produce a modified
- executable containing the modified Library. (It is understood
- that the user who changes the contents of definitions files in the
- Library will not necessarily be able to recompile the application
- to use the modified definitions.)
-
- b) Use a suitable shared library mechanism for linking with the
- Library. A suitable mechanism is one that (1) uses at run time a
- copy of the library already present on the user's computer system,
- rather than copying library functions into the executable, and (2)
- will operate properly with a modified version of the library, if
- the user installs one, as long as the modified version is
- interface-compatible with the version that the work was made with.
-
- c) Accompany the work with a written offer, valid for at
- least three years, to give the same user the materials
- specified in Subsection 6a, above, for a charge no more
- than the cost of performing this distribution.
-
- d) If distribution of the work is made by offering access to copy
- from a designated place, offer equivalent access to copy the above
- specified materials from the same place.
-
- e) Verify that the user has already received a copy of these
- materials or that you have already sent this user a copy.
-
- For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it. However, as a special exception,
-the materials to be distributed need not include anything that is
-normally distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
- It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system. Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-
- 7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
- a) Accompany the combined library with a copy of the same work
- based on the Library, uncombined with any other library
- facilities. This must be distributed under the terms of the
- Sections above.
-
- b) Give prominent notice with the combined library of the fact
- that part of it is a work based on the Library, and explaining
- where to find the accompanying uncombined form of the same work.
-
- 8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License. Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License. However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
- 9. You are not required to accept this License, since you have not
-signed it. However, nothing else grants you permission to modify or
-distribute the Library or its derivative works. These actions are
-prohibited by law if you do not accept this License. Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
- 10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions. You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties with
-this License.
-
- 11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all. For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under any
-particular circumstance, the balance of the section is intended to apply,
-and the section as a whole is intended to apply in other circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices. Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
- 12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License may add
-an explicit geographical distribution limitation excluding those countries,
-so that distribution is permitted only in or among countries not thus
-excluded. In such case, this License incorporates the limitation as if
-written in the body of this License.
-
- 13. The Free Software Foundation may publish revised and/or new
-versions of the Lesser General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number. If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation. If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-
- 14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission. For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this. Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
- NO WARRANTY
-
- 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Libraries
-
- If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change. You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms of the
-ordinary General Public License).
-
- To apply these terms, attach the following notices to the library. It is
-safest to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least the
-"copyright" line and a pointer to where the full notice is found.
-
- <one line to give the library's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- 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
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the library, if
-necessary. Here is a sample; alter the names:
-
- Yoyodyne, Inc., hereby disclaims all copyright interest in the
- library `Frob' (a library for tweaking knobs) written by James Random Hacker.
-
- <signature of Ty Coon>, 1 April 1990
- Ty Coon, President of Vice
-
-That's all there is to it!
-
-
diff --git a/src/extension/dxf2svg/Makefile b/src/extension/dxf2svg/Makefile
deleted file mode 100644
index d0f06daf0..000000000
--- a/src/extension/dxf2svg/Makefile
+++ /dev/null
@@ -1,21 +0,0 @@
-objs = read_dxf.o entities.o entities2elements.o tables.o tables2svg_info.o blocks.o
-flags = -O1
-
-dxf2svg : dxf2svg.cpp $(objs)
- g++ $(flags) -o dxf2svg dxf2svg.cpp $(objs)
-
-test : test_dxf.cpp $(objs)
- g++ $(flags) -o test test_dxf.cpp $(objs)
-
-%.o : %.cpp %.h
- g++ $(flags) -c $<
-
-clean :
- rm dxf2svg $(objs)
-
-install:
- echo ****User intervention required****
- echo
- echo Copy dxf2svg executable and dxf2svg.inx to share/extension directory
- echo Make sure file permissions are set correctly
-
diff --git a/src/extension/dxf2svg/README b/src/extension/dxf2svg/README
deleted file mode 100644
index dbf98d2cc..000000000
--- a/src/extension/dxf2svg/README
+++ /dev/null
@@ -1,41 +0,0 @@
-26 Aug 05
-
-To use:
-I have only gotten this to work with Inkscape under linux (debian sarge). But the converter works from the commandline if you want to test it otherwise.
-
-1. Run make and copy dxf2svg to somewhere that is looked at by the PATH variable. Or add the current directory to your path
-2. Copy the dxf_import.inx to ../Inkscape/share/extensions
-3. Run Inkscape
-4. Click on open or import and the dxf option should be there
-
-I have compiled and then succesfully converted dxf files to svg files with the following setups
-
-WinXP Pro, Cygwin, g++ 3.3.3
-Debian Sarge, AMD x86_64, g++ 4.0.2
-RedHat(?), x86(?), g++ 3.2.3
-
-I have weakly tried and failed to compile using
-Borland's free compiler bcc32
-MinGW
-
-What is supported:
-polylines, lines, arc, circles, blocks, text, and a little linetypes
-
-currently not supported but I hope will be in the near future (probably after Sept 05)
-layers, colors, trace, splines, dimentions
-
-If you don't have dxf files of your own, but would like to easily test some I would suggest a few places...
-
-www.newfocus.com -- look under optomechanics. There are a variety of mounts and such that are posted in dxf and pdf
-www.thorlabs.com -- dido what I said about newfocus
-
-Free CAD programs:
-Windows -- A free and not too bad CAD program for windows is CadStd Lite. It exports to dxf and has a variety of samples.
-Windows/Linux -- QCad is ok. It has a lot of nice features but when I used it a year ago it would import dxf files but then you couldn't edit what was imported. It is free but with a time limit. My experience is that it can be a little annoying. Because of that and others comments I didn't use their libraries for dxf reading.
-
-
-Matt Squires
-squiresm@colorado.edu
-
-27 Aug 05, Fixed a fair number of bugs, and broken conversions. LWPOLYLINE works now, text rotation is ok but needs multiple transfomations to get it right, can read broken dxf files (w/o dxf EOF information)
-
diff --git a/src/extension/dxf2svg/aci2rgb.cpp b/src/extension/dxf2svg/aci2rgb.cpp
deleted file mode 100644
index 57e488bfc..000000000
--- a/src/extension/dxf2svg/aci2rgb.cpp
+++ /dev/null
@@ -1,114 +0,0 @@
-#include <iostream>
-#include <sstream>
-#include <string>
-
-
-char* RGB(double R, double G, double B);
-char* RGB(double R, double G, double B){
- int r = int (R);
- int g = int (G);
- int b = int (B);
-
- char out[6];
- char *chr_ptr;
- string output;
- stringstream oss;
-
- if (r < 16 ){
- oss << 0;
- }
- oss << hex << r;
-
- if (g < 16 ){
- oss << 0;
- }
- oss << hex << g;
-
- if (b < 16 ){
- oss << 0;
- }
- oss << hex << b;
-
- output = oss.str();
-
- for (int i = 0; i < 6; i++){
- out[i] = output[i];
- }
- chr_ptr = &out;
- return chr_ptr;
-}
-
-
-float aci_to_rgb(int aci);
-
-float aci_to_rgb(int aci)
- {
- aci = abs(aci); // hidden layers have negative color values
- if (aci<10 || aci>249) // values of these ranges are special colors
- {
- switch (aci)
- {
- case 1: return RGB(255,0,0); // basic colors
- case 2: return RGB(255,255,0);
- case 3: return RGB(0,255,0);
- case 4: return RGB(0,255,255);
- case 5: return RGB(0,0,255);
- case 6: return RGB(255,0,255);
- case 7: return RGB(255,255,255);
- case 8: return RGB(128,128,128);
- case 9: return RGB(192,192,192);
- case 250: return RGB(51,51,51); // grey shades
- case 251: return RGB(91,91,91);
- case 252: return RGB(132,132,132);
- case 253: return RGB(173,173,173);
- case 254: return RGB(214,214,214);
- case 255: return RGB(255,255,255);
- case 256: // "by layer"
- // Here you should decide how to handle "by layer" logical color.
- // Maybe it is a good idea to return a value like -1.
- // The outer code will find what is the color of the layer which
- // this entity belongs to.
- return -1;
- }
- }
- // for all the rest of ACI codes
- float H,S,L, R,G,B;
- int remainder = aci % 10;
- H = 1.5f * (aci - remainder - 10); // hue in range 0-360
- S = ((aci % 2) ? 0.5f : 1.0f); // odd colors have 50% of saturation, even - 100%
- // set lighteness, the last digit of aci code stands for this
- if (reminder == 0 || reminder == 1) L = 1.0f;
- if (reminder == 2 || reminder == 3) L = 0.8f;
- if (reminder == 4 || reminder == 5) L = 0.6f;
- if (reminder == 6 || reminder == 7) L = 0.5f;
- if (reminder == 8 || reminder == 9) L = 0.3f;
- // here we have H,S,L set already
- // let's convert it to RGB, first without consideration of S and L
- if (H<=120)
- {
- R = (120-H)/60;
- G = H/60;
- B = 0;
- }
- if (H>120 && H<=240)
- {
- R = 0;
- G = (240-H)/60;
- B = (H-120)/60;
- }
- if (H>240 && H<=360)
- {
- R = (H-240)/60;
- G = 0;
- B = (360-H)/60;
- }
- R = min(R, 1);
- G = min(G, 1);
- B = min(B, 1);
- // influence of S and L
- float max_value = max(R,max(G,B));
- R = (max_value-S*(max_value-R)) * L * 255;
- G = (max_value-S*(max_value-G)) * L * 255;
- B = (max_value-S*(max_value-B)) * L * 255;
- return RGB(R,G,B);
- } \ No newline at end of file
diff --git a/src/extension/dxf2svg/blocks.cpp b/src/extension/dxf2svg/blocks.cpp
deleted file mode 100644
index 36f2b9e7e..000000000
--- a/src/extension/dxf2svg/blocks.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Read Blocks from file and convert to vectors of entities
- *
- * Author:
- * Matt Squires <squiresm@colorado.edu>
- *
- * Copyright (C) 2005 Matt Squires
- *
- * Released under GNU GPL and LGPL, read the file 'GPL.txt' and 'LGPL.txt' for details
- */
-
-
-#include"blocks.h"
-#include<iostream>
-
-block::block(std::vector< std::vector< dxfpair > > sections) : entities( sections ){
- // Inherit most of the functionality of the entitites section
-
- basic_entity( sections[0] );
- block_info( sections[0] );
-}
-
-char* block::name(char* string){
- return( strcpy(string,block_name) );
-}
-
-
-void block::block_info( std::vector< dxfpair > info){
- static char string[10000];
- for (int i = 0; i < info.size(); i++){
- switch( info[i].group_code ){
- case 2: // Block name
- strcpy( string," "); // Clear the string out
- info[i].value_char(string);
- strcpy(block_name,string);
- break;
- }
- }
-}
-
-
-blocks::blocks(std::vector< std::vector< dxfpair > > sections){
- // Read the main information about the entities section and then put it in the enetites class
- char string[10000];
- std::vector< dxfpair > single_line;
- std::vector< std::vector< dxfpair > > ents;
- ents.clear();
- single_line.clear();
-
- int n_loop = sections.size();
- n_loop--;
- //for(int i = 0; i < (sections.size()-1); i++){ // It is odd but the last value seems to be bad so don't use it
- // I am not really sure if I need the -1. I needed it once upon a time to make things work but I don't have time to test it well right now
- // But sections.size() is an unsigned int so when you subtract 1 it becomes 4294967295 and tries to run the loop so work around that by making n_loop that is signed
- for(int i = 0; i < n_loop; i++){ // It is odd but the last value seems to be bad so don't use it
- sections[i][0].value_char(string);
- ents.clear(); // First clear out the pline information
-
-
- // Get everything from the start of the BLOCK designation to an ENDBLK value
- if ( strncmp(string,"BLOCK",5) == 0 && (i < sections.size())){
- do{
- ents.push_back( sections[i] );
- sections[++i][0].value_char(string);
- }while( strncmp(string,"ENDBLK",6) != 0 && (i < sections.size()-1) );
- blocks_blocks.push_back( block( ents ) );
- }
- }
-}
-
-block blocks::ret_block(char block_name[10000]){
- int string_len = 0;
- char temp[10000];
-
- for (int i = 0; i < blocks_blocks.size();i++){
- string_len = strlen(blocks_blocks[i].name(temp));
- if (strncmp(blocks_blocks[i].name(temp),block_name,string_len) == 0 ) return blocks_blocks[i];
- }
- return blocks_blocks[0];
-}
-
-
-
diff --git a/src/extension/dxf2svg/blocks.h b/src/extension/dxf2svg/blocks.h
deleted file mode 100644
index 27e0b8be1..000000000
--- a/src/extension/dxf2svg/blocks.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/* Read Blocks from file and convert to vectors of entities
-Matt Squires
-Google SOC 2005
-*/
-
-#ifndef DXF_BLOCKS_H
-#define DXF_BLOCKS_H
-
-#include"read_dxf.h"
-#include"entities.h"
-#include<vector>
-
-
-class block : public entity, public entities{// : public entities, {
- public:
- block( std::vector< std::vector< dxfpair > > sections ); // Group all of the blocks as entities
- char* name(char* string);
- //void blocks_display();
-
-
- protected:
- char block_name[10000];
- double rotation;
-
- private:
- void block_info(std::vector< dxfpair > info);
-};
-
-class blocks{
- public:
- blocks(std::vector< std::vector< dxfpair > > sections);
- block ret_block(char block_name[10000]);
-
- protected:
- std::vector< block > blocks_blocks;
-};
-
-#endif
diff --git a/src/extension/dxf2svg/dxf2svg.cpp b/src/extension/dxf2svg/dxf2svg.cpp
deleted file mode 100644
index 4884ed3fe..000000000
--- a/src/extension/dxf2svg/dxf2svg.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Build a SVG from an dxf, will support conversion to Inkscape types
- *
- * Author:
- * Matt Squires <squiresm@colorado.edu>
- *
- * Copyright (C) 2005 Matt Squires
- *
- * Released under GNU GPL and LGPL, read the file 'GPL.txt' and 'LGPL.txt' for details
- */
-
-
-#include<fstream>
-#include<iostream>
-#include"read_dxf.h"
-#include"entities.h"
-#include"blocks.h"
-#include"entities2elements.h"
-
-
-int main(int argc,char *argv[]){
- // Later include options for different conversions like converting as much as possible into paths
-
- if(argc > 1){
- double scaling = 90; // converstion from in to pt
-
- // Read the DXF file
- std::vector< std::vector< dxfpair > > output, entities_info, tables_info, blocks_info;
- //std::cout << "About to read file \n" << std::endl;
- output = dxf_get_sections(argv[1]);
- //std::cout << "Finished reading file \n" << std::endl;
-
- entities_info = separate_parts(output[4]); // Entities is the 5th part of the file.
- entities ents(entities_info); // Sort entities into their respective parts
-
- tables_info = separate_parts(output[2]); // Tables is the 3rd part of a dxf file.
- tables tbls(tables_info); // Sort the information in the tables
-
- blocks_info = separate_parts(output[3]); // Tables is the 4th part of a dxf file.
- blocks blks(blocks_info); // Sort the information in the tables
-
-
-
- // Get the various file informations
- /*std::vector< polyline > plines = ents.ret_plines();
- std::vector< lwpolyline > lwplines = ents.ret_lwplines();
- std::vector< arc > arcs = ents.ret_arcs();
- std::vector< circle > circs = ents.ret_circles();
- std::vector< line > lns = ents.ret_lines();
- std::vector< text > txts = ents.ret_texts();
- std::vector< insert > ins = ents.ret_inserts();
- */
-
-
- std::vector< layer > layers = tbls.ret_layers();
-
- char units[5] = "in";
- char tmp_char[100000];
- char layer_string[500];
- // int ink = 1; // Assume for now there is no inkscape stuff to add extra
-
- /*if (ink < 1){
- // Write a general svg header
- std::cout << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n\t\"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n<svg xmlns=\"http://www.w3.org/2000/svg\"\n\txmlns:xlink=\"http://www.w3.org/1999/xlink\">\n";
- std::cout << "\tx=\"0.00000000\"\n\ty=\"0.00000000\"\n\twidth=\"744.09448\"\n\theight=\"-1052.3622\"" << std::endl;
- }
- else{*/
- std::cout << "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" << std::endl;
- std::cout << "<!-- Created with dxf2svg -->" << std::endl;
- std::cout << "<svg" << std::endl;
- std::cout << "\txmlns:dc=\"http://purl.org/dc/elements/1.1/\"" << std::endl;
- std::cout << "\txmlns:cc=\"http://web.resource.org/cc/\"" << std::endl;
- std::cout << "\txmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"" << std::endl;
- std::cout << "\txmlns:svg=\"http://www.w3.org/2000/svg\"" << std::endl;
- std::cout << "\txmlns=\"http://www.w3.org/2000/svg\"" << std::endl;
- std::cout << "\txmlns:sodipodi=\"http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd\"" << std::endl;
- std::cout << "\txmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\"" << std::endl;
- std::cout << "\t>" << std::endl;
- //}
-
-
- // Now write SVG elements to file
- if ( layers.size() < 1 ){
- write_all(0, ents, tbls, blks, scaling, units, tmp_char);
- }
- else{
- for (int i = 0; i < layers.size(); i++){
- std::cout << "\t<g\n\t\tinkscape:label=\"" << layers[i].name(layer_string) << "\"\n\t\tinkscape:groupmode=\"layer\"\n\t\tid=\"layer" << i+1 << "\">" << std::endl;
- write_by_layer(0, ents, tbls, blks, scaling, units, layers[i].name(layer_string), tmp_char);
- std::cout << "\t</g>" << std::endl;
- }
- }
-
- // Close SVG
- std::cout << "</svg>";
- }
-
- return 0;
-}
diff --git a/src/extension/dxf2svg/dxf_input.inx b/src/extension/dxf2svg/dxf_input.inx
deleted file mode 100644
index b96274ade..000000000
--- a/src/extension/dxf2svg/dxf_input.inx
+++ /dev/null
@@ -1,16 +0,0 @@
-<inkscape-extension>
- <name>DXF Input</name>
- <id>org.inkscape.input.dxf</id>
- <dependency type="executable" description="dxf2svg may come with Inkscape, but is also at http://dxf-svg-convert.sourceforge.net/" location="extensions">dxf2svg</dependency>
- <dependency type="extension">org.inkscape.input.svg</dependency>
- <input>
- <extension>.dxf</extension>
- <mimetype>image/x-svgz</mimetype>
- <filetypename>AutoCAD DXF (*.dxf)</filetypename>
- <filetypetooltip>Import AutoCAD's Document Exchange Format</filetypetooltip>
- <output_extension>org.inkscape.output.svg</output_extension>
- </input>
- <script>
- <command reldir="extensions">dxf2svg</command>
- </script>
-</inkscape-extension>
diff --git a/src/extension/dxf2svg/dxf_input_windows.inx b/src/extension/dxf2svg/dxf_input_windows.inx
deleted file mode 100644
index 7dbe6a11b..000000000
--- a/src/extension/dxf2svg/dxf_input_windows.inx
+++ /dev/null
@@ -1,17 +0,0 @@
-<inkscape-extension>
- <name>DXF Input</name>
- <id>org.inkscape.input.dxf</id>
- <dependency type="executable" description="dxf2svg may come with Inkscape, but is also at
-http://dxf-svg-convert.sourceforge.net/" location="extensions">dxf2svg.exe</dependency>
- <dependency type="extension">org.inkscape.input.svg</dependency>
- <input>
- <extension>.dxf</extension>
- <mimetype>image/x-svgz</mimetype>
- <filetypename>AutoCAD DXF (*.dxf)</filetypename>
- <filetypetooltip>Import AutoCAD's Document Exchange Format</filetypetooltip>
- <output_extension>org.inkscape.output.svg</output_extension>
- </input>
- <script>
- <command reldir="extensions">dxf2svg.exe</command>
- </script>
-</inkscape-extension>
diff --git a/src/extension/dxf2svg/entities.cpp b/src/extension/dxf2svg/entities.cpp
deleted file mode 100644
index 4e2f83ee7..000000000
--- a/src/extension/dxf2svg/entities.cpp
+++ /dev/null
@@ -1,996 +0,0 @@
-/*
- * Class for interpereting the entities found in a DXF file
- *
- * Author:
- * Matt Squires <squiresm@colorado.edu>
- *
- * Copyright (C) 2005 Matt Squires
- *
- * Released under GNU GPL and LGPL, read the file 'GPL.txt' and 'LGPL.txt' for details
- */
-
-
-#include"entities.h"
-#include<iostream>
-#include<math.h>
-
-int detmine_entity(char* value){
- // Common Elements as far as I am concerend
- if ( strncmp(value,"POLYLINE",8) == 0 ) return 0;
- if ( strncmp(value,"ARC",3) == 0 ) return 1;
- if ( strncmp(value,"CIRCLE",6) == 0 ) return 2;
- if ( strncmp(value,"LINE",4) == 0 ) return 3;
- if ( strncmp(value,"SPLINE",6) == 0 ) return 4;
- if ( strncmp(value,"XLINE",5) == 0 ) return 5;
- if ( strncmp(value,"RAY",3) == 0 ) return 6;
- if ( strncmp(value,"DIMENSION",9) == 0 ) return 7;
- if ( strncmp(value,"ELLIPSE",7) == 0 ) return 8;
- if ( strncmp(value,"INSERT",6) == 0 ) return 9;
- if ( strncmp(value,"VERTEX",6) == 0 ) return 10;
- if ( strncmp(value,"TEXT",4) == 0 ) return 11;
-
- // Less Common eletities as far as I am concerend
- if ( strncmp(value,"3DSOLID",7) == 0 ) return 12;
- if ( strncmp(value,"ACAD_PROXY_ENTITY",17) == 0 ) return 13;
- if ( strncmp(value,"ARCALIGNEDTEXT",14) == 0 ) return 14;
- if ( strncmp(value,"ATTDEF",6) == 0 ) return 15;
- if ( strncmp(value,"ATTRIB",6) == 0 ) return 16;
- if ( strncmp(value,"BODY",4) == 0 ) return 17;
- if ( strncmp(value,"HATCH",5) == 0 ) return 18;
- if ( strncmp(value,"IMAGE",5) == 0 ) return 19;
- if ( strncmp(value,"LEADER",6) == 0 ) return 20;
- if ( strncmp(value,"LWPOLYLINE",10) == 0 ) return 21;
- if ( strncmp(value,"MLINE",5) == 0 ) return 22;
- if ( strncmp(value,"MTEXT",5) == 0 ) return 23;
- if ( strncmp(value,"OLEFRAME",8) == 0 ) return 24;
- if ( strncmp(value,"POINT",5) == 0 ) return 25;
- if ( strncmp(value,"REGION",6) == 0 ) return 26;
- if ( strncmp(value,"RTEXT",5) == 0 ) return 27;
- if ( strncmp(value,"SEQEND",6) == 0 ) return 28;
- if ( strncmp(value,"SHAPE",5) == 0 ) return 29;
- if ( strncmp(value,"SOLID",5) == 0 ) return 30;
- if ( strncmp(value,"3DFACE",6) == 0 ) return 31;
- if ( strncmp(value,"TOLERANCE",9) == 0 ) return 32;
- if ( strncmp(value,"TRACE",5) == 0 ) return 33;
- if ( strncmp(value,"VIEWPORT",8) == 0 ) return 34;
- if ( strncmp(value,"WIPEOUT",7) == 0 ) return 35;
- else return -1;
-}
-
-
-void entity::basic_entity( std::vector< dxfpair > info){
- // Extract all of the typical entity information (e.g. layer name, positions)
- static char string[10000];
- for (int i = 0; i < info.size(); i++){
- switch( info[i].group_code ){
- case 6:
- strcpy( string," "); // Clear the string out
- info[i].value_char(string);
- strcpy(linetype,string);
- break;
- case 8:
- strcpy( string," "); // Clear the string out
- info[i].value_char(string);
- strcpy(layer,string);
- break;
- case 10:
- info[i].value_char(string);
- x = atof(string);
- if ( x < min_x ){
- min_x = x;
- }
- if ( x > max_x ){
- max_x = x;
- }
- break;
- case 20:
- info[i].value_char(string);
- y = atof(string);
- if ( y < min_y ){
- min_y = y;
- }
- if ( y > max_y ){
- max_y = y;
- }
- break;
- case 30:
- info[i].value_char(string);
- z = atof(string);
- break;
- }
- }
-
-}
-
-void entity::entity_display(){
- std::cout << "\tlayer = " << layer << "\n\tlinetype = " << linetype << "\n\tx = " << x << "\ty = " << y << "\tz = " << z << std::flush;
-}
-
-double entity::ret_x(){
- return x;
-}
-
-double entity::ret_y(){
- return y;
-}
-
-double entity::ret_z(){
- return z;
-}
-
-
-char* entity::ret_layer_name(char* string){
- return( strcpy(string,layer) );
-}
-
-char* entity::ret_ltype_name(char* string){
- return( strcpy(string,linetype) );
-}
-
-double entity::ret_min_x(){
- return min_x;
-}
-
-double entity::ret_max_x(){
- return max_x;
-}
-
-double entity::ret_min_y(){
- return min_y;
-}
-
-double entity::ret_max_y(){
- return max_y;
-}
-
-void entity::test_coord(double x, double y){
- if ( x < min_x ){
- min_x = x;
- }
- if ( x > max_x ){
- max_x = x;
- }
- if ( y < min_y ){
- min_y = y;
- }
- if ( y > max_y ){
- max_y = y;
- }
-}
-
-
-void entity::reset_extents(){
- min_x = -1e20;
- max_x = 1e20;
- min_y = -1e20;
- max_y = 1e20;
-}
-
-
-/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// VERTEX
-/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-
-vertex::vertex( std::vector< dxfpair > info){
- // Get the vertex information
-
- basic_entity( info );
- static char string[10000];
- for (int i = 0; i < info.size(); i++){
- switch( info[i].group_code ){
- case 42:
- info[i].value_char(string);
- bulge = atof(string);
- break;
- }
- }
-}
-
-double vertex::ret_bulge(){
- return bulge;
-}
-
-void vertex::display(){
- std::cout << "VERTEX\n";
- std::cout << "\tx = " << x << "\ty = " << y << "\tz = " << z << "\tbulge = " << bulge << std::flush;
-}
-
-
-
-
-
-
-/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// POLYLINE
-/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-
-// The polyline is handled a little differently compared to the other entities because a POLYLINE is built from a bunch of VERTEX entities
-polyline::polyline( std::vector< std::vector< dxfpair > > sections ){
- buldge = 0;
- pline_flag = 0;
- reset_extents();
- // get the polyline information
- basic_entity( sections[0] );
- points.clear();
- static char string[10000];
- for (int i = 0; i < sections[0].size(); i++){
- switch( sections[0][i].group_code ){
- case 70:
- sections[0][i].value_char(string);
- pline_flag = atoi(string);
- break;
- case 40:
- sections[0][i].value_char(string);
- start_width = atoi(string);
- break;
- case 41:
- sections[0][i].value_char(string);
- end_width = atoi(string);
- break;
- case 75:
- sections[0][i].value_char(string);
- curves_flag = atoi(string);
- break;
- }
- }
- curves_flag = 0;
-
- // Now add the VERTEX entities to the POLYLINE
- for (int i = 1; i < sections.size(); i++){
- points.push_back( vertex( sections[i] ) );
- }
-}
-
-
-std::vector< vertex > polyline::ret_points(){
- return points;
-}
-
-double polyline::bulge(int point){
- return points[point].ret_bulge();
-}
-
-double polyline::bulge_r(int point){
- // Make sure we are not exceeding the bounds of the points vector
- if (point >= (points.size()-1)) return 0;
-
- double dx = points[point+1].ret_x() - points[point].ret_x();
- double dy = points[point+1].ret_y() - points[point].ret_y();
- double bulge = points[point].ret_bulge();
- double l = sqrt(dx*dx + dy*dy);
- double r = fabs(l*(bulge*bulge+1)/bulge/4);
-
- return r;
-}
-
-double polyline::bulge_start_angle(int point){
- // Make sure we are not exceeding the bounds of the points vector
- if (point >= (points.size()-1))
- {
- return 0;
- }
-
- double dx = points[point+1].ret_x() - points[point].ret_x();
- double dy = points[point+1].ret_y() - points[point].ret_y();
- double bulge = points[point].ret_bulge();
- double l = sqrt(dx*dx + dy*dy);
- double r = fabs(l*(bulge*bulge+1)/bulge/4);
-
- if (dx > 0)
- {
- sb *= -1; // Correct for different point ordering and bulge direction
- }
-
- // Now calculate the angle
- double theta = asin(points[point].ret_x()/r);
- if (dy < 0) theta = 6.2831853 - theta; // The angle is greater than pi so fix this because max(asin) = pi
-
- return theta;
-}
-
-double polyline::bulge_end_angle(int point){
- // Make sure we are not exceeding the bounds of the points vector
- if (point >= (points.size()-1))
- {
- return 0;
- }
-
- double dx = points[point+1].ret_x() - points[point].ret_x();
- double dy = points[point+1].ret_y() - points[point].ret_y();
- double bulge = points[point].ret_bulge();
- double l = sqrt(dx*dx + dy*dy);
- double r = fabs(l*(bulge*bulge+1)/bulge/4);
-
- // Now calculate the angle
- double theta = asin(points[point+1].ret_x()/r);
- if (dy < 0) theta = 6.2831853 - theta; // The angle is greater than pi so fix this because max(asin) = pi
-
- return theta;
-}
-
-bool polyline::is_closed(){
- // pline-flag holds info about closed pline in the 1 bit. The info is bit wise encoded so use bit wise operators
- return bool(pline_flag&1);
-}
-
-void polyline::display(){
- std::cout << "POLYLINE\n";
- entity_display();
- std::cout << std::endl;
- for (int i = 0; i < points.size(); i++){
- points[i].display();
- std::cout << std::endl;
- }
- std::cout << std::endl;
-}
-
-
-/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// LWPOLYLINE
-/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-
-// The lwpolyline is different than the polyline because there are no vertex entities. Use the same basic process as the polyline but parse it out differently
-lwpolyline::lwpolyline( std::vector< dxfpair > section ){
-
- // First break up the data into the same format that is used by the polyline entity
- std::vector< std::vector< dxfpair > > sections;
- std::vector< dxfpair > first;
- std::vector< dxfpair > others;
-
- sections.clear();
- first.clear();
- others.clear();
-
- int gc; // make a shorter name for group_code;
-
- int vertex_part;
- int already_found = 0;
-
- for (int i = 0; i < section.size(); i++){
- gc = section[i].group_code;
- // Encode bitwise information to keep track of what has been found
- vertex_part = 0;
- if (gc == 10 ) vertex_part += 1;
- if (gc == 20 ) vertex_part += 2;
- if (gc == 30 ) vertex_part += 4;
- if (gc == 40 ) vertex_part += 8;
- if (gc == 41 ) vertex_part += 16;
- if (gc == 42 ) vertex_part += 32;
- //std::cout << "\n\nvertex_part = " << vertex_part << std::endl << "already_found = " << already_found << std::endl << "(vertex_part&already_found) = " << (vertex_part&already_found) << std::endl;
- if ( vertex_part == 0 ){
- // If header stuff has been found save it under first.
- // I.E. in a polyline the first set of information is linetype and layer, all of what should be in here
- first.push_back( section[i] );
- }
- else if ( (vertex_part&already_found) == 0 ){
- // Now work on what would be the vertex information
- // New information is still being found so keep saving it
- others.push_back( section[i] );
- //std::cout << "add to others" << std::endl;
- already_found += vertex_part; // Keep track of what has been found
- }
- else{
- sections.push_back( others );
- //std::cout << "sections.size() = " << sections.size() << std::endl;
- // Now clear the information out and start over
- others.clear();
- others.push_back( section[i] );
- already_found = vertex_part;
- }
- }
-
- // Now put on the last data that was found
- if (!others.empty()){
- sections.push_back(others);
- }
-
- reset_extents();
- basic_entity( first );
- points.clear();
- static char string[10000];
- buldge = 0;
- pline_flag = 0;
- curves_flag = 0;
- for (int i = 0; i < first.size(); i++){
- switch( sections[0][i].group_code ){
- case 70:
- first[i].value_char(string);
- pline_flag = atoi(string);
- break;
- case 40:
- first[i].value_char(string);
- start_width = atoi(string);
- break;
- case 41:
- first[i].value_char(string);
- end_width = atoi(string);
- break;
- case 75:
- first[i].value_char(string);
- curves_flag = atoi(string);
- break;
- }
- }
- // Now add the VERTEX entities to the POLYLINE
- for (int i = 0; i < sections.size(); i++){
- points.push_back( vertex( sections[i] ) );
- }
-}
-
-
-
-std::vector< vertex > lwpolyline::ret_points(){
- return points;
-}
-
-
-double lwpolyline::bulge(int point){
- return points[point].ret_bulge();
-}
-
-double lwpolyline::bulge_r(int point){
- // Make sure we are not exceeding the bounds of the points vector
- if (point >= (points.size()-1)) return 0;
-
- double dx = points[point+1].ret_x() - points[point].ret_x();
- double dy = points[point+1].ret_y() - points[point].ret_y();
- double bulge = points[point].ret_bulge();
- double l = sqrt(dx*dx + dy*dy);
- double r = fabs(l*(bulge*bulge+1)/bulge/4);
-
- return r;
-}
-
-double lwpolyline::bulge_start_angle(int point){
- // Make sure we are not exceeding the bounds of the points vector
- if (point >= (points.size()-1)) return 0;
-
- double dx = points[point+1].ret_x() - points[point].ret_x();
- double dy = points[point+1].ret_y() - points[point].ret_y();
- double bulge = points[point].ret_bulge();
- double l = sqrt(dx*dx + dy*dy);
- double r = fabs(l*(bulge*bulge+1)/bulge/4);
-
- // Now calculate the angle
- double theta = asin(points[point].ret_x()/r);
- if (dy < 0) theta = 6.2831853 - theta; // The angle is greater than pi so fix this because max(asin) = pi
-
- return theta;
-}
-
-double lwpolyline::bulge_end_angle(int point){
- // Make sure we are not exceeding the bounds of the points vector
- if (point >= (points.size()-1)) return 0;
-
- double dx = points[point+1].ret_x() - points[point].ret_x();
- double dy = points[point+1].ret_y() - points[point].ret_y();
- double bulge = points[point].ret_bulge();
- double l = sqrt(dx*dx + dy*dy);
- double r = fabs(l*(bulge*bulge+1)/bulge/4);
-
- // Now calculate the angle
- double theta = asin(points[point+1].ret_x()/r);
- if (dy < 0) theta = 6.2831853 - theta; // The angle is greater than pi so fix this because max(asin) = pi
-
- return theta;
-}
-
-bool lwpolyline::is_closed(){
- // pline-flag holds info about closed pline in the 1 bit. The info is bit wise encoded so use bit wise operators
- return bool(pline_flag&1);
-}
-
-void lwpolyline::display(){
- std::cout << "lwpolyline\n";
- entity_display();
- std::cout << std::endl;
- for (int i = 0; i < points.size(); i++){
- points[i].display();
- std::cout << std::endl;
- }
- std::cout << std::endl;
-}
-
-
-
-/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// ARC
-/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-
-arc::arc( std::vector< dxfpair > info){
-
- reset_extents();
- basic_entity( info );
- static char string[10000];
- for (int i = 0; i < info.size(); i++){
- switch( info[i].group_code ){
- case 40:
- info[i].value_char(string);
- radius = atof(string);
- test_coord(x+radius,y+radius);
- test_coord(x-radius,y-radius);
- break;
- case 50:
- info[i].value_char(string);
- start_angle = atof(string);
- break;
- case 51:
- info[i].value_char(string);
- end_angle = atof(string);
- break;
- default:
- break;
- }
- }
-}
-
-double arc::ret_radius(){
- return radius;
-}
-
-
-double arc::ret_srt_ang(){
- return start_angle;
-}
-
-
-double arc::ret_end_ang(){
- return end_angle;
-}
-
-
-void arc::display(){
- std::cout << "ARC\n";
- entity_display();
- std::cout << "\n\tradius = " << radius << "\tstart_angle = " << start_angle << "end_angle = " << end_angle << std::flush;
-}
-
-
-
-/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// CIRCLE
-/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-
-circle::circle( std::vector< dxfpair > info){
-
- reset_extents();
- basic_entity( info );
- static char string[10000];
- for (int i = 0; i < info.size(); i++){
- switch( info[i].group_code ){
- case 40:
- info[i].value_char(string);
- radius = atof(string);
- test_coord(x+radius,y+radius);
- test_coord(x-radius,y-radius);
- break;
- }
- }
-}
-
-void circle::display(){
- std::cout << "CIRCLE\n";
- entity_display();
- std::cout << "\n\tradius = " << radius << std::flush;
-}
-
-
-double circle::ret_radius(){
- return radius;
-}
-
-
-/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// LINE
-/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-
-line::line( std::vector< dxfpair > info){
-
- reset_extents();
- basic_entity( info );
- static char string[10000];
- for (int i = 0; i < info.size(); i++){
- switch( info[i].group_code ){
- case 11:
- info[i].value_char(string);
- xf = atof(string);
- break;
- case 21:
- info[i].value_char(string);
- yf = atof(string);
- break;
- case 31:
- info[i].value_char(string);
- zf = atof(string);
- break;
- }
- }
- test_coord(xf,yf);
-
-}
-
-void line::display(){
- std::cout << "LINE\n";
- entity_display();
- std::cout << "\n\txf = " << xf << "\tyf = " << yf << "\tzf = " << zf << std::flush;
-}
-
-
-double line::ret_xf(){
- return xf;
-}
-
-double line::ret_yf(){
- return yf;
-}
-
-double line::ret_zf(){
- return zf;
-}
-
-
-
-
-/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// TEXT
-/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-text::text( std::vector< dxfpair > info){
-
- reset_extents();
- basic_entity( info );
- static char string[10000];
- for (int i = 0; i < info.size(); i++){
- switch( info[i].group_code ){
- case 1:
- info[i].value_char(dxf_text); // directly copy the text into a string
- break;
- case 40:
- info[i].value_char(string);
- text_height = atof(string);
- break;
- case 50:
- info[i].value_char(string);
- text_rotation = atof(string);
- break;
- }
- }
-}
-
-char * text::ret_text(char *string){
- return( strcpy(string,dxf_text) );
-}
-
-double text::ret_txt_ht(){
- return text_height;
-}
-
-double text::ret_txt_rot(){
- return text_rotation;
-}
-
-void text::display(){
- char tmp[10000];
- std::cout << "TEXT\n";
- entity_display();
- std::cout << "\ndxf_text = " << ret_text(tmp) << std::flush;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// INSERT
-/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-insert::insert( std::vector< dxfpair > info){
- ret_x_sf = 0;
- ret_y_sf = 0;
- ret_z_sf = 0;
- ret_rotation = 0;
-
- basic_entity( info );
- static char string[10000];
- for (int i = 0; i < info.size(); i++){
- switch( info[i].group_code ){
- case 2:
- info[i].value_char(block_name); // directly copy the text into a string
- break;
- case 41:
- info[i].value_char(string);
- x_scale_factor = atof(string);
- break;
- case 42:
- info[i].value_char(string);
- y_scale_factor = atof(string);
- break;
- case 43:
- info[i].value_char(string);
- z_scale_factor = atof(string);
- break;
- case 50:
- info[i].value_char(string);
- rotation = atof(string);
- break;
- }
- }
-}
-
-
-char * insert::name(char *string){
- return( strcpy(string,block_name) );
-}
-
-
-
-/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// entities
-/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-
-
-entities::entities(std::vector< std::vector< dxfpair > > sections){
- // Read the main information about the entities section and then put it in the enetites class
- int value;
- char string[10000];
- std::vector< dxfpair > single_line;
- std::vector< std::vector< dxfpair > > pline;
- pline.clear();
- single_line.clear();
-
- for(int i = 0; i < sections.size(); i++){
- sections[i][0].value_char(string);
- value = detmine_entity(string);
- switch( value ){
- case 0:
- // Get everything from the start of the polyline designation to an SEQEND value
- pline.clear(); // First clear out the pline information
- do{
- pline.push_back( sections[i] );
- sections[++i][0].value_char(string);
- }while( strncmp(string,"SEQEND",6) != 0 );
- ents_polyline.push_back( polyline( pline ) );
- break;
-
- case 1:
- // ARC
- ents_arc.push_back( arc( sections[i] ) );
- break;
-
- case 2:
- // CIRCLE
- ents_circle.push_back( circle( sections[i] ) );
- break;
-
- case 3:
- // LINE
- ents_line.push_back( line( sections[i] ) );
- break;
- case 11:
- // TEXT
- ents_text.push_back( text( sections[i] ) );
- break;
- case 21:
- // LWPOLYLINE
- ents_lwpolyline.push_back( lwpolyline( sections[i] ) );
- case 9:
- // INSERT
- ents_insert.push_back( insert( sections[i] ) );
-
- //default:
- // Nothing here
- }
-
- }
-
-}
-
-
-// Maybe all of this could be turned into fewer function by using templates, but no time right now. MBS
-
-std::vector< polyline > entities::ret_plines(){
- std::vector< polyline > pls;
- pls.clear();
- for(int i = 0; i < ents_polyline.size();i++){
- pls.push_back( ents_polyline[i] );
- }
- return pls;
-}
-
-std::vector< lwpolyline > entities::ret_lwplines(){
- std::vector< lwpolyline > lwpls;
- lwpls.clear();
- for(int i = 0; i < ents_lwpolyline.size();i++){
- lwpls.push_back( ents_lwpolyline[i] );
- }
- return lwpls;
-}
-
-
-std::vector< arc > entities::ret_arcs(){
- std::vector< arc > a;
- a.clear();
- for(int i = 0; i < ents_arc.size();i++){
- a.push_back( ents_arc[i] );
- }
- return a;
-}
-
-std::vector< circle > entities::ret_circles(){
- std::vector< circle > circs;
- circs.clear();
- for(int i = 0; i < ents_circle.size();i++){
- circs.push_back( ents_circle[i] );
- }
- return circs;
-}
-
-
-std::vector< line > entities::ret_lines(){
- std::vector< line > lns;
- lns.clear();
- for(int i = 0; i < ents_line.size();i++){
- lns.push_back( ents_line[i] );
- }
- return lns;
-}
-
-
-std::vector< text > entities::ret_texts(){
- std::vector< text > txts;
- txts.clear();
- for(int i = 0; i < ents_text.size();i++){
- txts.push_back( ents_text[i] );
- }
- return txts;
-}
-
-
-std::vector< insert > entities::ret_inserts(){
- std::vector< insert > ins;
- ins.clear();
- for(int i = 0; i < ents_insert.size();i++){
- ins.push_back( ents_insert[i] );
- }
- return ins;
-}
-
-
-
-// Overload the return function to depend on the layer
-std::vector< polyline > entities::ret_plines(char * layer){
- char temp[10000];
- std::vector< polyline > pls;
- pls.clear();
-
- for(int i = 0; i < ents_polyline.size();i++){
- if ( strcmp( layer,ents_polyline[i].ret_layer_name(temp) ) == 0 ){
- pls.push_back( ents_polyline[i] );
- }
- }
- return pls;
-}
-
-
-std::vector< lwpolyline > entities::ret_lwplines(char * layer){
- char temp[10000];
- std::vector< lwpolyline > lwpls;
- lwpls.clear();
-
- for(int i = 0; i < ents_lwpolyline.size();i++){
- if ( strcmp( layer,ents_lwpolyline[i].ret_layer_name(temp) ) == 0 ){
- lwpls.push_back( ents_lwpolyline[i] );
- }
- }
- return lwpls;
-}
-
-
-std::vector< circle > entities::ret_circles(char * layer){
- char temp[10000];
- std::vector< circle > circs;
- circs.clear();
-
- for(int i = 0; i < ents_circle.size();i++){
- if ( strcmp( layer,ents_circle[i].ret_layer_name(temp) ) == 0 ){
- circs.push_back( ents_circle[i] );
- }
- }
- return circs;
-}
-
-
-std::vector< line > entities::ret_lines(char * layer){
- char temp[10000];
- std::vector< line > lns;
- lns.clear();
-
- for(int i = 0; i < ents_line.size();i++){
- if ( strcmp( layer,ents_line[i].ret_layer_name(temp) ) == 0 ){
- lns.push_back( ents_line[i] );
- }
- }
- return lns;
-}
-
-
-std::vector< text > entities::ret_texts(char * layer){
- char temp[10000];
- std::vector< text > txts;
- txts.clear();
-
- for(int i = 0; i < ents_text.size();i++){
- if ( strcmp( layer,ents_text[i].ret_layer_name(temp) ) == 0 ){
- txts.push_back( ents_text[i] );
- }
- }
- return txts;
-}
-
-
-/*std::vector< ellipse > entities::ret_ellipses(char * layer){
- char temp[10000];
- std::vector< polyline > pls;
- pls.clear();
-
- for(int i = 0; i < ents_polyline.size();i++){
- if ( strcmp( layer,ents_polyline[i].ret_layer_name(temp) ) == 0 ){
- pls.push_back( ents_polyline[i] );
- }
- }
- return pls;
-}*/
-
-
-std::vector< arc > entities::ret_arcs(char * layer){
- char temp[10000];
- std::vector< arc > a;
- a.clear();
-
- for(int i = 0; i < ents_arc.size();i++){
- if ( strcmp( layer,ents_arc[i].ret_layer_name(temp) ) == 0 ){
- a.push_back( ents_arc[i] );
- }
- }
- return a;
-}
-
-
-std::vector< insert > entities::ret_inserts(char * layer){
- char temp[10000];
- std::vector< insert > ins;
- ins.clear();
-
- for(int i = 0; i < ents_insert.size();i++){
- if ( strcmp( layer,ents_insert[i].ret_layer_name(temp) ) == 0 ){
- ins.push_back( ents_insert[i] );
- }
- }
- return ins;
-}
-
-
-
-
-void entities::display_all(){
- for (int i = 0; i < ents_polyline.size(); i++){
- ents_polyline[i].display();
- }
- std::cout << std::endl;
- for (int i = 0; i < ents_lwpolyline.size(); i++){
- ents_lwpolyline[i].display();
- }
- std::cout << std::endl;
- for (int i = 0; i < ents_circle.size(); i++){
- ents_circle[i].display();
- }
- std::cout << std::endl;
- for (int i = 0; i < ents_text.size(); i++){
- ents_text[i].display();
- }
-}
-
-
diff --git a/src/extension/dxf2svg/entities.h b/src/extension/dxf2svg/entities.h
deleted file mode 100644
index 3afd949b0..000000000
--- a/src/extension/dxf2svg/entities.h
+++ /dev/null
@@ -1,256 +0,0 @@
-/* Class for interpereting the entities found in a DXF file
-Matt Squires
-Google SOC
-2 July 05
-*/
-
-#ifndef DXF_ENTITIES_H
-#define DXF_ENTITIES_H
-
-#include"read_dxf.h"
-#include<vector>
-
-
-
-
-class entity{
- public:
- void basic_entity( std::vector< dxfpair > info); // Extract all of the typical entity information (e.g. layer name, positions)
- void entity_display();
- double ret_x();
- double ret_y();
- double ret_z();
- char* ret_layer_name(char* string);
- char* ret_ltype_name(char* string);
- double ret_min_x();
- double ret_max_x();
- double ret_min_y();
- double ret_max_y();
-
-
- protected:
- char layer[10000];
- char linetype[10000];
- double x;
- double y;
- double z;
- double min_x;
- double max_x;
- double min_y;
- double max_y;
- void reset_extents();
- void test_coord(double x, double y);
-};
-
-
-
-
-
-class vertex : public entity {
- public:
- vertex( std::vector< dxfpair > info);
- void display();
- double ret_bulge();
-
- private:
- double bulge;
-};
-
-
-
-
-
-class polyline : public entity {
- public:
- polyline( std::vector< std::vector< dxfpair > > sections );
- std::vector< vertex > ret_points();
- double bulge(int point);
- double bulge_r(int point);
- double bulge_start_angle(int point);
- double bulge_end_angle(int point);
- bool is_closed();
- void display();
-
- private:
- double buldge;
- int pline_flag; // 70
- double start_width; // 40
- double end_width; // 41
- int curves_flag;
- std::vector< vertex > points;
-};
-
-class lwpolyline : public entity {
- public:
- lwpolyline( std::vector< dxfpair > section );
- std::vector< vertex > ret_points();
- double bulge(int point);
- double bulge_r(int point);
- double bulge_start_angle(int point);
- double bulge_end_angle(int point);
- bool is_closed();
- void display();
-
- private:
- double buldge;
- int pline_flag; // 70
- double start_width; // 40
- double end_width; // 41
- int curves_flag;
- std::vector< vertex > points;
-};
-
-class arc : public entity {
- public:
- arc( std::vector< dxfpair > info);
- double ret_radius();
- double ret_srt_ang();
- double ret_end_ang();
- void display();
-
- private:
- double radius;
- double start_angle;
- double end_angle;
-};
-
-
-
-
-class circle : public entity {
- public:
- circle( std::vector< dxfpair > info);
- void display();
- double ret_radius();
-
- private:
- double radius;
-};
-
-
-class line : public entity {
- public:
- line( std::vector< dxfpair > info);
- void display();
- double ret_xf();
- double ret_yf();
- double ret_zf();
-
- private:
- double xf;
- double yf;
- double zf;
-};
-
-class ellipse : public entity {
- public:
- ellipse( std::vector< dxfpair > info);
- void display();
- double ret_x_ma;
- double ret_y_ma;
- double ret_z_ma;
- double ret_ratio;
- double ret_start_p;
- double ret_end_p;
-
-
- private:
- double x_major_axis;
- double y_major_axis;
- double z_major_axis;
- double ratio;
- double start_param;
- double end_param;
-};
-
-
-
-class text : public entity {
- public:
- text( std::vector< dxfpair > info);
- void display();
- char * ret_text(char *string);
- double ret_txt_ht();
- double ret_txt_rot();
-
- private:
- char dxf_text[10000];
- double text_height; // dxf 40
- double text_rotation; //dxf 50
-};
-
-
-class insert : public entity {
- public:
- insert( std::vector< dxfpair > info);
- void display();
- char* name(char* string);
- double ret_x_sf;
- double ret_y_sf;
- double ret_z_sf;
- double ret_rotation;
-
- private:
- char block_name[10000];
- double x_scale_factor;
- double y_scale_factor;
- double z_scale_factor;
- double rotation;
-};
-
-
-
-
-
-
-class entities{
- // Well I said that I would only use STL containers internally, but I would have to use a dynamically linked list, and I haven't done for a long time soo STL is my crutch.
- // I also think that there are others in my same boat that prefer stl containers because they are much easier to use
- public:
- entities(std::vector< std::vector< dxfpair > > sections); // Put the various entities into their respective vectors
- void display_all();
- std::vector< polyline > ret_plines();
- std::vector< circle > ret_circles();
- std::vector< line > ret_lines();
- std::vector< text > ret_texts();
- std::vector< ellipse > ret_ellipses();
- std::vector< arc > ret_arcs();
- std::vector< lwpolyline > ret_lwplines();
- std::vector< insert > ret_inserts();
- // Overload the return function to depend on the layer
- std::vector< polyline > ret_plines(char * layer);
- std::vector< circle > ret_circles(char * layer);
- std::vector< line > ret_lines(char * layer);
- std::vector< text > ret_texts(char * layer);
- std::vector< ellipse > ret_ellipses(char * layer);
- std::vector< arc > ret_arcs(char * layer);
- std::vector< lwpolyline > ret_lwplines(char * layer);
- std::vector< insert > ret_inserts(char * layer);
-
- int plines_size();
- int circles_size();
- int lines_size();
- int texts_size();
-
-
-
- private:
- void add_polyline(polyline pline);
- void add_circle(circle circ);
- void add_line(line ln);
-
- std::vector< polyline > ents_polyline;
- std::vector< arc > ents_arc;
- std::vector< circle > ents_circle;
- std::vector< line > ents_line;
- std::vector< ellipse > ents_ellipse;
- std::vector< text > ents_text;
- std::vector< lwpolyline > ents_lwpolyline;
- std::vector< insert > ents_insert;
-
-
-};
-
-
-
-#endif
diff --git a/src/extension/dxf2svg/entities2elements.cpp b/src/extension/dxf2svg/entities2elements.cpp
deleted file mode 100644
index 8a17a0d84..000000000
--- a/src/extension/dxf2svg/entities2elements.cpp
+++ /dev/null
@@ -1,678 +0,0 @@
-/*
- * Code for converting dxf entities to SVG elements
- * There are multiple ways for converting different items
- * If possible most DXF enetities will be converted to paths because that is the most flexable object
- *
- * Author:
- * Matt Squires <squiresm@colorado.edu>
- *
- * Copyright (C) 2005 Matt Squires
- *
- * Released under GNU GPL and LGPL, read the file 'GPL.txt' and 'LGPL.txt' for details
- */
-
-
-
-/*
-
-Matt Squires
-SoC 2005
-
-*/
-
-#include "entities2elements.h"
-#include "tables2svg_info.h"
-#include <iostream>
-#include <math.h>
-#include <string.h>
-#include <stdlib.h>
-// The names indicate the DXF entitiy first and the SVG element last
-
-// Common elements
-char* to_arc(double bulge, double r, double start_ang, double end_ang, int precision,char* delim, char * units, double scaling, char *out){
- // This is used for arcs, polylines, and lwpolylines
- char temp[50];
-
- // Assume that we are adding to the input and not starting over
- strcat(out," A ");
- // For arcs there is only one radius
- strcat(out,gcvt(scaling*r,precision,temp) );
- strcat(out,",");
- strcat(out,gcvt(scaling*r,precision,temp) );
-
- strcat(out," 0"); // For arc assume no x-axis rotation. That seems to apply to elipse elements only
- // Determine if it is a large arc
- if ( (end_ang > start_ang) && ( (end_ang - start_ang) > 180) ){
- //strcat(out," 1,0 "); // Large arc flag...Always use a zero sweep flag
- strcat(out," 1, "); // Large arc flag...Always use a zero sweep flag
- }
- else{
- //strcat(out," 0,0 "); // Small arc flag...Always use a zero sweep flag
- strcat(out," 0,");
- }
- // This may be easier if I allow r to be plus and minus, but for now this works
- if (bulge > 0){
- strcat(out,"0 ");
- }
- else{
- strcat(out,"1 ");
- }
-}
-
-// Build Coordinate
-void coord(entity *ent, int precision,char* delim, char * units, double scaling, char *out){
- // Pairs of coords with units will be used so often build a function build a dedicated function for returning such
-
- char temp[20];
- if (units != NULL) scaling = 1; // If units have been defined then ignore the scaling parameter
- strcat(out, gcvt(scaling*ent->ret_x(),precision,temp) ); // There must be a better function for double to ascii conversion that is defined in most libraries
- if (units != NULL) strcat(out, units);
- strcat(out, delim);
- strcat(out, gcvt(-scaling*ent->ret_y(),precision,temp) ); // Because SVG has a the Y-axis pointed down multiply by -1
- if (units != NULL) strcat(out, units);
- strcat(out, " ");
-}
-
-// DXF Polyline -> SVG
-// General function for the conversion of a pline to a SVG element. Very similar functions just make accomidations for parts that may not be supported
-void pline2svg(polyline pline, int type, int precision, char * units, double scaling, tables plot_info, char *out){
- // 0 is pline2path
- // 1 is pline2pline
- // 2 is pline2polygon
-
-
- char delim[2];
-
- std::vector< vertex >::iterator vver_iter;
- std::vector< vertex > points = pline.ret_points();
-
- if (type < 1){
- // Put the first Move To at the first, everything else will be a lineto
- strcpy(delim," ");
- strcat(out, "M ");
- coord( &points[0], precision, delim, units, scaling, out );
- double prev_mag_bulge = sqrt(pow(points[0].ret_bulge(),2)); // Because the bulge value can be positive or negative calculate the magnitude
- if ( prev_mag_bulge > pow(0.1,precision) ){
- to_arc(pline.bulge(0), pline.bulge_r(0), pline.bulge_start_angle(0), pline.bulge_end_angle(0), precision, delim, units, scaling, out);
- }
- for (int i = 1; i < points.size(); i++){
- if ( prev_mag_bulge < pow(0.1,precision) ){
- // If the previous point was a bulge then don't use a line to
- strcat(out, "L ");
- }
- coord( &points[i], precision, delim, units, scaling, out );
- // If bulge > some precsion then add bulge
- double mag_bulge = sqrt(pow(points[i].ret_bulge(),2));
- if ( (mag_bulge > pow(0.1,precision)) && (i < (points.size() - 1) )){
- to_arc(pline.bulge(i), pline.bulge_r(i), pline.bulge_start_angle(i), pline.bulge_end_angle(i), precision, delim, units, scaling, out);
- }
- prev_mag_bulge = mag_bulge;
- }
- if ( pline.is_closed() ){
- strcat(out,"z");
- }
- strcat(out,"\" ");
- }
- else{
- strcpy(delim,",");
- for (int i = 0; i < points.size(); i++){
- coord( &points[i], precision, delim, NULL, scaling, out );
- // If bulge > some precsion then add bulge
- }
- // if the element is a SVG::pline and the DXF::pline is closed then simulate by adding an extra point
- if ( (type == 1) && pline.is_closed() ){
- coord( &points[0], precision, delim, NULL, scaling, out );
- }
- }
-
-}
-
-char* pline2path(polyline pline, char * units, double scaling, tables plot_info){
- // Convert a dxf polyline to a SVG path. This is the closest conversion of the DXF polyline to an SVG element
- char *out_ptr;
- char out[10000] = "<path d=\"";
- entity *ent_ptr = &pline;
- char temp[20];
- int precision = 6;
-
- pline2svg(pline, 0, precision, units, scaling, plot_info, out);
- // Add some line information
- strcat(out,"fill=\"none\" stroke=\"black\" stroke-width=\"1\" ");
- pattern2dasharray(plot_info.ret_ltype( ent_ptr->ret_ltype_name(temp),ent_ptr->ret_layer_name(temp) ), precision, scaling, out); // Add the linetype information
-
- strcat(out," />");
- out_ptr = out;
- return out_ptr;
-}
-
-char* pline2pline(polyline pline, char * units, double scaling, tables plot_info){
- // Convert a dxf polyline to a SVG polyline. The conversion is not 1:1 because the SVG pline doesn't support closed objects or curves
- entity *ent_ptr = &pline;
- char temp[2000];
- int precision = 6;
-
- char out[10000] = "<polyline fill=\"none\" stroke=\"black\" stroke-width=\"1\" ";
- ltype linfo = plot_info.ret_ltype(ent_ptr->ret_ltype_name(temp), ent_ptr->ret_layer_name(temp));
- pattern2dasharray(linfo, precision, scaling, out); // Add the linetype information
- //strcpy(temp," ");
-
- strcat(out,"points=\"");
-
- //strcat(out,"<polyline fill=\"none\" stroke=\"black\" stroke-width=\"1\" points=\"");
- pline2svg(pline, 1, precision, units, scaling, plot_info, out);
- // Add some line information
- // if the DXF pline is closed then add an extra point
-
- strcat(out,"\"/>");
- char *out_ptr = out;
- return out_ptr;
-}
-char* pline2polygon(polyline pline, char * units, double scaling, tables plot_info){
- // Convert a dxf polyline to a SVG polygon. The conversion is not 1:1 because the SVG polygone assumes a closed path. If the pline is not closed it will be forced closed
- //return pline2svg(pline, 2, 6, units, double scaling,out);
-}
-
-
-// DXF LWPolyline -> SVG
-
-
-// This could be a template with polyline and lwpolyline but right now it is not that important
-void lwpline2svg(lwpolyline pline, int type, int precision, char * units, double scaling, tables plot_info, char *out); // General function for the conversion of a pline to a SVG element. Very similar functions just make accomidations for parts that may not be supported
-void lwpline2svg(lwpolyline pline, int type, int precision, char * units, double scaling, tables plot_info, char *out){
- // 0 is pline2path
- // 1 is pline2pline
- // 2 is pline2polygon
-
-
- char delim[2];
-
- std::vector< vertex >::iterator vver_iter;
- std::vector< vertex > points = pline.ret_points();
-
- if (type < 1){
- // Put the first Move To at the first, everything else will be a lineto
- strcpy(delim," ");
- strcat(out, "M ");
- coord( &points[0], precision, delim, NULL, scaling, out );
- double prev_mag_bulge = sqrt(pow(points[0].ret_bulge(),2)); // Because the bulge value can be positive or negative calculate the magnitude
- if ( prev_mag_bulge > pow(0.1,precision) ){
- to_arc(pline.bulge(0),pline.bulge_r(0), pline.bulge_start_angle(0), pline.bulge_end_angle(0), precision, delim, NULL, scaling, out);
- }
-
- for (int i = 1; i < points.size(); i++){
- if ( prev_mag_bulge < pow(0.1,precision) ){
- // If the previous point was a bulge then don't use a line to
- strcat(out, "L ");
- }
- coord( &points[i], precision, delim, NULL , scaling, out );
- // If bulge > some precsion then add bulge
- double mag_bulge = sqrt(pow(points[i].ret_bulge(),2));
- if ( ( mag_bulge > pow(0.1,precision) ) && (i < (points.size() - 1) )){ // Make sure the final point doesn't add a bulge on accident
- to_arc(pline.bulge(i), pline.bulge_r(i), pline.bulge_start_angle(i), pline.bulge_end_angle(i), precision, delim, units, scaling, out);
- }
- prev_mag_bulge = mag_bulge;
- }
- if ( pline.is_closed() ){
- strcat(out,"z");
- }
- strcat(out,"\" ");
- }
- else{
- strcpy(delim,",");
- for (int i = 0; i < points.size(); i++){
- coord( &points[i], precision, delim, units, scaling, out );
- // If bulge > some precsion then add bulge
- }
- // if the element is a SVG::pline and the DXF::pline is closed then simulate by adding an extra point
- if ( (type == 1) && pline.is_closed() ){
- coord( &points[0], precision, delim, units, scaling, out );
- }
- }
-
-}
-
-char* lwpline2path(lwpolyline pline, char * units, double scaling, tables plot_info){
- // Convert a dxf polyline to a SVG path. This is the closest conversion of the DXF polyline to an SVG element
- char *out_ptr;
- char out[10000] = "<path d=\"";
- entity *ent_ptr = &pline;
- char temp[20];
- int precision = 6;
-
- lwpline2svg(pline, 0, precision, units, scaling, plot_info, out);
- // Add some line information
- strcat(out,"fill=\"none\" stroke=\"black\" stroke-width=\"1\" ");
- pattern2dasharray(plot_info.ret_ltype( ent_ptr->ret_ltype_name(temp),ent_ptr->ret_layer_name(temp) ), precision, scaling, out); // Add the linetype information
-
- strcat(out," />");
- out_ptr = out;
- return out_ptr;
-}
-
-// DXF ARC -> SVG
-char* arc2path(arc a, int precision, char * units, double scaling, tables plot_info, char *out){
- // So far this appears to be the only way to convert arcs into something recognized by SVG
- char *out_ptr;
- char temp[20];
- entity *ent_ptr = &a;
-
- strcpy(out,"<path d=\"M");
- // Calculate the starting point from the center and the start angle. As far as I can tell the rotation is CCW in the dxf notation and it in degrees
- strcat(out,gcvt(scaling*(ent_ptr->ret_x()+a.ret_radius()*cos( a.ret_srt_ang()*3.14159/180 )),precision,temp) );
- strcat(out," ");
- strcat(out,gcvt(-1*scaling*(ent_ptr->ret_y()+a.ret_radius()*sin( a.ret_srt_ang()*3.14159/180 )),precision,temp) );
- strcat(out," A ");
- // For arcs there is only one radius
- strcat(out,gcvt(scaling*a.ret_radius(),precision,temp) );
- strcat(out,",");
- strcat(out,gcvt(scaling*a.ret_radius(),precision,temp) );
-
- strcat(out," 0"); // For arc assume no x-axis rotation. That seems to apply to elipse elements only
- // Determine if it is a large arc
- if ( (a.ret_end_ang() > a.ret_srt_ang()) && ( (a.ret_end_ang() - a.ret_srt_ang()) > 180) ){
- strcat(out," 1,0 "); // Large arc flag...Always use a zero sweep flag
- }
- else{
- strcat(out," 0,0 "); // Small arc flag...Always use a zero sweep flag
- }
-
- //The final point
- strcat(out,gcvt(scaling*(ent_ptr->ret_x()+a.ret_radius()*cos( a.ret_end_ang()*3.14159/180 )),precision,temp) );
- strcat(out,",");
- strcat(out,gcvt(-1*scaling*(ent_ptr->ret_y()+a.ret_radius()*sin( a.ret_end_ang()*3.14159/180 )),precision,temp) );
- strcat(out,"\" fill=\"none\" stroke=\"black\" stroke-width=\"1\" ");
- ltype linfo = plot_info.ret_ltype(ent_ptr->ret_ltype_name(temp), ent_ptr->ret_layer_name(temp));
- pattern2dasharray(linfo, precision, scaling, out); // Add the linetype information
- strcat(out, " />");
-
-
- out_ptr = out;
- return out_ptr;
-
-}
-
-
-// DXF Circle -> SVG
-char* circle2circle(circle circ, int precision, char * units, double scaling, tables plot_info, char *out){
- // Direct conversion of DXF circle to SVG circle
- char *out_ptr;
- char temp[1000]="\" cy=\"";
- entity *ent_ptr = &circ;
- strcpy(out,"<circle cx=\"");
- coord(ent_ptr, precision,temp, units, scaling, out);
- strcat(out,"\" r=\"");
- strcat(out,gcvt(circ.ret_radius(),precision,temp) );
- strcat(out,units);
- strcat(out,"\" fill=\"none\" stroke=\"black\" stroke-width=\"1\" ");
- ltype linfo = plot_info.ret_ltype(ent_ptr->ret_ltype_name(temp), ent_ptr->ret_layer_name(temp));
- //plot_info.ret_ltype(ent_ptr->ret_ltype_name(temp), ent_ptr->ret_layer_name(temp));
- pattern2dasharray(linfo, precision, scaling, out); // Add the linetype information
- //pattern2dasharray(plot_info.ret_ltype(ent_ptr->ret_ltype_name(temp), ent_ptr->ret_layer_name(temp)), precision, scaling, out); // Add the linetype information
- strcat(out, " />");
- out_ptr = out;
- return out_ptr;
-}
-
-char* circle2path(circle circ, int precision, char * units, double scaling, tables plot_info, char *out){
- // Conversion of DXF circle to SVG circle assuming the path will represent the circle
-
- char *out_ptr;
- char temp[20]=",";
- entity *ent_ptr = &circ;
-
- strcpy(out,"<path d=\"M");
- // The starting point is x-r,y so subtract off the radius from the x coord
- strcat(out,gcvt(ent_ptr->ret_x()-circ.ret_radius(),precision,temp) );
- strcat(out," ");
- strcat(out,gcvt(ent_ptr->ret_y(),precision,temp) );
-
- strcat(out," a");
- strcat(out,gcvt(circ.ret_radius(),precision,temp) );
- strcat(out,",");
- strcat(out,gcvt(circ.ret_radius(),precision,temp) );
- strcat(out,"0 0,0 0,0\" fill=\"none\" stroke=\"black\" stroke-width=\"1\"");
-
- out_ptr = out;
- return out_ptr;
-}
-
-
-// DXF Line -> SVG
-char* line2line(line ln, int precision, char * units, double scaling, tables plot_info, char *out){
- // Directly convert DXF to SVG because it works
- char *out_ptr;
- char temp[20];
- entity *ent_ptr = &ln;
-
- strcpy(out,"<line x1=\"");
- strcat(out,gcvt(ent_ptr->ret_x(),precision,temp) );
- strcat(out,units);
- strcat(out,"\" y1=\"");
- strcat(out,gcvt(-1*ent_ptr->ret_y(),precision,temp) ); // Put in an extra minus because of the way SVG has defined the axis
- strcat(out,units);
-
- strcat(out,"\" x2=\"");
- strcat(out,gcvt(ln.ret_xf(),precision,temp) );
- strcat(out,units);
- strcat(out,"\" y2=\"");
- strcat(out,gcvt(-1*ln.ret_yf(),precision,temp) ); // Put in an extra minus because of the way SVG has defined the axis
- strcat(out,units);
- strcat(out,"\" stroke-width=\"1\" stroke=\"black\" ");
- ltype linfo = plot_info.ret_ltype(ent_ptr->ret_ltype_name(temp), ent_ptr->ret_layer_name(temp));
- pattern2dasharray(linfo, precision, scaling, out); // Add the linetype information
- strcat(out, " />");
-
- out_ptr = out;
- return out_ptr;
-}
-
-
-char* line2path(line ln, int precision, char * units, double scaling, tables plot_info, char *out){
- // Convert DXF line to SVG path
-
- char *out_ptr;
- char temp[20];
- entity *ent_ptr = &ln;
-
- strcpy(out,"<path d=\"M");
- strcat(out,gcvt(scaling*ent_ptr->ret_x(),precision,temp) );
- strcat(out," ");
- strcat(out,gcvt(scaling*ent_ptr->ret_y(),precision,temp) );
-
- strcat(out," L");
- strcat(out,gcvt(scaling*ln.ret_xf(),precision,temp) );
- strcat(out," ");
- strcat(out,gcvt(scaling*ln.ret_yf(),precision,temp) );
- strcat(out,"\" fill=\"none\" stroke=\"black\" stroke-width=\"1\" /");
-
- out_ptr = out;
- return out_ptr;
-}
-
-// DXF Text -> SVG
-char* text2text(text txt, int precision, char * units, double scaling, tables plot_info, char *out){
- // Directly convert DXF to SVG because it works
- char *out_ptr;
- char temp[10000];
- entity *ent_ptr = &txt;
-
- // If the text is rotated use the transform matrix
-
- if ( txt.ret_txt_rot() > precision ){
- double ca = cos(0.017453*txt.ret_txt_rot()); // ca = cosine(a)
- double sa = sin(-0.017453*txt.ret_txt_rot()); // sa = sine(a)
- double tx = ent_ptr->ret_x()*scaling;
- double ty = -ent_ptr->ret_y()*scaling;
- // Apply a translation to the orgin, then a rotation, then a translation back to the original position
- double a = ca;
- double b = sa;
- double c = -sa;
- double d = ca;
- double e = -1*(tx*ca-ty*sa-tx);
- double f = -1*(tx*sa+ty*ca-ty);
-
- strcpy(out, "<g transform=\"matrix(");
- strcat(out,gcvt(a,precision,temp) );
- strcat(out," ");
- strcat(out,gcvt(b,precision,temp) );
- strcat(out," ");
- strcat(out,gcvt(c,precision,temp) );
- strcat(out," ");
- strcat(out,gcvt(d,precision,temp) );
- strcat(out," ");
- strcat(out,gcvt(e,precision,temp) );
- strcat(out," ");
- strcat(out,gcvt(f,precision,temp) );
- strcat(out,")\" >\n<text x=\"");
- }
- else{
- strcpy(out,"<text x=\"");
- }
- /*
- strcat(out,gcvt(ent_ptr->ret_x(),precision,temp) );
- strcat(out,units);
- strcat(out,"\" y=\"-"); // Put in an extra minus because of the way SVG has defined the axis
- strcat(out,gcvt(ent_ptr->ret_y(),precision,temp) );
- strcat(out,units);
- */
- strcat(out,gcvt(ent_ptr->ret_x()*scaling,precision,temp) );
- //strcat(out,units);
- strcat(out,"\" y=\"-"); // Put in an extra minus because of the way SVG has defined the axis
- strcat(out,gcvt(ent_ptr->ret_y()*scaling,precision,temp) );
- //strcat(out,units);
- strcat(out,"\" font-family=\"Verdana\" font-size=\"");
- strcat(out,gcvt(scaling*txt.ret_txt_ht(),precision,temp) );
- strcat(out,"\" Fill=\"black\"");
-
- strcat(out," >");
- // Now put in the text
- strcat(out,txt.ret_text(temp));
-
- // Now close the text element
- strcat(out,"</text>");
- // If the text was rotated finish off the tranform group
- if ( txt.ret_txt_rot() > precision ){
- strcat(out,"</g>");
- }
-
- out_ptr = out;
- return out_ptr;
-}
-
-
-
-// DXF Insert -> SVG
-char* insert2group(insert in, int precision, char * units, double scaling, tables plot_info, blocks blks, char *out){
- char *out_ptr;
- char tmp_char[100000];
-
- // get the block using the name from the insert information
- block blk = blks.ret_block(in.name(tmp_char));
-
- entity *ent_ptr = &in;
- entities *ents_ptr = &blk;
- // For now just translations MBS 22 Aug 05
- strcpy(out, "<g transform=\"matrix(1,0,0,1,");
- strcat(out,gcvt(scaling*ent_ptr->ret_x(),precision,tmp_char) );
- strcat(out,",");
- strcat(out,gcvt(-scaling*ent_ptr->ret_y(),precision,tmp_char) );
- strcat(out,")\" >\n");
-
-
- // Now convert the entities in the block
- std::vector< polyline > plines = ents_ptr->ret_plines();
- std::vector< lwpolyline > lwplines = ents_ptr->ret_lwplines();
- std::vector< arc > arcs = ents_ptr->ret_arcs();
- std::vector< circle > circs = ents_ptr->ret_circles();
- std::vector< line > lns = ents_ptr->ret_lines();
- std::vector< text > txts = ents_ptr->ret_texts();
-
-
-
- for(int i = 0; i < plines.size();i++){
- strcat( out,pline2pline(plines[i], units, scaling, plot_info ) );
- strcat( out, "\n" );
- }
- for(int i = 0; i < lwplines.size();i++){
- strcat( out,lwpline2path(lwplines[i], units, scaling, plot_info ) );
- strcat( out, "\n" );
- }
- for(int i = 0; i < arcs.size();i++){
- strcat( out, arc2path(arcs[i], 6,units, scaling, plot_info, tmp_char ) );
- strcat( out, "\n" );
- }
- for(int i = 0; i < circs.size();i++){
- strcat( out, circle2circle(circs[i], 6, units, scaling, plot_info, tmp_char) );
- strcat( out, "\n" );
- }
- for(int i = 0; i < lns.size();i++){
- strcat( out, line2line(lns[i], 6, units, scaling, plot_info, tmp_char) );
- strcat( out, "\n" );
- }
- for(int i = 0; i < txts.size();i++){
- strcat( out, text2text(txts[i], 6, units, scaling, plot_info, tmp_char) );
- strcat( out, "\n" );
- }
- // End the group
- strcat(out,"</g>");
-
- out_ptr = out;
- return out_ptr;
-}
-
-
-
-char* write_by_layer(int output_type, entities &ents, tables &tbls, blocks &blks, double scaling, char * units, char * layer, char * out){
- // output_type = 0 is to std:out
- // output_type = 1 is to the input filename but with .dxf on the end
-
- // For now everything will go to stdout later may directed to other places
-
- // Get the various file informations as dependent on the layer type
- std::vector< polyline > plines = ents.ret_plines(layer);
- std::vector< lwpolyline > lwplines = ents.ret_lwplines(layer);
- std::vector< arc > arcs = ents.ret_arcs(layer);
- std::vector< circle > circs = ents.ret_circles(layer);
- std::vector< line > lns = ents.ret_lines(layer);
- std::vector< text > txts = ents.ret_texts(layer);
- std::vector< insert > ins = ents.ret_inserts(layer);
-
- // It would be better to redirect stdout to different places. That would make the code cleaner but I don't think it will work better
- char tmp_char[100000];
- for(int i = 0; i < plines.size();i++){
- if (output_type == 0){
- std::cout << "\t" << pline2path(plines[i], NULL, scaling, tbls ) << std::endl;
- }
- else if (output_type == 1){
- std::cout << "\t" << pline2path(plines[i], NULL, scaling, tbls ) << std::endl;
- }
- }
- for(int i = 0; i < lwplines.size();i++){
- if (output_type == 0){
- std::cout << "\t" << lwpline2path(lwplines[i], units, scaling, tbls ) << std::endl;
- }
- else if (output_type == 1){
- std::cout << "\t" << lwpline2path(lwplines[i], units, scaling, tbls ) << std::endl;
- }
- }
- for(int i = 0; i < arcs.size();i++){
- if (output_type == 0){
- std::cout << "\t" << arc2path(arcs[i], 6,units, scaling, tbls, tmp_char ) << std::endl;
- }
- else if (output_type == 1){
- std::cout << "\t" << arc2path(arcs[i], 6,units, scaling, tbls, tmp_char ) << std::endl;
- }
- }
- for(int i = 0; i < circs.size();i++){
- if (output_type == 0){
- std::cout << "\t" << circle2circle(circs[i], 6, units, scaling, tbls, tmp_char) << std::endl;
- }
- else if (output_type == 1){
- std::cout << "\t" << circle2circle(circs[i], 6, units, scaling, tbls, tmp_char) << std::endl;
- }
- }
- for(int i = 0; i < lns.size();i++){
- if (output_type == 0){
- std::cout << "\t" << line2line(lns[i], 6, units, scaling, tbls, tmp_char) << std::endl;
- }
- else if (output_type == 1){
- std::cout << "\t" << line2line(lns[i], 6, units, scaling, tbls, tmp_char) << std::endl;
- }
- }
- for(int i = 0; i < txts.size();i++){
- if (output_type == 0){
- std::cout << "\t" << text2text(txts[i], 6, units, scaling, tbls, tmp_char) << std::endl;
- }
- else if (output_type == 1){
- std::cout << "\t" << text2text(txts[i], 6, units, scaling, tbls, tmp_char) << std::endl;
- }
- }
- for(int i = 0; i < ins.size();i++){
- if (output_type == 0){
- std::cout << "\t" << insert2group(ins[i], 6, units, scaling, tbls, blks, tmp_char) << std::endl;
- }
- else if (output_type == 1){
- std::cout << "\t" << insert2group(ins[i], 6, units, scaling, tbls, blks, tmp_char) << std::endl;
- }
- }
-}
-
-
-
-char* write_all(int output_type, entities &ents, tables &tbls, blocks &blks, double scaling, char * units, char * out){
- // output_type = 0 is to std:out
- // output_type = 1 is to the input filename but with .dxf on the end
-
- // For now everything will go to stdout later may directed to other places
-
- // Get the various file informations as dependent on the layer type
- std::vector< polyline > plines = ents.ret_plines();
- std::vector< lwpolyline > lwplines = ents.ret_lwplines();
- std::vector< arc > arcs = ents.ret_arcs();
- std::vector< circle > circs = ents.ret_circles();
- std::vector< line > lns = ents.ret_lines();
- std::vector< text > txts = ents.ret_texts();
- std::vector< insert > ins = ents.ret_inserts();
-
- // It would be better to redirect stdout to different places. That would make the code cleaner but I don't think it will work better
- char tmp_char[100000];
- for(int i = 0; i < plines.size();i++){
- if (output_type == 0){
- std::cout << "\t" << pline2path(plines[i], NULL, scaling, tbls ) << std::endl;
- }
- else if (output_type == 1){
- std::cout << "\t" << pline2path(plines[i], NULL, scaling, tbls ) << std::endl;
- }
- }
- for(int i = 0; i < lwplines.size();i++){
- if (output_type == 0){
- std::cout << "\t" << lwpline2path(lwplines[i], units, scaling, tbls ) << std::endl;
- }
- else if (output_type == 1){
- std::cout << "\t" << lwpline2path(lwplines[i], units, scaling, tbls ) << std::endl;
- }
- }
- for(int i = 0; i < arcs.size();i++){
- if (output_type == 0){
- std::cout << "\t" << arc2path(arcs[i], 6,units, scaling, tbls, tmp_char ) << std::endl;
- }
- else if (output_type == 1){
- std::cout << "\t" << arc2path(arcs[i], 6,units, scaling, tbls, tmp_char ) << std::endl;
- }
- }
- for(int i = 0; i < circs.size();i++){
- if (output_type == 0){
- std::cout << "\t" << circle2circle(circs[i], 6, units, scaling, tbls, tmp_char) << std::endl;
- }
- else if (output_type == 1){
- std::cout << "\t" << circle2circle(circs[i], 6, units, scaling, tbls, tmp_char) << std::endl;
- }
- }
- for(int i = 0; i < lns.size();i++){
- if (output_type == 0){
- std::cout << "\t" << line2line(lns[i], 6, units, scaling, tbls, tmp_char) << std::endl;
- }
- else if (output_type == 1){
- std::cout << "\t" << line2line(lns[i], 6, units, scaling, tbls, tmp_char) << std::endl;
- }
- }
- for(int i = 0; i < txts.size();i++){
- if (output_type == 0){
- std::cout << "\t" << text2text(txts[i], 6, units, scaling, tbls, tmp_char) << std::endl;
- }
- else if (output_type == 1){
- std::cout << "\t" << text2text(txts[i], 6, units, scaling, tbls, tmp_char) << std::endl;
- }
- }
- for(int i = 0; i < ins.size();i++){
- if (output_type == 0){
- std::cout << "\t" << insert2group(ins[i], 6, units, scaling, tbls, blks, tmp_char) << std::endl;
- }
- else if (output_type == 1){
- std::cout << "\t" << insert2group(ins[i], 6, units, scaling, tbls, blks, tmp_char) << std::endl;
- }
- }
-}
-
-
-
diff --git a/src/extension/dxf2svg/entities2elements.h b/src/extension/dxf2svg/entities2elements.h
deleted file mode 100644
index cceefcf15..000000000
--- a/src/extension/dxf2svg/entities2elements.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/* Method for converting dxf entities to SVG elements
-There are multiple ways for converting different items
-
-If possible most DXF enetities will be converted to paths because that is the most flexable object
-
-Matt Squires
-SoC 2005
-
-*/
-
-#include"entities.h"
-#include"tables.h"
-#include"blocks.h"
-
-// The names indicate the DXF entitiy first and the SVG element last
-
-// Common elements
-char* to_arc(double bulge, double r, double start_ang, double end_ang, int precision,char* delim, char * units, double scaling, char *out); // This is used for arcs, polylines, and lwpolylines
-
-// DXF Polyline -> SVG
-
-char* pline2path(polyline pline, char * units, double scaling, tables plot_info); // Convert a dxf polyline to a SVG path. This is the closest conversion of the DXF polyline to an SVG element
-char* pline2pline(polyline pline, char * units, double scaling, tables plot_info); // Convert a dxf polyline to a SVG polyline. The conversion is not 1:1 because the SVG pline doesn't support closed objects or curves
-char* pline2polygon(polyline pline, char * units, double scaling, tables plot_info); // Convert a dxf polyline to a SVG polygon. The conversion is not 1:1 because the SVG polygone assumes a closed path. If the pline is not closed it will be forced closed
-
-// DXF LWPolyline -> SVG
-char* lwpline2path(lwpolyline pline, char * units, double scaling, tables plot_info); // Convert a dxf polyline to a SVG path. This is the closest conversion of the DXF polyline to an SVG element
-
-// DXF ARC -> SVG
-char* arc2path(arc a, int precision, char * units, double scaling, tables plot_info, char *out); // So far this appears to be the only way to convert arcs into something recognized by SVG
-
-
-// DXF Circle -> SVG
-char* circle2circle(circle circ, int precision, char * units, double scaling, tables plot_info, char *out); // Direct conversion of DXF circle to SVG circle
-char* circle2path(circle circ, int precision, char * units, double scaling, tables plot_info, char *out); // Conversion of DXF circle to SVG circle assuming the path will represent the circle
-
-
-// DXF Line -> SVG
-char* line2line(line ln, int precision, char * units, double scaling, tables plot_info, char *out); // Directly convert DXF to SVG because it works
-char* line2path(line ln, int precision, char * units, double scaling, tables plot_info, char *out); // Convert DXF line to SVG path
-
-// DXF Text -> SVG
-char* text2text(text txt, int precision, char * units, double scaling, tables plot_info, char *out); // Directly convert DXF to SVF assuming VERANDA font
-
-// DXF Insert -> SVG
-char* insert2group(insert in, int precision, char * units, double scaling, tables plot_info, blocks blks, char *out);
-
-// Write all of the possible enties with a variety of options
-
-char* write_by_layer(int output_type, entities &ents, tables &tbls, blocks &blks, double scaling, char * units, char * layer, char * out); // Write out the entities by layer designation
-char* write_all(int output_type, entities &ents, tables &tbls, blocks &blks, double scaling, char * units, char * out);
-
-
diff --git a/src/extension/dxf2svg/read_dxf.cpp b/src/extension/dxf2svg/read_dxf.cpp
deleted file mode 100644
index 1a4eefbc9..000000000
--- a/src/extension/dxf2svg/read_dxf.cpp
+++ /dev/null
@@ -1,275 +0,0 @@
-/*
- * For reading and slight parsing of dxf files
- *
- * Author:
- * Matt Squires <squiresm@colorado.edu>
- *
- * Copyright (C) 2005 Matt Squires
- *
- * Released under GNU GPL and LGPL, read the file 'GPL.txt' and 'LGPL.txt' for details
- */
-
-
-
-#include <fstream>
-#include <string>
-#include "read_dxf.h"
-
-#include <iostream>
-#include <string.h>
-#include <stdlib.h>
-using namespace std;
-
-
-int MAX_STR_LN = 10000;
-
-int section(char* value){
- if ( strncmp(value,"HEADER",6) == 0 ) return 0;
- if ( strncmp(value,"CLASSES",7) == 0 ) return 1;
- if ( strncmp(value,"TABLES",6) == 0 ) return 2;
- if ( strncmp(value,"BLOCKS",6) == 0 ) return 3;
- if ( strncmp(value,"ENTITIES",8) == 0 ) return 4;
- if ( strncmp(value,"OBJECTS",7) == 0 ) return 5;
- if ( strncmp(value,"THUMBNAILIMAGE",14) == 0 ) return 6;
-}
-
-
-dxfpair::dxfpair(int gcode, char val[10000]){
- group_code = gcode;
- // Dynamically save the strings, otherwise the memory uses is bad
-
- for (int i = 0; i < strlen(val); i++){
- value.push_back(val[i]);
- }
-}
-
-
-dxfpair::~dxfpair(){
- //delete [] value;
-}
-
-char * dxfpair::value_char(char *string){
- int size = value.size();
- while( ( size > 0 ) && int(value[size-1]) < 33){
- // Strip off any control characters and spaces off the end of the string
- size--;
- }
- for(int i = 0; i < size; i++){
- string[i] = value[i];
- }
- string[size]=0;
-}
-
-std::vector< std::vector< dxfpair > > dxf_get_sections(char* filename){
- // In the dxf format information is paired into group codes that indicate the information that follows on the next line. The information on the next line is called the value
-
- int n =0;
-
- int group_code;
- char value[MAX_STR_LN];
-
- int section_num;
-
-
-
-
- std::vector< std::vector< dxfpair > > out;
-
- std::vector< dxfpair > header;
- std::vector< dxfpair > classes;
- std::vector< dxfpair > tables;
- std::vector< dxfpair > blocks;
- std::vector< dxfpair > entities;
- std::vector< dxfpair > objects;
- std::vector< dxfpair > thumbnailimage;
-
- header.clear();
- classes.clear();
- tables.clear();
- blocks.clear();
- entities.clear();
- objects.clear();
- thumbnailimage.clear();
-
-
- // Open dxf file for reading
- std::ifstream file(filename);
-
- if (!file.is_open()){
- exit (1); // Change this to an exception
- }
-
- // Find the first SECTION header
-
- while ( (!file.eof()) ){
- n++;
-
- // get the first group code and value
- file.getline(value,MAX_STR_LN);
- group_code = atoi(value);
- file.getline(value,MAX_STR_LN);
-
- do{
-
- // TO DO set all the chars to be caps for later comparison
-
- // Find the SECTION codes
- if ( (group_code == 0 ) && ( strncmp(value,"SECTION",7) == 0 ) ){
- // Directly after a section value is the type of section ( e.g. HEADER, TABLES )
- file.getline(value,MAX_STR_LN);
- group_code = atoi(value);
- file.getline(value,MAX_STR_LN);
- section_num = section( value );
- if ( group_code == 2 ){
- // Make sure the the group code is 2 for the SECTION name
- // This is a big block of mostly repetitive code, it will result in larger code, but would be faster than putting the switch in another while loop. If I still live in a time when file size mattered alot I would change it
- //std::cout << "section_num = " << section_num << std::endl;
- switch ( section_num ){
- case 0:
- file.getline(value,MAX_STR_LN);
- group_code = atoi(value);
- file.getline(value,MAX_STR_LN);
- do{
- header.push_back( dxfpair( group_code, value ) );
- file.getline(value,MAX_STR_LN);
- group_code = atoi(value);
- file.getline(value,MAX_STR_LN);
- }while( ( (group_code != 0) || strncmp(value,"ENDSEC",6) != 0 ) && (!file.eof()) ); // I put in the (group_code != 0) in the hope that it will be a faster bool compare than the string compare. Test this later
- break;
- case 1:
- file.getline(value,MAX_STR_LN);
- group_code = atoi(value);
- file.getline(value,MAX_STR_LN);
- if ( (group_code != 0) || (strncmp(value,"ENDSEC",6) != 0) ){
- // Some dxf files have blank sections. These are not handled by the do/while loop so break about if needed
- do{
- classes.push_back( dxfpair( group_code, value ) );
- file.getline(value,MAX_STR_LN);
- group_code = atoi(value);
- file.getline(value,MAX_STR_LN);
- }while( ( (group_code != 0) || strncmp(value,"ENDSEC",6) != 0 ) && (!file.eof()) ); // I put in the (group_code != 0) in the hope that it will be a faster bool compare than the string compare. Test this later
- }
- break;
- case 2:
- file.getline(value,MAX_STR_LN);
- group_code = atoi(value);
- file.getline(value,MAX_STR_LN);
- do{
- tables.push_back( dxfpair( group_code, value ) );
- file.getline(value,MAX_STR_LN);
- group_code = atoi(value);
- file.getline(value,MAX_STR_LN);
- }while( ( (group_code != 0) || strncmp(value,"ENDSEC",6) != 0 ) && (!file.eof()) );
- break;
- case 3:
- file.getline(value,MAX_STR_LN);
- group_code = atoi(value);
- file.getline(value,MAX_STR_LN);
- do{
- blocks.push_back( dxfpair( group_code, value ) );
- file.getline(value,MAX_STR_LN);
- group_code = atoi(value);
- file.getline(value,MAX_STR_LN);
- }while( ( (group_code != 0) || strncmp(value,"ENDSEC",6) != 0 ) && (!file.eof()) ); // I put in the (group_code != 0) in the hope that it will be a faster bool compare than the string compare. Test this later
- break;
- case 4:
- file.getline(value,MAX_STR_LN);
- group_code = atoi(value);
- file.getline(value,MAX_STR_LN);
- do{
- entities.push_back( dxfpair( group_code, value ) );
- file.getline(value,MAX_STR_LN);
- group_code = atoi(value);
- file.getline(value,MAX_STR_LN);
- }while( ( (group_code != 0) || strncmp(value,"ENDSEC",6) != 0 ) && (!file.eof()) ); // I put in the (group_code != 0) in the hope that it will be a faster bool compare than the string compare. Test this later
- break;
- case 5:
- file.getline(value,MAX_STR_LN);
- group_code = atoi(value);
- file.getline(value,MAX_STR_LN);
- do{
- objects.push_back( dxfpair( group_code, value ) );
- file.getline(value,MAX_STR_LN);
- group_code = atoi(value);
- file.getline(value,MAX_STR_LN);
- }while( ( (group_code != 0) || strncmp(value,"ENDSEC",6) != 0 ) && (!file.eof()) ); // I put in the (group_code != 0) in the hope that it will be a faster bool compare than the string compare. Test this later
- break;
- case 6:
- file.getline(value,MAX_STR_LN);
- group_code = atoi(value);
- file.getline(value,MAX_STR_LN);
- do{
- thumbnailimage.push_back( dxfpair( group_code, value ) );
- file.getline(value,MAX_STR_LN);
- group_code = atoi(value);
- file.getline(value,MAX_STR_LN);
- }while( ( (group_code != 0) || strncmp(value,"ENDSEC",6) != 0 ) && (!file.eof()) ); // I put in the (group_code != 0) in the hope that it will be a faster bool compare than the string compare. Test this later
- break;
- default:
- file.getline(value,MAX_STR_LN);
- group_code = atoi(value);
- file.getline(value,MAX_STR_LN);
- }
- }
- }
- file.getline(value,MAX_STR_LN);
- group_code = atoi(value);
- file.getline(value,MAX_STR_LN);
-
- n++;
- }while( ( strncmp(value,"EOF",3) != 0 ) && (!file.eof()) );
- }
-
- out.push_back(header);
- out.push_back(classes);
- out.push_back(tables);
- out.push_back(blocks);
- out.push_back(entities);
- out.push_back(objects);
- out.push_back(thumbnailimage);
-
- return out;
-}
-
-
-std::vector< std::vector< dxfpair > > separate_parts( std::vector< dxfpair > section){
- //std::cout << "1" << std::endl;
- //std::cout << "section.size() = " << section.size() << std::endl;
- // Find where the major sections are and break into smaller parts
- // Major section is defined as anything beween group_code 0 to 0
- std::vector< dxfpair > inner;
- std::vector< std::vector< dxfpair > > outer;
- //std::cout << "2" << std::endl;
- for (int i = 0; i < section.size(); i++){
- //std::cout << "i = " << i << std::endl;
- //std::cout << "section[i].value.size() = " << section[i].value.size() << std::endl;
-
- // Make sure no control codes like LF or CR are making it past this section
- if ( (section[i].value.size() > 0) && int(section[i].value.back()) < 32 ){
- section[i].value.pop_back();
- }
- //for(int j = 0;j < section[i].value.size();j++ ) std::cout << section[i].value[j];
- //std::cout << std::endl;
-
- inner.push_back( section[i] );
-
- // If the next group code is 0 then push the previously found info on outer and start looking for data again
- if (section[i+1].group_code == 0){
- //std::cout << "inner.push_back" << std::endl;
- outer.push_back( inner );
- inner.clear();
- }
- }
- // Because putting the data on outer depends on find a GC=0 the last bit of data may be left behind so it inner has data in it put it on outer
- if (!inner.empty()){
- outer.push_back( inner );
- inner.clear();
- }
- //std::cout << "3" << std::endl;
- if (section.back().group_code == 0){
- //outer.push_back( inner ); // Put the last part on if there is information, but I don't think it needs to.
- }
-
- return outer;
-}
-
diff --git a/src/extension/dxf2svg/read_dxf.h b/src/extension/dxf2svg/read_dxf.h
deleted file mode 100644
index 7e008b4e0..000000000
--- a/src/extension/dxf2svg/read_dxf.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Header file for reading dxf information and basic parsing. Interprting information is found in other files
-*/
-
-#ifndef READ_DXF_H
-#define READ_DXF_H
-
-#include<vector>
-
-
-
-class dxfpair{
-public:
- dxfpair(int gcode, char val[10000]);
- virtual ~dxfpair();
-
- char * value_char(char *string);
-
- // Leave this data public
- int group_code;
- std::vector< char > value;
-};
-
-
-
-
-int section(char* value); // Convert the section titles into integers
-
-std::vector< std::vector< dxfpair > > dxf_get_sections(char* filename);
-
-std::vector< std::vector< dxfpair > > separate_parts( std::vector< dxfpair > section ); // Find where the major sections are and break into smaller parts
-
-#endif
diff --git a/src/extension/dxf2svg/tables.cpp b/src/extension/dxf2svg/tables.cpp
deleted file mode 100644
index fcaff33c0..000000000
--- a/src/extension/dxf2svg/tables.cpp
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * Code for the conversion of DXF information in the TABLES section
- *
- * Author:
- * Matt Squires <squiresm@colorado.edu>
- *
- * Copyright (C) 2005 Matt Squires
- *
- * Released under GNU GPL and LGPL, read the file 'GPL.txt' and 'LGPL.txt' for details
- */
-
-#include"tables.h"
-#include<iostream>
-
-
-
-
-int determine_table(char* value){
- // Common Elements as far as I am concerend
- if ( strncmp(value,"LAYER",5) == 0 ) return 0;
- if ( strncmp(value,"LTYPE",5) == 0 ) return 1;
- if ( strncmp(value,"STYLE",5) == 0 ) return 2;
- if ( strncmp(value,"UCS",3) == 0 ) return 3;
- if ( strncmp(value,"VIEW",4) == 0 ) return 4;
- if ( strncmp(value,"VPORT",4) == 0 ) return 5;
- if ( strncmp(value,"APPID",5) == 0 ) return 6;
- if ( strncmp(value,"BLOCK_RECORD",12) == 0 ) return 7;
- else return -1;
-}
-
-
-/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// TABLE
-/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-
-int table::ret_maxN(){
- return max_number;
-}
-
-
-
-
-
-/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// LAYER
-/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-
-layer::layer( std::vector< dxfpair > info){
- // Get the vertex information
-
- //basic_entity( info );
- //static char string[10000];
- char string[10000];
- for (int i = 0; i < info.size(); i++){
- switch( info[i].group_code ){
- case 2:
- info[i].value_char(layer_name);
- break;
- case 6:
- info[i].value_char(ltype_name);
- break;
-
- case 62:
- info[i].value_char(string);
- color_number = atoi(string);
- //std::cout << "I found a color and its number = " << color_number << std::endl;
- break;
- case 290:
- info[i].value_char(string);
- plotting_flag = atoi(string);
- break;
- }
- }
-}
-
-void layer::display(){
- std::cout << "LAYER\n";
- //std::cout << "\tx = " << x << "\ty = " << y << "\tz = " << z << "\tbulge = " << bulge << std::flush;
-}
-
-char* layer::name(char* string){
- return( strcpy(string,layer_name) );
-}
-
-
-
-/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// LTYPE
-/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-
-ltype::ltype( std::vector< dxfpair > info){
- // Get the linetype information
-
- //static char string[10000];
- char string[10000];
- for (int i = 0; i < info.size(); i++){
- switch( info[i].group_code ){
- case 2:
- info[i].value_char(ltype_name);
- break;
- case 3:
- info[i].value_char(descriptive_txt);
- break;
- case 73:
- info[i].value_char(string);
- num_elements = atoi(string);
- break;
- case 40:
- info[i].value_char(string);
- pattern_length = atof(string);
- break;
- case 49:
- info[i].value_char(string);
- pattern.push_back( atof(string) );
- break;
- }
- }
-}
-
-
-
-char* ltype::name(char* string){
- return( strcpy(string,ltype_name) );
-}
-
-
-std::vector< double > ltype::ret_pattern(){
- return pattern;
-}
-
-
-/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// tables
-/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-
-
-tables::tables(std::vector< std::vector< dxfpair > > sections){
- // Read the main information about the entities section and then put it in the enetites class
- int value;
- char string[10000];
-
- for(int i = 0; i < sections.size(); i++){
- //std::cout << "start" << std::endl;
- sections[i][0].value_char(string);
- value = determine_table(string);
- //std::cout << "sections.size() = " << sections.size() << std::endl << "i = " << i << std::endl << "string = " << string << std::endl;
- switch( value ){
- case 0:
- // LAYER
- //std::cout << "tables start layer " << std::endl;
- tables_layer.push_back( layer( sections[i] ) );
- //std::cout << "tables end layer " << std::endl;
- break;
-
- case 1:
- // LTYPE
- //std::cout << "tables start ltype " << std::endl;
- tables_ltype.push_back( ltype( sections[i] ) );
- //std::cout << "tables end ltype " << std::endl;
- break;
-
- //case 3:
- // break;
-
- default:
- break;
- // Nothing here
- }
-
- }
-
-}
-
-
-
-
-ltype tables::ret_ltype(char ltype_name[10000], char layer_name[10000]){
- int string_len = 0;
- char name[10000];
- char temp[10000];
- // The ltype information may be given in the entitity or in the layer information
- // Assume that if there is a name defined in the linetype that it trumps any other layer information
- if ( strlen(ltype_name) > 0 ) strcpy(name,ltype_name);
- else strcpy(name,layer_name);
- for (int i = 0; i < tables_ltype.size();i++){
- string_len = strlen(tables_ltype[i].name(temp));
- if (strncmp(tables_ltype[i].name(temp),name,string_len) == 0 ) return tables_ltype[i];
- }
- return tables_ltype[0];
-}
-
-
-layer tables::ret_layer(char layer_name[10000]){
- int string_len = 0;
- char temp[10000];
-
- for (int i = 0; i < tables_layer.size();i++){
- string_len = strlen(tables_layer[i].name(temp));
- if (strncmp(tables_layer[i].name(temp),layer_name,string_len) == 0 ) return tables_layer[i];
- }
- return tables_layer[0];
-}
-
-
-std::vector< layer > tables::ret_layers(){
- return tables_layer;
-}
diff --git a/src/extension/dxf2svg/tables.h b/src/extension/dxf2svg/tables.h
deleted file mode 100644
index f63122eaf..000000000
--- a/src/extension/dxf2svg/tables.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/* Code for the conversion of DXF information in the TABLES section
-Matt Squires
-SoC
-2005*/
-
-#ifndef DXF_TABLES_H
-#define DXF_TABLES_H
-
-#include<vector>
-#include"read_dxf.h"
-
-class table{
- public:
- int ret_maxN();
- private:
- int max_number;
-};
-
-
-class layer : public table{
- public:
- layer( std::vector< dxfpair > info);
- void display();
- char* name(char* string);
- private:
- char layer_name[10000];
- char ltype_name[10000]; // The layer may also hold the ltype infomation
- int color_number;
- int plotting_flag;
-
-};
-
-
-class ltype : public table{
- public:
- ltype( std::vector< dxfpair > info);
- char* name(char* string);
- std::vector< double > ret_pattern();
- private:
- char ltype_name[10000];
- char descriptive_txt[10000];
- int num_elements;
- double pattern_length;
- std::vector< double > pattern;
-
-};
-
-
-class tables{
- // Well I said that I would only use STL containers internally, but I would have to use a dynamically linked list, and I haven't done for a long time soo STL is my crutch.
- public:
- tables(std::vector< std::vector< dxfpair > > sections); // Put the various entities into their respective vectors
- void display_all();
-
- ltype ret_ltype(char ltype_name[10000], char layer_name[10000]);
- layer ret_layer(char layer_name[10000]);
-
- std::vector< layer > ret_layers();
-
-
- private:
- //void add_dimstyle(polyline pline);
- void add_layer(layer layr);
- void add_ltype(ltype line_type);
-
- std::vector< layer > tables_layer;
- std::vector< ltype > tables_ltype;
-};
-
-
-#endif
diff --git a/src/extension/dxf2svg/tables2svg_info.cpp b/src/extension/dxf2svg/tables2svg_info.cpp
deleted file mode 100644
index c59060306..000000000
--- a/src/extension/dxf2svg/tables2svg_info.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Convert DXF table information to a format that is recognized by SVG
- *
- * Author:
- * Matt Squires <squiresm@colorado.edu>
- *
- * Copyright (C) 2005 Matt Squires
- *
- * Released under GNU GPL and LGPL, read the file 'GPL.txt' and 'LGPL.txt' for details
- */
-
-
-#include "tables2svg_info.h"
-#include <math.h>
-#include <iostream>
-#include <stdlib.h>
-#include <string.h>
-
-char* pattern2dasharray(ltype info, int precision, double scaling, char* out){
- std::vector< double > pattern = info.ret_pattern();
- char temp[50];
- char *out_ptr;
-
-
- if (!pattern.empty()){
- strcat(out," stroke-dasharray=\"");
- for(int i = 0; i < pattern.size()-1;i++){
- strcat(out,gcvt(scaling*sqrt(pow(pattern[i],2)),precision,temp) );
- strcat(out,",");
- }
- strcat( out,gcvt(scaling*sqrt(pow(pattern[pattern.size()-1],2)),precision,temp) );
- strcat(out,"\" ");
- }
-
- out_ptr = out;
- return out_ptr;
-}
diff --git a/src/extension/dxf2svg/tables2svg_info.h b/src/extension/dxf2svg/tables2svg_info.h
deleted file mode 100644
index 2c99f034e..000000000
--- a/src/extension/dxf2svg/tables2svg_info.h
+++ /dev/null
@@ -1,9 +0,0 @@
-/* Convert DXF table information to a format that is recognized by SVG
-Matt Squires
-SOC 2005
-*/
-
-
-#include"tables.h"
-
-char* pattern2dasharray(ltype info, int precision, double scaling, char* temp);
diff --git a/src/extension/dxf2svg/test_dxf.cpp b/src/extension/dxf2svg/test_dxf.cpp
deleted file mode 100644
index c3bbdc141..000000000
--- a/src/extension/dxf2svg/test_dxf.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-/* test read_dxf */
-#include"read_dxf.h"
-#include"entities.h"
-#include"blocks.h"
-#include"tables.h"
-#include<iostream>
-#include"entities2elements.h"
-
-using namespace std;
-
-int main(){
- std::vector< std::vector< dxfpair > > output, entities_info, blocks_info, tables_info;
- //output = dxf_get_sections("circ_sqr.dxf");
- //output = dxf_get_sections("Labjack.dxf");
- //output = dxf_get_sections("mini_post.dxf");
- //output = dxf_get_sections("../8599-E0W.dxf");
- //output = dxf_get_sections("../bulged_lwpoly.dxf");
- //output = dxf_get_sections("../aspheric_lens.dxf");
- output = dxf_get_sections("../layers_colors.dxf");
- /*std::vector< dxfpair > header;
- std::vector< dxfpair > classes;
- std::vector< dxfpair > tables;
- std::vector< dxfpair > blocks;
- std::vector< dxfpair > entities;
- std::vector< dxfpair > objects;
- std::vector< dxfpair > thumbnailimage;
- */
-
-
- //dxf_get_sections("circ_sqr.dxf",header,classes,tables,blocks,entities,objects,thumbnailimage);
- //dxf_get_sections("mini_post.dxf",header,classes,tables,blocks,entities,objects,thumbnailimage);
-
- //cout << entities.size() << endl;
- for (int i=0;i<output.size();i++) cout << "output[i].size()" << i << " = " << output[i].size() << endl;
- //cout << endl;
- //for (int i=0;i<output[0].size();i++) cout << output[0][i].group_code << "\t" << output[0][i].value << endl;
- //cout << endl;
- //for (int i=0;i<output[4].size();i++) cout << output[4][i].group_code << "\t" << output[4][i].value << endl;
-
- // Now display the different parts of the entities section
- //cout << endl;
- for (int i=0;i < output[4].size();i++){
- //cout << output[4][i].group_code << " " << output[4][i].value[0] << output[4][i].value[1] << endl;
- }
- cout << endl;
- entities_info = separate_parts(output[4]);
- cout << "entities_info.size() = " << entities_info.size() << endl;
-
- for (int i=0;i < entities_info.size();i++){
- //for (int j=0;j < entities_info[i].size();j++) cout << entities_info[i][j].group_code << " " << entities_info[i][j].value[0] << entities_info[i][j].value[1] << entities_info[i][j].value[2] << entities_info[i][j].value[3] << entities_info[i][j].value[4] << "\n";
- //cout << endl << endl << endl;
- }
-
- cout << "blocks separate parts" << endl;
- blocks_info = separate_parts(output[3]); // Tables is the 4th part of a dxf file.
- cout << "sort separated parts" << endl;
- blocks blks(blocks_info); // Sort the information in the tables
- cout << "blocks_info.size() = " << blocks_info.size() << endl;
-
- for (int i=0;i < blocks_info.size();i++){
- //for (int j=0;j < blocks_info[i].size();j++) cout << blocks_info[i][j].group_code << " " << blocks_info[i][j].value[0] << blocks_info[i][j].value[1] << blocks_info[i][j].value[2] << blocks_info[i][j].value[3] << blocks_info[i][j].value[4] << "\n";
- //cout << endl << endl << endl;
- }
-
-
- tables_info = separate_parts(output[2]); // Tables is the 3rd part of a dxf file.
- cout << "tables_info.size() = " << tables_info.size() << endl;
- for (int i=0;i < tables_info.size();i++){
- //for (int j=0;j < tables_info[i].size();j++) cout << tables_info[i][j].group_code << " " << tables_info[i][j].value[0] << tables_info[i][j].value[1] << tables_info[i][j].value[2] << tables_info[i][j].value[3] << tables_info[i][j].value[4] << "\n";
- //cout << "i = " << i << endl << endl;
- }
- tables tbls(tables_info); // Sort the information in the tables
-
-
-
- cout << "This should change \n";
-
- cout << "\n\nNow display all parsed info \n";
- entities ents(entities_info);
- ents.display_all();
-
- //char units[5] = "in";
- // char units[5] = "";
-
- cout << "\nNow for the begining of the SVG...\n\n";
-
- cout << "Polyline conversion\n";
- //std::vector< polyline > pl_tmp= ents.ret_plines();
- //cout << "pline2pline\n" << pline2pline(pl_tmp[0], units ) << endl;
- //cout << "pline2pline\n" << pline2pline(ents.ret_plines()[0], units ) << endl;
- //cout << "pline2path\n" << pline2path(ents.ret_plines()[0], units );
-
- // char tmp_char[10000];
-
- cout << "\nCircle conversion\n";
- //cout << "circle2circle\n" << circle2circle(ents.ret_circles()[0], 3, units, tmp_char) << endl;
-
- return 0;
-}
diff --git a/src/extension/effect.h b/src/extension/effect.h
index bb36b9238..193b90a97 100644
--- a/src/extension/effect.h
+++ b/src/extension/effect.h
@@ -20,7 +20,7 @@ namespace Gtk {
class VBox;
}
-struct SPDocument;
+class SPDocument;
namespace Inkscape {
@@ -67,7 +67,7 @@ class Effect : public Extension {
gchar const * image,
Effect * effect,
bool showPrefs) :
- Verb(id, _(name), _(tip), image),
+ Verb(id, _(name), _(tip), image, _("Extensions")),
_effect(effect),
_showPrefs(showPrefs),
_elip_name(NULL) {
diff --git a/src/extension/error-file.cpp b/src/extension/error-file.cpp
index 2a56f55e8..5a8bede70 100644
--- a/src/extension/error-file.cpp
+++ b/src/extension/error-file.cpp
@@ -12,12 +12,11 @@
#include "config.h"
#endif
-#include <glibmm/i18n.h>
-
+#include "ui/dialog/extensions.h"
+#include <glibmm/i18n.h>
#include "inkscape.h"
#include "preferences.h"
-#include "ui/dialog/extensions.h"
#include "extension/extension.h"
#include "error-file.h"
@@ -56,7 +55,11 @@ ErrorFileNotice::ErrorFileNotice (void) :
g_free(ext_error_file);
set_message(dialog_text, true);
+#if WITH_GTKMM_3_0
+ Gtk::Box * vbox = get_content_area();
+#else
Gtk::Box * vbox = get_vbox();
+#endif
/* This is some filler text, needs to change before relase */
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
diff --git a/src/extension/extension.cpp b/src/extension/extension.cpp
index 4e2c5b9e4..f9cf70960 100644
--- a/src/extension/extension.cpp
+++ b/src/extension/extension.cpp
@@ -19,13 +19,17 @@
# include "config.h"
#endif
-
-#include <glibmm/i18n.h>
#include <gtkmm/box.h>
#include <gtkmm/label.h>
#include <gtkmm/frame.h>
-#include <gtkmm/table.h>
+#if WITH_GTKMM_3_0
+# include <gtkmm/grid.h>
+#else
+# include <gtkmm/table.h>
+#endif
+
+#include <glibmm/i18n.h>
#include "inkscape.h"
#include "extension/implementation/implementation.h"
#include "extension.h"
@@ -720,7 +724,12 @@ Extension::get_info_widget(void)
Gtk::Frame * info = Gtk::manage(new Gtk::Frame("General Extension Information"));
retval->pack_start(*info, true, true, 5);
+#if WITH_GTKMM_3_0
+ Gtk::Grid * table = Gtk::manage(new Gtk::Grid());
+#else
Gtk::Table * table = Gtk::manage(new Gtk::Table());
+#endif
+
info->add(*table);
int row = 0;
@@ -733,8 +742,11 @@ Extension::get_info_widget(void)
return retval;
}
-void
-Extension::add_val(Glib::ustring labelstr, Glib::ustring valuestr, Gtk::Table * table, int * row)
+#if WITH_GTKMM_3_0
+void Extension::add_val(Glib::ustring labelstr, Glib::ustring valuestr, Gtk::Grid * table, int * row)
+#else
+void Extension::add_val(Glib::ustring labelstr, Glib::ustring valuestr, Gtk::Table * table, int * row)
+#endif
{
Gtk::Label * label;
Gtk::Label * value;
@@ -742,8 +754,14 @@ Extension::add_val(Glib::ustring labelstr, Glib::ustring valuestr, Gtk::Table *
(*row)++;
label = Gtk::manage(new Gtk::Label(labelstr));
value = Gtk::manage(new Gtk::Label(valuestr));
+
+#if WITH_GTKMM_3_0
+ table->attach(*label, 0, (*row) - 1, 1, 1);
+ table->attach(*value, 1, (*row) - 1, 1, 1);
+#else
table->attach(*label, 0, 1, (*row) - 1, *row);
table->attach(*value, 1, 2, (*row) - 1, *row);
+#endif
label->show();
value->show();
diff --git a/src/extension/extension.h b/src/extension/extension.h
index e0b643b6d..b6b4c51ed 100644
--- a/src/extension/extension.h
+++ b/src/extension/extension.h
@@ -19,9 +19,15 @@
#include <vector>
#include <glibmm/ustring.h>
#include "xml/repr.h"
+#include <sigc++/signal.h>
namespace Gtk {
+#if WITH_GTKMM_3_0
+ class Grid;
+#else
class Table;
+#endif
+
class VBox;
class Widget;
}
@@ -65,7 +71,7 @@ namespace Gtk {
#define INKSCAPE_EXTENSION_NS_NC "extension"
#define INKSCAPE_EXTENSION_NS "extension:"
-struct SPDocument;
+class SPDocument;
namespace Inkscape {
namespace Extension {
@@ -284,8 +290,11 @@ public:
Gtk::VBox * get_help_widget(void);
Gtk::VBox * get_params_widget(void);
protected:
+#if WITH_GTKMM_3_0
+ inline static void add_val(Glib::ustring labelstr, Glib::ustring valuestr, Gtk::Grid * table, int * row);
+#else
inline static void add_val(Glib::ustring labelstr, Glib::ustring valuestr, Gtk::Table * table, int * row);
-
+#endif
};
diff --git a/src/extension/implementation/implementation.h b/src/extension/implementation/implementation.h
index b0230b7c4..9d679982a 100644
--- a/src/extension/implementation/implementation.h
+++ b/src/extension/implementation/implementation.h
@@ -29,7 +29,7 @@ namespace Gtk {
}
class SPDocument;
-class SPStyle;
+struct SPStyle;
namespace Inkscape {
@@ -104,6 +104,7 @@ public:
virtual bool check(Inkscape::Extension::Extension * /*module*/) { return true; }
virtual bool cancelProcessing () { return true; }
+ virtual bool wasCancelled () { return false; }
virtual void commitDocument () {}
// ----- Input functions -----
diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp
index d3aeace55..3ac1e06ab 100644
--- a/src/extension/implementation/script.cpp
+++ b/src/extension/implementation/script.cpp
@@ -23,6 +23,8 @@
#include <gtkmm/main.h>
#include <gtkmm/scrolledwindow.h>
#include <gtkmm/textview.h>
+#include <glibmm/miscutils.h>
+#include <glibmm/convert.h>
#include <unistd.h>
#include <errno.h>
@@ -852,7 +854,11 @@ void Script::checkStderr (const Glib::ustring &data,
GtkWidget *dlg = GTK_WIDGET(warning.gobj());
sp_transientize(dlg);
+#if WITH_GTKMM_3_0
+ Gtk::Box * vbox = warning.get_content_area();
+#else
Gtk::Box * vbox = warning.get_vbox();
+#endif
/* Gtk::TextView * textview = new Gtk::TextView(Gtk::TextBuffer::create()); */
Gtk::TextView * textview = new Gtk::TextView();
@@ -956,7 +962,14 @@ int Script::execute (const std::list<std::string> &in_command,
// assemble the rest of argv
std::copy(in_params.begin(), in_params.end(), std::back_inserter(argv));
if (!filein.empty()) {
- argv.push_back(filein);
+ if(Glib::path_is_absolute(filein))
+ argv.push_back(filein);
+ else {
+ std::vector<std::string> buildargs;
+ buildargs.push_back(Glib::get_current_dir());
+ buildargs.push_back(filein);
+ argv.push_back(Glib::build_filename(buildargs));
+ }
}
int stdout_pipe, stderr_pipe;
diff --git a/src/extension/implementation/script.h b/src/extension/implementation/script.h
index f52683623..270c361af 100644
--- a/src/extension/implementation/script.h
+++ b/src/extension/implementation/script.h
@@ -15,6 +15,9 @@
#include "implementation.h"
#include <gtkmm/enums.h>
+#include <glibmm/main.h>
+#include <glibmm/spawn.h>
+#include <glibmm/fileutils.h>
namespace Inkscape {
namespace XML {
diff --git a/src/extension/init.cpp b/src/extension/init.cpp
index b0732568f..d403d270f 100644
--- a/src/extension/init.cpp
+++ b/src/extension/init.cpp
@@ -26,8 +26,10 @@
#include "path-prefix.h"
#include "inkscape.h"
-#include <glibmm/ustring.h>
+
+#include <glibmm/fileutils.h>
#include <glibmm/i18n.h>
+#include <glibmm/ustring.h>
#include "system.h"
#include "db.h"
@@ -53,6 +55,12 @@
#ifdef WITH_LIBWPG
#include "internal/wpg-input.h"
#endif
+#ifdef WITH_LIBVISIO
+#include "internal/vsd-input.h"
+#endif
+#ifdef WITH_LIBCDR
+#include "internal/cdr-input.h"
+#endif
#include "preferences.h"
#include "io/sys.h"
#ifdef WITH_DBUS
@@ -99,6 +107,8 @@
#include "internal/filter/filter.h"
+#include "init.h"
+
extern gboolean inkscape_app_use_gui( Inkscape::Application const *app );
namespace Inkscape {
@@ -183,6 +193,12 @@ init()
#ifdef WITH_LIBWPG
Internal::WpgInput::init();
#endif
+#ifdef WITH_LIBVISIO
+ Internal::VsdInput::init();
+#endif
+#ifdef WITH_LIBCDR
+ Internal::CdrInput::init();
+#endif
/* Effects */
Internal::BlurEdge::init();
diff --git a/src/extension/input.cpp b/src/extension/input.cpp
index 1662ef073..5cef38009 100644
--- a/src/extension/input.cpp
+++ b/src/extension/input.cpp
@@ -152,6 +152,10 @@ Input::open (const gchar *uri)
SPDocument *const doc = imp->open(this, uri);
+ if (imp->wasCancelled()) {
+ throw Input::open_cancelled();
+ }
+
return doc;
}
@@ -227,8 +231,7 @@ Input::prefs (const gchar *uri)
delete dialog;
- if (response == Gtk::RESPONSE_OK) return true;
- return false;
+ return (response == Gtk::RESPONSE_OK);
}
} } /* namespace Inkscape, Extension */
diff --git a/src/extension/input.h b/src/extension/input.h
index 8b198495e..b01ffeb86 100644
--- a/src/extension/input.h
+++ b/src/extension/input.h
@@ -39,6 +39,10 @@ public:
virtual ~no_extension_found() throw() {}
const char *what() const throw() { return "No suitable input extension found"; }
};
+ struct open_cancelled : public std::exception {
+ virtual ~open_cancelled() throw() {}
+ const char *what() const throw() { return "Open was cancelled"; }
+ };
Input (Inkscape::XML::Node * in_repr,
Implementation::Implementation * in_imp);
diff --git a/src/extension/internal/Makefile_insert b/src/extension/internal/Makefile_insert
index e9b11553b..9e55598df 100644
--- a/src/extension/internal/Makefile_insert
+++ b/src/extension/internal/Makefile_insert
@@ -4,7 +4,18 @@ if WITH_LIBWPG
ink_common_sources += \
extension/internal/wpg-input.cpp \
extension/internal/wpg-input.h
+endif
+
+if WITH_LIBVISIO
+ink_common_sources += \
+ extension/internal/vsd-input.cpp \
+ extension/internal/vsd-input.h
+endif
+if WITH_LIBCDR
+ink_common_sources += \
+ extension/internal/cdr-input.cpp \
+ extension/internal/cdr-input.h
endif
if USE_IMAGE_MAGICK
@@ -127,12 +138,24 @@ ink_common_sources += \
extension/internal/latex-pstricks.h \
extension/internal/latex-pstricks-out.cpp \
extension/internal/latex-pstricks-out.h \
+ extension/internal/filter/bevels.h \
+ extension/internal/filter/blurs.h \
+ extension/internal/filter/bumps.h \
+ extension/internal/filter/color.h \
+ extension/internal/filter/distort.h \
+ extension/internal/filter/filter.h \
+ extension/internal/filter/image.h \
+ extension/internal/filter/morphology.h \
+ extension/internal/filter/overlays.h \
+ extension/internal/filter/paint.h \
+ extension/internal/filter/protrusions.h \
+ extension/internal/filter/shadows.h \
+ extension/internal/filter/textures.h \
+ extension/internal/filter/transparency.h \
extension/internal/filter/filter-all.cpp \
extension/internal/filter/filter-file.cpp \
extension/internal/filter/filter.cpp \
extension/internal/filter/filter.h \
- extension/internal/filter/drop-shadow.h \
- extension/internal/filter/snow.h \
extension/internal/emf-win32-print.h \
extension/internal/emf-win32-print.cpp \
extension/internal/emf-win32-inout.h \
diff --git a/src/extension/internal/cairo-png-out.cpp b/src/extension/internal/cairo-png-out.cpp
index 4751a229a..956fcce9a 100644
--- a/src/extension/internal/cairo-png-out.cpp
+++ b/src/extension/internal/cairo-png-out.cpp
@@ -68,7 +68,7 @@ png_render_document_to_file(SPDocument *doc, gchar const *filename)
ctx = renderer->createContext();
/* Render document */
- bool ret = renderer->setupDocument(ctx, doc, TRUE, NULL);
+ bool ret = renderer->setupDocument(ctx, doc, TRUE, 0., NULL);
if (ret) {
renderer->renderItem(ctx, base);
ctx->saveAsPng(filename);
diff --git a/src/extension/internal/cairo-ps-out.cpp b/src/extension/internal/cairo-ps-out.cpp
index 8b1b3fbfd..983c9dfb5 100644
--- a/src/extension/internal/cairo-ps-out.cpp
+++ b/src/extension/internal/cairo-ps-out.cpp
@@ -104,7 +104,7 @@ ps_print_document_to_file(SPDocument *doc, gchar const *filename, unsigned int l
bool ret = ctx->setPsTarget(filename);
if(ret) {
/* Render document */
- ret = renderer->setupDocument(ctx, doc, pageBoundingBox, base);
+ ret = renderer->setupDocument(ctx, doc, pageBoundingBox, 0., base);
if (ret) {
renderer->renderItem(ctx, base);
ret = ctx->finish();
@@ -169,13 +169,10 @@ CairoPsOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar con
bool new_areaPage = true;
try {
- new_areaPage = mod->get_param_bool("areaPage");
+ new_areaPage = (strcmp(ext->get_param_optiongroup("area"), "page") == 0);
} catch(...) {}
- bool new_areaDrawing = true;
- try {
- new_areaDrawing = mod->get_param_bool("areaDrawing");
- } catch(...) {}
+ bool new_areaDrawing = !new_areaPage;
const gchar *new_exportId = NULL;
try {
@@ -195,7 +192,7 @@ CairoPsOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar con
// Create LaTeX file (if requested)
if (new_textToLaTeX) {
- ret = latex_render_document_text_to_file(doc, filename, new_exportId, new_areaDrawing, new_areaPage, false);
+ ret = latex_render_document_text_to_file(doc, filename, new_exportId, new_areaDrawing, new_areaPage, 0., false);
if (!ret)
throw Inkscape::Extension::Output::save_failed();
@@ -252,13 +249,10 @@ CairoEpsOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar co
bool new_areaPage = true;
try {
- new_areaPage = mod->get_param_bool("areaPage");
+ new_areaPage = (strcmp(ext->get_param_optiongroup("area"), "page") == 0);
} catch(...) {}
- bool new_areaDrawing = true;
- try {
- new_areaDrawing = mod->get_param_bool("areaDrawing");
- } catch(...) {}
+ bool new_areaDrawing = !new_areaPage;
const gchar *new_exportId = NULL;
try {
@@ -278,7 +272,7 @@ CairoEpsOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar co
// Create LaTeX file (if requested)
if (new_textToLaTeX) {
- ret = latex_render_document_text_to_file(doc, filename, new_exportId, new_areaDrawing, new_areaPage, false);
+ ret = latex_render_document_text_to_file(doc, filename, new_exportId, new_areaDrawing, new_areaPage, 0., false);
if (!ret)
throw Inkscape::Extension::Output::save_failed();
@@ -310,32 +304,34 @@ CairoEpsOutput::textToPath(Inkscape::Extension::Print * ext)
void
CairoPsOutput::init (void)
{
- Inkscape::Extension::build_from_mem(
- "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
- "<name>" N_("PostScript") "</name>\n"
- "<id>" SP_MODULE_KEY_PRINT_CAIRO_PS "</id>\n"
- "<param name=\"PSlevel\" gui-text=\"" N_("Restrict to PS level:") "\" type=\"enum\" >\n"
- "<_item value='PS3'>" N_("PostScript level 3") "</_item>\n"
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("PostScript") "</name>\n"
+ "<id>" SP_MODULE_KEY_PRINT_CAIRO_PS "</id>\n"
+ "<param name=\"PSlevel\" gui-text=\"" N_("Restrict to PS level:") "\" type=\"enum\" >\n"
+ "<_item value='PS3'>" N_("PostScript level 3") "</_item>\n"
#if (CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 5, 2))
"<_item value='PS2'>" N_("PostScript level 2") "</_item>\n"
#endif
"</param>\n"
- "<param name=\"textToPath\" gui-text=\"" N_("Convert texts to paths") "\" type=\"boolean\">false</param>\n"
- "<param name=\"textToLaTeX\" gui-text=\"" N_("PS+LaTeX: Omit text in PS, and create LaTeX file") "\" type=\"boolean\">false</param>\n"
- "<param name=\"blurToBitmap\" gui-text=\"" N_("Rasterize filter effects") "\" type=\"boolean\">true</param>\n"
- "<param name=\"resolution\" gui-text=\"" N_("Resolution for rasterization (dpi):") "\" type=\"int\" min=\"1\" max=\"10000\">90</param>\n"
- "<param name=\"areaDrawing\" gui-text=\"" N_("Export area is drawing") "\" type=\"boolean\">true</param>\n"
- "<param name=\"areaPage\" gui-text=\"" N_("Export area is page") "\" type=\"boolean\">true</param>\n"
- "<param name=\"exportId\" gui-text=\"" N_("Limit export to the object with ID:") "\" type=\"string\"></param>\n"
- "<output>\n"
- "<extension>.ps</extension>\n"
- "<mimetype>image/x-postscript</mimetype>\n"
- "<filetypename>" N_("PostScript (*.ps)") "</filetypename>\n"
- "<filetypetooltip>" N_("PostScript File") "</filetypetooltip>\n"
- "</output>\n"
- "</inkscape-extension>", new CairoPsOutput());
-
- return;
+ "<param name=\"textToPath\" gui-text=\"" N_("Convert texts to paths") "\" type=\"boolean\">false</param>\n"
+ "<param name=\"textToLaTeX\" gui-text=\"" N_("PS+LaTeX: Omit text in PS, and create LaTeX file") "\" type=\"boolean\">false</param>\n"
+ "<param name=\"blurToBitmap\" gui-text=\"" N_("Rasterize filter effects") "\" type=\"boolean\">true</param>\n"
+ "<param name=\"resolution\" gui-text=\"" N_("Resolution for rasterization (dpi):") "\" type=\"int\" min=\"1\" max=\"10000\">90</param>\n"
+ "<param name=\"area\" gui-text=\"" N_("Output page size") "\" type=\"optiongroup\" >\n"
+ "<_option value=\"page\">" N_("Use document's page size") "</_option>"
+ "<_option value=\"drawing\">" N_("Use exported object's size") "</_option>"
+ "</param>"
+ "<param name=\"exportId\" gui-text=\"" N_("Limit export to the object with ID:") "\" type=\"string\"></param>\n"
+ "<output>\n"
+ "<extension>.ps</extension>\n"
+ "<mimetype>image/x-postscript</mimetype>\n"
+ "<filetypename>" N_("PostScript (*.ps)") "</filetypename>\n"
+ "<filetypetooltip>" N_("PostScript File") "</filetypetooltip>\n"
+ "</output>\n"
+ "</inkscape-extension>", new CairoPsOutput());
+
+ return;
}
/**
@@ -348,32 +344,34 @@ CairoPsOutput::init (void)
void
CairoEpsOutput::init (void)
{
- Inkscape::Extension::build_from_mem(
- "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
- "<name>" N_("Encapsulated PostScript") "</name>\n"
- "<id>" SP_MODULE_KEY_PRINT_CAIRO_EPS "</id>\n"
- "<param name=\"PSlevel\" gui-text=\"" N_("Restrict to PS level:") "\" type=\"enum\" >\n"
- "<_item value='PS3'>" N_("PostScript level 3") "</_item>\n"
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("Encapsulated PostScript") "</name>\n"
+ "<id>" SP_MODULE_KEY_PRINT_CAIRO_EPS "</id>\n"
+ "<param name=\"PSlevel\" gui-text=\"" N_("Restrict to PS level:") "\" type=\"enum\" >\n"
+ "<_item value='PS3'>" N_("PostScript level 3") "</_item>\n"
#if (CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 5, 2))
"<_item value='PS2'>" N_("PostScript level 2") "</_item>\n"
#endif
"</param>\n"
- "<param name=\"textToPath\" gui-text=\"" N_("Convert texts to paths") "\" type=\"boolean\">false</param>\n"
- "<param name=\"textToLaTeX\" gui-text=\"" N_("EPS+LaTeX: Omit text in EPS, and create LaTeX file") "\" type=\"boolean\">false</param>\n"
- "<param name=\"blurToBitmap\" gui-text=\"" N_("Rasterize filter effects") "\" type=\"boolean\">true</param>\n"
- "<param name=\"resolution\" gui-text=\"" N_("Resolution for rasterization (dpi):") "\" type=\"int\" min=\"1\" max=\"10000\">90</param>\n"
- "<param name=\"areaDrawing\" gui-text=\"" N_("Export area is drawing") "\" type=\"boolean\">true</param>\n"
- "<param name=\"areaPage\" gui-text=\"" N_("Export area is page") "\" type=\"boolean\">true</param>\n"
- "<param name=\"exportId\" gui-text=\"" N_("Limit export to the object with ID:") "\" type=\"string\"></param>\n"
- "<output>\n"
- "<extension>.eps</extension>\n"
- "<mimetype>image/x-e-postscript</mimetype>\n"
- "<filetypename>" N_("Encapsulated PostScript (*.eps)") "</filetypename>\n"
- "<filetypetooltip>" N_("Encapsulated PostScript File") "</filetypetooltip>\n"
- "</output>\n"
- "</inkscape-extension>", new CairoEpsOutput());
-
- return;
+ "<param name=\"textToPath\" gui-text=\"" N_("Convert texts to paths") "\" type=\"boolean\">false</param>\n"
+ "<param name=\"textToLaTeX\" gui-text=\"" N_("EPS+LaTeX: Omit text in EPS, and create LaTeX file") "\" type=\"boolean\">false</param>\n"
+ "<param name=\"blurToBitmap\" gui-text=\"" N_("Rasterize filter effects") "\" type=\"boolean\">true</param>\n"
+ "<param name=\"resolution\" gui-text=\"" N_("Resolution for rasterization (dpi):") "\" type=\"int\" min=\"1\" max=\"10000\">90</param>\n"
+ "<param name=\"area\" gui-text=\"" N_("Output page size") "\" type=\"optiongroup\" >\n"
+ "<_option value=\"page\">" N_("Use document's page size") "</_option>"
+ "<_option value=\"drawing\">" N_("Use exported object's size") "</_option>"
+ "</param>"
+ "<param name=\"exportId\" gui-text=\"" N_("Limit export to the object with ID:") "\" type=\"string\"></param>\n"
+ "<output>\n"
+ "<extension>.eps</extension>\n"
+ "<mimetype>image/x-e-postscript</mimetype>\n"
+ "<filetypename>" N_("Encapsulated PostScript (*.eps)") "</filetypename>\n"
+ "<filetypetooltip>" N_("Encapsulated PostScript File") "</filetypetooltip>\n"
+ "</output>\n"
+ "</inkscape-extension>", new CairoEpsOutput());
+
+ return;
}
} } } /* namespace Inkscape, Extension, Implementation */
diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp
index b6a58c526..cf6730650 100644
--- a/src/extension/internal/cairo-render-context.cpp
+++ b/src/extension/internal/cairo-render-context.cpp
@@ -708,7 +708,7 @@ CairoRenderContext::popLayer(void)
for (int row = 0 ; row < height; row++) {
unsigned char *row_data = pixels + (row * stride);
for (int i = 0 ; i < width; i++) {
- guint32 *pixel = (guint32 *)row_data + i;
+ guint32 *pixel = reinterpret_cast<guint32 *>(row_data) + i;
float lum_alpha = (((*pixel & 0x00ff0000) >> 16) * coeff_r +
((*pixel & 0x0000ff00) >> 8) * coeff_g +
((*pixel & 0x000000ff) ) * coeff_b );
diff --git a/src/extension/internal/cairo-render-context.h b/src/extension/internal/cairo-render-context.h
index 94c7bb294..8829940c6 100644
--- a/src/extension/internal/cairo-render-context.h
+++ b/src/extension/internal/cairo-render-context.h
@@ -29,7 +29,7 @@
#include <cairo.h>
class SPClipPath;
-class SPMask;
+struct SPMask;
namespace Inkscape {
namespace Extension {
@@ -37,8 +37,8 @@ namespace Internal {
class CairoRenderer;
class CairoRenderContext;
-class CairoRenderState;
-class CairoGlyphInfo;
+struct CairoRenderState;
+struct CairoGlyphInfo;
// Holds info for rendering a glyph
struct CairoGlyphInfo {
diff --git a/src/extension/internal/cairo-renderer-pdf-out.cpp b/src/extension/internal/cairo-renderer-pdf-out.cpp
index 5d45fcf87..63e46ad17 100644
--- a/src/extension/internal/cairo-renderer-pdf-out.cpp
+++ b/src/extension/internal/cairo-renderer-pdf-out.cpp
@@ -39,6 +39,8 @@
#include <2geom/affine.h>
#include "document.h"
+#include "unit-constants.h"
+
namespace Inkscape {
namespace Extension {
namespace Internal {
@@ -57,7 +59,7 @@ bool CairoRendererPdfOutput::check(Inkscape::Extension::Extension * /*module*/)
static bool
pdf_render_document_to_file(SPDocument *doc, gchar const *filename, unsigned int level,
bool texttopath, bool omittext, bool filtertobitmap, int resolution,
- const gchar * const exportId, bool exportDrawing, bool exportCanvas)
+ const gchar * const exportId, bool exportDrawing, bool exportCanvas, float bleedmargin_px)
{
doc->ensureUpToDate();
@@ -99,7 +101,7 @@ pdf_render_document_to_file(SPDocument *doc, gchar const *filename, unsigned int
bool ret = ctx->setPdfTarget (filename);
if(ret) {
/* Render document */
- ret = renderer->setupDocument(ctx, doc, pageBoundingBox, base);
+ ret = renderer->setupDocument(ctx, doc, pageBoundingBox, bleedmargin_px, base);
if (ret) {
renderer->renderItem(ctx, base);
ret = ctx->finish();
@@ -185,20 +187,20 @@ CairoRendererPdfOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc,
g_warning("Parameter <exportId> might not exist");
}
- bool new_exportDrawing = FALSE;
+ bool new_exportCanvas = true;
try {
- new_exportDrawing = mod->get_param_bool("areaDrawing");
- }
- catch(...) {
- g_warning("Parameter <areaDrawing> might not exist");
+ new_exportCanvas = (strcmp(ext->get_param_optiongroup("area"), "page") == 0);
+ } catch(...) {
+ g_warning("Parameter <area> might not exist");
}
+ bool new_exportDrawing = !new_exportCanvas;
- bool new_exportCanvas = FALSE;
+ float new_bleedmargin_px = 0.;
try {
- new_exportCanvas = mod->get_param_bool("areaPage");
+ new_bleedmargin_px = mod->get_param_float("bleed") * PX_PER_MM;
}
catch(...) {
- g_warning("Parameter <exportCanvas> might not exist");
+ g_warning("Parameter <bleed> might not exist");
}
// Create PDF file
@@ -207,7 +209,7 @@ CairoRendererPdfOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc,
final_name = g_strdup_printf("> %s", filename);
ret = pdf_render_document_to_file(doc, final_name, level,
new_textToPath, new_textToLaTeX, new_blurToBitmap, new_bitmapResolution,
- new_exportId, new_exportDrawing, new_exportCanvas);
+ new_exportId, new_exportDrawing, new_exportCanvas, new_bleedmargin_px);
g_free(final_name);
if (!ret)
@@ -216,7 +218,7 @@ CairoRendererPdfOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc,
// Create LaTeX file (if requested)
if (new_textToLaTeX) {
- ret = latex_render_document_text_to_file(doc, filename, new_exportId, new_exportDrawing, new_exportCanvas, true);
+ ret = latex_render_document_text_to_file(doc, filename, new_exportId, new_exportDrawing, new_exportCanvas, new_bleedmargin_px, true);
if (!ret)
throw Inkscape::Extension::Output::save_failed();
@@ -235,32 +237,35 @@ CairoRendererPdfOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc,
void
CairoRendererPdfOutput::init (void)
{
- Inkscape::Extension::build_from_mem(
- "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
- "<name>Portable Document Format</name>\n"
- "<id>org.inkscape.output.pdf.cairorenderer</id>\n"
- "<param name=\"PDFversion\" gui-text=\"" N_("Restrict to PDF version:") "\" type=\"enum\" >\n"
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>Portable Document Format</name>\n"
+ "<id>org.inkscape.output.pdf.cairorenderer</id>\n"
+ "<param name=\"PDFversion\" gui-text=\"" N_("Restrict to PDF version:") "\" type=\"enum\" >\n"
#if (CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 10, 0))
- "<_item value='PDF-1.5'>" N_("PDF 1.5") "</_item>\n"
+ "<_item value='PDF-1.5'>" N_("PDF 1.5") "</_item>\n"
#endif
"<_item value='PDF-1.4'>" N_("PDF 1.4") "</_item>\n"
- "</param>\n"
- "<param name=\"textToPath\" gui-text=\"" N_("Convert texts to paths") "\" type=\"boolean\">false</param>\n"
- "<param name=\"textToLaTeX\" gui-text=\"" N_("PDF+LaTeX: Omit text in PDF, and create LaTeX file") "\" type=\"boolean\">false</param>\n"
- "<param name=\"blurToBitmap\" gui-text=\"" N_("Rasterize filter effects") "\" type=\"boolean\">true</param>\n"
- "<param name=\"resolution\" gui-text=\"" N_("Resolution for rasterization (dpi):") "\" type=\"int\" min=\"1\" max=\"10000\">90</param>\n"
- "<param name=\"areaDrawing\" gui-text=\"" N_("Export area is drawing") "\" type=\"boolean\">false</param>\n"
- "<param name=\"areaPage\" gui-text=\"" N_("Export area is page") "\" type=\"boolean\">false</param>\n"
- "<param name=\"exportId\" gui-text=\"" N_("Limit export to the object with ID:") "\" type=\"string\"></param>\n"
- "<output>\n"
- "<extension>.pdf</extension>\n"
- "<mimetype>application/pdf</mimetype>\n"
- "<filetypename>Portable Document Format (*.pdf)</filetypename>\n"
- "<filetypetooltip>PDF File</filetypetooltip>\n"
- "</output>\n"
- "</inkscape-extension>", new CairoRendererPdfOutput());
-
- return;
+ "</param>\n"
+ "<param name=\"textToPath\" gui-text=\"" N_("Convert texts to paths") "\" type=\"boolean\">false</param>\n"
+ "<param name=\"textToLaTeX\" gui-text=\"" N_("PDF+LaTeX: Omit text in PDF, and create LaTeX file") "\" type=\"boolean\">false</param>\n"
+ "<param name=\"blurToBitmap\" gui-text=\"" N_("Rasterize filter effects") "\" type=\"boolean\">true</param>\n"
+ "<param name=\"resolution\" gui-text=\"" N_("Resolution for rasterization (dpi):") "\" type=\"int\" min=\"1\" max=\"10000\">90</param>\n"
+ "<param name=\"area\" gui-text=\"" N_("Output page size") "\" type=\"optiongroup\" >\n"
+ "<_option value=\"page\">" N_("Use document's page size") "</_option>"
+ "<_option value=\"drawing\">" N_("Use exported object's size") "</_option>"
+ "</param>"
+ "<param name=\"bleed\" gui-text=\"" N_("Bleed/margin (mm)") "\" type=\"float\" min=\"-10000\" max=\"10000\">0</param>\n"
+ "<param name=\"exportId\" gui-text=\"" N_("Limit export to the object with ID:") "\" type=\"string\"></param>\n"
+ "<output>\n"
+ "<extension>.pdf</extension>\n"
+ "<mimetype>application/pdf</mimetype>\n"
+ "<filetypename>Portable Document Format (*.pdf)</filetypename>\n"
+ "<filetypetooltip>PDF File</filetypetooltip>\n"
+ "</output>\n"
+ "</inkscape-extension>", new CairoRendererPdfOutput());
+
+ return;
}
} } } /* namespace Inkscape, Extension, Internal */
diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp
index 09d69becb..0a3cff26a 100644
--- a/src/extension/internal/cairo-renderer.cpp
+++ b/src/extension/internal/cairo-renderer.cpp
@@ -604,7 +604,7 @@ void CairoRenderer::renderItem(CairoRenderContext *ctx, SPItem *item)
}
bool
-CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool pageBoundingBox, SPItem *base)
+CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool pageBoundingBox, float bleedmargin_px, SPItem *base)
{
// PLEASE note when making changes to the boundingbox and transform calculation, corresponding changes should be made to PDFLaTeXRenderer::setupDocument !!!
@@ -625,6 +625,7 @@ CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool page
}
d = *bbox;
}
+ d.expandBy(bleedmargin_px);
if (ctx->_vector_based_target) {
// convert from px to pt
@@ -638,16 +639,21 @@ CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool page
bool ret = ctx->setupSurface(ctx->_width, ctx->_height);
- if (ret && !pageBoundingBox)
- {
- double high = doc->getHeight();
- if (ctx->_vector_based_target)
- high *= PT_PER_PX;
-
- /// @fixme hardcoded dt2doc transform?
- Geom::Affine tp(Geom::Translate(-d.left() * (ctx->_vector_based_target ? PX_PER_PT : 1.0),
- (d.bottom() - high) * (ctx->_vector_based_target ? PX_PER_PT : 1.0)));
- ctx->transform(tp);
+ if (ret) {
+ if (pageBoundingBox) {
+ // translate to set bleed/margin
+ Geom::Affine tp( Geom::Translate( bleedmargin_px, bleedmargin_px ) );
+ ctx->transform(tp);
+ } else {
+ double high = doc->getHeight();
+ if (ctx->_vector_based_target)
+ high *= PT_PER_PX;
+
+ // this transform translates the export drawing to a virtual page (0,0)-(width,height)
+ Geom::Affine tp(Geom::Translate(-d.left() * (ctx->_vector_based_target ? PX_PER_PT : 1.0),
+ (d.bottom() - high) * (ctx->_vector_based_target ? PX_PER_PT : 1.0)));
+ ctx->transform(tp);
+ }
}
return ret;
diff --git a/src/extension/internal/cairo-renderer.h b/src/extension/internal/cairo-renderer.h
index 7fa7c7ff5..c1482d82e 100644
--- a/src/extension/internal/cairo-renderer.h
+++ b/src/extension/internal/cairo-renderer.h
@@ -28,7 +28,7 @@
#include <cairo.h>
class SPClipPath;
-class SPMask;
+struct SPMask;
namespace Inkscape {
namespace Extension {
@@ -53,7 +53,7 @@ public:
/** Initializes the CairoRenderContext according to the specified
SPDocument. A set*Target function can only be called on the context
before setupDocument. */
- bool setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool pageBoundingBox, SPItem *base);
+ bool setupDocument(CairoRenderContext *ctx, SPDocument *doc, bool pageBoundingBox, float bleedmargin_px, SPItem *base);
/** Traverses the object tree and invokes the render methods. */
void renderItem(CairoRenderContext *ctx, SPItem *item);
diff --git a/src/extension/internal/cdr-input.cpp b/src/extension/internal/cdr-input.cpp
new file mode 100644
index 000000000..e6c400fb5
--- /dev/null
+++ b/src/extension/internal/cdr-input.cpp
@@ -0,0 +1,332 @@
+/*
+ * This file came from libwpg as a source, their utility wpg2svg
+ * specifically. It has been modified to work as an Inkscape extension.
+ * The Inkscape extension code is covered by this copyright, but the
+ * rest is covered by the one bellow.
+ *
+ * Authors:
+ * Fridrich Strba (fridrich.strba@bluewin.ch)
+ *
+ * Copyright (C) 2012 Authors
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ *
+ */
+
+#include <stdio.h>
+#include "config.h"
+
+#include "cdr-input.h"
+
+#ifdef WITH_LIBCDR
+
+#include <string>
+#include <cstring>
+
+#include <libcdr/libcdr.h>
+#include <libwpd-stream/libwpd-stream.h>
+
+#include <gtkmm/alignment.h>
+#include <gtkmm/comboboxtext.h>
+#include <gtkmm/drawingarea.h>
+#include <gtkmm/frame.h>
+#include <gtkmm/scale.h>
+
+#include "extension/system.h"
+#include "extension/input.h"
+#include "document.h"
+
+#include "document-private.h"
+#include "document-undo.h"
+#include "inkscape.h"
+
+#include "dialogs/dialog-events.h"
+#include <gtk/gtk.h>
+#include "ui/widget/spinbutton.h"
+#include "ui/widget/frame.h"
+#include <glibmm/i18n.h>
+
+#include <gdkmm/general.h>
+
+#include "svg-view.h"
+#include "svg-view-widget.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+
+
+class CdrImportDialog : public Gtk::Dialog {
+public:
+ CdrImportDialog(const std::vector<WPXString> &vec);
+ virtual ~CdrImportDialog();
+
+ bool showDialog();
+ unsigned getSelectedPage();
+ void getImportSettings(Inkscape::XML::Node *prefs);
+
+private:
+ void _setPreviewPage(unsigned page);
+
+ // Signal handlers
+#if !WITH_GTKMM_3_0
+ bool _onExposePreview(GdkEventExpose *event);
+#endif
+
+ void _onPageNumberChanged();
+
+ class Gtk::Button * cancelbutton;
+ class Gtk::Button * okbutton;
+ class Gtk::Label * _labelSelect;
+ class Inkscape::UI::Widget::SpinButton * _pageNumberSpin;
+ class Gtk::Label * _labelTotalPages;
+ class Gtk::VBox * vbox1;
+ class Gtk::VBox * vbox2;
+ class Gtk::Widget * _previewArea;
+
+ const std::vector<WPXString> &_vec; // Document to be imported
+ unsigned _current_page; // Current selected page
+ int _preview_width, _preview_height; // Size of the preview area
+};
+
+CdrImportDialog::CdrImportDialog(const std::vector<WPXString> &vec)
+ : _vec(vec), _current_page(1)
+{
+ int num_pages = _vec.size();
+ if ( num_pages <= 1 )
+ return;
+ cancelbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-cancel")));
+ okbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-ok")));
+ _labelSelect = Gtk::manage(new class Gtk::Label(_("Select page:")));
+
+ // Page number
+#if WITH_GTKMM_3_0
+ Glib::RefPtr<Gtk::Adjustment> _pageNumberSpin_adj = Gtk::Adjustment::create(1, 1, _vec.size(), 1, 10, 0);
+ _pageNumberSpin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(_pageNumberSpin_adj, 1, 1));
+#else
+ Gtk::Adjustment *_pageNumberSpin_adj = Gtk::manage(
+ new class Gtk::Adjustment(1, 1, _vec.size(), 1, 10, 0));
+ _pageNumberSpin = Gtk::manage(new class Inkscape::UI::Widget::SpinButton(*_pageNumberSpin_adj, 1, 1));
+#endif
+ _labelTotalPages = Gtk::manage(new class Gtk::Label());
+ gchar *label_text = g_strdup_printf(_("out of %i"), num_pages);
+ _labelTotalPages->set_label(label_text);
+ g_free(label_text);
+
+ vbox1 = Gtk::manage(new class Gtk::VBox(false, 4));
+ SPDocument *doc = SPDocument::createNewDocFromMem(_vec[0].cstr(), strlen(_vec[0].cstr()), 0);
+ _previewArea = Glib::wrap(sp_svg_view_widget_new(doc));
+
+ vbox2 = Gtk::manage(new class Gtk::VBox(false, 4));
+ cancelbutton->set_can_focus();
+ cancelbutton->set_can_default();
+ cancelbutton->set_relief(Gtk::RELIEF_NORMAL);
+ okbutton->set_can_focus();
+ okbutton->set_can_default();
+ okbutton->set_relief(Gtk::RELIEF_NORMAL);
+ this->get_action_area()->property_layout_style().set_value(Gtk::BUTTONBOX_END);
+ _labelSelect->set_line_wrap(false);
+ _labelSelect->set_use_markup(false);
+ _labelSelect->set_selectable(false);
+ _pageNumberSpin->set_can_focus();
+ _pageNumberSpin->set_update_policy(Gtk::UPDATE_ALWAYS);
+ _pageNumberSpin->set_numeric(true);
+ _pageNumberSpin->set_digits(0);
+ _pageNumberSpin->set_wrap(false);
+ _labelTotalPages->set_line_wrap(false);
+ _labelTotalPages->set_use_markup(false);
+ _labelTotalPages->set_selectable(false);
+ vbox2->pack_start(*_previewArea, Gtk::PACK_SHRINK, 0);
+ this->get_vbox()->set_homogeneous(false);
+ this->get_vbox()->set_spacing(0);
+ this->get_vbox()->pack_start(*vbox2);
+ this->set_title(_("Page Selector"));
+ this->set_modal(true);
+ sp_transientize(GTK_WIDGET(this->gobj())); //Make transient
+ this->property_window_position().set_value(Gtk::WIN_POS_NONE);
+ this->set_resizable(true);
+ this->property_destroy_with_parent().set_value(false);
+ this->get_action_area()->add(*_labelSelect);
+ this->add_action_widget(*_pageNumberSpin, -7);
+ this->get_action_area()->add(*_labelTotalPages);
+ this->add_action_widget(*cancelbutton, -6);
+ this->add_action_widget(*okbutton, -5);
+ cancelbutton->show();
+ okbutton->show();
+ _labelSelect->show();
+ _pageNumberSpin->show();
+ _labelTotalPages->show();
+ vbox1->show();
+ _previewArea->show();
+ vbox2->show();
+
+ // Connect signals
+ _pageNumberSpin_adj->signal_value_changed().connect(sigc::mem_fun(*this, &CdrImportDialog::_onPageNumberChanged));
+}
+
+CdrImportDialog::~CdrImportDialog() {}
+
+bool CdrImportDialog::showDialog()
+{
+ show();
+ gint b = run();
+ hide();
+ if ( b == Gtk::RESPONSE_OK ) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+}
+
+unsigned CdrImportDialog::getSelectedPage()
+{
+ return _current_page;
+}
+
+void CdrImportDialog::_onPageNumberChanged()
+{
+ unsigned page = static_cast<unsigned>(_pageNumberSpin->get_value_as_int());
+ _current_page = CLAMP(page, 1U, _vec.size());
+ _setPreviewPage(_current_page);
+}
+
+/**
+ * \brief Renders the given page's thumbnail
+ */
+void CdrImportDialog::_setPreviewPage(unsigned page)
+{
+ SPDocument *doc = SPDocument::createNewDocFromMem(_vec[page-1].cstr(), strlen(_vec[page-1].cstr()), 0);
+ Gtk::Widget * tmpPreviewArea = Glib::wrap(sp_svg_view_widget_new(doc));
+ std::swap(_previewArea, tmpPreviewArea);
+ if (tmpPreviewArea) {
+ _previewArea->set_size_request( tmpPreviewArea->get_width(), tmpPreviewArea->get_height() );
+ delete tmpPreviewArea;
+ }
+ vbox2->pack_start(*_previewArea, Gtk::PACK_SHRINK, 0);
+ _previewArea->show_now();
+}
+
+SPDocument *CdrInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * uri)
+{
+ WPXFileStream input(uri);
+
+ if (!libcdr::CDRDocument::isSupported(&input)) {
+ return NULL;
+ }
+
+ libcdr::CDRStringVector output;
+ if (!libcdr::CDRDocument::generateSVG(&input, output)) {
+ return NULL;
+ }
+
+ if (output.empty()) {
+ return NULL;
+ }
+
+ std::vector<WPXString> tmpSVGOutput;
+ for (unsigned i=0; i<output.size(); ++i) {
+ WPXString tmpString("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n");
+ tmpString.append(output[i]);
+ tmpSVGOutput.push_back(tmpString);
+ }
+
+ unsigned page_num = 1;
+
+ // If only one page is present, import that one without bothering user
+ if (tmpSVGOutput.size() > 1) {
+ CdrImportDialog *dlg = 0;
+ if (inkscape_use_gui()) {
+ dlg = new CdrImportDialog(tmpSVGOutput);
+ if (!dlg->showDialog()) {
+ delete dlg;
+ return NULL;
+ }
+ }
+
+ // Get needed page
+ if (dlg) {
+ page_num = dlg->getSelectedPage();
+ if (page_num < 1)
+ page_num = 1;
+ if (page_num > tmpSVGOutput.size())
+ page_num = tmpSVGOutput.size();
+ }
+ }
+
+ SPDocument * doc = SPDocument::createNewDocFromMem(tmpSVGOutput[page_num-1].cstr(), strlen(tmpSVGOutput[page_num-1].cstr()), TRUE);
+ return doc;
+}
+
+#include "clear-n_.h"
+
+void CdrInput::init(void)
+{
+ /* CDR */
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("Corel DRAW Input") "</name>\n"
+ "<id>org.inkscape.input.cdr</id>\n"
+ "<input>\n"
+ "<extension>.cdr</extension>\n"
+ "<mimetype>image/x-xcdr</mimetype>\n"
+ "<filetypename>" N_("Corel DRAW 7-X4 files (*.cdr)") "</filetypename>\n"
+ "<filetypetooltip>" N_("Open files saved in Corel DRAW 7-X4") "</filetypetooltip>\n"
+ "</input>\n"
+ "</inkscape-extension>", new CdrInput());
+
+ /* CDT */
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("Corel DRAW templates input") "</name>\n"
+ "<id>org.inkscape.input.cdt</id>\n"
+ "<input>\n"
+ "<extension>.cdt</extension>\n"
+ "<mimetype>application/x-xcdt</mimetype>\n"
+ "<filetypename>" N_("Corel DRAW 7-13 template files (*.cdt)") "</filetypename>\n"
+ "<filetypetooltip>" N_("Open files saved in Corel DRAW 7-13") "</filetypetooltip>\n"
+ "</input>\n"
+ "</inkscape-extension>", new CdrInput());
+
+ /* CCX */
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("Corel DRAW Compressed Exchange files input") "</name>\n"
+ "<id>org.inkscape.input.ccx</id>\n"
+ "<input>\n"
+ "<extension>.ccx</extension>\n"
+ "<mimetype>application/x-xccx</mimetype>\n"
+ "<filetypename>" N_("Corel DRAW Compressed Exchange files (*.ccx)") "</filetypename>\n"
+ "<filetypetooltip>" N_("Open compressed exchange files saved in Corel DRAW") "</filetypetooltip>\n"
+ "</input>\n"
+ "</inkscape-extension>", new CdrInput());
+
+ /* CMX */
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("Corel DRAW Presentation Exchange files input") "</name>\n"
+ "<id>org.inkscape.input.cmx</id>\n"
+ "<input>\n"
+ "<extension>.cmx</extension>\n"
+ "<mimetype>application/x-xcmx</mimetype>\n"
+ "<filetypename>" N_("Corel DRAW Presentation Exchange files (*.cmx)") "</filetypename>\n"
+ "<filetypetooltip>" N_("Open presentation exchange files saved in Corel DRAW") "</filetypetooltip>\n"
+ "</input>\n"
+ "</inkscape-extension>", new CdrInput());
+
+ return;
+
+} // init
+
+} } } /* namespace Inkscape, Extension, Implementation */
+#endif /* WITH_LIBCDR */
+
+/*
+ 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=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/extension/internal/cdr-input.h b/src/extension/internal/cdr-input.h
new file mode 100644
index 000000000..10af41d5a
--- /dev/null
+++ b/src/extension/internal/cdr-input.h
@@ -0,0 +1,54 @@
+/*
+ * This code abstracts the libwpg interfaces into the Inkscape
+ * input extension interface.
+ *
+ * Authors:
+ * Fridrich Strba (fridrich.strba@bluewin.ch)
+ *
+ * Copyright (C) 2012 Authors
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#ifndef __EXTENSION_INTERNAL_CDROUTPUT_H__
+#define __EXTENSION_INTERNAL_CDROUTPUT_H__
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#ifdef WITH_LIBCDR
+
+#include <gtkmm/dialog.h>
+
+#include "../implementation/implementation.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+
+class CdrInput : public Inkscape::Extension::Implementation::Implementation {
+ CdrInput () { };
+public:
+ SPDocument *open( Inkscape::Extension::Input *mod,
+ const gchar *uri );
+ static void init( void );
+
+};
+
+} } } /* namespace Inkscape, Extension, Implementation */
+
+#endif /* WITH_LIBCDR */
+#endif /* __EXTENSION_INTERNAL_CDROUTPUT_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=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/extension/internal/emf-win32-inout.cpp b/src/extension/internal/emf-win32-inout.cpp
index b3f7db106..e9360a0ea 100644
--- a/src/extension/internal/emf-win32-inout.cpp
+++ b/src/extension/internal/emf-win32-inout.cpp
@@ -61,6 +61,8 @@ namespace Extension {
namespace Internal {
static float device_scale = DEVICESCALE;
+static float device_x;
+static float device_y;
static RECTL rc_old;
static bool clipset = false;
@@ -322,11 +324,11 @@ _pix_y_to_point(PEMF_CALLBACK_DATA d, double px)
static double
pix_to_x_point(PEMF_CALLBACK_DATA d, double px, double py)
{
- double ppx = _pix_x_to_point(d, px);
- double ppy = _pix_y_to_point(d, py);
+ double ppx = px * d->dc[d->level].worldTransform.eM11 + py * d->dc[d->level].worldTransform.eM21 + d->dc[d->level].worldTransform.eDx;
+ double x = _pix_x_to_point(d, ppx);
- double x = ppx * d->dc[d->level].worldTransform.eM11 + ppy * d->dc[d->level].worldTransform.eM21 + d->dc[d->level].worldTransform.eDx;
x *= device_scale;
+ x -= device_x;
return x;
}
@@ -334,11 +336,11 @@ pix_to_x_point(PEMF_CALLBACK_DATA d, double px, double py)
static double
pix_to_y_point(PEMF_CALLBACK_DATA d, double px, double py)
{
- double ppx = _pix_x_to_point(d, px);
- double ppy = _pix_y_to_point(d, py);
+ double ppy = px * d->dc[d->level].worldTransform.eM12 + py * d->dc[d->level].worldTransform.eM22 + d->dc[d->level].worldTransform.eDy;
+ double y = _pix_y_to_point(d, ppy);
- double y = ppx * d->dc[d->level].worldTransform.eM12 + ppy * d->dc[d->level].worldTransform.eM22 + d->dc[d->level].worldTransform.eDy;
y *= device_scale;
+ y -= device_y;
return y;
}
@@ -773,8 +775,10 @@ myEnhMetaFileProc(HDC /*hDC*/, HANDLETABLE * /*lpHTable*/, ENHMETARECORD const *
d->xDPI = 2540;
d->yDPI = 2540;
- d->dc[d->level].PixelsInX = pEmr->rclFrame.right; // - pEmr->rclFrame.left;
- d->dc[d->level].PixelsInY = pEmr->rclFrame.bottom; // - pEmr->rclFrame.top;
+ d->dc[d->level].PixelsInX = pEmr->rclFrame.right - pEmr->rclFrame.left;
+ d->dc[d->level].PixelsInY = pEmr->rclFrame.bottom - pEmr->rclFrame.top;
+ device_x = pEmr->rclFrame.left/100.0*PX_PER_MM;
+ device_y = pEmr->rclFrame.top/100.0*PX_PER_MM;
d->MMX = d->dc[d->level].PixelsInX / 100.0;
d->MMY = d->dc[d->level].PixelsInY / 100.0;
@@ -1603,8 +1607,51 @@ myEnhMetaFileProc(HDC /*hDC*/, HANDLETABLE * /*lpHTable*/, ENHMETARECORD const *
dbg_str << "<!-- EMR_CHORD -->\n";
break;
case EMR_PIE:
+ {
dbg_str << "<!-- EMR_PIE -->\n";
+
+ PEMRPIE pEmr = (PEMRPIE) lpEMFR;
+ RECTL rc = pEmr->rclBox;
+
+ double l = pix_to_x_point( d, rc.left, rc.top );
+ double t = pix_to_y_point( d, rc.left, rc.top );
+ double r = pix_to_x_point( d, rc.right, rc.bottom );
+ double b = pix_to_y_point( d, rc.right, rc.bottom );
+ double x1 = pix_to_x_point( d, pEmr->ptlStart.x, pEmr->ptlStart.y );
+ double y1 = pix_to_y_point( d, pEmr->ptlStart.x, pEmr->ptlStart.y );
+ double x2 = pix_to_x_point( d, pEmr->ptlEnd.x, pEmr->ptlEnd.y );
+ double y2 = pix_to_y_point( d, pEmr->ptlEnd.x, pEmr->ptlEnd.y );
+
+ SVGOStringStream tmp_pie;
+ tmp_pie << "d=\"" <<
+ "\n\tM " << x1 << " " << y1 << " ";
+
+ double angle1 = -atan2(y1 - (t + b) / 2.0, x1 - (l + r) / 2.0);
+ double angle2 = -atan2(y2 - (t + b) / 2.0, x2 - (l + r) / 2.0);
+ double angle = angle2 - angle1;
+ if (angle < 0) angle += 2*M_PI;
+
+ bool large_arc_flag = false;
+ if (angle > M_PI) large_arc_flag = true;
+
+ tmp_pie << "\n\tA " <<
+ fabs(l - r) / 2.0 << " " <<
+ fabs(t - b) / 2.0 << " " <<
+ "0 " << large_arc_flag << " 0 " <<
+ x2 << " " << y2 << " " <<
+ "\n\tL " << (l + r) / 2.0 << " " << (t + b) / 2.0 << " " <<
+ "\n\tz";
+
+ assert_empty_path(d, "EMR_PIE");
+
+ *(d->outsvg) += " <path ";
+ output_style(d, lpEMFR->iType);
+ *(d->outsvg) += "\n\t";
+ *(d->outsvg) += tmp_pie.str().c_str();
+ *(d->outsvg) += " \" /> \n";
+ *(d->path) = "";
break;
+ }
case EMR_SELECTPALETTE:
dbg_str << "<!-- EMR_SELECTPALETTE -->\n";
break;
@@ -1772,7 +1819,7 @@ myEnhMetaFileProc(HDC /*hDC*/, HANDLETABLE * /*lpHTable*/, ENHMETARECORD const *
dbg_str << "<!-- EMR_BITBLT -->\n";
PEMRBITBLT pEmr = (PEMRBITBLT) lpEMFR;
- if (pEmr->dwRop == DPA) {
+ if ((pEmr->dwRop == PATCOPY) || (pEmr->dwRop == DPA)) {
// should be an application of a DIBPATTERNBRUSHPT, use a solid color instead
double l = pix_to_x_point( d, pEmr->xDest, pEmr->yDest);
double t = pix_to_y_point( d, pEmr->xDest, pEmr->yDest);
@@ -1862,6 +1909,10 @@ myEnhMetaFileProc(HDC /*hDC*/, HANDLETABLE * /*lpHTable*/, ENHMETARECORD const *
(gchar *) g_utf16_to_utf8( (gunichar2 *) wide_text, pEmr->emrtext.nChars, NULL, NULL, NULL );
if (ansi_text) {
+ if ((wide_text[0] < 32) && (strlen(ansi_text) == 1)) {
+ g_free(ansi_text); // filter out isolated control characters
+ ansi_text = g_strdup("");
+ }
// gchar *p = ansi_text;
// while (*p) {
// if (*p < 32 || *p >= 127) {
@@ -2417,9 +2468,10 @@ EmfWin32::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri )
DWORD dwNeeded = GetEnhMetaFileDescriptionA( hemf, 0, NULL );
if ( dwNeeded > 0 ) {
d.pDesc = (CHAR *) malloc( dwNeeded + 1 );
+ d.pDesc[dwNeeded] = 0;
if ( GetEnhMetaFileDescription( hemf, dwNeeded, d.pDesc ) == 0 )
lstrcpy( d.pDesc, "" );
- if ( lstrlen( d.pDesc ) > 1 )
+ if ((lstrlen(d.pDesc) > 1) && (lstrlen(d.pDesc) < dwNeeded))
d.pDesc[lstrlen(d.pDesc)] = '#';
}
diff --git a/src/extension/internal/filter/bumps.h b/src/extension/internal/filter/bumps.h
index 8db6c67d2..f0c4c16aa 100644
--- a/src/extension/internal/filter/bumps.h
+++ b/src/extension/internal/filter/bumps.h
@@ -167,9 +167,6 @@ Bump::get_filter_text (Inkscape::Extension::Extension * ext)
std::ostringstream lightOptions;
std::ostringstream lightEnd;
- std::ostringstream lightRed;
- std::ostringstream lightGreen;
- std::ostringstream lightBlue;
std::ostringstream floodRed;
std::ostringstream floodGreen;
std::ostringstream floodBlue;
diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h
index b6b194c8b..09079453f 100644
--- a/src/extension/internal/filter/color.h
+++ b/src/extension/internal/filter/color.h
@@ -3,7 +3,7 @@
/* Change the 'COLOR' above to be your file name */
/*
- * Copyright (C) 2011 Authors:
+ * Copyright (C) 2013 Authors:
* Ivan Louette (filters)
* Nicolas Dufour (UI) <nicoduf@yahoo.fr>
*
@@ -20,7 +20,8 @@
* Invert
* Lighting
* Lightness-contrast
- * Nudge
+ * Nudge RGB
+ * Nudge CMY
* Quadritone
* Solarize
* Tritone
@@ -211,7 +212,7 @@ ChannelPaint::get_filter_text (Inkscape::Extension::Extension * ext)
}
_filter = g_strdup_printf(
- "<filter inkscape:label=\"Channel Painting\" style=\"color-interpolation-filters:sRGB;\" >\n"
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Channel Painting\">\n"
"<feColorMatrix values=\"%s\" type=\"saturate\" result=\"colormatrix1\" />\n"
"<feColorMatrix values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 %s %s %s %s 0 \" in=\"SourceGraphic\" result=\"colormatrix2\" />\n"
"<feFlood flood-color=\"rgb(%s,%s,%s)\" flood-opacity=\"%s\" result=\"flood\" />\n"
@@ -615,9 +616,8 @@ Duochrome::get_filter_text (Inkscape::Extension::Extension * ext)
Filter's parameters:
* Channel (enum, all colors, default Red) -> colormatrix (values)
- * Background blend (enum, all blend modes, default Multiply) -> blend (mode)
+ * Background blend (enum, Normal, Multiply, Screen, default Normal) -> blend (mode)
* Channel to alpha (boolean, default false) -> colormatrix (values)
- * Invert (boolean, default false) -> colormatrix (values)
*/
class ExtractChannel : public Inkscape::Extension::Internal::Filter::Filter {
@@ -637,16 +637,16 @@ public:
"<_item value=\"r\">" N_("Red") "</_item>\n"
"<_item value=\"g\">" N_("Green") "</_item>\n"
"<_item value=\"b\">" N_("Blue") "</_item>\n"
+ "<_item value=\"c\">" N_("Cyan") "</_item>\n"
+ "<_item value=\"m\">" N_("Magenta") "</_item>\n"
+ "<_item value=\"y\">" N_("Yellow") "</_item>\n"
"</param>\n"
"<param name=\"blend\" gui-text=\"" N_("Background blend mode:") "\" type=\"enum\">\n"
"<_item value=\"multiply\">" N_("Multiply") "</_item>\n"
"<_item value=\"normal\">" N_("Normal") "</_item>\n"
"<_item value=\"screen\">" N_("Screen") "</_item>\n"
- "<_item value=\"darken\">" N_("Darken") "</_item>\n"
- "<_item value=\"lighten\">" N_("Lighten") "</_item>\n"
"</param>\n"
"<param name=\"alpha\" gui-text=\"" N_("Channel to alpha") "\" type=\"boolean\">false</param>\n"
- "<param name=\"invert\" gui-text=\"" N_("Inverted") "\" type=\"boolean\">false</param>\n"
"<effect>\n"
"<object-type>all</object-type>\n"
"<effects-menu>\n"
@@ -667,45 +667,45 @@ ExtractChannel::get_filter_text (Inkscape::Extension::Extension * ext)
std::ostringstream blend;
std::ostringstream colors;
- std::ostringstream alpha;
- std::ostringstream invert;
blend << ext->get_param_enum("blend");
const gchar *channel = ext->get_param_enum("source");
if (ext->get_param_bool("alpha")) {
- colors << "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0";
- } else if ((g_ascii_strcasecmp("r", channel) == 0)) {
- colors << "0 0 0 0 1 0 0 0 0 0 0 0 0 0 0";
- } else if ((g_ascii_strcasecmp("g", channel) == 0)) {
- colors << "0 0 0 0 0 0 0 0 0 1 0 0 0 0 0";
- } else {
- colors << "0 0 0 0 0 0 0 0 0 0 0 0 0 0 1";
- }
-
- if (ext->get_param_bool("invert")) {
if ((g_ascii_strcasecmp("r", channel) == 0)) {
- alpha << "-1 0 0 1";
+ colors << "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0";
} else if ((g_ascii_strcasecmp("g", channel) == 0)) {
- alpha << "0 -1 0 1";
+ colors << "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0";
+ } else if ((g_ascii_strcasecmp("b", channel) == 0)) {
+ colors << "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0";
+ } else if ((g_ascii_strcasecmp("c", channel) == 0)) {
+ colors << "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 1 0";
+ } else if ((g_ascii_strcasecmp("m", channel) == 0)) {
+ colors << "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 1 0";
} else {
- alpha << "0 0 -1 1";
+ colors << "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 1 0";
}
} else {
if ((g_ascii_strcasecmp("r", channel) == 0)) {
- alpha << "1 0 0 0";
+ colors << "0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0";
} else if ((g_ascii_strcasecmp("g", channel) == 0)) {
- alpha << "0 1 0 0";
+ colors << "0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0";
+ } else if ((g_ascii_strcasecmp("b", channel) == 0)) {
+ colors << "0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0";
+ } else if ((g_ascii_strcasecmp("c", channel) == 0)) {
+ colors << "0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 -1 0 0 1 0";
+ } else if ((g_ascii_strcasecmp("m", channel) == 0)) {
+ colors << "0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 -1 0 1 0";
} else {
- alpha << "0 0 1 0";
+ colors << "0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 -1 1 0";
}
}
_filter = g_strdup_printf(
"<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Extract Channel\">\n"
- "<feColorMatrix in=\"SourceGraphic\" values=\"%s %s %s 0 \" result=\"colormatrix\" />\n"
+ "<feColorMatrix in=\"SourceGraphic\" values=\"%s 0 \" result=\"colormatrix\" />\n"
"<feBlend in2=\"BackgroundImage\" mode=\"%s\" result=\"blend\" />\n"
- "</filter>\n", colors.str().c_str(), alpha.str().c_str(), invert.str().c_str(), blend.str().c_str() );
+ "</filter>\n", colors.str().c_str(), blend.str().c_str() );
return _filter;
}; /* ExtractChannel filter */
@@ -1157,72 +1157,52 @@ LightnessContrast::get_filter_text (Inkscape::Extension::Extension * ext)
}; /* Lightness-Contrast filter */
/**
- \brief Custom predefined Nudge filter.
+ \brief Custom predefined Nudge RGB filter.
- Nudge separately RGB channels and blend them to different types of backgrounds
+ Nudge RGB channels separately and blend them to different types of backgrounds
Filter's parameters:
Offsets
* Red
- * x (-100.->100., default -7) -> offset1 (dx)
- * y (-100.->100., default 5) -> offset1 (dy)
+ * x (-100.->100., default -6) -> offset1 (dx)
+ * y (-100.->100., default -6) -> offset1 (dy)
* Green
- * x (-100.->100., default 0) -> offset2 (dx)
- * y (-100.->100., default 10) -> offset2 (dy)
+ * x (-100.->100., default 6) -> offset2 (dx)
+ * y (-100.->100., default 7) -> offset2 (dy)
* Blue
- * x (-100.->100., default 3) -> offset3 (dx)
- * y (-100.->100., default -9) -> offset3 (dy)
+ * x (-100.->100., default 1) -> offset3 (dx)
+ * y (-100.->100., default -16) -> offset3 (dy)
Color
- * Background color (guint, default -1)-> flood (flood-color, flood-opacity)
- * Blend type (enum [normal,multiply and screen], default screen) -> blend1,2,3 (mode)
- * Blend source (enum, default color) ->
- * color: blend1 (in="flood")
- * image: blend1 (in="SourceGraphic")
- * background: blend1 (in="BackgroundImage")
- * Composite (enum [in,over], default over) -> composite (operator)
+ * Background color (guint, default 255)-> flood (flood-color, flood-opacity)
*/
-class Nudge : public Inkscape::Extension::Internal::Filter::Filter {
+class NudgeRGB : public Inkscape::Extension::Internal::Filter::Filter {
protected:
virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
public:
- Nudge ( ) : Filter() { };
- virtual ~Nudge ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
+ NudgeRGB ( ) : Filter() { };
+ virtual ~NudgeRGB ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
static void init (void) {
Inkscape::Extension::build_from_mem(
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
- "<name>" N_("Nudge") "</name>\n"
- "<id>org.inkscape.effect.filter.Nudge</id>\n"
+ "<name>" N_("Nudge RGB") "</name>\n"
+ "<id>org.inkscape.effect.filter.NudgeRGB</id>\n"
"<param name=\"tab\" type=\"notebook\">\n"
"<page name=\"offsettab\" _gui-text=\"Offset\">\n"
"<_param name=\"redOffset\" type=\"description\" appearance=\"header\">" N_("Red offset") "</_param>\n"
- "<param name=\"rx\" gui-text=\"" N_("X:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">-7</param>\n"
- "<param name=\"ry\" gui-text=\"" N_("Y:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">5</param>\n"
+ "<param name=\"rx\" gui-text=\"" N_("X:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">-6</param>\n"
+ "<param name=\"ry\" gui-text=\"" N_("Y:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">-6</param>\n"
"<_param name=\"greenOffset\" type=\"description\" appearance=\"header\">" N_("Green offset") "</_param>\n"
- "<param name=\"gx\" gui-text=\"" N_("X:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">0</param>\n"
- "<param name=\"gy\" gui-text=\"" N_("Y:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">10</param>\n"
+ "<param name=\"gx\" gui-text=\"" N_("X:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">6</param>\n"
+ "<param name=\"gy\" gui-text=\"" N_("Y:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">7</param>\n"
"<_param name=\"redOffset\" type=\"description\" appearance=\"header\">" N_("Blue offset") "</_param>\n"
- "<param name=\"bx\" gui-text=\"" N_("X:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">3</param>\n"
- "<param name=\"by\" gui-text=\"" N_("Y:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">-9</param>\n"
+ "<param name=\"bx\" gui-text=\"" N_("X:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">1</param>\n"
+ "<param name=\"by\" gui-text=\"" N_("Y:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">-16</param>\n"
"</page>\n"
"<page name=\"coltab\" _gui-text=\"Color\">\n"
"<param name=\"color\" gui-text=\"" N_("Background color") "\" type=\"color\">255</param>\n"
- "<param name=\"blend\" gui-text=\"" N_("Blend type:") "\" type=\"enum\">\n"
- "<_item value=\"screen\">" N_("Screen") "</_item>\n"
- "<_item value=\"multiply\">" N_("Multiply") "</_item>\n"
- "<_item value=\"normal\">" N_("Normal") "</_item>\n"
- "</param>\n"
- "<param name=\"source\" gui-text=\"" N_("Blend source:") "\" type=\"enum\">\n"
- "<_item value=\"flood\">" N_("Color") "</_item>\n"
- "<_item value=\"SourceGraphic\">" N_("Image") "</_item>\n"
- "<_item value=\"BackgroundImage\">" N_("Background") "</_item>\n"
- "</param>\n"
- "<param name=\"composite\" gui-text=\"" N_("Composite:") "\" type=\"enum\">\n"
- "<_item value=\"over\">" N_("Over") "</_item>\n"
- "<_item value=\"in\">" N_("In") "</_item>\n"
- "</param>\n"
"</page>\n"
"</param>\n"
"<effect>\n"
@@ -1232,14 +1212,14 @@ public:
"<submenu name=\"" N_("Color") "\"/>\n"
"</submenu>\n"
"</effects-menu>\n"
- "<menu-tip>" N_("Nudge separately RGB channels and blend them to different types of backgrounds") "</menu-tip>\n"
+ "<menu-tip>" N_("Nudge RGB channels separately and blend them to different types of backgrounds") "</menu-tip>\n"
"</effect>\n"
- "</inkscape-extension>\n", new Nudge());
+ "</inkscape-extension>\n", new NudgeRGB());
};
};
gchar const *
-Nudge::get_filter_text (Inkscape::Extension::Extension * ext)
+NudgeRGB::get_filter_text (Inkscape::Extension::Extension * ext)
{
if (_filter != NULL) g_free((void *)_filter);
@@ -1250,10 +1230,6 @@ Nudge::get_filter_text (Inkscape::Extension::Extension * ext)
std::ostringstream bx;
std::ostringstream by;
- std::ostringstream blend;
- std::ostringstream source;
- std::ostringstream composite;
-
std::ostringstream a;
std::ostringstream r;
std::ostringstream g;
@@ -1266,10 +1242,6 @@ Nudge::get_filter_text (Inkscape::Extension::Extension * ext)
bx << ext->get_param_float("bx");
by << ext->get_param_float("by");
- blend << ext->get_param_enum("blend");
- source << ext->get_param_enum("source");
- composite << ext->get_param_enum("composite");
-
guint32 color = ext->get_param_color("color");
r << ((color >> 24) & 0xff);
g << ((color >> 16) & 0xff);
@@ -1277,27 +1249,137 @@ Nudge::get_filter_text (Inkscape::Extension::Extension * ext)
a << (color & 0xff) / 255.0F;
_filter = g_strdup_printf(
- "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Nudge\">\n"
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Nudge RGB\">\n"
"<feFlood flood-opacity=\"%s\" flood-color=\"rgb(%s,%s,%s)\" result=\"flood\" />\n"
"<feColorMatrix in=\"SourceGraphic\" values=\"0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 \" result=\"colormatrix1\" />\n"
"<feOffset dy=\"%s\" dx=\"%s\" result=\"offset1\" />\n"
- "<feBlend in2=\"%s\" mode=\"%s\" result=\"blend1\" />\n"
+ "<feBlend in2=\"flood\" mode=\"screen\" result=\"blend1\" />\n"
"<feColorMatrix in=\"SourceGraphic\" values=\"0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 \" result=\"colormatrix2\" />\n"
"<feOffset dy=\"%s\" dx=\"%s\" result=\"offset2\" />\n"
- "<feBlend in2=\"blend1\" mode=\"%s\" result=\"blend2\" />\n"
+ "<feBlend in2=\"blend1\" mode=\"screen\" result=\"blend2\" />\n"
"<feOffset dy=\"%s\" dx=\"%s\" result=\"offset3\" />\n"
"<feColorMatrix in=\"SourceGraphic\" values=\"0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 \" result=\"colormatrix3\" />\n"
- "<feBlend in2=\"offset3\" mode=\"%s\" result=\"blend3\" />\n"
- "<feComposite in2=\"SourceGraphic\" operator=\"%s\" />\n"
+ "<feBlend in2=\"offset3\" mode=\"screen\" result=\"blend3\" />\n"
+ "</filter>\n", a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(),
+ rx.str().c_str(), ry.str().c_str(),
+ gx.str().c_str(), gy.str().c_str(),
+ bx.str().c_str(), by.str().c_str() );
+
+ return _filter;
+
+}; /* Nudge RGB filter */
+
+/**
+ \brief Custom predefined Nudge CMY filter.
+
+ Nudge CMY channels separately and blend them to different types of backgrounds
+
+ Filter's parameters:
+ Offsets
+ * Cyan
+ * x (-100.->100., default -6) -> offset1 (dx)
+ * y (-100.->100., default -6) -> offset1 (dy)
+ * Magenta
+ * x (-100.->100., default 6) -> offset2 (dx)
+ * y (-100.->100., default 7) -> offset2 (dy)
+ * Yellow
+ * x (-100.->100., default 1) -> offset3 (dx)
+ * y (-100.->100., default -16) -> offset3 (dy)
+ Color
+ * Background color (guint, default -1)-> flood (flood-color, flood-opacity)
+*/
+class NudgeCMY : public Inkscape::Extension::Internal::Filter::Filter {
+protected:
+ virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
+
+public:
+ NudgeCMY ( ) : Filter() { };
+ virtual ~NudgeCMY ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
+
+ static void init (void) {
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("Nudge CMY") "</name>\n"
+ "<id>org.inkscape.effect.filter.NudgeCMY</id>\n"
+ "<param name=\"tab\" type=\"notebook\">\n"
+ "<page name=\"offsettab\" _gui-text=\"Offset\">\n"
+ "<_param name=\"cyanOffset\" type=\"description\" appearance=\"header\">" N_("Cyan offset") "</_param>\n"
+ "<param name=\"cx\" gui-text=\"" N_("X:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">-6</param>\n"
+ "<param name=\"cy\" gui-text=\"" N_("Y:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">-6</param>\n"
+ "<_param name=\"magentaOffset\" type=\"description\" appearance=\"header\">" N_("Magenta offset") "</_param>\n"
+ "<param name=\"mx\" gui-text=\"" N_("X:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">6</param>\n"
+ "<param name=\"my\" gui-text=\"" N_("Y:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">7</param>\n"
+ "<_param name=\"yellowOffset\" type=\"description\" appearance=\"header\">" N_("Yellow offset") "</_param>\n"
+ "<param name=\"yx\" gui-text=\"" N_("X:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">1</param>\n"
+ "<param name=\"yy\" gui-text=\"" N_("Y:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"-100.\" max=\"100.\">-16</param>\n"
+ "</page>\n"
+ "<page name=\"coltab\" _gui-text=\"Color\">\n"
+ "<param name=\"color\" gui-text=\"" N_("Background color") "\" type=\"color\">-1</param>\n"
+ "</page>\n"
+ "</param>\n"
+ "<effect>\n"
+ "<object-type>all</object-type>\n"
+ "<effects-menu>\n"
+ "<submenu name=\"" N_("Filters") "\">\n"
+ "<submenu name=\"" N_("Color") "\"/>\n"
+ "</submenu>\n"
+ "</effects-menu>\n"
+ "<menu-tip>" N_("Nudge CMY channels separately and blend them to different types of backgrounds") "</menu-tip>\n"
+ "</effect>\n"
+ "</inkscape-extension>\n", new NudgeCMY());
+ };
+};
+
+gchar const *
+NudgeCMY::get_filter_text (Inkscape::Extension::Extension * ext)
+{
+ if (_filter != NULL) g_free((void *)_filter);
+
+ std::ostringstream cx;
+ std::ostringstream cy;
+ std::ostringstream mx;
+ std::ostringstream my;
+ std::ostringstream yx;
+ std::ostringstream yy;
+
+ std::ostringstream a;
+ std::ostringstream r;
+ std::ostringstream g;
+ std::ostringstream b;
+
+ cx << ext->get_param_float("cx");
+ cy << ext->get_param_float("cy");
+ mx << ext->get_param_float("mx");
+ my << ext->get_param_float("my");
+ yx << ext->get_param_float("yx");
+ yy << ext->get_param_float("yy");
+
+ guint32 color = ext->get_param_color("color");
+ r << ((color >> 24) & 0xff);
+ g << ((color >> 16) & 0xff);
+ b << ((color >> 8) & 0xff);
+ a << (color & 0xff) / 255.0F;
+
+ _filter = g_strdup_printf(
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Nudge CMY\">\n"
+ "<feFlood flood-opacity=\"%s\" flood-color=\"rgb(%s,%s,%s)\" result=\"flood\" />\n"
+ "<feColorMatrix in=\"SourceGraphic\" values=\"0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 -1 0 0 1 0 \" result=\"colormatrix1\" />\n"
+ "<feOffset dy=\"%s\" dx=\"%s\" result=\"offset1\" />\n"
+ "<feBlend in2=\"flood\" mode=\"multiply\" result=\"blend1\" />\n"
+ "<feColorMatrix in=\"SourceGraphic\" values=\"0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 -1 0 1 0 \" result=\"colormatrix2\" />\n"
+ "<feOffset dy=\"%s\" dx=\"%s\" result=\"offset2\" />\n"
+ "<feBlend in2=\"blend1\" mode=\"multiply\" result=\"blend2\" />\n"
+ "<feOffset dy=\"%s\" dx=\"%s\" result=\"offset3\" />\n"
+ "<feColorMatrix in=\"SourceGraphic\" values=\"0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 -1 1 0 \" result=\"colormatrix3\" />\n"
+ "<feBlend in2=\"offset3\" mode=\"multiply\" result=\"blend3\" />\n"
"</filter>\n", a.str().c_str(), r.str().c_str(), g.str().c_str(), b.str().c_str(),
- rx.str().c_str(), ry.str().c_str(), source.str().c_str(), blend.str().c_str(),
- gx.str().c_str(), gy.str().c_str(), blend.str().c_str(),
- bx.str().c_str(), by.str().c_str(), blend.str().c_str(),
- composite.str().c_str() );
+ cx.str().c_str(), cy.str().c_str(),
+ mx.str().c_str(), my.str().c_str(),
+ yx.str().c_str(), yy.str().c_str() );
return _filter;
-}; /* Nudge filter */
+}; /* Nudge CMY filter */
/**
\brief Custom predefined Quadritone filter.
diff --git a/src/extension/internal/filter/filter-all.cpp b/src/extension/internal/filter/filter-all.cpp
index b5d47ae45..0273d1669 100755
--- a/src/extension/internal/filter/filter-all.cpp
+++ b/src/extension/internal/filter/filter-all.cpp
@@ -64,7 +64,8 @@ Filter::filters_all (void )
Invert::init();
Lighting::init();
LightnessContrast::init();
- Nudge::init();
+ NudgeRGB::init();
+ NudgeCMY::init();
Quadritone::init();
Solarize::init();
Tritone::init();
diff --git a/src/extension/internal/filter/filter-file.cpp b/src/extension/internal/filter/filter-file.cpp
index d129f590c..d569c6438 100644
--- a/src/extension/internal/filter/filter-file.cpp
+++ b/src/extension/internal/filter/filter-file.cpp
@@ -20,6 +20,7 @@
/* System includes */
#include <glibmm/i18n.h>
+#include <glibmm/fileutils.h>
namespace Inkscape {
namespace Extension {
diff --git a/src/extension/internal/filter/filter.cpp b/src/extension/internal/filter/filter.cpp
index af597685b..a2c565699 100644
--- a/src/extension/internal/filter/filter.cpp
+++ b/src/extension/internal/filter/filter.cpp
@@ -144,11 +144,11 @@ void Filter::effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::Vie
if (filter == NULL) {
Inkscape::XML::Node * newfilterroot = xmldoc->createElement("svg:filter");
+ merge_filters(newfilterroot, filterdoc->root(), xmldoc);
defsrepr->appendChild(newfilterroot);
Glib::ustring url = "url(#"; url += newfilterroot->attribute("id"); url += ")";
- merge_filters(newfilterroot, filterdoc->root(), xmldoc);
Inkscape::GC::release(newfilterroot);
@@ -172,7 +172,7 @@ void Filter::effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::Vie
// no filter
if (filternode == NULL) {
- g_warning("no assoziating filter found!");
+ g_warning("no assigned filter found!");
continue;
}
diff --git a/src/extension/internal/filter/filter.h b/src/extension/internal/filter/filter.h
index 1e8a3be0f..9aaa84aec 100644
--- a/src/extension/internal/filter/filter.h
+++ b/src/extension/internal/filter/filter.h
@@ -19,7 +19,7 @@
namespace Inkscape {
namespace XML {
- class Document;
+ struct Document;
}
namespace Extension {
diff --git a/src/extension/internal/filter/paint.h b/src/extension/internal/filter/paint.h
index debdd7d79..4052f4391 100644
--- a/src/extension/internal/filter/paint.h
+++ b/src/extension/internal/filter/paint.h
@@ -3,7 +3,7 @@
/* Change the 'PAINT' above to be your file name */
/*
- * Copyright (C) 2011 Authors:
+ * Copyright (C) 2012 Authors:
* Ivan Louette (filters)
* Nicolas Dufour (UI) <nicoduf@yahoo.fr>
*
@@ -88,7 +88,7 @@ public:
"<param name=\"noise\" gui-text=\"" N_("Noise reduction:") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"1000\">10</param>\n"
"<param name=\"smooth\" gui-text=\"" N_("Smoothness:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"10.00\">1</param>\n"
"</page>\n"
- "<page name=\"graintab\" _gui-text=\""N_("Grain") "\">\n"
+ "<page name=\"graintab\" _gui-text=\"" N_("Grain") "\">\n"
"<param name=\"grain\" gui-text=\"" N_("Grain mode") "\" type=\"boolean\" >true</param>\n"
"<param name=\"grainxf\" gui-text=\"" N_("Horizontal frequency:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"1000\">1000</param>\n"
"<param name=\"grainyf\" gui-text=\"" N_("Vertical frequency:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"1000\">1000</param>\n"
@@ -133,7 +133,6 @@ Chromolitho::get_filter_text (Inkscape::Extension::Extension * ext)
std::ostringstream noise;
std::ostringstream dblend;
std::ostringstream smooth;
- std::ostringstream grain;
std::ostringstream grainxf;
std::ostringstream grainyf;
std::ostringstream grainc;
@@ -563,13 +562,13 @@ Electrize::get_filter_text (Inkscape::Extension::Extension * ext)
Filter's parameters:
* Lines type (enum, default smooth) ->
- smooth = component1 (type="table"), component2 (type="table"), composite1 (in2="blur2")
- hard = component1 (type="discrete"), component2 (type="discrete"), composite1 (in2="component1")
- * Simplify (0.01->20., default 1.5) -> blur1 (stdDeviation)
- * Line width (0.01->20., default 1.5) -> blur2 (stdDeviation)
- * Lightness (0.->10., default 0.5) -> composite1 (k3)
+ smooth = component2 (type="table"), composite1 (in2="blur2")
+ hard = component2 (type="discrete"), composite1 (in2="component1")
+ * Simplify (0.01->20., default 3) -> blur1 (stdDeviation)
+ * Line width (0.01->20., default 3) -> blur2 (stdDeviation)
+ * Lightness (0.->10., default 1) -> composite1 (k2)
* Blend (enum [normal, multiply, screen], default normal) -> blend (mode)
- * Dark mode (boolean, default false) -> composite1 (true: in2="component2")
+ * Dark mode (boolean, default false) -> composite2 (true: in2="component2")
*/
class NeonDraw : public Inkscape::Extension::Internal::Filter::Filter {
protected:
@@ -588,15 +587,14 @@ public:
"<_item value=\"table\">" N_("Smoothed") "</_item>\n"
"<_item value=\"discrete\">" N_("Contrasted") "</_item>\n"
"</param>\n"
- "<param name=\"simply\" gui-text=\"" N_("Simplify:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">1.5</param>\n"
- "<param name=\"width\" gui-text=\"" N_("Line width:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">1.5</param>\n"
- "<param name=\"lightness\" gui-text=\"" N_("Lightness:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"10.00\">0.5</param>\n"
+ "<param name=\"simply\" gui-text=\"" N_("Simplify:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">3</param>\n"
+ "<param name=\"width\" gui-text=\"" N_("Line width:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">3</param>\n"
+ "<param name=\"lightness\" gui-text=\"" N_("Lightness:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"10.00\">1</param>\n"
"<param name=\"blend\" gui-text=\"" N_("Blend mode:") "\" type=\"enum\">\n"
"<_item value=\"normal\">Normal</_item>\n"
"<_item value=\"multiply\">Multiply</_item>\n"
"<_item value=\"screen\">Screen</_item>\n"
"</param>\n"
- "<param name=\"dark\" gui-text=\"" N_("Dark mode") "\" type=\"boolean\" >false</param>\n"
"<effect>\n"
"<object-type>all</object-type>\n"
"<effects-menu>\n"
@@ -620,7 +618,6 @@ NeonDraw::get_filter_text (Inkscape::Extension::Extension * ext)
std::ostringstream width;
std::ostringstream lightness;
std::ostringstream type;
- std::ostringstream dark;
type << ext->get_param_enum("type");
blend << ext->get_param_enum("blend");
@@ -628,33 +625,26 @@ NeonDraw::get_filter_text (Inkscape::Extension::Extension * ext)
width << ext->get_param_float("width");
lightness << ext->get_param_float("lightness");
- const gchar *typestr = ext->get_param_enum("type");
- if (ext->get_param_bool("dark")) {
- dark << "component2";
- } else if ((g_ascii_strcasecmp("table", typestr) == 0)) {
- dark << "blur2";
- } else {
- dark << "component1";
- }
-
_filter = g_strdup_printf(
"<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Neon Draw\">\n"
"<feBlend mode=\"%s\" result=\"blend\" />\n"
"<feGaussianBlur in=\"blend\" stdDeviation=\"%s\" result=\"blur1\" />\n"
+ "<feColorMatrix values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 50 0\" result=\"color1\" />\n"
"<feComponentTransfer result=\"component1\">\n"
- "<feFuncR type=\"discrete\" tableValues=\"0 0.3 0.6 1 1\" />\n"
- "<feFuncG type=\"discrete\" tableValues=\"0 0.3 0.6 1 1\" />\n"
- "<feFuncB type=\"discrete\" tableValues=\"0 0.3 0.6 1 1\" />\n"
+ "<feFuncR type=\"discrete\" tableValues=\"0 0.3 0.3 0.3 0.3 0.6 0.6 0.6 0.6 1 1\" />\n"
+ "<feFuncG type=\"discrete\" tableValues=\"0 0.3 0.3 0.3 0.3 0.6 0.6 0.6 0.6 1 1\" />\n"
+ "<feFuncB type=\"discrete\" tableValues=\"0 0.3 0.3 0.3 0.3 0.6 0.6 0.6 0.6 1 1\" />\n"
"</feComponentTransfer>\n"
"<feGaussianBlur in=\"component1\" stdDeviation=\"%s\" result=\"blur2\" />\n"
- "<feComponentTransfer in=\"blur2\" result=\"component2\">\n"
- "<feFuncR type=\"%s\" tableValues=\"0 1 0 1 0 1 0 1\" />\n"
- "<feFuncG type=\"%s\" tableValues=\"0 1 0 1 0 1 0 1\" />\n"
- "<feFuncB type=\"%s\" tableValues=\"0 1 0 1 0 1 0 1\" />\n"
+ "<feColorMatrix values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 50 0\" result=\"color2\" />\n"
+ "<feComponentTransfer in=\"color2\" result=\"component2\">\n"
+ "<feFuncR type=\"%s\" tableValues=\"0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1\" />\n"
+ "<feFuncG type=\"%s\" tableValues=\"0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1\" />\n"
+ "<feFuncB type=\"%s\" tableValues=\"0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1\" />\n"
"</feComponentTransfer>\n"
- "<feComposite in=\"component2\" in2=\"%s\" k3=\"%s\" operator=\"arithmetic\" k2=\"1\" result=\"composite1\" />\n"
+ "<feComposite in=\"component2\" in2=\"blur2\" k3=\"%s\" operator=\"arithmetic\" k2=\"1\" result=\"composite1\" />\n"
"<feComposite in=\"composite1\" in2=\"SourceGraphic\" operator=\"in\" result=\"composite2\" />\n"
- "</filter>\n", blend.str().c_str(), simply.str().c_str(), width.str().c_str(), type.str().c_str(), type.str().c_str(), type.str().c_str(), dark.str().c_str(), lightness.str().c_str());
+ "</filter>\n", blend.str().c_str(), simply.str().c_str(), width.str().c_str(), type.str().c_str(), type.str().c_str(), type.str().c_str(), lightness.str().c_str());
return _filter;
}; /* NeonDraw filter */
diff --git a/src/extension/internal/filter/shadows.h b/src/extension/internal/filter/shadows.h
index d76358a96..415776607 100644
--- a/src/extension/internal/filter/shadows.h
+++ b/src/extension/internal/filter/shadows.h
@@ -3,7 +3,7 @@
/* Change the 'SHADOWS' above to be your file name */
/*
- * Copyright (C) 2011 Authors:
+ * Copyright (C) 2013 Authors:
* Ivan Louette (filters)
* Nicolas Dufour (UI) <nicoduf@yahoo.fr>
*
@@ -39,6 +39,7 @@ namespace Filter {
inner = composite1 (operator="out"), composite2 (operator="atop", in1="offset", in2="SourceGraphic")
innercut = composite1 (operator="in"), composite2 (operator="out", in1="offset", in2="SourceGraphic")
outercut = composite1 (operator="out"), composite2 (operator="in", in1="SourceGraphic", in2="offset")
+ shadow = composite1 (operator="out"), composite2 (operator="atop", in1="offset", in2="offset")
* Color (guint, default 0,0,0,127) -> flood (flood-opacity, flood-color)
* Use object's color (boolean, default false) -> composite1 (in1, in2)
*/
@@ -60,11 +61,12 @@ public:
"<param name=\"blur\" gui-text=\"" N_("Blur radius (px):") "\" type=\"float\" appearance=\"full\" min=\"0.0\" max=\"200.0\">3.0</param>\n"
"<param name=\"xoffset\" gui-text=\"" N_("Horizontal offset (px):") "\" type=\"float\" appearance=\"full\" min=\"-50.0\" max=\"50.0\">6.0</param>\n"
"<param name=\"yoffset\" gui-text=\"" N_("Vertical offset (px):") "\" type=\"float\" appearance=\"full\" min=\"-50.0\" max=\"50.0\">6.0</param>\n"
- "<param name=\"type\" gui-text=\"" N_("Blur type:") "\" type=\"enum\" >\n"
+ "<param name=\"type\" gui-text=\"" N_("Shadow type:") "\" type=\"enum\" >\n"
"<_item value=\"outer\">" N_("Outer") "</_item>\n"
"<_item value=\"inner\">" N_("Inner") "</_item>\n"
"<_item value=\"outercut\">" N_("Outer cutout") "</_item>\n"
"<_item value=\"innercut\">" N_("Inner cutout") "</_item>\n"
+ "<_item value=\"shadow\">" N_("Shadow only") "</_item>\n"
"</param>\n"
"</page>\n"
"<page name=\"coltab\" _gui-text=\"" N_("Blur color") "\">\n"
@@ -151,11 +153,16 @@ ColorizableDropShadow::get_filter_text (Inkscape::Extension::Extension * ext)
comp2op << "out";
comp2in1 << "offset";
comp2in2 << "SourceGraphic";
- } else { //innercut
+ } else if ((g_ascii_strcasecmp("innercut", type) == 0)){
comp1op << "out";
comp1in1 << "flood";
comp1in2 << "SourceGraphic";
comp2op << "in";
+ } else { //shadow
+ comp1op << "in";
+ comp2op << "atop";
+ comp2in1 << "offset";
+ comp2in2 << "offset";
}
_filter = g_strdup_printf(
diff --git a/src/extension/internal/gdkpixbuf-input.cpp b/src/extension/internal/gdkpixbuf-input.cpp
index 30c4d4338..abfad518f 100644
--- a/src/extension/internal/gdkpixbuf-input.cpp
+++ b/src/extension/internal/gdkpixbuf-input.cpp
@@ -80,6 +80,7 @@ GdkpixbufInput::open(Inkscape::Extension::Input *mod, char const *uri)
double width = gdk_pixbuf_get_width(pb);
double height = gdk_pixbuf_get_height(pb);
double defaultxdpi = prefs->getDouble("/dialogs/import/defaultxdpi/value", PX_PER_IN);
+ bool forcexdpi = prefs->getBool("/dialogs/import/forcexdpi");
ImageResolution *ir = 0;
double xscale = 1;
double yscale = 1;
@@ -91,10 +92,10 @@ GdkpixbufInput::open(Inkscape::Extension::Input *mod, char const *uri)
xscale = 72.0 / (double)dpi;
}
} else {
- if (!ir)
+ if (!ir && !forcexdpi)
ir = new ImageResolution(uri);
- if (ir->ok())
- xscale = 90.0 / ir->x();
+ if (ir && ir->ok())
+ xscale = 900.0 / floor(10.*ir->x() + .5); // round-off to 0.1 dpi
else
xscale = 90.0 / defaultxdpi;
}
@@ -107,10 +108,10 @@ GdkpixbufInput::open(Inkscape::Extension::Input *mod, char const *uri)
yscale = 72.0 / (double)dpi;
}
} else {
- if (!ir)
+ if (!ir && !forcexdpi)
ir = new ImageResolution(uri);
- if (ir->ok())
- yscale = 90.0 / ir->y();
+ if (ir && ir->ok())
+ yscale = 900.0 / floor(10.*ir->y() + .5); // round-off to 0.1 dpi
else
yscale = 90.0 / defaultxdpi;
}
diff --git a/src/extension/internal/image-resolution.cpp b/src/extension/internal/image-resolution.cpp
index 53fcc0fbf..51a3fe9c1 100644
--- a/src/extension/internal/image-resolution.cpp
+++ b/src/extension/internal/image-resolution.cpp
@@ -27,27 +27,30 @@ namespace Extension {
namespace Internal {
ImageResolution::ImageResolution(char const *fn) {
- ok_ = false;
-
- readpng(fn);
- if (!ok_)
- readexif(fn);
- if (!ok_)
- readexiv(fn);
- if (!ok_)
- readjfif(fn);
+ ok_ = false;
+
+ readpng(fn);
+ if (!ok_) {
+ readexiv(fn);
+ }
+ if (!ok_) {
+ readjfif(fn);
+ }
+ if (!ok_) {
+ readexif(fn);
+ }
}
bool ImageResolution::ok() const {
- return ok_;
+ return ok_;
}
double ImageResolution::x() const {
- return x_;
+ return x_;
}
double ImageResolution::y() const {
- return y_;
+ return y_;
}
@@ -57,60 +60,62 @@ double ImageResolution::y() const {
#include <png.h>
static bool haspngheader(FILE *fp) {
- unsigned char header[8];
- if (fread(header, 1, 8, fp)!=8)
- return false;
+ unsigned char header[8];
+ if ( fread(header, 1, 8, fp) != 8 ) {
+ return false;
+ }
- fseek(fp, 0, SEEK_SET);
-
- if (png_sig_cmp(header, 0, 8))
- return false;
+ fseek(fp, 0, SEEK_SET);
+
+ if (png_sig_cmp(header, 0, 8)) {
+ return false;
+ }
- return true;
+ return true;
}
// Implementation using libpng
void ImageResolution::readpng(char const *fn) {
- FILE *fp = fopen(fn, "rb");
- if (!fp)
- return;
+ FILE *fp = fopen(fn, "rb");
+ if (!fp)
+ return;
- if (!haspngheader(fp)) {
- fclose(fp);
- return;
- }
+ if (!haspngheader(fp)) {
+ fclose(fp);
+ return;
+ }
- png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0);
- if (!png_ptr)
- return;
-
- png_infop info_ptr = png_create_info_struct(png_ptr);
- if (!png_ptr) {
- png_destroy_read_struct(&png_ptr, 0, 0);
- return;
- }
-
- if (setjmp(png_jmpbuf(png_ptr))) {
- png_destroy_read_struct(&png_ptr, &info_ptr, 0);
- fclose(fp);
- return;
- }
+ png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0);
+ if (!png_ptr)
+ return;
+
+ png_infop info_ptr = png_create_info_struct(png_ptr);
+ if (!info_ptr) {
+ png_destroy_read_struct(&png_ptr, 0, 0);
+ return;
+ }
+
+ if (setjmp(png_jmpbuf(png_ptr))) {
+ png_destroy_read_struct(&png_ptr, &info_ptr, 0);
+ fclose(fp);
+ return;
+ }
- png_init_io(png_ptr, fp);
- png_read_info(png_ptr, info_ptr);
+ png_init_io(png_ptr, fp);
+ png_read_info(png_ptr, info_ptr);
- png_uint_32 res_x, res_y;
- int unit_type;
- png_get_pHYs(png_ptr, info_ptr, &res_x, &res_y, &unit_type);
+ png_uint_32 res_x, res_y;
+ int unit_type;
+ png_get_pHYs(png_ptr, info_ptr, &res_x, &res_y, &unit_type);
- png_destroy_read_struct(&png_ptr, &info_ptr, 0);
- fclose(fp);
+ png_destroy_read_struct(&png_ptr, &info_ptr, 0);
+ fclose(fp);
- if (unit_type == PNG_RESOLUTION_METER) {
- ok_ = true;
- x_ = res_x * 2.54/100;
- y_ = res_y * 2.54/100;
- }
+ if (unit_type == PNG_RESOLUTION_METER) {
+ ok_ = true;
+ x_ = res_x * 2.54 / 100;
+ y_ = res_y * 2.54 / 100;
+ }
}
#else
@@ -126,63 +131,71 @@ void ImageResolution::readpng(char const *) {
#include <libexif/exif-data.h>
static double exifDouble(ExifEntry *entry, ExifByteOrder byte_order) {
- switch (entry->format) {
- case EXIF_FORMAT_BYTE:
- return double(entry->data[0]);
- case EXIF_FORMAT_SHORT:
- return double(exif_get_short(entry->data, byte_order));
- case EXIF_FORMAT_LONG:
- return double(exif_get_long(entry->data, byte_order));
- case EXIF_FORMAT_RATIONAL: {
- ExifRational r = exif_get_rational(entry->data, byte_order);
- return double(r.numerator)/double(r.denominator);
- }
- case EXIF_FORMAT_SBYTE:
- return double(*(signed char *)entry->data);
- case EXIF_FORMAT_SSHORT:
- return double(exif_get_sshort(entry->data, byte_order));
- case EXIF_FORMAT_SLONG:
- return double(exif_get_slong(entry->data, byte_order));
- case EXIF_FORMAT_SRATIONAL: {
- ExifSRational r = exif_get_srational(entry->data, byte_order);
- return double(r.numerator)/double(r.denominator);
- }
- case EXIF_FORMAT_FLOAT:
- return double(((float *)entry->data)[0]);
- case EXIF_FORMAT_DOUBLE:
- return ((double *)entry->data)[0];
- default:
- return nan(0);
- }
+ switch (entry->format) {
+ case EXIF_FORMAT_BYTE: {
+ return double(entry->data[0]);
+ }
+ case EXIF_FORMAT_SHORT: {
+ return double(exif_get_short(entry->data, byte_order));
+ }
+ case EXIF_FORMAT_LONG: {
+ return double(exif_get_long(entry->data, byte_order));
+ }
+ case EXIF_FORMAT_RATIONAL: {
+ ExifRational r = exif_get_rational(entry->data, byte_order);
+ return double(r.numerator) / double(r.denominator);
+ }
+ case EXIF_FORMAT_SBYTE: {
+ return double(*(signed char *)entry->data);
+ }
+ case EXIF_FORMAT_SSHORT: {
+ return double(exif_get_sshort(entry->data, byte_order));
+ }
+ case EXIF_FORMAT_SLONG: {
+ return double(exif_get_slong(entry->data, byte_order));
+ }
+ case EXIF_FORMAT_SRATIONAL: {
+ ExifSRational r = exif_get_srational(entry->data, byte_order);
+ return double(r.numerator) / double(r.denominator);
+ }
+ case EXIF_FORMAT_FLOAT: {
+ return double((reinterpret_cast<float *>(entry->data))[0]);
+ }
+ case EXIF_FORMAT_DOUBLE: {
+ return (reinterpret_cast<double *>(entry->data))[0];
+ }
+ default: {
+ return nan(0);
+ }
+ }
}
// Implementation using libexif
void ImageResolution::readexif(char const *fn) {
- ExifData *ed;
- ed = exif_data_new_from_file(fn);
- if (!ed)
- return;
- ExifByteOrder byte_order = exif_data_get_byte_order(ed);
-
- ExifEntry *xres = exif_content_get_entry(ed->ifd[EXIF_IFD_0],
- EXIF_TAG_X_RESOLUTION);
- ExifEntry *yres = exif_content_get_entry(ed->ifd[EXIF_IFD_0],
- EXIF_TAG_Y_RESOLUTION);
- ExifEntry *unit = exif_content_get_entry(ed->ifd[EXIF_IFD_0],
- EXIF_TAG_RESOLUTION_UNIT);
- if (xres && yres) {
- x_ = exifDouble(xres, byte_order);
- y_ = exifDouble(yres, byte_order);
- if (unit) {
- double u = exifDouble(unit, byte_order);
- if (u==3) {
- x_ *= 2.54;
- y_ *= 2.54;
- }
+ ExifData *ed;
+ ed = exif_data_new_from_file(fn);
+ if (!ed)
+ return;
+
+ ExifByteOrder byte_order = exif_data_get_byte_order(ed);
+
+ ExifEntry *xres = exif_content_get_entry(ed->ifd[EXIF_IFD_0], EXIF_TAG_X_RESOLUTION);
+ ExifEntry *yres = exif_content_get_entry(ed->ifd[EXIF_IFD_0], EXIF_TAG_Y_RESOLUTION);
+ ExifEntry *unit = exif_content_get_entry(ed->ifd[EXIF_IFD_0], EXIF_TAG_RESOLUTION_UNIT);
+
+ if ( xres && yres ) {
+ x_ = exifDouble(xres, byte_order);
+ y_ = exifDouble(yres, byte_order);
+ if (unit) {
+ double u = exifDouble(unit, byte_order);
+ if ( u == 3 ) {
+ x_ *= 2.54;
+ y_ *= 2.54;
+ }
+ }
+ ok_ = true;
}
- ok_ = true;
- }
- exif_data_free(ed);
+ exif_data_free(ed);
}
#else
@@ -196,43 +209,43 @@ void ImageResolution::readexif(char const *) {
#if IR_TRY_EXIV
void ImageResolution::readexiv(char const *fn) {
- Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(fn);
- if (!image.get())
- return;
-
- image->readMetadata();
- Exiv2::ExifData &exifData = image->exifData();
- if (exifData.empty())
- return;
-
- Exiv2::ExifData::const_iterator end = exifData.end();
- bool havex = false;
- bool havey = false;
- bool haveunit = false;
- int unit;
- for (Exiv2::ExifData::const_iterator i = exifData.begin(); i != end; ++i) {
- if (ok_)
- break;
- if (i->tag()==0x011a) {
- // X Resolution
- x_ = i->toFloat();
- havex = true;
- } else if (i->tag()==0x011b) {
- // Y Resolution
- y_ = i->toFloat();
- havey = true;
- } else if (i->tag()==0x0128) {
- unit = i->toLong();
+ Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(fn);
+ if (!image.get())
+ return;
+
+ image->readMetadata();
+ Exiv2::ExifData &exifData = image->exifData();
+ if (exifData.empty())
+ return;
+
+ Exiv2::ExifData::const_iterator end = exifData.end();
+ bool havex = false;
+ bool havey = false;
+ bool haveunit = false;
+ int unit;
+ for (Exiv2::ExifData::const_iterator i = exifData.begin(); i != end; ++i) {
+ if (ok_)
+ break;
+ if ( i->tag() == 0x011a ) {
+ // X Resolution
+ x_ = i->toFloat();
+ havex = true;
+ } else if ( i->tag() == 0x011b ) {
+ // Y Resolution
+ y_ = i->toFloat();
+ havey = true;
+ } else if ( i->tag() == 0x0128 ) {
+ unit = i->toLong();
+ }
+ ok_ = havex && havey && haveunit;
}
- ok_ = havex && havey && haveunit;
- }
- if (haveunit) {
- if (unit==3) {
- x_ *= 2.54;
- y_ *= 2.54;
+ if (haveunit) {
+ if ( unit == 3 ) {
+ x_ *= 2.54;
+ y_ *= 2.54;
+ }
}
- }
- ok_ = havex && havey;
+ ok_ = havex && havey;
}
#else
@@ -249,7 +262,7 @@ void ImageResolution::readexiv(char const *) {
#include <setjmp.h>
static void irjfif_error_exit(j_common_ptr cinfo) {
- longjmp(*(jmp_buf*)cinfo->client_data, 1);
+ longjmp(*(jmp_buf*)cinfo->client_data, 1);
}
static void irjfif_emit_message(j_common_ptr, int) {
@@ -265,44 +278,46 @@ static void irjfif_reset(j_common_ptr) {
}
void ImageResolution::readjfif(char const *fn) {
- FILE *ifd = fopen(fn, "rb");
- if (!ifd)
- return;
+ FILE *ifd = fopen(fn, "rb");
+ if (!ifd) {
+ return;
+ }
- struct jpeg_decompress_struct cinfo;
- jmp_buf jbuf;
- struct jpeg_error_mgr jerr;
- bool constr = false;
+ struct jpeg_decompress_struct cinfo;
+ jmp_buf jbuf;
+ struct jpeg_error_mgr jerr;
- if (setjmp(jbuf)) {
+ if (setjmp(jbuf)) {
+ fclose(ifd);
+ jpeg_destroy_decompress(&cinfo);
+ return;
+ }
+
+ cinfo.err = jpeg_std_error(&jerr);
+ jpeg_create_decompress(&cinfo);
+ jerr.error_exit = &irjfif_error_exit;
+ jerr.emit_message = &irjfif_emit_message;
+ jerr.output_message = &irjfif_output_message;
+ jerr.format_message = &irjfif_format_message;
+ jerr.reset_error_mgr = &irjfif_reset;
+ cinfo.client_data = (void*)&jbuf;
+
+ jpeg_stdio_src(&cinfo, ifd);
+ jpeg_read_header(&cinfo, TRUE);
+
+ if (cinfo.saw_JFIF_marker) { // JFIF APP0 marker was seen
+ if ( cinfo.density_unit == 1 ) { // dots/inch
+ x_ = cinfo.X_density;
+ y_ = cinfo.Y_density;
+ ok_ = true;
+ } else if ( cinfo.density_unit == 2 ) { // dots/cm
+ x_ = cinfo.X_density * 2.54;
+ y_ = cinfo.Y_density * 2.54;
+ ok_ = true;
+ }
+ }
+ jpeg_destroy_decompress(&cinfo);
fclose(ifd);
- if (constr)
- jpeg_destroy_decompress(&cinfo);
- return;
- }
-
- cinfo.err = jpeg_std_error(&jerr);
- jpeg_create_decompress(&cinfo);
- jerr.error_exit = &irjfif_error_exit;
- jerr.emit_message = &irjfif_emit_message;
- jerr.output_message = &irjfif_output_message;
- jerr.format_message = &irjfif_format_message;
- jerr.reset_error_mgr = &irjfif_reset;
- cinfo.client_data = (void*)&jbuf;
- constr = true;
-
- jpeg_stdio_src(&cinfo, ifd);
- jpeg_read_header(&cinfo, TRUE);
-
- if (cinfo.density_unit==1) {
- x_ = cinfo.X_density;
- y_ = cinfo.Y_density;
- ok_ = true;
- }
-
- constr = false;
- jpeg_destroy_decompress(&cinfo);
- fclose(ifd);
}
#else
@@ -312,7 +327,7 @@ void ImageResolution::readjfif(char const *) {
}
#endif
-
+
}
}
}
diff --git a/src/extension/internal/javafx-out.cpp b/src/extension/internal/javafx-out.cpp
index 67c0fae66..035a6f0aa 100644
--- a/src/extension/internal/javafx-out.cpp
+++ b/src/extension/internal/javafx-out.cpp
@@ -20,6 +20,8 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
+
+#include <glibmm/miscutils.h>
#include "javafx-out.h"
#include <inkscape.h>
#include <inkscape-version.h>
diff --git a/src/extension/internal/latex-text-renderer.cpp b/src/extension/internal/latex-text-renderer.cpp
index ebd73a033..ecc201733 100644
--- a/src/extension/internal/latex-text-renderer.cpp
+++ b/src/extension/internal/latex-text-renderer.cpp
@@ -56,7 +56,7 @@ namespace Internal {
*/
bool
latex_render_document_text_to_file( SPDocument *doc, gchar const *filename,
- const gchar * const exportId, bool exportDrawing, bool exportCanvas,
+ const gchar * const exportId, bool exportDrawing, bool exportCanvas, float bleedmargin_px,
bool pdflatex)
{
doc->ensureUpToDate();
@@ -84,7 +84,7 @@ latex_render_document_text_to_file( SPDocument *doc, gchar const *filename,
bool ret = renderer->setTargetFile(filename);
if (ret) {
/* Render document */
- bool ret = renderer->setupDocument(doc, pageBoundingBox, base);
+ bool ret = renderer->setupDocument(doc, pageBoundingBox, bleedmargin_px, base);
if (ret) {
renderer->renderItem(base);
}
@@ -569,7 +569,7 @@ LaTeXTextRenderer::renderItem(SPItem *item)
}
bool
-LaTeXTextRenderer::setupDocument(SPDocument *doc, bool pageBoundingBox, SPItem *base)
+LaTeXTextRenderer::setupDocument(SPDocument *doc, bool pageBoundingBox, float bleedmargin_px, SPItem *base)
{
// The boundingbox calculation here should be exactly the same as the one by CairoRenderer::setupDocument !
@@ -588,6 +588,7 @@ LaTeXTextRenderer::setupDocument(SPDocument *doc, bool pageBoundingBox, SPItem *
}
d = *bbox;
}
+ d.expandBy(bleedmargin_px);
// scale all coordinates, such that the width of the image is 1, this is convenient for scaling the image in LaTeX
double scale = 1/(d.width());
diff --git a/src/extension/internal/latex-text-renderer.h b/src/extension/internal/latex-text-renderer.h
index 66055a3bc..0fa94c9e6 100644
--- a/src/extension/internal/latex-text-renderer.h
+++ b/src/extension/internal/latex-text-renderer.h
@@ -29,7 +29,7 @@ namespace Extension {
namespace Internal {
bool latex_render_document_text_to_file(SPDocument *doc, gchar const *filename,
- const gchar * const exportId, bool exportDrawing, bool exportCanvas,
+ const gchar * const exportId, bool exportDrawing, bool exportCanvas, float bleedmargin_px,
bool pdflatex);
class LaTeXTextRenderer {
@@ -41,7 +41,7 @@ public:
/** Initializes the LaTeXTextRenderer according to the specified
SPDocument. Important to set the boundingbox to the pdf boundingbox */
- bool setupDocument(SPDocument *doc, bool pageBoundingBox, SPItem *base);
+ bool setupDocument(SPDocument *doc, bool pageBoundingBox, float bleedmargin_px, SPItem *base);
/** Traverses the object tree and invokes the render methods. */
void renderItem(SPItem *item);
diff --git a/src/extension/internal/odf.cpp b/src/extension/internal/odf.cpp
index c8c187c77..4c27925ae 100644
--- a/src/extension/internal/odf.cpp
+++ b/src/extension/internal/odf.cpp
@@ -4,7 +4,7 @@
* This is an an entry in the extensions mechanism to begin to enable
* the inputting and outputting of OpenDocument Format (ODF) files from
* within Inkscape. Although the initial implementations will be very lossy
- * do to the differences in the models of SVG and ODF, they will hopefully
+ * due to the differences in the models of SVG and ODF, they will hopefully
* improve greatly with time. People should consider this to be a framework
* that can be continously upgraded for ever improving fidelity. Potential
* developers should especially look in preprocess() and writeTree() to see how
@@ -15,8 +15,10 @@
* Authors:
* Bob Jamison
* Abhishek Sharma
+ * Kris De Gussem
*
* Copyright (C) 2006, 2007 Bob Jamison
+ * Copyright (C) 2013 Kris De Gussem
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -78,16 +80,15 @@
//# DOM-specific includes
#include "dom/dom.h"
#include "dom/util/ziptool.h"
-#include "dom/io/domstream.h"
-#include "dom/io/bufferstream.h"
-#include "dom/io/stringstream.h"
+//#include "dom/io/domstream.h"
+#include "inkscape-version.h"
#include "document.h"
-
#include "extension/extension.h"
-
+#include "io/inkscapestream.h"
+#include "io/bufferstream.h"
namespace Inkscape
{
@@ -95,15 +96,12 @@ namespace Extension
{
namespace Internal
{
-
-
-
//# Shorthand notation
typedef org::w3c::dom::DOMString DOMString;
-typedef org::w3c::dom::XMLCh XMLCh;
-typedef org::w3c::dom::io::OutputStreamWriter OutputStreamWriter;
-typedef org::w3c::dom::io::BufferOutputStream BufferOutputStream;
-typedef org::w3c::dom::io::StringOutputStream StringOutputStream;
+typedef Inkscape::IO::BufferOutputStream BufferOutputStream;
+typedef Inkscape::IO::OutputStreamWriter OutputStreamWriter;
+typedef Inkscape::IO::StringOutputStream StringOutputStream;
+
//########################################################################
//# C L A S S SingularValueDecomposition
@@ -293,11 +291,13 @@ public:
@return Structure to access U, S and V.
*/
- SingularValueDecomposition (const SVDMatrix &mat)
+ SingularValueDecomposition (const SVDMatrix &mat) :
+ A (mat),
+ U (),
+ s (NULL),
+ s_size (0),
+ V ()
{
- A = mat;
- s = NULL;
- s_size = 0;
calculate();
}
@@ -969,7 +969,7 @@ static Geom::Affine getODFTransform(const SPItem *item)
static Geom::OptRect getODFBoundingBox(const SPItem *item)
{
// TODO: geometric or visual?
- Geom::OptRect bbox = ((SPItem *)item)->documentVisualBounds();
+ Geom::OptRect bbox = item->documentVisualBounds();
if (bbox) {
*bbox *= Geom::Affine(Geom::Scale(pxToCm));
}
@@ -1078,14 +1078,16 @@ OdfOutput::preprocess(ZipFile &zf, Inkscape::XML::Node *node)
//Now consider items.
SPObject *reprobj = SP_ACTIVE_DOCUMENT->getObjectByRepr(node);
if (!reprobj)
+ {
return;
+ }
if (!SP_IS_ITEM(reprobj))
- {
+ {
return;
- }
- SPItem *item = SP_ITEM(reprobj);
+ }
+ //SPItem *item = SP_ITEM(reprobj);
//### Get SVG-to-ODF transform
- Geom::Affine tf = getODFTransform(item);
+ //Geom::Affine tf = getODFTransform(item);
if (nodeName == "image" || nodeName == "svg:image")
{
@@ -1180,7 +1182,7 @@ bool OdfOutput::writeManifest(ZipFile &zf)
else if (ext == ".jpg")
outs.printf("image/jpeg");
outs.printf("\" manifest:full-path=\"");
- outs.printf(newName.c_str());
+ outs.writeString(newName.c_str());
outs.printf("\"/>\n");
}
outs.printf("</manifest:manifest>\n");
@@ -1208,14 +1210,19 @@ bool OdfOutput::writeMeta(ZipFile &zf)
time(&tim);
std::map<Glib::ustring, Glib::ustring>::iterator iter;
- Glib::ustring creator = "unknown";
+ Glib::ustring InkscapeVersion = Glib::ustring("Inkscape.org - ") + Inkscape::version_string;
+ Glib::ustring creator = InkscapeVersion;
iter = metadata.find("dc:creator");
if (iter != metadata.end())
+ {
creator = iter->second;
+ }
Glib::ustring date = "";
iter = metadata.find("dc:date");
if (iter != metadata.end())
+ {
date = iter->second;
+ }
outs.printf("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
outs.printf("\n");
@@ -1240,20 +1247,20 @@ bool OdfOutput::writeMeta(ZipFile &zf)
outs.printf("xmlns:anim=\"urn:oasis:names:tc:opendocument:xmlns:animation:1.0\"\n");
outs.printf("office:version=\"1.0\">\n");
outs.printf("<office:meta>\n");
- outs.printf(" <meta:generator>Inkscape.org - 0.45</meta:generator>\n");
- outs.printf(" <meta:initial-creator>%#s</meta:initial-creator>\n",
- creator.c_str());
- outs.printf(" <meta:creation-date>%#s</meta:creation-date>\n", date.c_str());
+ Glib::ustring tmp = Glib::ustring(" <meta:generator>") + InkscapeVersion + "</meta:generator>\n";
+ outs.writeUString(tmp);
+ outs.printf(" <meta:initial-creator>%s</meta:initial-creator>\n", creator.c_str());
+ outs.printf(" <meta:creation-date>%s</meta:creation-date>\n", date.c_str());
for (iter = metadata.begin() ; iter != metadata.end() ; ++iter)
- {
+ {
Glib::ustring name = iter->first;
Glib::ustring value = iter->second;
- if (name.size() > 0 && value.size()>0)
- {
- outs.printf(" <%#s>%#s</%#s>\n",
- name.c_str(), value.c_str(), name.c_str());
- }
+ if (!name.empty() && !value.empty())
+ {
+ tmp = Glib::ustring::compose(" <%1>%2</%3>\n", name, value, name);
+ outs.writeUString(tmp);
}
+ }
outs.printf(" <meta:editing-cycles>2</meta:editing-cycles>\n");
outs.printf(" <meta:editing-duration>PT56S</meta:editing-duration>\n");
outs.printf(" <meta:user-defined meta:name=\"Info 1\"/>\n");
@@ -1330,7 +1337,7 @@ bool OdfOutput::writeStyle(ZipFile &zf)
}
//## Dump our gradient table
- int gradientCount = 0;
+ unsigned int gradientCount = 0;
outs.printf("\n");
outs.printf("<!-- ####### Gradients from Inkscape document ####### -->\n");
std::vector<GradientInfo>::iterator giter;
@@ -1356,8 +1363,8 @@ bool OdfOutput::writeStyle(ZipFile &zf)
continue;
}
outs.printf("<svg:linearGradient ");
- outs.printf("id=\"%#s_g\" ", gi.name.c_str());
- outs.printf("draw:name=\"%#s_g\"\n", gi.name.c_str());
+ outs.printf("id=\"%s\" ", gi.name.c_str());
+ outs.printf("draw:name=\"%s\"\n", gi.name.c_str());
outs.printf(" draw:display-name=\"imported linear %u\"\n",
gradientCount);
outs.printf(" svg:x1=\"%05.3fcm\" svg:y1=\"%05.3fcm\"\n",
@@ -1399,9 +1406,9 @@ bool OdfOutput::writeStyle(ZipFile &zf)
continue;
}
outs.printf("<svg:radialGradient ");
- outs.printf("id=\"%#s_g\" ", gi.name.c_str());
- outs.printf("draw:name=\"%#s_g\"\n", gi.name.c_str());
- outs.printf(" draw:display-name=\"imported radial %d\"\n",
+ outs.printf("id=\"%s\" ", gi.name.c_str());
+ outs.printf("draw:name=\"%s\"\n", gi.name.c_str());
+ outs.printf(" draw:display-name=\"imported radial %u\"\n",
gradientCount);
outs.printf(" svg:cx=\"%05.3f\" svg:cy=\"%05.3f\"\n",
gi.cx, gi.cy);
@@ -1428,11 +1435,11 @@ bool OdfOutput::writeStyle(ZipFile &zf)
{
g_warning("unsupported gradient style '%s'", gi.style.c_str());
}
- outs.printf("<style:style style:name=\"%#s\" style:family=\"graphic\" ",
+ outs.printf("<style:style style:name=\"%s\" style:family=\"graphic\" ",
gi.name.c_str());
outs.printf("style:parent-style-name=\"standard\">\n");
outs.printf(" <style:graphic-properties draw:fill=\"gradient\" ");
- outs.printf("draw:fill-gradient-name=\"%#s_g\"\n",
+ outs.printf("draw:fill-gradient-name=\"%s\"\n",
gi.name.c_str());
outs.printf(" draw:textarea-horizontal-align=\"center\" ");
outs.printf("draw:textarea-vertical-align=\"middle\"/>\n");
@@ -1465,7 +1472,7 @@ bool OdfOutput::writeStyle(ZipFile &zf)
outs.printf("<!--\n");
outs.printf("*************************************************************************\n");
outs.printf(" E N D O F F I L E\n");
- outs.printf(" Have a nice day - ishmal\n");
+ outs.printf(" Have a nice day\n");
outs.printf("*************************************************************************\n");
outs.printf("-->\n");
outs.printf("\n");
@@ -1749,8 +1756,8 @@ bool OdfOutput::processGradient(Writer &outs, SPItem *item,
return false;;
}
outs.printf("<svg:linearGradient ");
- outs.printf("id=\"%#s_g\" ", gi.name.c_str());
- outs.printf("draw:name=\"%#s_g\"\n", gi.name.c_str());
+ outs.printf("id=\"%s\" ", gi.name.c_str());
+ outs.printf("draw:name=\"%s\"\n", gi.name.c_str());
outs.printf(" draw:display-name=\"imported linear %d\"\n",
gradientCount);
outs.printf(" svg:gradientUnits=\"objectBoundingBox\"\n");
@@ -1792,8 +1799,8 @@ bool OdfOutput::processGradient(Writer &outs, SPItem *item,
return false;
}
outs.printf("<svg:radialGradient ");
- outs.printf("id=\"%#s_g\" ", gi.name.c_str());
- outs.printf("draw:name=\"%#s_g\"\n", gi.name.c_str());
+ outs.printf("id=\"%s\" ", gi.name.c_str());
+ outs.printf("draw:name=\"%s\"\n", gi.name.c_str());
outs.printf(" draw:display-name=\"imported radial %d\"\n",
gradientCount);
outs.printf(" svg:gradientUnits=\"objectBoundingBox\"\n");
@@ -1822,11 +1829,11 @@ bool OdfOutput::processGradient(Writer &outs, SPItem *item,
g_warning("unsupported gradient style '%s'", gi.style.c_str());
return false;
}
- outs.printf("<style:style style:name=\"%#s\" style:family=\"graphic\" ",
+ outs.printf("<style:style style:name=\"%s\" style:family=\"graphic\" ",
gi.name.c_str());
outs.printf("style:parent-style-name=\"standard\">\n");
outs.printf(" <style:graphic-properties draw:fill=\"gradient\" ");
- outs.printf("draw:fill-gradient-name=\"%#s_g\"\n",
+ outs.printf("draw:fill-gradient-name=\"%s\"\n",
gi.name.c_str());
outs.printf(" draw:textarea-horizontal-align=\"center\" ");
outs.printf("draw:textarea-vertical-align=\"middle\"/>\n");
@@ -1888,35 +1895,47 @@ bool OdfOutput::writeTree(Writer &couts, Writer &souts,
if (nodeName == "svg" || nodeName == "svg:svg")
- {
+ {
//# Iterate through the children
for (Inkscape::XML::Node *child = node->firstChild() ;
child ; child = child->next())
- {
+ {
if (!writeTree(couts, souts, child))
+ {
return false;
}
- return true;
}
+ return true;
+ }
else if (nodeName == "g" || nodeName == "svg:g")
+ {
+ if (!id.empty())
{
- if (id.size() > 0)
couts.printf("<draw:g id=\"%s\">\n", id.c_str());
+ }
else
+ {
couts.printf("<draw:g>\n");
+ }
//# Iterate through the children
for (Inkscape::XML::Node *child = node->firstChild() ;
child ; child = child->next())
- {
+ {
if (!writeTree(couts, souts, child))
+ {
return false;
}
- if (id.size() > 0)
+ }
+ if (!id.empty())
+ {
couts.printf("</draw:g> <!-- id=\"%s\" -->\n", id.c_str());
+ }
else
+ {
couts.printf("</draw:g>\n");
- return true;
}
+ return true;
+ }
//######################################
//# S T Y L E
@@ -1929,19 +1948,17 @@ bool OdfOutput::writeTree(Writer &couts, Writer &souts,
processGradient(souts, item, id, tf);
-
-
//######################################
//# I T E M D A T A
//######################################
//g_message("##### %s #####", nodeName.c_str());
if (nodeName == "image" || nodeName == "svg:image")
- {
+ {
if (!SP_IS_IMAGE(item))
- {
+ {
g_warning("<image> is not an SPImage. Why? ;-)");
return false;
- }
+ }
SPImage *img = SP_IMAGE(item);
double ix = img->x.value;
@@ -1953,8 +1970,6 @@ bool OdfOutput::writeTree(Writer &couts, Writer &souts,
ibbox = ibbox * tf;
ix = ibbox.min()[Geom::X];
iy = ibbox.min()[Geom::Y];
- //iwidth = ibbox.max()[Geom::X] - ibbox.min()[Geom::X];
- //iheight = ibbox.max()[Geom::Y] - ibbox.min()[Geom::Y];
iwidth = xscale * iwidth;
iheight = yscale * iheight;
@@ -1965,29 +1980,30 @@ bool OdfOutput::writeTree(Writer &couts, Writer &souts,
Glib::ustring href = getAttribute(node, "xlink:href");
std::map<Glib::ustring, Glib::ustring>::iterator iter = imageTable.find(href);
if (iter == imageTable.end())
- {
+ {
g_warning("image '%s' not in table", href.c_str());
return false;
- }
+ }
Glib::ustring newName = iter->second;
couts.printf("<draw:frame ");
- if (id.size() > 0)
+ if (!id.empty())
+ {
couts.printf("id=\"%s\" ", id.c_str());
+ }
couts.printf("draw:style-name=\"gr1\" draw:text-style-name=\"P1\" draw:layer=\"layout\" ");
//no x or y. make them the translate transform, last one
couts.printf("svg:width=\"%.3fcm\" svg:height=\"%.3fcm\" ",
iwidth, iheight);
- if (itemTransformString.size() > 0)
- {
+ if (!itemTransformString.empty())
+ {
couts.printf("draw:transform=\"%s translate(%.3fcm, %.3fcm)\" ",
itemTransformString.c_str(), ix, iy);
- }
+ }
else
- {
- couts.printf("draw:transform=\"translate(%.3fcm, %.3fcm)\" ",
- ix, iy);
- }
+ {
+ couts.printf("draw:transform=\"translate(%.3fcm, %.3fcm)\" ", ix, iy);
+ }
couts.printf(">\n");
couts.printf(" <draw:image xlink:href=\"%s\" xlink:type=\"simple\"\n",
@@ -1997,41 +2013,41 @@ bool OdfOutput::writeTree(Writer &couts, Writer &souts,
couts.printf(" </draw:image>\n");
couts.printf("</draw:frame>\n");
return true;
- }
+ }
else if (SP_IS_SHAPE(item))
- {
- //g_message("### %s is a shape", nodeName.c_str());
+ {
curve = SP_SHAPE(item)->getCurve();
- }
+ }
else if (SP_IS_TEXT(item) || SP_IS_FLOWTEXT(item))
- {
+ {
curve = te_get_layout(item)->convertToCurves();
- }
+ }
if (curve)
- {
+ {
//### Default <path> output
-
couts.printf("<draw:path ");
- if (id.size()>0)
+ if (!id.empty())
+ {
couts.printf("id=\"%s\" ", id.c_str());
+ }
std::map<Glib::ustring, Glib::ustring>::iterator siter;
siter = styleLookupTable.find(id);
if (siter != styleLookupTable.end())
- {
+ {
Glib::ustring styleName = siter->second;
couts.printf("draw:style-name=\"%s\" ", styleName.c_str());
- }
+ }
std::map<Glib::ustring, Glib::ustring>::iterator giter;
giter = gradientLookupTable.find(id);
if (giter != gradientLookupTable.end())
- {
+ {
Glib::ustring gradientName = giter->second;
couts.printf("draw:fill-gradient-name=\"%s\" ",
gradientName.c_str());
- }
+ }
couts.printf("draw:layer=\"layout\" svg:x=\"%.3fcm\" svg:y=\"%.3fcm\" ",
bbox_x, bbox_y);
@@ -2051,7 +2067,7 @@ bool OdfOutput::writeTree(Writer &couts, Writer &souts,
curve->unref();
- }
+ }
return true;
}
@@ -2170,7 +2186,7 @@ bool OdfOutput::writeStyleFooter(Writer &outs)
outs.printf("<!--\n");
outs.printf("*************************************************************************\n");
outs.printf(" E N D O F F I L E\n");
- outs.printf(" Have a nice day - ishmal\n");
+ outs.printf(" Have a nice day\n");
outs.printf("*************************************************************************\n");
outs.printf("-->\n");
outs.printf("\n");
@@ -2281,7 +2297,7 @@ bool OdfOutput::writeContentFooter(Writer &outs)
outs.printf("<!--\n");
outs.printf("*************************************************************************\n");
outs.printf(" E N D O F F I L E\n");
- outs.printf(" Have a nice day - ishmal\n");
+ outs.printf(" Have a nice day\n");
outs.printf("*************************************************************************\n");
outs.printf("-->\n");
outs.printf("\n");
@@ -2303,29 +2319,40 @@ bool OdfOutput::writeContent(ZipFile &zf, Inkscape::XML::Node *node)
OutputStreamWriter couts(cbouts);
if (!writeContentHeader(couts))
+ {
return false;
+ }
//Style.xml stream
BufferOutputStream sbouts;
OutputStreamWriter souts(sbouts);
if (!writeStyleHeader(souts))
+ {
return false;
-
+ }
//# Descend into the tree, doing all of our conversions
- //# to both files as the same time
+ //# to both files at the same time
+ char *oldlocale = g_strdup (setlocale (LC_NUMERIC, NULL));
+ setlocale (LC_NUMERIC, "C");
if (!writeTree(couts, souts, node))
- {
+ {
g_warning("Failed to convert SVG tree");
+ setlocale (LC_NUMERIC, oldlocale);
+ g_free (oldlocale);
return false;
- }
+ }
+ setlocale (LC_NUMERIC, oldlocale);
+ g_free (oldlocale);
//# Finish content file
if (!writeContentFooter(couts))
+ {
return false;
+ }
ZipEntry *ze = zf.newEntry("content.xml", "ODF master content file");
ze->setUncompressedData(cbouts.getBuffer());
@@ -2335,7 +2362,9 @@ bool OdfOutput::writeContent(ZipFile &zf, Inkscape::XML::Node *node)
//# Finish style file
if (!writeStyleFooter(souts))
+ {
return false;
+ }
ze = zf.newEntry("styles.xml", "ODF style file");
ze->setUncompressedData(sbouts.getBuffer());
@@ -2441,27 +2470,6 @@ OdfOutput::check (Inkscape::Extension::Extension */*module*/)
-//########################################################################
-//# I N P U T
-//########################################################################
-
-
-
-//#######################
-//# L A T E R !!! :-)
-//#######################
-
-
-
-
-
-
-
-
-
-
-
-
} //namespace Internal
} //namespace Extension
diff --git a/src/extension/internal/odf.h b/src/extension/internal/odf.h
index 6b8883134..001f5e1f1 100644
--- a/src/extension/internal/odf.h
+++ b/src/extension/internal/odf.h
@@ -24,22 +24,21 @@
#define EXTENSION_INTERNAL_ODG_OUT_H
#include <dom/dom.h>
-#include <dom/io/stringstream.h>
+#include <io/stringstream.h>
#include <dom/uri.h>
-#include <glibmm.h>
#include "extension/implementation/implementation.h"
-
#include <xml/repr.h>
#include <string>
#include <map>
#include <dom/util/ziptool.h>
-#include <dom/io/domstream.h>
#include "sp-item.h"
+#include <glibmm/ustring.h>
+
namespace Inkscape
{
namespace Extension
@@ -48,8 +47,7 @@ namespace Internal
{
typedef org::w3c::dom::URI URI;
-typedef org::w3c::dom::io::Writer Writer;
-
+typedef Inkscape::IO::Writer Writer;
class StyleInfo
{
diff --git a/src/extension/internal/pdf-input-cairo.cpp b/src/extension/internal/pdf-input-cairo.cpp
index eee1b43bf..c83ebad82 100644
--- a/src/extension/internal/pdf-input-cairo.cpp
+++ b/src/extension/internal/pdf-input-cairo.cpp
@@ -95,11 +95,7 @@ PdfImportCairoDialog::PdfImportCairoDialog(PopplerDocument *doc)
_cropTypeCombo = Gtk::manage(new class Gtk::ComboBoxText());
int num_crop_choices = sizeof(crop_setting_choices) / sizeof(crop_setting_choices[0]);
for ( int i = 0 ; i < num_crop_choices ; i++ ) {
-#if WITH_GTKMM_2_24
_cropTypeCombo->append(_(crop_setting_choices[i]));
-#else
- _cropTypeCombo->append_text(_(crop_setting_choices[i]));
-#endif
}
_cropTypeCombo->set_active_text(_(crop_setting_choices[0]));
_cropTypeCombo->set_sensitive(false);
@@ -112,7 +108,7 @@ PdfImportCairoDialog::PdfImportCairoDialog(PopplerDocument *doc)
#if WITH_GTKMM_3_0
_fallbackPrecisionSlider_adj = Gtk::Adjustment::create(2, 1, 256, 1, 10, 10);
- _fallbackPrecisionSlider = Gtk::manage(new Gtk::HScale(_fallbackPrecisionSlider_adj));
+ _fallbackPrecisionSlider = Gtk::manage(new Gtk::Scale(_fallbackPrecisionSlider_adj));
#else
_fallbackPrecisionSlider_adj = Gtk::manage(new class Gtk::Adjustment(2, 1, 256, 1, 10, 10));
_fallbackPrecisionSlider = Gtk::manage(new class Gtk::HScale(*_fallbackPrecisionSlider_adj));
@@ -124,11 +120,7 @@ PdfImportCairoDialog::PdfImportCairoDialog(PopplerDocument *doc)
// Text options
_labelText = Gtk::manage(new class Gtk::Label(_("Text handling:")));
_textHandlingCombo = Gtk::manage(new class Gtk::ComboBoxText());
-#if WITH_GTKMM_2_24
_textHandlingCombo->append(_("Import text as text"));
-#else
- _textHandlingCombo->append_text(_("Import text as text"));
-#endif
_textHandlingCombo->set_active_text(_("Import text as text"));
_localFontsCheck = Gtk::manage(new class Gtk::CheckButton(_("Replace PDF fonts by closest-named installed fonts")));
@@ -232,12 +224,20 @@ PdfImportCairoDialog::PdfImportCairoDialog(PopplerDocument *doc)
vbox1->pack_start(*_importSettingsFrame, Gtk::PACK_EXPAND_PADDING, 0);
hbox1->pack_start(*vbox1);
hbox1->pack_start(*_previewArea, Gtk::PACK_EXPAND_WIDGET, 4);
+
+#if WITH_GTKMM_3_0
+ get_content_area()->set_homogeneous(false);
+ get_content_area()->set_spacing(0);
+ get_content_area()->pack_start(*hbox1);
+#else
this->get_vbox()->set_homogeneous(false);
this->get_vbox()->set_spacing(0);
this->get_vbox()->pack_start(*hbox1);
+#endif
+
this->set_title(_("PDF Import Settings"));
this->set_modal(true);
- sp_transientize((GtkWidget *)this->gobj()); //Make transient
+ sp_transientize(GTK_WIDGET(this->gobj())); //Make transient
this->property_window_position().set_value(Gtk::WIN_POS_NONE);
this->set_resizable(true);
this->property_destroy_with_parent().set_value(false);
@@ -424,7 +424,7 @@ static void copy_cairo_surface_to_pixbuf (cairo_surface_t *surface,
cairo_height = gdk_pixbuf_get_height (pixbuf);
for (y = 0; y < cairo_height; y++)
{
- src = (unsigned int *) (cairo_data + y * cairo_rowstride);
+ src = reinterpret_cast<unsigned int *>(cairo_data + y * cairo_rowstride);
dst = pixbuf_data + y * pixbuf_rowstride;
for (x = 0; x < cairo_width; x++)
{
@@ -630,8 +630,8 @@ PdfInputCairo::open(Inkscape::Extension::Input * /*mod*/, const gchar * uri) {
static cairo_status_t
_write_ustring_cb(void *closure, const unsigned char *data, unsigned int length)
{
- Glib::ustring* stream = (Glib::ustring*)closure;
- stream->append((const char*)data, length);
+ Glib::ustring* stream = static_cast<Glib::ustring*>(closure);
+ stream->append(reinterpret_cast<const char*>(data), length);
return CAIRO_STATUS_SUCCESS;
}
diff --git a/src/extension/internal/pdf-input-cairo.h b/src/extension/internal/pdf-input-cairo.h
index 81e9a8f00..66f1e5e7e 100644
--- a/src/extension/internal/pdf-input-cairo.h
+++ b/src/extension/internal/pdf-input-cairo.h
@@ -37,6 +37,14 @@
#include "../implementation/implementation.h"
+namespace Gtk {
+#if WITH_GTKMM_3_0
+ class Scale;
+#else
+ class HScale;
+#endif
+}
+
namespace Inkscape {
namespace UI {
@@ -85,10 +93,11 @@ private:
class Inkscape::UI::Widget::Frame * _pageSettingsFrame;
class Gtk::Label * _labelPrecision;
class Gtk::Label * _labelPrecisionWarning;
- class Gtk::HScale * _fallbackPrecisionSlider;
#if WITH_GTKMM_3_0
+ class Gtk::Scale * _fallbackPrecisionSlider;
Glib::RefPtr<Gtk::Adjustment> _fallbackPrecisionSlider_adj;
#else
+ class Gtk::HScale * _fallbackPrecisionSlider;
class Gtk::Adjustment *_fallbackPrecisionSlider_adj;
#endif
class Gtk::Label * _labelPrecisionComment;
diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp
index 6b6107444..b04c9782f 100644
--- a/src/extension/internal/pdfinput/pdf-input.cpp
+++ b/src/extension/internal/pdfinput/pdf-input.cpp
@@ -32,6 +32,7 @@
#endif
#include <gtkmm/alignment.h>
+#include <gtkmm/checkbutton.h>
#include <gtkmm/comboboxtext.h>
#include <gtkmm/drawingarea.h>
#include <gtkmm/frame.h>
@@ -111,11 +112,7 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/)
_cropTypeCombo = Gtk::manage(new class Gtk::ComboBoxText());
int num_crop_choices = sizeof(crop_setting_choices) / sizeof(crop_setting_choices[0]);
for ( int i = 0 ; i < num_crop_choices ; i++ ) {
-#if WITH_GTKMM_2_24
_cropTypeCombo->append(_(crop_setting_choices[i]));
-#else
- _cropTypeCombo->append_text(_(crop_setting_choices[i]));
-#endif
}
_cropTypeCombo->set_active_text(_(crop_setting_choices[0]));
_cropTypeCombo->set_sensitive(false);
@@ -128,7 +125,7 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/)
#if WITH_GTKMM_3_0
_fallbackPrecisionSlider_adj = Gtk::Adjustment::create(2, 1, 256, 1, 10, 10);
- _fallbackPrecisionSlider = Gtk::manage(new class Gtk::HScale(_fallbackPrecisionSlider_adj));
+ _fallbackPrecisionSlider = Gtk::manage(new class Gtk::Scale(_fallbackPrecisionSlider_adj));
#else
_fallbackPrecisionSlider_adj = Gtk::manage(new class Gtk::Adjustment(2, 1, 256, 1, 10, 10));
_fallbackPrecisionSlider = Gtk::manage(new class Gtk::HScale(*_fallbackPrecisionSlider_adj));
@@ -140,11 +137,7 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/)
// Text options
_labelText = Gtk::manage(new class Gtk::Label(_("Text handling:")));
_textHandlingCombo = Gtk::manage(new class Gtk::ComboBoxText());
-#if WITH_GTKMM_2_24
_textHandlingCombo->append(_("Import text as text"));
-#else
- _textHandlingCombo->append_text(_("Import text as text"));
-#endif
_textHandlingCombo->set_active_text(_("Import text as text"));
_localFontsCheck = Gtk::manage(new class Gtk::CheckButton(_("Replace PDF fonts by closest-named installed fonts")));
@@ -248,12 +241,20 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/)
vbox1->pack_start(*_importSettingsFrame, Gtk::PACK_EXPAND_PADDING, 0);
hbox1->pack_start(*vbox1);
hbox1->pack_start(*_previewArea, Gtk::PACK_EXPAND_WIDGET, 4);
+
+#if WITH_GTKMM_3_0
+ get_content_area()->set_homogeneous(false);
+ get_content_area()->set_spacing(0);
+ get_content_area()->pack_start(*hbox1);
+#else
this->get_vbox()->set_homogeneous(false);
this->get_vbox()->set_spacing(0);
this->get_vbox()->pack_start(*hbox1);
+#endif
+
this->set_title(_("PDF Import Settings"));
this->set_modal(true);
- sp_transientize((GtkWidget *)this->gobj()); //Make transient
+ sp_transientize(GTK_WIDGET(this->gobj())); //Make transient
this->property_window_position().set_value(Gtk::WIN_POS_NONE);
this->set_resizable(true);
this->property_destroy_with_parent().set_value(false);
@@ -454,7 +455,7 @@ static void copy_cairo_surface_to_pixbuf (cairo_surface_t *surface,
cairo_height = gdk_pixbuf_get_height (pixbuf);
for (y = 0; y < cairo_height; y++)
{
- src = (unsigned int *) (cairo_data + y * cairo_rowstride);
+ src = reinterpret_cast<unsigned int *>(cairo_data + y * cairo_rowstride);
dst = pixbuf_data + y * pixbuf_rowstride;
for (x = 0; x < cairo_width; x++)
{
@@ -588,12 +589,19 @@ void PdfImportDialog::_setPreviewPage(int page) {
////////////////////////////////////////////////////////////////////////////////
+bool
+PdfInput::wasCancelled () {
+ return _cancelled;
+}
+
/**
* Parses the selected page of the given PDF document using PdfParser.
*/
SPDocument *
PdfInput::open(::Inkscape::Extension::Input * /*mod*/, const gchar * uri) {
+ _cancelled = false;
+
// Initialize the globalParams variable for poppler
if (!globalParams) {
globalParams = new GlobalParams();
@@ -604,7 +612,7 @@ PdfInput::open(::Inkscape::Extension::Input * /*mod*/, const gchar * uri) {
PDFDoc *pdf_doc = new PDFDoc(filename_goo, NULL, NULL, NULL); // TODO: Could ask for password
//delete filename_goo;
#else
- wchar_t *wfilename = (wchar_t*)g_utf8_to_utf16 (uri, -1, NULL, NULL, NULL);
+ wchar_t *wfilename = reinterpret_cast<wchar_t*>(g_utf8_to_utf16 (uri, -1, NULL, NULL, NULL));
if (wfilename == NULL) {
return NULL;
@@ -648,6 +656,7 @@ PdfInput::open(::Inkscape::Extension::Input * /*mod*/, const gchar * uri) {
if (inkscape_use_gui()) {
dlg = new PdfImportDialog(pdf_doc, uri);
if (!dlg->showDialog()) {
+ _cancelled = true;
delete dlg;
delete pdf_doc;
return NULL;
diff --git a/src/extension/internal/pdfinput/pdf-input.h b/src/extension/internal/pdfinput/pdf-input.h
index 75fcfa69a..3710e4667 100644
--- a/src/extension/internal/pdfinput/pdf-input.h
+++ b/src/extension/internal/pdfinput/pdf-input.h
@@ -39,7 +39,11 @@ namespace Gtk {
class DrawingArea;
class Frame;
class HBox;
+#if WITH_GTKMM_3_0
+ class Scale;
+#else
class HScale;
+#endif
class VBox;
class Label;
}
@@ -95,10 +99,11 @@ private:
class Inkscape::UI::Widget::Frame * _pageSettingsFrame;
class Gtk::Label * _labelPrecision;
class Gtk::Label * _labelPrecisionWarning;
- class Gtk::HScale * _fallbackPrecisionSlider;
#if WITH_GTKMM_3_0
+ class Gtk::Scale * _fallbackPrecisionSlider;
Glib::RefPtr<Gtk::Adjustment> _fallbackPrecisionSlider_adj;
#else
+ class Gtk::HScale * _fallbackPrecisionSlider;
class Gtk::Adjustment *_fallbackPrecisionSlider_adj;
#endif
class Gtk::Label * _labelPrecisionComment;
@@ -135,7 +140,9 @@ public:
SPDocument *open( Inkscape::Extension::Input *mod,
const gchar *uri );
static void init( void );
-
+ virtual bool wasCancelled();
+private:
+ bool _cancelled;
};
} // namespace Implementation
diff --git a/src/extension/internal/pdfinput/pdf-parser.cpp b/src/extension/internal/pdfinput/pdf-parser.cpp
index e57161e5a..3be7af34f 100644
--- a/src/extension/internal/pdfinput/pdf-parser.cpp
+++ b/src/extension/internal/pdfinput/pdf-parser.cpp
@@ -1220,7 +1220,6 @@ void PdfParser::opSetStrokeColor(Object args[], int numArgs) {
void PdfParser::opSetFillColorN(Object args[], int numArgs) {
GfxColor color;
- GfxPattern *pattern;
int i;
if (state->getFillColorSpace()->getMode() == csPattern) {
@@ -1243,6 +1242,7 @@ void PdfParser::opSetFillColorN(Object args[], int numArgs) {
state->setFillColor(&color);
builder->updateStyle(state);
}
+ GfxPattern *pattern;
#if defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
if (args[numArgs-1].isName() &&
(pattern = res->lookupPattern(args[numArgs-1].getName(), NULL))) {
@@ -1279,7 +1279,6 @@ void PdfParser::opSetFillColorN(Object args[], int numArgs) {
void PdfParser::opSetStrokeColorN(Object args[], int numArgs) {
GfxColor color;
- GfxPattern *pattern;
int i;
if (state->getStrokeColorSpace()->getMode() == csPattern) {
@@ -1303,6 +1302,7 @@ void PdfParser::opSetStrokeColorN(Object args[], int numArgs) {
state->setStrokeColor(&color);
builder->updateStyle(state);
}
+ GfxPattern *pattern;
#if defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
if (args[numArgs-1].isName() &&
(pattern = res->lookupPattern(args[numArgs-1].getName(), NULL))) {
@@ -2702,333 +2702,338 @@ void PdfParser::opXObject(Object args[], int /*numArgs*/)
void PdfParser::doImage(Object * /*ref*/, Stream *str, GBool inlineImg)
{
- Dict *dict, *maskDict;
- int width, height;
- int bits;
- StreamColorSpaceMode csMode;
- GBool mask;
- GBool invert;
- GfxColorSpace *colorSpace, *maskColorSpace;
- GfxImageColorMap *colorMap, *maskColorMap;
- Object maskObj, smaskObj;
- GBool haveColorKeyMask, haveExplicitMask, haveSoftMask;
- int maskColors[2*gfxColorMaxComps];
- int maskWidth, maskHeight;
- GBool maskInvert;
- Stream *maskStr;
- Object obj1, obj2;
- int i;
-
- // get info from the stream
- bits = 0;
- csMode = streamCSNone;
- str->getImageParams(&bits, &csMode);
-
- // get stream dict
- dict = str->getDict();
-
- // get size
- dict->lookup(const_cast<char*>("Width"), &obj1);
- if (obj1.isNull()) {
- obj1.free();
- dict->lookup(const_cast<char*>("W"), &obj1);
- }
- if (obj1.isInt())
- width = obj1.getInt();
- else if (obj1.isReal())
- width = (int)obj1.getReal();
- else
- goto err2;
- obj1.free();
- dict->lookup(const_cast<char*>("Height"), &obj1);
- if (obj1.isNull()) {
- obj1.free();
- dict->lookup(const_cast<char*>("H"), &obj1);
- }
- if (obj1.isInt())
- height = obj1.getInt();
- else if (obj1.isReal())
- height = (int)obj1.getReal();
- else
- goto err2;
- obj1.free();
-
- // image or mask?
- dict->lookup(const_cast<char*>("ImageMask"), &obj1);
- if (obj1.isNull()) {
- obj1.free();
- dict->lookup(const_cast<char*>("IM"), &obj1);
- }
- mask = gFalse;
- if (obj1.isBool())
- mask = obj1.getBool();
- else if (!obj1.isNull())
- goto err2;
- obj1.free();
-
- // bit depth
- if (bits == 0) {
- dict->lookup(const_cast<char*>("BitsPerComponent"), &obj1);
+ Dict *dict;
+ int width, height;
+ int bits;
+ StreamColorSpaceMode csMode;
+ GBool mask;
+ GBool invert;
+ Object maskObj, smaskObj;
+ GBool haveColorKeyMask, haveExplicitMask, haveSoftMask;
+ GBool maskInvert;
+ Object obj1, obj2;
+
+ // get info from the stream
+ bits = 0;
+ csMode = streamCSNone;
+ str->getImageParams(&bits, &csMode);
+
+ // get stream dict
+ dict = str->getDict();
+
+ // get size
+ dict->lookup(const_cast<char*>("Width"), &obj1);
if (obj1.isNull()) {
- obj1.free();
- dict->lookup(const_cast<char*>("BPC"), &obj1);
+ obj1.free();
+ dict->lookup(const_cast<char*>("W"), &obj1);
}
- if (obj1.isInt()) {
- bits = obj1.getInt();
- } else if (mask) {
- bits = 1;
- } else {
- goto err2;
+ if (obj1.isInt()){
+ width = obj1.getInt();
}
- obj1.free();
- }
-
- // display a mask
- if (mask) {
-
- // check for inverted mask
- if (bits != 1)
- goto err1;
- invert = gFalse;
- dict->lookup(const_cast<char*>("Decode"), &obj1);
- if (obj1.isNull()) {
- obj1.free();
- dict->lookup(const_cast<char*>("D"), &obj1);
+ else if (obj1.isReal()) {
+ width = (int)obj1.getReal();
}
- if (obj1.isArray()) {
- obj1.arrayGet(0, &obj2);
- if (obj2.isInt() && obj2.getInt() == 1)
- invert = gTrue;
- obj2.free();
- } else if (!obj1.isNull()) {
- goto err2;
+ else {
+ goto err2;
}
obj1.free();
-
- // draw it
- builder->addImageMask(state, str, width, height, invert);
-
- } else {
-
- // get color space and color map
- dict->lookup(const_cast<char*>("ColorSpace"), &obj1);
+ dict->lookup(const_cast<char*>("Height"), &obj1);
if (obj1.isNull()) {
- obj1.free();
- dict->lookup(const_cast<char*>("CS"), &obj1);
+ obj1.free();
+ dict->lookup(const_cast<char*>("H"), &obj1);
}
- if (obj1.isName()) {
- res->lookupColorSpace(obj1.getName(), &obj2);
- if (!obj2.isNull()) {
- obj1.free();
- obj1 = obj2;
- } else {
- obj2.free();
- }
+ if (obj1.isInt()) {
+ height = obj1.getInt();
}
- if (!obj1.isNull()) {
-#if defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
- colorSpace = GfxColorSpace::parse(&obj1, NULL);
-#else
- colorSpace = GfxColorSpace::parse(&obj1);
-#endif
- } else if (csMode == streamCSDeviceGray) {
- colorSpace = new GfxDeviceGrayColorSpace();
- } else if (csMode == streamCSDeviceRGB) {
- colorSpace = new GfxDeviceRGBColorSpace();
- } else if (csMode == streamCSDeviceCMYK) {
- colorSpace = new GfxDeviceCMYKColorSpace();
- } else {
- colorSpace = NULL;
+ else if (obj1.isReal()){
+ height = static_cast<int>(obj1.getReal());
}
- obj1.free();
- if (!colorSpace) {
- goto err1;
+ else {
+ goto err2;
}
- dict->lookup(const_cast<char*>("Decode"), &obj1);
+ obj1.free();
+
+ // image or mask?
+ dict->lookup(const_cast<char*>("ImageMask"), &obj1);
if (obj1.isNull()) {
- obj1.free();
- dict->lookup(const_cast<char*>("D"), &obj1);
+ obj1.free();
+ dict->lookup(const_cast<char*>("IM"), &obj1);
+ }
+ mask = gFalse;
+ if (obj1.isBool()) {
+ mask = obj1.getBool();
+ }
+ else if (!obj1.isNull()) {
+ goto err2;
}
- colorMap = new GfxImageColorMap(bits, &obj1, colorSpace);
obj1.free();
- if (!colorMap->isOk()) {
- delete colorMap;
- goto err1;
- }
-
- // get the mask
- haveColorKeyMask = haveExplicitMask = haveSoftMask = gFalse;
- maskStr = NULL; // make gcc happy
- maskWidth = maskHeight = 0; // make gcc happy
- maskInvert = gFalse; // make gcc happy
- maskColorMap = NULL; // make gcc happy
- dict->lookup(const_cast<char*>("Mask"), &maskObj);
- dict->lookup(const_cast<char*>("SMask"), &smaskObj);
- if (smaskObj.isStream()) {
- // soft mask
- if (inlineImg) {
- goto err1;
- }
- maskStr = smaskObj.getStream();
- maskDict = smaskObj.streamGetDict();
- maskDict->lookup(const_cast<char*>("Width"), &obj1);
+
+ // bit depth
+ if (bits == 0) {
+ dict->lookup(const_cast<char*>("BitsPerComponent"), &obj1);
if (obj1.isNull()) {
- obj1.free();
- maskDict->lookup(const_cast<char*>("W"), &obj1);
+ obj1.free();
+ dict->lookup(const_cast<char*>("BPC"), &obj1);
}
- if (!obj1.isInt()) {
- goto err2;
+ if (obj1.isInt()) {
+ bits = obj1.getInt();
+ } else if (mask) {
+ bits = 1;
+ } else {
+ goto err2;
}
- maskWidth = obj1.getInt();
obj1.free();
- maskDict->lookup(const_cast<char*>("Height"), &obj1);
- if (obj1.isNull()) {
- obj1.free();
- maskDict->lookup(const_cast<char*>("H"), &obj1);
- }
- if (!obj1.isInt()) {
- goto err2;
+ }
+
+ // display a mask
+ if (mask) {
+ // check for inverted mask
+ if (bits != 1) {
+ goto err1;
}
- maskHeight = obj1.getInt();
- obj1.free();
- maskDict->lookup(const_cast<char*>("BitsPerComponent"), &obj1);
+ invert = gFalse;
+ dict->lookup(const_cast<char*>("Decode"), &obj1);
if (obj1.isNull()) {
- obj1.free();
- maskDict->lookup(const_cast<char*>("BPC"), &obj1);
+ obj1.free();
+ dict->lookup(const_cast<char*>("D"), &obj1);
}
- if (!obj1.isInt()) {
- goto err2;
+ if (obj1.isArray()) {
+ obj1.arrayGet(0, &obj2);
+ if (obj2.isInt() && obj2.getInt() == 1) {
+ invert = gTrue;
+ }
+ obj2.free();
+ } else if (!obj1.isNull()) {
+ goto err2;
}
- int maskBits = obj1.getInt();
obj1.free();
- maskDict->lookup(const_cast<char*>("ColorSpace"), &obj1);
+
+ // draw it
+ builder->addImageMask(state, str, width, height, invert);
+
+ } else {
+ // get color space and color map
+ GfxColorSpace *colorSpace;
+ dict->lookup(const_cast<char*>("ColorSpace"), &obj1);
if (obj1.isNull()) {
- obj1.free();
- maskDict->lookup(const_cast<char*>("CS"), &obj1);
+ obj1.free();
+ dict->lookup(const_cast<char*>("CS"), &obj1);
}
if (obj1.isName()) {
- res->lookupColorSpace(obj1.getName(), &obj2);
- if (!obj2.isNull()) {
+ res->lookupColorSpace(obj1.getName(), &obj2);
+ if (!obj2.isNull()) {
obj1.free();
obj1 = obj2;
- } else {
+ } else {
obj2.free();
- }
+ }
}
+ if (!obj1.isNull()) {
#if defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
- maskColorSpace = GfxColorSpace::parse(&obj1, NULL);
+ colorSpace = GfxColorSpace::parse(&obj1, NULL);
#else
- maskColorSpace = GfxColorSpace::parse(&obj1);
-#endif
+ colorSpace = GfxColorSpace::parse(&obj1);
+#endif
+ } else if (csMode == streamCSDeviceGray) {
+ colorSpace = new GfxDeviceGrayColorSpace();
+ } else if (csMode == streamCSDeviceRGB) {
+ colorSpace = new GfxDeviceRGBColorSpace();
+ } else if (csMode == streamCSDeviceCMYK) {
+ colorSpace = new GfxDeviceCMYKColorSpace();
+ } else {
+ colorSpace = NULL;
+ }
obj1.free();
- if (!maskColorSpace || maskColorSpace->getMode() != csDeviceGray) {
+ if (!colorSpace) {
goto err1;
}
- maskDict->lookup(const_cast<char*>("Decode"), &obj1);
+ dict->lookup(const_cast<char*>("Decode"), &obj1);
if (obj1.isNull()) {
- obj1.free();
- maskDict->lookup(const_cast<char*>("D"), &obj1);
+ obj1.free();
+ dict->lookup(const_cast<char*>("D"), &obj1);
}
- maskColorMap = new GfxImageColorMap(maskBits, &obj1, maskColorSpace);
+ GfxImageColorMap *colorMap = new GfxImageColorMap(bits, &obj1, colorSpace);
obj1.free();
- if (!maskColorMap->isOk()) {
- delete maskColorMap;
+ if (!colorMap->isOk()) {
+ delete colorMap;
goto err1;
}
- //~ handle the Matte entry
- haveSoftMask = gTrue;
- } else if (maskObj.isArray()) {
- // color key mask
- for (i = 0;
- i < maskObj.arrayGetLength() && i < 2*gfxColorMaxComps;
- ++i) {
- maskObj.arrayGet(i, &obj1);
- maskColors[i] = obj1.getInt();
- obj1.free();
- }
- haveColorKeyMask = gTrue;
- } else if (maskObj.isStream()) {
- // explicit mask
- if (inlineImg) {
- goto err1;
- }
- maskStr = maskObj.getStream();
- maskDict = maskObj.streamGetDict();
- maskDict->lookup(const_cast<char*>("Width"), &obj1);
- if (obj1.isNull()) {
- obj1.free();
- maskDict->lookup(const_cast<char*>("W"), &obj1);
- }
- if (!obj1.isInt()) {
- goto err2;
- }
- maskWidth = obj1.getInt();
- obj1.free();
- maskDict->lookup(const_cast<char*>("Height"), &obj1);
- if (obj1.isNull()) {
- obj1.free();
- maskDict->lookup(const_cast<char*>("H"), &obj1);
- }
- if (!obj1.isInt()) {
- goto err2;
- }
- maskHeight = obj1.getInt();
- obj1.free();
- maskDict->lookup(const_cast<char*>("ImageMask"), &obj1);
- if (obj1.isNull()) {
- obj1.free();
- maskDict->lookup(const_cast<char*>("IM"), &obj1);
- }
- if (!obj1.isBool() || !obj1.getBool()) {
- goto err2;
- }
- obj1.free();
- maskInvert = gFalse;
- maskDict->lookup(const_cast<char*>("Decode"), &obj1);
- if (obj1.isNull()) {
- obj1.free();
- maskDict->lookup(const_cast<char*>("D"), &obj1);
- }
- if (obj1.isArray()) {
- obj1.arrayGet(0, &obj2);
- if (obj2.isInt() && obj2.getInt() == 1) {
- maskInvert = gTrue;
- }
- obj2.free();
- } else if (!obj1.isNull()) {
- goto err2;
- }
- obj1.free();
- haveExplicitMask = gTrue;
- }
-
- // draw it
- if (haveSoftMask) {
- builder->addSoftMaskedImage(state, str, width, height, colorMap,
+
+ // get the mask
+ int maskColors[2*gfxColorMaxComps];
+ haveColorKeyMask = haveExplicitMask = haveSoftMask = gFalse;
+ Stream *maskStr = NULL;
+ int maskWidth = 0;
+ int maskHeight = 0;
+ maskInvert = gFalse;
+ GfxImageColorMap *maskColorMap = NULL;
+ dict->lookup(const_cast<char*>("Mask"), &maskObj);
+ dict->lookup(const_cast<char*>("SMask"), &smaskObj);
+ Dict* maskDict;
+ if (smaskObj.isStream()) {
+ // soft mask
+ if (inlineImg) {
+ goto err1;
+ }
+ maskStr = smaskObj.getStream();
+ maskDict = smaskObj.streamGetDict();
+ maskDict->lookup(const_cast<char*>("Width"), &obj1);
+ if (obj1.isNull()) {
+ obj1.free();
+ maskDict->lookup(const_cast<char*>("W"), &obj1);
+ }
+ if (!obj1.isInt()) {
+ goto err2;
+ }
+ maskWidth = obj1.getInt();
+ obj1.free();
+ maskDict->lookup(const_cast<char*>("Height"), &obj1);
+ if (obj1.isNull()) {
+ obj1.free();
+ maskDict->lookup(const_cast<char*>("H"), &obj1);
+ }
+ if (!obj1.isInt()) {
+ goto err2;
+ }
+ maskHeight = obj1.getInt();
+ obj1.free();
+ maskDict->lookup(const_cast<char*>("BitsPerComponent"), &obj1);
+ if (obj1.isNull()) {
+ obj1.free();
+ maskDict->lookup(const_cast<char*>("BPC"), &obj1);
+ }
+ if (!obj1.isInt()) {
+ goto err2;
+ }
+ int maskBits = obj1.getInt();
+ obj1.free();
+ maskDict->lookup(const_cast<char*>("ColorSpace"), &obj1);
+ if (obj1.isNull()) {
+ obj1.free();
+ maskDict->lookup(const_cast<char*>("CS"), &obj1);
+ }
+ if (obj1.isName()) {
+ res->lookupColorSpace(obj1.getName(), &obj2);
+ if (!obj2.isNull()) {
+ obj1.free();
+ obj1 = obj2;
+ } else {
+ obj2.free();
+ }
+ }
+#if defined(POPPLER_NEW_COLOR_SPACE_API) || defined(POPPLER_NEW_ERRORAPI)
+ GfxColorSpace *maskColorSpace = GfxColorSpace::parse(&obj1, NULL);
+#else
+ GfxColorSpace *maskColorSpace = GfxColorSpace::parse(&obj1);
+#endif
+ obj1.free();
+ if (!maskColorSpace || maskColorSpace->getMode() != csDeviceGray) {
+ goto err1;
+ }
+ maskDict->lookup(const_cast<char*>("Decode"), &obj1);
+ if (obj1.isNull()) {
+ obj1.free();
+ maskDict->lookup(const_cast<char*>("D"), &obj1);
+ }
+ maskColorMap = new GfxImageColorMap(maskBits, &obj1, maskColorSpace);
+ obj1.free();
+ if (!maskColorMap->isOk()) {
+ delete maskColorMap;
+ goto err1;
+ }
+ //~ handle the Matte entry
+ haveSoftMask = gTrue;
+ } else if (maskObj.isArray()) {
+ // color key mask
+ int i;
+ for (i = 0; i < maskObj.arrayGetLength() && i < 2*gfxColorMaxComps; ++i) {
+ maskObj.arrayGet(i, &obj1);
+ maskColors[i] = obj1.getInt();
+ obj1.free();
+ }
+ haveColorKeyMask = gTrue;
+ } else if (maskObj.isStream()) {
+ // explicit mask
+ if (inlineImg) {
+ goto err1;
+ }
+ maskStr = maskObj.getStream();
+ maskDict = maskObj.streamGetDict();
+ maskDict->lookup(const_cast<char*>("Width"), &obj1);
+ if (obj1.isNull()) {
+ obj1.free();
+ maskDict->lookup(const_cast<char*>("W"), &obj1);
+ }
+ if (!obj1.isInt()) {
+ goto err2;
+ }
+ maskWidth = obj1.getInt();
+ obj1.free();
+ maskDict->lookup(const_cast<char*>("Height"), &obj1);
+ if (obj1.isNull()) {
+ obj1.free();
+ maskDict->lookup(const_cast<char*>("H"), &obj1);
+ }
+ if (!obj1.isInt()) {
+ goto err2;
+ }
+ maskHeight = obj1.getInt();
+ obj1.free();
+ maskDict->lookup(const_cast<char*>("ImageMask"), &obj1);
+ if (obj1.isNull()) {
+ obj1.free();
+ maskDict->lookup(const_cast<char*>("IM"), &obj1);
+ }
+ if (!obj1.isBool() || !obj1.getBool()) {
+ goto err2;
+ }
+ obj1.free();
+ maskInvert = gFalse;
+ maskDict->lookup(const_cast<char*>("Decode"), &obj1);
+ if (obj1.isNull()) {
+ obj1.free();
+ maskDict->lookup(const_cast<char*>("D"), &obj1);
+ }
+ if (obj1.isArray()) {
+ obj1.arrayGet(0, &obj2);
+ if (obj2.isInt() && obj2.getInt() == 1) {
+ maskInvert = gTrue;
+ }
+ obj2.free();
+ } else if (!obj1.isNull()) {
+ goto err2;
+ }
+ obj1.free();
+ haveExplicitMask = gTrue;
+ }
+
+ // draw it
+ if (haveSoftMask) {
+ builder->addSoftMaskedImage(state, str, width, height, colorMap,
maskStr, maskWidth, maskHeight, maskColorMap);
- delete maskColorMap;
- } else if (haveExplicitMask) {
- builder->addMaskedImage(state, str, width, height, colorMap,
+ delete maskColorMap;
+ } else if (haveExplicitMask) {
+ builder->addMaskedImage(state, str, width, height, colorMap,
maskStr, maskWidth, maskHeight, maskInvert);
- } else {
- builder->addImage(state, str, width, height, colorMap,
- haveColorKeyMask ? maskColors : (int *)NULL);
+ } else {
+ builder->addImage(state, str, width, height, colorMap,
+ haveColorKeyMask ? maskColors : static_cast<int *>(NULL));
+ }
+ delete colorMap;
+
+ maskObj.free();
+ smaskObj.free();
}
- delete colorMap;
- maskObj.free();
- smaskObj.free();
- }
-
- return;
+ return;
err2:
- obj1.free();
+ obj1.free();
err1:
#ifdef POPPLER_NEW_ERRORAPI
- error(errSyntaxError, getPos(), "Bad image parameters");
+ error(errSyntaxError, getPos(), "Bad image parameters");
#else
- error(getPos(), const_cast<char*>("Bad image parameters"));
+ error(getPos(), const_cast<char*>("Bad image parameters"));
#endif
}
diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp
index e3d0a80ac..75849f6cc 100644
--- a/src/extension/internal/pdfinput/svg-builder.cpp
+++ b/src/extension/internal/pdfinput/svg-builder.cpp
@@ -629,7 +629,6 @@ gchar *SvgBuilder::_createPattern(GfxPattern *pattern, GfxState *state, bool is_
if ( pattern->getType() == 2 ) { // Shading pattern
GfxShadingPattern *shading_pattern = static_cast<GfxShadingPattern *>(pattern);
double *ptm;
- double ittm[6]; // invert ttm
double m[6] = {1, 0, 0, 1, 0, 0};
double det;
@@ -638,6 +637,7 @@ gchar *SvgBuilder::_createPattern(GfxPattern *pattern, GfxState *state, bool is_
ptm = shading_pattern->getMatrix();
det = ttm[0] * ttm[3] - ttm[1] * ttm[2];
if (det) {
+ double ittm[6]; // invert ttm
ittm[0] = ttm[3] / det;
ittm[1] = -ttm[1] / det;
ittm[2] = -ttm[2] / det;
@@ -1208,7 +1208,7 @@ void SvgBuilder::updateTextMatrix(GfxState *state) {
*/
void SvgBuilder::_flushText() {
// Ignore empty strings
- if ( _glyphs.size() < 1 ) {
+ if ( _glyphs.empty()) {
_glyphs.clear();
return;
}
@@ -1300,7 +1300,8 @@ void SvgBuilder::_flushText() {
sp_repr_css_set_property(glyph.style, "-inkscape-font-specification", properFontSpec.c_str());
// Set style and unref SPCSSAttr if it won't be needed anymore
- sp_repr_css_change(tspan_node, glyph.style, "style");
+ // assume all <tspan> nodes in a <text> node share the same style
+ sp_repr_css_change(text_node, glyph.style, "style");
if ( glyph.style_changed && i != _glyphs.begin() ) { // Free previous style
sp_repr_css_attr_unref((*prev_iterator).style);
}
diff --git a/src/extension/internal/pdfinput/svg-builder.h b/src/extension/internal/pdfinput/svg-builder.h
index a550565d6..610822959 100644
--- a/src/extension/internal/pdfinput/svg-builder.h
+++ b/src/extension/internal/pdfinput/svg-builder.h
@@ -19,7 +19,7 @@
class SPDocument;
namespace Inkscape {
namespace XML {
- class Document;
+ struct Document;
class Node;
}
}
@@ -31,10 +31,10 @@ namespace Inkscape {
#include "CharTypes.h"
class GooString;
class Function;
-struct GfxState;
-class GfxColor;
+class GfxState;
+struct GfxColor;
class GfxColorSpace;
-class GfxRGB;
+struct GfxRGB;
class GfxPath;
class GfxPattern;
class GfxTilingPattern;
diff --git a/src/extension/internal/svg.cpp b/src/extension/internal/svg.cpp
index 9b1098afd..8b272af60 100644
--- a/src/extension/internal/svg.cpp
+++ b/src/extension/internal/svg.cpp
@@ -44,7 +44,7 @@ using Inkscape::XML::Node;
-void pruneExtendedAttributes( Inkscape::XML::Node *repr )
+static void pruneExtendedAttributes( Inkscape::XML::Node *repr )
{
if (repr) {
if ( repr->type() == Inkscape::XML::ELEMENT_NODE ) {
diff --git a/src/extension/internal/vsd-input.cpp b/src/extension/internal/vsd-input.cpp
new file mode 100644
index 000000000..12e5150cb
--- /dev/null
+++ b/src/extension/internal/vsd-input.cpp
@@ -0,0 +1,332 @@
+/*
+ * This file came from libwpg as a source, their utility wpg2svg
+ * specifically. It has been modified to work as an Inkscape extension.
+ * The Inkscape extension code is covered by this copyright, but the
+ * rest is covered by the one bellow.
+ *
+ * Authors:
+ * Fridrich Strba (fridrich.strba@bluewin.ch)
+ *
+ * Copyright (C) 2012 Authors
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ *
+ */
+
+#include <stdio.h>
+#include "config.h"
+
+#include "vsd-input.h"
+
+#ifdef WITH_LIBVISIO
+
+#include <string>
+#include <cstring>
+
+#include <libvisio/libvisio.h>
+#include <libwpd-stream/libwpd-stream.h>
+
+#include <gtkmm/alignment.h>
+#include <gtkmm/comboboxtext.h>
+#include <gtkmm/drawingarea.h>
+#include <gtkmm/frame.h>
+#include <gtkmm/scale.h>
+
+#include "extension/system.h"
+#include "extension/input.h"
+#include "document.h"
+
+#include "document-private.h"
+#include "document-undo.h"
+#include "inkscape.h"
+
+#include "dialogs/dialog-events.h"
+#include <gtk/gtk.h>
+#include "ui/widget/spinbutton.h"
+#include "ui/widget/frame.h"
+#include <glibmm/i18n.h>
+
+#include <gdkmm/general.h>
+
+#include "svg-view.h"
+#include "svg-view-widget.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+
+
+class VsdImportDialog : public Gtk::Dialog {
+public:
+ VsdImportDialog(const std::vector<WPXString> &vec);
+ virtual ~VsdImportDialog();
+
+ bool showDialog();
+ unsigned getSelectedPage();
+ void getImportSettings(Inkscape::XML::Node *prefs);
+
+private:
+ void _setPreviewPage(unsigned page);
+
+ // Signal handlers
+#if !WITH_GTKMM_3_0
+ bool _onExposePreview(GdkEventExpose *event);
+#endif
+
+ void _onPageNumberChanged();
+
+ class Gtk::Button * cancelbutton;
+ class Gtk::Button * okbutton;
+ class Gtk::Label * _labelSelect;
+ class Inkscape::UI::Widget::SpinButton * _pageNumberSpin;
+ class Gtk::Label * _labelTotalPages;
+ class Gtk::VBox * vbox1;
+ class Gtk::VBox * vbox2;
+ class Gtk::Widget * _previewArea;
+
+ const std::vector<WPXString> &_vec; // Document to be imported
+ unsigned _current_page; // Current selected page
+ int _preview_width, _preview_height; // Size of the preview area
+};
+
+VsdImportDialog::VsdImportDialog(const std::vector<WPXString> &vec)
+ : _vec(vec), _current_page(1)
+{
+ int num_pages = _vec.size();
+ if ( num_pages <= 1 )
+ return;
+ cancelbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-cancel")));
+ okbutton = Gtk::manage(new class Gtk::Button(Gtk::StockID("gtk-ok")));
+ _labelSelect = Gtk::manage(new class Gtk::Label(_("Select page:")));
+
+ // Page number
+#if WITH_GTKMM_3_0
+ Glib::RefPtr<Gtk::Adjustment> _pageNumberSpin_adj = Gtk::Adjustment::create(1, 1, _vec.size(), 1, 10, 0);
+ _pageNumberSpin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(_pageNumberSpin_adj, 1, 1));
+#else
+ Gtk::Adjustment *_pageNumberSpin_adj = Gtk::manage(
+ new class Gtk::Adjustment(1, 1, _vec.size(), 1, 10, 0));
+ _pageNumberSpin = Gtk::manage(new class Inkscape::UI::Widget::SpinButton(*_pageNumberSpin_adj, 1, 1));
+#endif
+ _labelTotalPages = Gtk::manage(new class Gtk::Label());
+ gchar *label_text = g_strdup_printf(_("out of %i"), num_pages);
+ _labelTotalPages->set_label(label_text);
+ g_free(label_text);
+
+ vbox1 = Gtk::manage(new class Gtk::VBox(false, 4));
+ SPDocument *doc = SPDocument::createNewDocFromMem(_vec[0].cstr(), strlen(_vec[0].cstr()), 0);
+ _previewArea = Glib::wrap(sp_svg_view_widget_new(doc));
+
+ vbox2 = Gtk::manage(new class Gtk::VBox(false, 4));
+ cancelbutton->set_can_focus();
+ cancelbutton->set_can_default();
+ cancelbutton->set_relief(Gtk::RELIEF_NORMAL);
+ okbutton->set_can_focus();
+ okbutton->set_can_default();
+ okbutton->set_relief(Gtk::RELIEF_NORMAL);
+ this->get_action_area()->property_layout_style().set_value(Gtk::BUTTONBOX_END);
+ _labelSelect->set_line_wrap(false);
+ _labelSelect->set_use_markup(false);
+ _labelSelect->set_selectable(false);
+ _pageNumberSpin->set_can_focus();
+ _pageNumberSpin->set_update_policy(Gtk::UPDATE_ALWAYS);
+ _pageNumberSpin->set_numeric(true);
+ _pageNumberSpin->set_digits(0);
+ _pageNumberSpin->set_wrap(false);
+ _labelTotalPages->set_line_wrap(false);
+ _labelTotalPages->set_use_markup(false);
+ _labelTotalPages->set_selectable(false);
+ vbox2->pack_start(*_previewArea, Gtk::PACK_SHRINK, 0);
+ this->get_vbox()->set_homogeneous(false);
+ this->get_vbox()->set_spacing(0);
+ this->get_vbox()->pack_start(*vbox2);
+ this->set_title(_("Page Selector"));
+ this->set_modal(true);
+ sp_transientize(GTK_WIDGET(this->gobj())); //Make transient
+ this->property_window_position().set_value(Gtk::WIN_POS_NONE);
+ this->set_resizable(true);
+ this->property_destroy_with_parent().set_value(false);
+ this->get_action_area()->add(*_labelSelect);
+ this->add_action_widget(*_pageNumberSpin, -7);
+ this->get_action_area()->add(*_labelTotalPages);
+ this->add_action_widget(*cancelbutton, -6);
+ this->add_action_widget(*okbutton, -5);
+ cancelbutton->show();
+ okbutton->show();
+ _labelSelect->show();
+ _pageNumberSpin->show();
+ _labelTotalPages->show();
+ vbox1->show();
+ _previewArea->show();
+ vbox2->show();
+
+ // Connect signals
+ _pageNumberSpin_adj->signal_value_changed().connect(sigc::mem_fun(*this, &VsdImportDialog::_onPageNumberChanged));
+}
+
+VsdImportDialog::~VsdImportDialog() {}
+
+bool VsdImportDialog::showDialog()
+{
+ show();
+ gint b = run();
+ hide();
+ if ( b == Gtk::RESPONSE_OK ) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+}
+
+unsigned VsdImportDialog::getSelectedPage()
+{
+ return _current_page;
+}
+
+void VsdImportDialog::_onPageNumberChanged()
+{
+ unsigned page = static_cast<unsigned>(_pageNumberSpin->get_value_as_int());
+ _current_page = CLAMP(page, 1U, _vec.size());
+ _setPreviewPage(_current_page);
+}
+
+/**
+ * \brief Renders the given page's thumbnail
+ */
+void VsdImportDialog::_setPreviewPage(unsigned page)
+{
+ SPDocument *doc = SPDocument::createNewDocFromMem(_vec[page-1].cstr(), strlen(_vec[page-1].cstr()), 0);
+ Gtk::Widget * tmpPreviewArea = Glib::wrap(sp_svg_view_widget_new(doc));
+ std::swap(_previewArea, tmpPreviewArea);
+ if (tmpPreviewArea) {
+ _previewArea->set_size_request( tmpPreviewArea->get_width(), tmpPreviewArea->get_height() );
+ delete tmpPreviewArea;
+ }
+ vbox2->pack_start(*_previewArea, Gtk::PACK_SHRINK, 0);
+ _previewArea->show_now();
+}
+
+SPDocument *VsdInput::open(Inkscape::Extension::Input * /*mod*/, const gchar * uri)
+{
+ WPXFileStream input(uri);
+
+ if (!libvisio::VisioDocument::isSupported(&input)) {
+ return NULL;
+ }
+
+ libvisio::VSDStringVector output;
+ if (!libvisio::VisioDocument::generateSVG(&input, output)) {
+ return NULL;
+ }
+
+ if (output.empty()) {
+ return NULL;
+ }
+
+ std::vector<WPXString> tmpSVGOutput;
+ for (unsigned i=0; i<output.size(); ++i) {
+ WPXString tmpString("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n");
+ tmpString.append(output[i]);
+ tmpSVGOutput.push_back(tmpString);
+ }
+
+ unsigned page_num = 1;
+
+ // If only one page is present, import that one without bothering user
+ if (tmpSVGOutput.size() > 1) {
+ VsdImportDialog *dlg = 0;
+ if (inkscape_use_gui()) {
+ dlg = new VsdImportDialog(tmpSVGOutput);
+ if (!dlg->showDialog()) {
+ delete dlg;
+ return NULL;
+ }
+ }
+
+ // Get needed page
+ if (dlg) {
+ page_num = dlg->getSelectedPage();
+ if (page_num < 1)
+ page_num = 1;
+ if (page_num > tmpSVGOutput.size())
+ page_num = tmpSVGOutput.size();
+ }
+ }
+
+ SPDocument * doc = SPDocument::createNewDocFromMem(tmpSVGOutput[page_num-1].cstr(), strlen(tmpSVGOutput[page_num-1].cstr()), TRUE);
+ return doc;
+}
+
+#include "clear-n_.h"
+
+void VsdInput::init(void)
+{
+ /* VSD */
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("VSD Input") "</name>\n"
+ "<id>org.inkscape.input.vsd</id>\n"
+ "<input>\n"
+ "<extension>.vsd</extension>\n"
+ "<mimetype>application/vnd.visio</mimetype>\n"
+ "<filetypename>" N_("Microsoft Visio Diagram (*.vsd)") "</filetypename>\n"
+ "<filetypetooltip>" N_("File format used by Microsoft Visio 6 and later") "</filetypetooltip>\n"
+ "</input>\n"
+ "</inkscape-extension>", new VsdInput());
+
+ /* VDX */
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("VDX Input") "</name>\n"
+ "<id>org.inkscape.input.vdx</id>\n"
+ "<input>\n"
+ "<extension>.vdx</extension>\n"
+ "<mimetype>application/vnd.visio</mimetype>\n"
+ "<filetypename>" N_("Microsoft Visio XML Diagram (*.vdx)") "</filetypename>\n"
+ "<filetypetooltip>" N_("File format used by Microsoft Visio 2010 and later") "</filetypetooltip>\n"
+ "</input>\n"
+ "</inkscape-extension>", new VsdInput());
+
+ /* VSDM */
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("VSDM Input") "</name>\n"
+ "<id>org.inkscape.input.vsdm</id>\n"
+ "<input>\n"
+ "<extension>.vsdm</extension>\n"
+ "<mimetype>application/vnd.visio</mimetype>\n"
+ "<filetypename>" N_("Microsoft Visio 2013 drawing (*.vsdm)") "</filetypename>\n"
+ "<filetypetooltip>" N_("File format used by Microsoft Visio 2013 and later") "</filetypetooltip>\n"
+ "</input>\n"
+ "</inkscape-extension>", new VsdInput());
+
+ /* VSDX */
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("VSDX Input") "</name>\n"
+ "<id>org.inkscape.input.vsdx</id>\n"
+ "<input>\n"
+ "<extension>.vsdx</extension>\n"
+ "<mimetype>application/vnd.visio</mimetype>\n"
+ "<filetypename>" N_("Microsoft Visio 2013 drawing (*.vsdx)") "</filetypename>\n"
+ "<filetypetooltip>" N_("File format used by Microsoft Visio 2013 and later") "</filetypetooltip>\n"
+ "</input>\n"
+ "</inkscape-extension>", new VsdInput());
+
+ return;
+
+} // init
+
+} } } /* namespace Inkscape, Extension, Implementation */
+#endif /* WITH_LIBVISIO */
+
+/*
+ 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=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/extension/internal/vsd-input.h b/src/extension/internal/vsd-input.h
new file mode 100644
index 000000000..acc52debf
--- /dev/null
+++ b/src/extension/internal/vsd-input.h
@@ -0,0 +1,54 @@
+/*
+ * This code abstracts the libwpg interfaces into the Inkscape
+ * input extension interface.
+ *
+ * Authors:
+ * Fridrich Strba (fridrich.strba@bluewin.ch)
+ *
+ * Copyright (C) 2012 Authors
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#ifndef __EXTENSION_INTERNAL_VSDOUTPUT_H__
+#define __EXTENSION_INTERNAL_VSDOUTPUT_H__
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#ifdef WITH_LIBVISIO
+
+#include <gtkmm/dialog.h>
+
+#include "../implementation/implementation.h"
+
+namespace Inkscape {
+namespace Extension {
+namespace Internal {
+
+class VsdInput : public Inkscape::Extension::Implementation::Implementation {
+ VsdInput () { };
+public:
+ SPDocument *open( Inkscape::Extension::Input *mod,
+ const gchar *uri );
+ static void init( void );
+
+};
+
+} } } /* namespace Inkscape, Extension, Implementation */
+
+#endif /* WITH_LIBVISIO */
+#endif /* __EXTENSION_INTERNAL_VSDOUTPUT_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=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/extension/output.h b/src/extension/output.h
index 5f6785b8b..c5b1beb45 100644
--- a/src/extension/output.h
+++ b/src/extension/output.h
@@ -15,7 +15,7 @@
#include <gtk/gtk.h>
#include "extension.h"
-struct SPDocument;
+class SPDocument;
namespace Inkscape {
namespace Extension {
diff --git a/src/extension/param/enum.cpp b/src/extension/param/enum.cpp
index b1968a4d6..18a73beb6 100644
--- a/src/extension/param/enum.cpp
+++ b/src/extension/param/enum.cpp
@@ -242,11 +242,7 @@ Gtk::Widget *ParamComboBox::get_widget(SPDocument * doc, Inkscape::XML::Node * n
for (GSList * list = choices; list != NULL; list = g_slist_next(list)) {
enumentry * entr = reinterpret_cast<enumentry *>(list->data);
Glib::ustring text = entr->guitext;
-#if WITH_GTKMM_2_24
combo->append(text);
-#else
- combo->append_text(text);
-#endif
if ( _value && !entr->value.compare(_value) ) {
settext = entr->guitext;
diff --git a/src/extension/param/float.cpp b/src/extension/param/float.cpp
index b9ffe68d2..81508f6c0 100644
--- a/src/extension/param/float.cpp
+++ b/src/extension/param/float.cpp
@@ -14,6 +14,7 @@
#include <gtkmm/box.h>
#include <gtkmm/scale.h>
#include "ui/widget/spinbutton.h"
+#include "ui/widget/spin-scale.h"
#include "xml/node.h"
#include "extension/extension.h"
@@ -175,9 +176,6 @@ Gtk::Widget * ParamFloat::get_widget(SPDocument * doc, Inkscape::XML::Node * nod
}
Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4));
- Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_START));
- label->show();
- hbox->pack_start(*label, true, true, _indent);
#if WITH_GTKMM_3_0
ParamFloatAdjustment * pfa = new ParamFloatAdjustment(this, doc, node, changeSignal);
@@ -187,24 +185,27 @@ Gtk::Widget * ParamFloat::get_widget(SPDocument * doc, Inkscape::XML::Node * nod
#endif
if (_mode == FULL) {
-#if WITH_GTKMM_3_0
- Gtk::HScale * scale = Gtk::manage(new Gtk::HScale(fadjust));
-#else
- Gtk::HScale * scale = Gtk::manage(new Gtk::HScale(*fadjust));
-#endif
- scale->set_draw_value(false);
- scale->set_size_request(200, -1);
+
+ UI::Widget::SpinScale *scale = new UI::Widget::SpinScale(_(_text), fadjust, _precision);
+ scale->set_size_request(400, -1);
scale->show();
hbox->pack_start(*scale, false, false);
+
}
+ else if (_mode == MINIMAL) {
+
+ Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_START));
+ label->show();
+ hbox->pack_start(*label, true, true, _indent);
#if WITH_GTKMM_3_0
Inkscape::UI::Widget::SpinButton * spin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(fadjust, 0.1, _precision));
#else
Inkscape::UI::Widget::SpinButton * spin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(*fadjust, 0.1, _precision));
#endif
- spin->show();
- hbox->pack_start(*spin, false, false);
+ spin->show();
+ hbox->pack_start(*spin, false, false);
+ }
hbox->show();
diff --git a/src/extension/param/int.cpp b/src/extension/param/int.cpp
index 7cb930f50..c286018fd 100644
--- a/src/extension/param/int.cpp
+++ b/src/extension/param/int.cpp
@@ -14,6 +14,7 @@
#include <gtkmm/box.h>
#include <gtkmm/scale.h>
#include "ui/widget/spinbutton.h"
+#include "ui/widget/spin-scale.h"
#include "xml/node.h"
#include "extension/extension.h"
@@ -156,9 +157,7 @@ ParamInt::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal
}
Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4));
- Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_START));
- label->show();
- hbox->pack_start(*label, true, true, _indent);
+
#if WITH_GTKMM_3_0
ParamIntAdjustment * pia = new ParamIntAdjustment(this, doc, node, changeSignal);
@@ -168,24 +167,26 @@ ParamInt::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal
#endif
if (_mode == FULL) {
-#if WITH_GTKMM_3_0
- Gtk::HScale * scale = Gtk::manage(new Gtk::HScale(fadjust));
-#else
- Gtk::HScale * scale = Gtk::manage(new Gtk::HScale(*fadjust));
-#endif
- scale->set_draw_value(false);
- scale->set_size_request(200, -1);
+
+ UI::Widget::SpinScale *scale = new UI::Widget::SpinScale(_(_text), fadjust, 0);
+ scale->set_size_request(400, -1);
scale->show();
hbox->pack_start(*scale, false, false);
}
+ else if (_mode == MINIMAL) {
+ Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_START));
+ label->show();
+ hbox->pack_start(*label, true, true, _indent);
+
#if WITH_GTKMM_3_0
Inkscape::UI::Widget::SpinButton * spin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(fadjust, 1.0, 0));
#else
Inkscape::UI::Widget::SpinButton * spin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(*fadjust, 1.0, 0));
#endif
- spin->show();
- hbox->pack_start(*spin, false, false);
+ spin->show();
+ hbox->pack_start(*spin, false, false);
+ }
hbox->show();
diff --git a/src/extension/param/notebook.cpp b/src/extension/param/notebook.cpp
index b4d4cbd16..85cb5d04c 100644
--- a/src/extension/param/notebook.cpp
+++ b/src/extension/param/notebook.cpp
@@ -206,14 +206,16 @@ Gtk::Widget * ParamNotebookPage::get_widget(SPDocument * doc, Inkscape::XML::Nod
for (GSList * list = parameters; list != NULL; list = g_slist_next(list)) {
Parameter * param = reinterpret_cast<Parameter *>(list->data);
Gtk::Widget * widg = param->get_widget(doc, node, changeSignal);
- gchar const * tip = param->get_tooltip();
-// printf("Tip: '%s'\n", tip);
- vbox->pack_start(*widg, false, false, 2);
- if (tip) {
- widg->set_tooltip_text(tip);
- } else {
- widg->set_tooltip_text("");
- widg->set_has_tooltip(false);
+ if (widg) {
+ gchar const * tip = param->get_tooltip();
+ // printf("Tip: '%s'\n", tip);
+ vbox->pack_start(*widg, false, false, 2);
+ if (tip) {
+ widg->set_tooltip_text(tip);
+ } else {
+ widg->set_tooltip_text("");
+ widg->set_has_tooltip(false);
+ }
}
}
diff --git a/src/extension/param/radiobutton.cpp b/src/extension/param/radiobutton.cpp
index 5b5e179d2..921c322b6 100644
--- a/src/extension/param/radiobutton.cpp
+++ b/src/extension/param/radiobutton.cpp
@@ -305,11 +305,7 @@ Gtk::Widget * ParamRadioButton::get_widget(SPDocument * doc, Inkscape::XML::Node
switch ( _mode ) {
case MINIMAL:
{
-#if WITH_GTKMM_2_24
cbt->append(*text);
-#else
- cbt->append_text(*text);
-#endif
if (!entr->value->compare(_value)) {
cbt->set_active_text(*text);
comboSet = true;
diff --git a/src/extension/param/string.cpp b/src/extension/param/string.cpp
index 2020fb24d..4e525ff73 100644
--- a/src/extension/param/string.cpp
+++ b/src/extension/param/string.cpp
@@ -10,11 +10,12 @@
# include "config.h"
#endif
-#include <glibmm/value.h>
#include <gtkmm/adjustment.h>
#include <gtkmm/box.h>
#include <gtkmm/spinbutton.h>
+#include <glibmm/value.h>
+
#include "xml/node.h"
#include "extension/extension.h"
#include "string.h"
diff --git a/src/extension/prefdialog.cpp b/src/extension/prefdialog.cpp
index 761126bd5..f3c6508af 100644
--- a/src/extension/prefdialog.cpp
+++ b/src/extension/prefdialog.cpp
@@ -32,13 +32,13 @@ namespace Extension {
/** \brief Creates a new preference dialog for extension preferences
- \param name Name of the Extension who's dialog this is
+ \param name Name of the Extension whose dialog this is
\param help The help string for the extension (NULL if none)
\param controls The extension specific widgets in the dialog
This function initializes the dialog with the name of the extension
in the title. It adds a few buttons and sets up handlers for
- them. It also places the passed in widgets into the dialog.
+ them. It also places the passed-in widgets into the dialog.
*/
PrefDialog::PrefDialog (Glib::ustring name, gchar const * help, Gtk::Widget * controls, Effect * effect) :
#if WITH_GTKMM_3_0
@@ -67,7 +67,12 @@ PrefDialog::PrefDialog (Glib::ustring name, gchar const * help, Gtk::Widget * co
hbox->pack_start(*controls, true, true, 6);
hbox->show();
+
+#if WITH_GTKMM_3_0
+ this->get_content_area()->pack_start(*hbox, true, true, 6);
+#else
this->get_vbox()->pack_start(*hbox, true, true, 6);
+#endif
/*
Gtk::Button * help_button = add_button(Gtk::Stock::HELP, Gtk::RESPONSE_HELP);
@@ -88,32 +93,50 @@ PrefDialog::PrefDialog (Glib::ustring name, gchar const * help, Gtk::Widget * co
_param_preview = Parameter::make(doc->root(), _effect);
}
+#if WITH_GTKMM_3_0
+ Gtk::Separator * sep = Gtk::manage(new Gtk::Separator());
+#else
Gtk::HSeparator * sep = Gtk::manage(new Gtk::HSeparator());
+#endif
+
sep->show();
+
+#if WITH_GTKMM_3_0
+ this->get_content_area()->pack_start(*sep, true, true, 4);
+#else
this->get_vbox()->pack_start(*sep, true, true, 4);
+#endif
hbox = Gtk::manage(new Gtk::HBox());
_button_preview = _param_preview->get_widget(NULL, NULL, &_signal_preview);
_button_preview->show();
hbox->pack_start(*_button_preview, true, true,6);
hbox->show();
+
+#if WITH_GTKMM_3_0
+ this->get_content_area()->pack_start(*hbox, true, true, 6);
+#else
this->get_vbox()->pack_start(*hbox, true, true, 6);
+#endif
Gtk::Box * hbox = dynamic_cast<Gtk::Box *>(_button_preview);
if (hbox != NULL) {
#if WITH_GTKMM_3_0
- Gtk::Widget * back = hbox->get_children().back();
+ _checkbox_preview = dynamic_cast<Gtk::CheckButton *>(hbox->get_children().front());
#else
- Gtk::Widget * back = hbox->children().back().get_widget();
+ _checkbox_preview = dynamic_cast<Gtk::CheckButton *>(hbox->children().back().get_widget());
#endif
- Gtk::CheckButton * cb = dynamic_cast<Gtk::CheckButton *>(back);
- _checkbox_preview = cb;
}
preview_toggle();
_signal_preview.connect(sigc::mem_fun(this, &PrefDialog::preview_toggle));
}
+ // Set window modality for effects that don't use live preview
+ if (_effect != NULL && _effect->no_live_preview) {
+ set_modal(false);
+ }
+
GtkWidget *dlg = GTK_WIDGET(gobj());
sp_transientize(dlg);
diff --git a/src/extension/prefdialog.h b/src/extension/prefdialog.h
index 943273623..e1999791f 100644
--- a/src/extension/prefdialog.h
+++ b/src/extension/prefdialog.h
@@ -10,8 +10,8 @@
#ifndef INKSCAPE_EXTENSION_DIALOG_H__
#define INKSCAPE_EXTENSION_DIALOG_H__
-#include <glibmm/value.h>
#include <gtkmm/dialog.h>
+#include <glibmm/value.h>
#include <glibmm/ustring.h>
diff --git a/src/extension/script/InkscapeScript.h b/src/extension/script/InkscapeScript.h
index 2ebeb1b19..8d6346582 100644
--- a/src/extension/script/InkscapeScript.h
+++ b/src/extension/script/InkscapeScript.h
@@ -12,7 +12,9 @@
#include "config.h"
-#include <glibmm.h>
+namespace Glib {
+class ustring;
+}
namespace Inkscape
{
diff --git a/src/extension/system.cpp b/src/extension/system.cpp
index fc20095c5..f7fd48b3f 100644
--- a/src/extension/system.cpp
+++ b/src/extension/system.cpp
@@ -21,6 +21,8 @@
#endif
#include <interface.h>
+#include <unistd.h>
+#include <glibmm/miscutils.h>
#include "system.h"
#include "preferences.h"
@@ -68,34 +70,6 @@ static Extension *build_from_reprdoc(Inkscape::XML::Document *doc, Implementatio
*/
SPDocument *open(Extension *key, gchar const *filename)
{
- // Convert to absolute pathname to tolerate chdir().
- bool relpath = (filename[0] != '/');
-#ifdef WIN32
- relpath &= (filename[0] != '\\') && !(isalpha(filename[0]) && (filename[1] == ':'));
-#endif
-
- // Do not consider an URI as a relative path.
- if (relpath) {
- gchar const * cp = filename;
-
- while (isalpha(*cp) || isdigit(*cp) || *cp == '+' || *cp == '-' || *cp == '.')
- cp++;
-
- relpath = *cp != ':' || cp[1] != '/' || cp[2] != '/';
- }
-
- if (relpath) {
- gchar * curdir = NULL;
-#ifndef WIN32
- curdir = getcwd(NULL, 0);
-#else
- curdir = _getcwd(NULL, 0);
-#endif
-
- filename = g_build_filename(curdir, filename, NULL);
- free(curdir);
- }
-
Input *imod = NULL;
if (key == NULL) {
@@ -137,13 +111,11 @@ SPDocument *open(Extension *key, gchar const *filename)
}
if (!imod->prefs(filename)) {
- if (relpath){
- free((void *) filename);
- }
return NULL;
}
SPDocument *doc = imod->open(filename);
+
if (!doc) {
throw Input::open_failed();
}
@@ -161,9 +133,6 @@ SPDocument *open(Extension *key, gchar const *filename)
imod->set_gui(true);
}
- if (relpath){
- free((void *) filename);
- }
return doc;
}
@@ -311,10 +280,9 @@ save(Extension *key, SPDocument *doc, gchar const *filename, bool setextension,
// remember attributes in case this is an unofficial save and/or overwrite fails
gchar *saved_uri = g_strdup(doc->getURI());
- bool saved_modified = false;
gchar *saved_output_extension = NULL;
gchar *saved_dataloss = NULL;
- saved_modified = doc->isModifiedSinceSave();
+ bool saved_modified = doc->isModifiedSinceSave();
saved_output_extension = g_strdup(get_file_save_extension(save_method).c_str());
saved_dataloss = g_strdup(repr->attribute("inkscape:dataloss"));
if (official) {
diff --git a/src/extension/timer.cpp b/src/extension/timer.cpp
index 3941ddcfc..e4e8632d2 100644
--- a/src/extension/timer.cpp
+++ b/src/extension/timer.cpp
@@ -10,7 +10,7 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-
+#include <glibmm/main.h>
#include "extension.h"
#include "timer.h"