loleaflet/build/deps.js                       |    7 
 loleaflet/dist/images/lc_insertsymbol.png     |binary
 loleaflet/dist/loleaflet.css                  |   16 +
 loleaflet/dist/toolbar.css                    |    1 
 loleaflet/dist/toolbar/toolbar.js             |    6 
 loleaflet/src/control/Control.CharacterMap.js |  255 ++++++++++++++++++++++++++
 loleaflet/src/layer/tile/TileLayer.js         |   12 +
 7 files changed, 296 insertions(+), 1 deletion(-)

New commits:
commit 36474b21a647a728a6f53caab4ec7c34913ab0ae
Author: Henry Castro <[email protected]>
Date:   Fri Nov 11 15:24:48 2016 -0400

    loleaflet: add special character

diff --git a/loleaflet/build/deps.js b/loleaflet/build/deps.js
index b140214..cb394d8 100644
--- a/loleaflet/build/deps.js
+++ b/loleaflet/build/deps.js
@@ -301,6 +301,13 @@ var deps = {
                desc: 'Document Repair'
        },
 
+       ControlCharacterMap: {
+               src: ['control/Control.js',
+                     'control/Control.CharacterMap.js'],
+               heading: 'Controls',
+               desc: 'Character Map'
+       },
+
        ControlContextmenu: {
                src: ['control/Control.js',
                      'control/Control.ContextMenu.js'],
diff --git a/loleaflet/dist/images/lc_insertsymbol.png 
b/loleaflet/dist/images/lc_insertsymbol.png
new file mode 100644
index 0000000..5d82d86
Binary files /dev/null and b/loleaflet/dist/images/lc_insertsymbol.png differ
diff --git a/loleaflet/dist/loleaflet.css b/loleaflet/dist/loleaflet.css
index 68cbdf2..60f5503 100644
--- a/loleaflet/dist/loleaflet.css
+++ b/loleaflet/dist/loleaflet.css
@@ -37,4 +37,18 @@ body {
     font-family: "Segoe UI", Tahoma, Arial, Helvetica, sans-serif !important;
     font-size: 12px !important;
     font-weight: normal !important;
-}
\ No newline at end of file
+}
+
+.loleaflet-character {
+       table-layout: fixed;
+       font: 17px/1.5 "Helvetica Neue", Arial, Helvetica, sans-serif;
+       text-align: center;
+}
+
+.loleaflet-character td {
+       width: 20px;
+}
+
+.loleaflet-controls {
+       margin-right: 10px;
+}
diff --git a/loleaflet/dist/toolbar.css b/loleaflet/dist/toolbar.css
index 2713eec..093fc1a 100644
--- a/loleaflet/dist/toolbar.css
+++ b/loleaflet/dist/toolbar.css
@@ -269,6 +269,7 @@ button.leaflet-control-search-next
 .w2ui-icon.sortdescending{ background: url('../images/lc_sortdescending.png') 
no-repeat center !important; }
 .w2ui-icon.selected{ background: url('../images/lc_ok.png') no-repeat center 
!important; }
 .w2ui-icon.repair{ background: url('../images/lc_backward.png') no-repeat 
center !important; }
+.w2ui-icon.specialcharacter{ background: url('../images/lc_insertsymbol.png') 
no-repeat center !important; }
 
 .inserttable-pop {
     z-index: 100000;
diff --git a/loleaflet/dist/toolbar/toolbar.js 
b/loleaflet/dist/toolbar/toolbar.js
index 4cbb63e..8c1a849 100644
--- a/loleaflet/dist/toolbar/toolbar.js
+++ b/loleaflet/dist/toolbar/toolbar.js
@@ -223,6 +223,11 @@ function onClick(id, item, subItem) {
                map.fire('postMessage', {msgId: 'UI_Close'});
                map.remove();
        }
+       else if (id === 'specialcharacter') {
+               var fontList = $('.fonts-select option');
+               var selectedIndex = $('.fonts-select').prop('selectedIndex');
+               map._docLayer._onSpecialChar(fontList, selectedIndex);
+       }
 }
 
 function insertTable() {
@@ -373,6 +378,7 @@ $(function () {
                        {type: 'button',  id: 'inserttable',  img: 
'inserttable', hint: _('Insert table')},
                        {type: 'button',  id: 'annotation', img: 'annotation', 
hint: _('Insert comment'), uno: 'InsertAnnotation'},
                        {type: 'button',  id: 'insertgraphic',  img: 
'insertgraphic', hint: _('Insert graphic')},
+                       {type: 'button',  id: 'specialcharacter', img: 
'specialcharacter', hint: _('Special Character')},
                        {type: 'html', id: 'right'},
                        {type: 'button',  id: 'more', img: 'more', hint: 
_('More')},
                        {type: 'button',  id: 'close',  img: 'closedoc', hint: 
_('Close document'), hidden: true}
diff --git a/loleaflet/src/control/Control.CharacterMap.js 
b/loleaflet/src/control/Control.CharacterMap.js
new file mode 100644
index 0000000..77091ab
--- /dev/null
+++ b/loleaflet/src/control/Control.CharacterMap.js
@@ -0,0 +1,255 @@
+/*
+ * L.Control.CharacterMap.
+ */
+
+L.Control.CharacterMap = L.Control.extend({
+       options: {
+               position: 'topright'
+       },
+
+       unicodeCharts : [
+               { innerHTML: _('Basic Latin'),                          start: 
0x0021, end: 0x007F },
+               { innerHTML: _('Latin-1 Supplement'),                   start: 
0x0080, end: 0x00FF },
+               { innerHTML: _('Latin Extended-A'),                     start: 
0x0100, end: 0x017F },
+               { innerHTML: _('Latin Extended-B'),                     start: 
0x0180, end: 0x024F },
+               { innerHTML: _('IPA Extensions'),                       start: 
0x0250, end: 0x02AF },
+               { innerHTML: _('Spacing Modifier Letters'),             start: 
0x02B0, end: 0x02FF },
+               { innerHTML: _('Combining Diacritical Marks'),          start: 
0x0300, end: 0x036F },
+               { innerHTML: _('Greek'),                                start: 
0x0370, end: 0x03FF },
+               { innerHTML: _('Cyrillic'),                             start: 
0x0400, end: 0x04FF },
+               { innerHTML: _('Armenian'),                             start: 
0x0530, end: 0x058F },
+               { innerHTML: _('Hebrew'),                               start: 
0x0590, end: 0x05FF },
+               { innerHTML: _('Arabic'),                               start: 
0x0600, end: 0x06FF },
+               { innerHTML: _('Syriac'),                               start: 
0x0700, end: 0x074F },
+               { innerHTML: _('Thaana'),                               start: 
0x0780, end: 0x07BF },
+               { innerHTML: _('Devanagari'),                           start: 
0x0900, end: 0x097F },
+               { innerHTML: _('Bengali'),                              start: 
0x0980, end: 0x09FF },
+               { innerHTML: _('Gurmukhi'),                             start: 
0x0A00, end: 0x0A7F },
+               { innerHTML: _('Gujarati'),                             start: 
0x0A80, end: 0x0AFF },
+               { innerHTML: _('Oriya'),                                start: 
0x0B00, end: 0x0B7F },
+               { innerHTML: _('Tamil'),                                start: 
0x0B80, end: 0x0BFF },
+               { innerHTML: _('Telugu'),                               start: 
0x0C00, end: 0x0C7F },
+               { innerHTML: _('Kannada'),                              start: 
0x0C80, end: 0x0CFF },
+               { innerHTML: _('Malayalam'),                            start: 
0x0D00, end: 0x0D7F },
+               { innerHTML: _('Sinhala'),                              start: 
0x0D80, end: 0x0DFF },
+               { innerHTML: _('Thai'),                                 start: 
0x0E00, end: 0x0E7F },
+               { innerHTML: _('Lao'),                                  start: 
0x0E80, end: 0x0EFF },
+               { innerHTML: _('Tibetan'),                              start: 
0x0F00, end: 0x0FFF },
+               { innerHTML: _('Myanmar'),                              start: 
0x1000, end: 0x109F },
+               { innerHTML: _('Georgian'),                             start: 
0x10A0, end: 0x10FF },
+               { innerHTML: _('Hangul Jamo'),                          start: 
0x1100, end: 0x11FF },
+               { innerHTML: _('Ethiopic'),                             start: 
0x1200, end: 0x137F },
+               { innerHTML: _('Cherokee'),                             start: 
0x13A0, end: 0x13FF },
+               { innerHTML: _('Unified Canadian Aboriginal Syllabics'),start: 
0x1400, end: 0x167F },
+               { innerHTML: _('Ogham'),                                start: 
0x1680, end: 0x169F },
+               { innerHTML: _('Runic'),                                start: 
0x16A0, end: 0x16FF },
+               { innerHTML: _('Khmer'),                                start: 
0x1780, end: 0x17FF },
+               { innerHTML: _('Mongolian'),                            start: 
0x1800, end: 0x18AF },
+               { innerHTML: _('Latin Extended Additional'),            start: 
0x1E00, end: 0x1EFF },
+               { innerHTML: _('Greek Extended'),                       start: 
0x1F00, end: 0x1FFF },
+               { innerHTML: _('General Punctuation'),                  start: 
0x2000, end: 0x206F },
+               { innerHTML: _('Superscripts and Subscripts'),          start: 
0x2070, end: 0x209F },
+               { innerHTML: _('Currency Symbols'),                     start: 
0x20A0, end: 0x20CF },
+               { innerHTML: _('Combining Marks for Symbols'),          start: 
0x20D0, end: 0x20FF },
+               { innerHTML: _('Letterlike Symbols'),                   start: 
0x2100, end: 0x214F },
+               { innerHTML: _('Number Forms'),                         start: 
0x2150, end: 0x218F },
+               { innerHTML: _('Arrows'),                               start: 
0x2190, end: 0x21FF },
+               { innerHTML: _('Mathematical Operators'),               start: 
0x2200, end: 0x22FF },
+               { innerHTML: _('Miscellaneous Technical'),              start: 
0x2300, end: 0x23FF },
+               { innerHTML: _('Control Pictures'),                     start: 
0x2400, end: 0x243F },
+               { innerHTML: _('Optical Character Recognition'),        start: 
0x2440, end: 0x245F },
+               { innerHTML: _('Enclosed Alphanumerics'),               start: 
0x2460, end: 0x24FF },
+               { innerHTML: _('Box Drawing'),                          start: 
0x2500, end: 0x257F },
+               { innerHTML: _('Block Elements'),                       start: 
0x2580, end: 0x259F },
+               { innerHTML: _('Geometric Shapes'),                     start: 
0x25A0, end: 0x25FF },
+               { innerHTML: _('Miscellaneous Symbols'),                start: 
0x2600, end: 0x26FF },
+               { innerHTML: _('Dingbats'),                             start: 
0x2700, end: 0x27BF },
+               { innerHTML: _('Braille Patterns'),                     start: 
0x2800, end: 0x28FF },
+               { innerHTML: _('CJK Radicals Supplement'),              start: 
0x2E80, end: 0x2EFF },
+               { innerHTML: _('Kangxi Radicals'),                      start: 
0x2F00, end: 0x2FDF },
+               { innerHTML: _('Ideographic Description Characters'),   start: 
0x2FF0, end: 0x2FFF },
+               { innerHTML: _('CJK Symbols and Punctuation'),          start: 
0x3000, end: 0x303F },
+               { innerHTML: _('Hiragana'),                             start: 
0x3040, end: 0x309F },
+               { innerHTML: _('Katakana'),                             start: 
0x30A0, end: 0x30FF },
+               { innerHTML: _('Bopomofo'),                             start: 
0x3100, end: 0x312F },
+               { innerHTML: _('Hangul Compatability Jamo'),            start: 
0x3130, end: 0x318F },
+               { innerHTML: _('Kanbun'),                               start: 
0x3190, end: 0x319F },
+               { innerHTML: _('Bopomofo Extended'),                    start: 
0x31A0, end: 0x31BF },
+               { innerHTML: _('Enclosed CJK Letters and Months'),      start: 
0x3200, end: 0x32FF },
+               { innerHTML: _('CJK Compatibility'),                    start: 
0x3300, end: 0x33FF },
+               { innerHTML: _('CJK Unified Ideographs Extension A'),   start: 
0x3400, end: 0x4DB5 },
+               { innerHTML: _('CJK Unified Ideographs'),               start: 
0x4E00, end: 0x9FFF },
+               { innerHTML: _('Yi Syllables'),                         start: 
0xA000, end: 0xA48F },
+               { innerHTML: _('Yi Radicals'),                          start: 
0xA490, end: 0xA4CF },
+               { innerHTML: _('Hangul Syllables'),                     start: 
0xAC00, end: 0xD7A3 },
+               { innerHTML: _('High Surrogates'),                      start: 
0xD800, end: 0xDB7F },
+               { innerHTML: _('High Private Use Surrogates'),          start: 
0xDB80, end: 0xDBFF },
+               { innerHTML: _('Low Surrogates'),                       start: 
0xDC00, end: 0xDFFF },
+               //{ innerHTML: _('Private Use'),                        start: 
0xE000, end: 0xF8FF },
+               { innerHTML: _('CJK Compatibility Ideographs'),         start: 
0xF900, end: 0xFAFF },
+               { innerHTML: _('Alphabetic Presentation Forms'),        start: 
0xFB00, end: 0xFB4F },
+               { innerHTML: _('Arabic Presentation Forms-A'),          start: 
0xFB50, end: 0xFDFF },
+               { innerHTML: _('Combining Half Marks'),                 start: 
0xFE20, end: 0xFE2F },
+               { innerHTML: _('CJK Compatibility Forms'),              start: 
0xFE30, end: 0xFE4F },
+               { innerHTML: _('Small Form Variants'),                  start: 
0xFE50, end: 0xFE6F },
+               { innerHTML: _('Arabic Presentation Forms-B'),          start: 
0xFE70, end: 0xFEEE },
+               //{ innerHTML: _('Specials'),                           start: 
0xFEFF, end: 0xFEFF },
+               { innerHTML: _('Halfwidth and Fullwidth Forms'),        start: 
0xFF00, end: 0xFFEF },
+               //{ innerHTML: _('Specials'),                           start: 
0xFFF0, end: 0xFFFD }
+       ],
+
+       fillCharacters: function (index) {
+               var start = this.unicodeCharts[index].start;
+               var end = this.unicodeCharts[index].end;
+               var it = 0;
+               var tr, td;
+               L.DomUtil.empty(this._tbody);
+               while (start <= end) {
+                       if (it % 20 === 0) {
+                               tr = L.DomUtil.create('tr', '', this._tbody);
+                       }
+                       td = L.DomUtil.create('td', '', tr);
+                       td.innerHTML = '&#x' + start.toString(16);
+                       td.data = start;
+                       L.DomEvent.on(td, 'click', this._onSymbolClick, this);
+                       start++;
+                       it++;
+               }
+       },
+
+       fillDropDown: function(element, list, selectedIndex) {
+               for (var iterator = 0, len = list.length, option; iterator < 
len; iterator++) {
+                       option = document.createElement('option');
+                       option.innerHTML = list[iterator].innerHTML;
+                       element.appendChild(option);
+               }
+               element.selectedIndex = selectedIndex;
+       },
+
+       fillFontNames: function (fontList, selectedIndex) {
+               this.fillDropDown(this._fontNames, fontList, selectedIndex);
+       },
+
+       initialize: function (options) {
+               L.setOptions(this, options);
+       },
+
+       onAdd: function (map) {
+               this._initLayout();
+
+               map.on('renderfont', this._onRenderFontPreview, this);
+               return this._container;
+       },
+
+       onRemove: function (map) {
+               map.off('renderfont', this._onRenderFontPreview, this);
+       },
+
+
+       show: function () {
+               this._tbody.setAttribute('style', 'max-height:' + 
this._map.getSize().y / 2 + 'px');
+               this._container.style.visibility = '';
+       },
+
+       _initLayout: function () {
+               this._container = L.DomUtil.create('div', 
'leaflet-control-layers');
+               this._container.style.visibility = 'hidden';
+               var closeButton = L.DomUtil.create('a', 
'leaflet-popup-close-button', this._container);
+               closeButton.href = '#close';
+               closeButton.innerHTML = '&#215;';
+               L.DomEvent.on(closeButton, 'click', this._onCloseClick, this);
+               var wrapper = L.DomUtil.create('div', 
'leaflet-popup-content-wrapper', this._container);
+               var content = L.DomUtil.create('div', 'leaflet-popup-content', 
wrapper);
+               var labelTitle = document.createElement('span');
+               labelTitle.innerHTML = '<b>' + _('Special Characters') + '</b>';
+               content.appendChild(labelTitle);
+               content.appendChild(document.createElement('br'));
+               content.appendChild(document.createElement('br'));
+               this._unicodeChart = L.DomUtil.create('select', 
'loleaflet-controls', content);
+               L.DomEvent.on(this._unicodeChart, 'change', 
this._onUnicodeChartChange, this);
+               content.appendChild(document.createElement('br'));
+               var table = L.DomUtil.create('table', 'loleaflet-character', 
content);
+               this._tbody = L.DomUtil.create('tbody', '', table);
+               content.appendChild(document.createElement('br'));
+               var label = L.DomUtil.create('span', 'loleaflet-controls', 
content);
+               label.innerHTML = '<b>' + _('Font Name:') + '</b>';
+               this._fontNames = L.DomUtil.create('select', 
'loleaflet-controls', content);
+               L.DomEvent.on(this._fontNames, 'change', 
this._onFontNamesChange, this);
+               label = L.DomUtil.create('span', 'loleaflet-controls', content);
+               label.innerHTML = '<b>' + _('Hexadecimal:') + '</b>';
+               this._hexa = L.DomUtil.create('span', 'loleaflet-controls', 
content);
+               content.appendChild(document.createElement('br'));
+               content.appendChild(document.createElement('br'));
+               label = L.DomUtil.create('span', 'loleaflet-controls', content);
+               label.innerHTML = '<b>' + _('Preview:') + '</b>';
+               this._preview = L.DomUtil.create('img', '', content);
+               content.appendChild(document.createElement('br'));
+               content.appendChild(document.createElement('br'));
+               var button = L.DomUtil.create('input', 'loleaflet-controls', 
content);
+               button.type = 'button';
+               button.value = _('Insert');
+               L.DomEvent.on(button, 'click', this._onInsertClick, this);
+               button = L.DomUtil.create('input', 'loleaflet-controls', 
content);
+               button.type = 'button';
+               button.value = _('Cancel');
+               L.DomEvent.on(button, 'click', this._onCancelClick, this);
+               this.fillDropDown(this._unicodeChart, this.unicodeCharts, 0);
+               this.fillCharacters(this._unicodeChart.selectedIndex);
+       },
+
+       _onCancelClick: function (e) {
+               this._onCloseClick(e);
+       },
+
+       _onCloseClick: function (e) {
+               this._map.enable(true);
+               this._refocusOnMap();
+               this.remove();
+       },
+
+       _onFontNamesChange: function (e) {
+               /* if (this._hexa.data) {
+                               
window.encodeURIComponent(this._fontNames.options[this._fontNames.selectedIndex].value)
 +
+                               ' char=' + 
String.fromCharCode(this._hexa.data));
+               }*/
+       },
+
+       _onInsertClick: function (e) {
+               if (this._hexa.data) {
+                       var command = {
+                               Symbols: {
+                                       type: 'string',
+                                       value: 
String.fromCharCode(this._hexa.data)
+                               },
+                               FontName: {
+                                       type: 'string',
+                                       value: 
this._fontNames.options[this._fontNames.selectedIndex].value
+                               }
+                       };
+                       this._map.sendUnoCommand('.uno:InsertSymbol', command);
+                       this._onCloseClick(e);
+               }
+       },
+
+       _onRenderFontPreview: function (e) {
+               this._preview.src = e.img;
+       },
+
+       _onSymbolClick: function (e) {
+               var target = e.target || e.srcElement;
+               this._hexa.data = target.data;
+               this._hexa.innerHTML = 'U+' + 
target.data.toString(16).toUpperCase();
+               /*this._map._socket.sendMessage('renderfont font=' +
+                       
window.encodeURIComponent(this._fontNames.options[this._fontNames.selectedIndex].value)
 +
+                       ' char=' + String.fromCharCode(this._hexa.data));*/
+       },
+
+       _onUnicodeChartChange: function (e) {
+               var target = e.target || e.srcElement;
+               this.fillCharacters(target.selectedIndex);
+       }
+});
+
+L.control.characterMap = function (options) {
+       return new L.Control.CharacterMap(options);
+};
diff --git a/loleaflet/src/layer/tile/TileLayer.js 
b/loleaflet/src/layer/tile/TileLayer.js
index d575413..40ad0a3 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -604,6 +604,18 @@ L.TileLayer = L.GridLayer.extend({
                }
        },
 
+       _onSpecialChar: function(fontList, selectedIndex) {
+               if (!this._specialChar) {
+                       this._specialChar = L.control.characterMap();
+               }
+               if (!this._specialChar.isVisible()) {
+                       this._specialChar.addTo(this._map);
+                       this._specialChar.fillFontNames(fontList, 
selectedIndex);
+                       this._map.enable(false);
+                       this._specialChar.show();
+               }
+       },
+
        _onMousePointerMsg: function (textMsg) {
                textMsg = textMsg.substring(14); // "mousepointer: "
                textMsg = L.Cursor.getCustomCursor(textMsg) || textMsg;
_______________________________________________
Libreoffice-commits mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to