diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/attribute-rel-css.cpp | 27 | ||||
| -rw-r--r-- | src/attribute-rel-css.h | 2 | ||||
| -rw-r--r-- | src/attribute-rel-svg.cpp | 10 | ||||
| -rw-r--r-- | src/attribute-rel-svg.h | 1 |
4 files changed, 28 insertions, 12 deletions
diff --git a/src/attribute-rel-css.cpp b/src/attribute-rel-css.cpp index b014aeb77..b45382b75 100644 --- a/src/attribute-rel-css.cpp +++ b/src/attribute-rel-css.cpp @@ -27,6 +27,8 @@ #include "preferences.h" SPAttributeRelCSS * SPAttributeRelCSS::instance = NULL; +bool SPAttributeRelCSS::foundFileProp = false; +bool SPAttributeRelCSS::foundFileDefault = false; /* * This function checks whether an element -> CSS property pair @@ -38,6 +40,9 @@ bool SPAttributeRelCSS::findIfValid(Glib::ustring property, Glib::ustring elemen SPAttributeRelCSS::instance = new SPAttributeRelCSS(); } + // Always valid if data file not found! + if( !foundFileProp ) return true; + // Strip of "svg:" from the element's name Glib::ustring temp = element; if ( temp.find("svg:") != std::string::npos ) { @@ -73,6 +78,9 @@ bool SPAttributeRelCSS::findIfDefault(Glib::ustring property, Glib::ustring valu SPAttributeRelCSS::instance = new SPAttributeRelCSS(); } + // Always false if data file not found! + if( !foundFileDefault ) return false; + if( instance->defaultValuesOfProps[property] == value) { return true; } else { @@ -89,6 +97,9 @@ bool SPAttributeRelCSS::findIfInherit(Glib::ustring property) SPAttributeRelCSS::instance = new SPAttributeRelCSS(); } + // Always false if data file not found! + if( !foundFileDefault ) return false; + return instance->inheritProps[property]; } @@ -101,6 +112,9 @@ bool SPAttributeRelCSS::findIfProperty(Glib::ustring property) SPAttributeRelCSS::instance = new SPAttributeRelCSS(); } + // Always true if data file not found! + if( !foundFileProp ) return true; + return ( instance->defaultValuesOfProps.find( property ) != instance->defaultValuesOfProps.end() ); } @@ -112,10 +126,8 @@ SPAttributeRelCSS::SPAttributeRelCSS() filepath += "/cssprops"; // Try and load data from filepath - if (!readDataFromFileIn(filepath, SPAttributeRelCSS::prop_element_pair)) { - // Set default preference for CSS property checking to ignore - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setInt("/options/svgoutput/incorrect_style_properties", 3); + if (readDataFromFileIn(filepath, SPAttributeRelCSS::prop_element_pair)) { + foundFileProp = true; } // Read data from standard path @@ -123,11 +135,10 @@ SPAttributeRelCSS::SPAttributeRelCSS() filepath += "/css_defaults"; // Try and load data from filepath - if (!readDataFromFileIn(filepath, SPAttributeRelCSS::prop_defValue_pair)) { - // Set default preference for CSS defaults checking to ignore - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setInt("/options/svgoutput/style_defaults", 3); + if (readDataFromFileIn(filepath, SPAttributeRelCSS::prop_defValue_pair)) { + foundFileDefault = true; } + } bool SPAttributeRelCSS::readDataFromFileIn(Glib::ustring fileName, storageType type) diff --git a/src/attribute-rel-css.h b/src/attribute-rel-css.h index b5077f8a0..5f3aaf253 100644 --- a/src/attribute-rel-css.h +++ b/src/attribute-rel-css.h @@ -43,6 +43,8 @@ private: prop_defValue_pair }; static SPAttributeRelCSS *instance; + static bool foundFileProp; + static bool foundFileDefault; hashList propertiesOfElements; // Data structure to store CSS property and default value pair diff --git a/src/attribute-rel-svg.cpp b/src/attribute-rel-svg.cpp index 3f5ce9395..80d924f80 100644 --- a/src/attribute-rel-svg.cpp +++ b/src/attribute-rel-svg.cpp @@ -26,6 +26,7 @@ #include "preferences.h" SPAttributeRelSVG * SPAttributeRelSVG::instance = NULL; +bool SPAttributeRelSVG::foundFile = false; /* * This functions checks whether an element -> attribute pair is allowed or not @@ -36,6 +37,9 @@ bool SPAttributeRelSVG::findIfValid(Glib::ustring attribute, Glib::ustring eleme SPAttributeRelSVG::instance = new SPAttributeRelSVG(); } + // Always valid if data file not found! + if( !foundFile ) return true; + // Strip of "svg:" from the element's name Glib::ustring temp = element; if ( temp.find("svg:") != std::string::npos ) { @@ -75,16 +79,14 @@ SPAttributeRelSVG::SPAttributeRelSVG() f.open(filepath.c_str(), std::ios::in); if (!f.is_open()) { - // Set the default preference of attribute checking to ignore - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setInt("/options/svgoutput/incorrect_attributes", 3); - // Display warning for file not open g_warning("Could not open the data file for XML attribute-element map construction: %s", filepath.c_str()); f.close(); return ; } + foundFile = true; + while (!f.eof()){ std::stringstream ss; std::string s; diff --git a/src/attribute-rel-svg.h b/src/attribute-rel-svg.h index f0ba314b6..74c6d3b60 100644 --- a/src/attribute-rel-svg.h +++ b/src/attribute-rel-svg.h @@ -31,6 +31,7 @@ private: private: static SPAttributeRelSVG *instance; + static bool foundFile; hashList attributesOfElements; }; |
