summaryrefslogtreecommitdiffstats
path: root/clang_format_diff
blob: ae35ae8e8737fee4ed528a5483a7aaad03d8504a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
--- src/ui/dialog/selectordialog.cpp	(before formatting)
+++ src/ui/dialog/selectordialog.cpp	(after formatting)
@@ -28,8 +28,8 @@
 #include <glibmm/i18n.h>
 #include <glibmm/regex.h>
 
+#include <map>
 #include <regex>
-#include <map>
 #include <utility>
 
 //#define DEBUG_SELECTORDIALOG
@@ -43,9 +43,12 @@
  * This macro is used to remove spaces around selectors or any strings when
  * parsing is done to update XML style element or row labels in this dialog.
  */
-#define REMOVE_SPACES(x) x.erase(0, x.find_first_not_of(' ')); \
-    if(x.size() && x[0] == ',') x.erase(0, 1); \
-    if(x.size() && x[x.size()-1] == ',') x.erase(x.size()-1, 1); \
+#define REMOVE_SPACES(x)                                                                                               \
+    x.erase(0, x.find_first_not_of(' '));                                                                              \
+    if (x.size() && x[0] == ',')                                                                                       \
+        x.erase(0, 1);                                                                                                 \
+    if (x.size() && x[x.size() - 1] == ',')                                                                            \
+        x.erase(x.size() - 1, 1);                                                                                      \
     x.erase(x.find_last_not_of(' ') + 1);
 
 namespace Inkscape {
@@ -183,19 +186,17 @@
     const_iterator iter = unconstThis->get_iter(path);
     if (iter) {
         Gtk::TreeModel::Row row = *iter;
-        bool is_draggable =
-            row[_selectordialog->_mColumns._colType] == SELECTOR;
+        bool is_draggable = row[_selectordialog->_mColumns._colType] == SELECTOR;
         return is_draggable;
     }
     return Gtk::TreeStore::row_draggable_vfunc(path);
 }
 
-void
-SelectorDialog::fixCSSSelectors(Glib::ustring &selector)
+void SelectorDialog::fixCSSSelectors(Glib::ustring &selector)
 {
     REMOVE_SPACES(selector);
-    Glib::ustring my_selector = selector + " {";  // Parsing fails sometimes without '{'. Fix me
-    CRSelector *cr_selector = cr_selector_parse_from_buf ((guchar*)my_selector.c_str(), CR_UTF_8);
+    Glib::ustring my_selector = selector + " {"; // Parsing fails sometimes without '{'. Fix me
+    CRSelector *cr_selector = cr_selector_parse_from_buf((guchar *)my_selector.c_str(), CR_UTF_8);
     selector = Glib::ustring("");
     CRSelector const *cur = nullptr;
     for (cur = cr_selector; cur; cur = cur->next) {
@@ -221,7 +222,7 @@
             Glib::ustring tag = Glib::ustring("");
             if (toparse[0] != '.' && toparse[0] != '#') {
                 auto i = std::min(toparse.find("#"), toparse.find("."));
-                tag = toparse.substr(0,i);
+                tag = toparse.substr(0, i);
                 if (!SPAttributeRelSVG::isSVGElement(tag)) {
                     continue;
                 }
@@ -647,7 +648,7 @@
 
     _updating = false;
 }
-/* 
+/*
 void sp_get_selector_active(Glib::ustring &selector)
 {
     std::vector<Glib::ustring> tokensplus = Glib::Regex::split_simple("[ ]+", selector);
@@ -674,10 +675,9 @@
     }
 } */
 
-Glib::ustring
-sp_get_selector_classes(Glib::ustring selector)//, SelectorType selectortype,  Glib::ustring id = "")
-{
-    std::pair<Glib::ustring,Glib::ustring> result;
+Glib::ustring sp_get_selector_classes(Glib::ustring selector) //, SelectorType selectortype,  Glib::ustring id = "")
+{
+    std::pair<Glib::ustring, Glib::ustring> result;
     std::vector<Glib::ustring> tokensplus = Glib::Regex::split_simple("[ ]+", selector);
     selector = tokensplus[tokensplus.size() - 1];
     // Erase any comma/space
@@ -686,7 +686,7 @@
     selector = Glib::ustring("");
     if (toparse[0] != '.' && toparse[0] != '#') {
         auto i = std::min(toparse.find("#"), toparse.find("."));
-        Glib::ustring tag = toparse.substr(0,i);
+        Glib::ustring tag = toparse.substr(0, i);
         if (!SPAttributeRelSVG::isSVGElement(tag)) {
             return selector;
         }
@@ -705,13 +705,13 @@
     if (i != std::string::npos) {
         toparse.insert(i, "#");
         if (i) {
-            Glib::ustring post = toparse.substr(0,i);
-            Glib::ustring pre = toparse.substr(i, toparse.size()-i);
+            Glib::ustring post = toparse.substr(0, i);
+            Glib::ustring pre = toparse.substr(i, toparse.size() - i);
             toparse = pre + post;
         }
         auto k = toparse.find(".");
         if (k != std::string::npos) {
-            toparse = toparse.substr(k, toparse.size()-k);
+            toparse = toparse.substr(k, toparse.size() - k);
         }
     }
     return toparse;
@@ -727,16 +727,15 @@
     if (*row) {
         // Store list of selected elements on desktop (not to be confused with selector).
         _updating = true;
-        Inkscape::Selection* selection = getDesktop()->getSelection();
-        std::vector<SPObject *> toAddObjVec( selection->objects().begin(),
-                                        selection->objects().end() );
+        Inkscape::Selection *selection = getDesktop()->getSelection();
+        std::vector<SPObject *> toAddObjVec(selection->objects().begin(), selection->objects().end());
         Glib::ustring multiselector = row[_mColumns._colSelector];
         std::vector<SPObject *> objVec = _getObjVec(multiselector);
-        row[_mColumns._colObj]      = objVec;
+        row[_mColumns._colObj] = objVec;
         row[_mColumns._colExpand] = true;
         std::vector<Glib::ustring> tokens = Glib::Regex::split_simple("[,]+", multiselector);
         for (auto &obj : toAddObjVec) {
-            Glib::ustring id = (obj->getId()?obj->getId():"");
+            Glib::ustring id = (obj->getId() ? obj->getId() : "");
             for (auto tok : tokens) {
                 Glib::ustring clases = sp_get_selector_classes(tok);
                 if (!clases.empty()) {
@@ -770,7 +769,7 @@
             childrow[_mColumns._colObj] = std::vector<SPObject *>(1, obj);
             childrow[_mColumns._colProperties] = ""; // Unused
             childrow[_mColumns._colVisible] = true;  // Unused
-        }  
+        }
         objVec = _getObjVec(multiselector);
         row[_mColumns._colSelector] = multiselector;
         row[_mColumns._colObj] = objVec;
@@ -811,7 +810,7 @@
                 }
                 auto i = tok.find(row[_mColumns._colSelector]);
                 if (i == std::string::npos) {
-                    selector = selector.empty()? tok : selector + "," + tok;
+                    selector = selector.empty() ? tok : selector + "," + tok;
                 }
             }
             REMOVE_SPACES(selector);
@@ -821,8 +820,8 @@
             } else {
                 _store->erase(row);
                 parent[_mColumns._colSelector] = selector;
-                parent[_mColumns._colExpand]   = true;
-                parent[_mColumns._colObj]      = _getObjVec(selector);
+                parent[_mColumns._colExpand] = true;
+                parent[_mColumns._colObj] = _getObjVec(selector);
             }
         }
         _updating = false;
@@ -888,7 +887,7 @@
  * @param class: class to insert
  * Insert a class name into objects' 'class' attribute.
  */
-void SelectorDialog::_insertClass(const std::vector<SPObject *>& objVec, const Glib::ustring& className)
+void SelectorDialog::_insertClass(const std::vector<SPObject *> &objVec, const Glib::ustring &className)
 {
     for (auto& obj: objVec) {
         _insertClass(obj, className);
@@ -900,7 +899,7 @@
  * @param class: class to insert
  * Insert a class name into objects' 'class' attribute.
  */
-void SelectorDialog::_insertClass(SPObject * obj, const Glib::ustring& className) 
+void SelectorDialog::_insertClass(SPObject *obj, const Glib::ustring &className)
 {
     Glib::ustring classAttr = Glib::ustring("");
     if (obj->getRepr()->attribute("class")) {
@@ -912,7 +911,7 @@
     std::vector<Glib::ustring> tokensplus = Glib::Regex::split_simple("[\\s]+", classAttr);
     for (auto tok : tokens) {
         bool exist = false;
-        for (auto& tokenplus: tokensplus) {
+        for (auto &tokenplus : tokensplus) {
             if (tokenplus == tok) {
                 exist = true;
             }
@@ -929,9 +928,9 @@
  * @param class: class to insert
  * Insert a class name into objects' 'class' attribute.
  */
-void SelectorDialog::_removeClass(const std::vector<SPObject *>& objVec, const Glib::ustring& className, bool all)
-{
-    for (auto& obj: objVec) {
+void SelectorDialog::_removeClass(const std::vector<SPObject *> &objVec, const Glib::ustring &className, bool all)
+{
+    for (auto &obj : objVec) {
         _removeClass(obj, className, all);
     }
 }
@@ -941,7 +940,7 @@
  * @param class: class to insert
  * Insert a class name into objects' 'class' attribute.
  */
-void SelectorDialog::_removeClass(SPObject * obj, const Glib::ustring& className, bool all) //without "." 
+void SelectorDialog::_removeClass(SPObject *obj, const Glib::ustring &className, bool all) // without "."
 {
     if (obj->getRepr()->attribute("class")) {
         std::vector<Glib::ustring> tokens = Glib::Regex::split_simple("[.]+", className);
@@ -1028,9 +1027,7 @@
         sigc::bind<Gtk::Dialog *>(sigc::mem_fun(*this, &SelectorDialog::_closeDialog), textDialogPtr));
     textDialogPtr->get_content_area()->pack_start(*textEditPtr, Gtk::PACK_SHRINK);
 
-    Gtk::Label *textLabelPtr = manage ( new Gtk::Label(
-      _("Invalid CSS selector.")
-    ) );
+    Gtk::Label *textLabelPtr = manage(new Gtk::Label(_("Invalid CSS selector.")));
     textDialogPtr->get_content_area()->pack_start(*textLabelPtr, Gtk::PACK_SHRINK);
 
     /**
--- src/ui/dialog/selectordialog.h	(before formatting)
+++ src/ui/dialog/selectordialog.h	(after formatting)
@@ -59,18 +59,14 @@
 
     // Monitor all objects for addition/removal/attribute change
     class NodeWatcher;
-    enum SelectorType {
-        CLASS,
-        ID,
-        TAG
-    };
+    enum SelectorType { CLASS, ID, TAG };
     void fixCSSSelectors(Glib::ustring &selector);
     std::vector<SelectorDialog::NodeWatcher*> _nodeWatchers;
     void _nodeAdded(   Inkscape::XML::Node &repr );
     void _nodeRemoved( Inkscape::XML::Node &repr );
     void _nodeChanged( Inkscape::XML::Node &repr );
     // Data structure
-    enum coltype { OBJECT, SELECTOR};
+    enum coltype { OBJECT, SELECTOR };
     class ModelColumns : public Gtk::TreeModel::ColumnRecord {
     public:
         ModelColumns() {
@@ -138,10 +134,10 @@
     Glib::ustring _getIdList(std::vector<SPObject *>);
     std::vector<SPObject *> _getObjVec(Glib::ustring selector);
     void _insertClass(const std::vector<SPObject *>& objVec, const Glib::ustring& className);
-    void _insertClass(SPObject * obj, const Glib::ustring& className);
-    void _removeClass(const std::vector<SPObject *>& objVec, const Glib::ustring& className, bool all = false);
-    void _removeClass(SPObject * obj, const Glib::ustring& className, bool all = false);
-    
+    void _insertClass(SPObject *obj, const Glib::ustring &className);
+    void _removeClass(const std::vector<SPObject *> &objVec, const Glib::ustring &className, bool all = false);
+    void _removeClass(SPObject *obj, const Glib::ustring &className, bool all = false);
+
 
     void _selectObjects(int, int);
     // Variables