Commit 67127329 authored by Sergey.Luzyanin's avatar Sergey.Luzyanin Committed by Alexander.Trofimov

удалены лишние файлы

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@55907 954022d7-b5bf-4e40-9824-e11837661b57
parent 62e77403
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
"use strict";
var fontslot_ASCII = 0x00;
var fontslot_EastAsia = 0x01;
var fontslot_CS = 0x02;
var fontslot_HAnsi = 0x03;
var fonthint_Default = 0x00;
var fonthint_CS = 0x01;
var fonthint_EastAsia = 0x02;
var lcid_unknown = 0x0000; // Unknown
var lcid_ar = 0x0001; // Arabic
var lcid_bg = 0x0002; // Bulgarian
var lcid_ca = 0x0003; // Catalan
var lcid_zhHans = 0x0004; // Chinese, Han (Simplified variant)
var lcid_cs = 0x0005; // Czech
var lcid_da = 0x0006; // Danish
var lcid_de = 0x0007; // German
var lcid_el = 0x0008; // Modern Greek (1453-)
var lcid_en = 0x0009; // English
var lcid_es = 0x000a; // Spanish
var lcid_fi = 0x000b; // Finnish
var lcid_fr = 0x000c; // French
var lcid_he = 0x000d; // Hebrew
var lcid_hu = 0x000e; // Hungarian
var lcid_is = 0x000f; // Icelandic
var lcid_it = 0x0010; // Italian
var lcid_ja = 0x0011; // Japanese
var lcid_ko = 0x0012; // Korean
var lcid_nl = 0x0013; // Dutch
var lcid_no = 0x0014; // Norwegian
var lcid_pl = 0x0015; // Polish
var lcid_pt = 0x0016; // Portuguese
var lcid_rm = 0x0017; // Romansh
var lcid_ro = 0x0018; // Romanian
var lcid_ru = 0x0019; // Russian
var lcid_hr = 0x001a; // Croatian
var lcid_sk = 0x001b; // Slovak
var lcid_sq = 0x001c; // Albanian
var lcid_sv = 0x001d; // Swedish
var lcid_th = 0x001e; // Thai
var lcid_tr = 0x001f; // Turkish
var lcid_ur = 0x0020; // Urdu
var lcid_id = 0x0021; // Indonesian
var lcid_uk = 0x0022; // Ukrainian
var lcid_be = 0x0023; // Belarusian
var lcid_sl = 0x0024; // Slovenian
var lcid_et = 0x0025; // Estonian
var lcid_lv = 0x0026; // Latvian
var lcid_lt = 0x0027; // Lithuanian
var lcid_tg = 0x0028; // Tajik
var lcid_fa = 0x0029; // Persian
var lcid_vi = 0x002a; // Vietnamese
var lcid_hy = 0x002b; // Armenian
var lcid_az = 0x002c; // Azerbaijani
var lcid_eu = 0x002d; // Basque
var lcid_hsb = 0x002e; // Upper Sorbian
var lcid_mk = 0x002f; // Macedonian
var lcid_tn = 0x0032; // Tswana
var lcid_xh = 0x0034; // Xhosa
var lcid_zu = 0x0035; // Zulu
var lcid_af = 0x0036; // Afrikaans
var lcid_ka = 0x0037; // Georgian
var lcid_fo = 0x0038; // Faroese
var lcid_hi = 0x0039; // Hindi
var lcid_mt = 0x003a; // Maltese
var lcid_se = 0x003b; // Northern Sami
var lcid_ga = 0x003c; // Irish
var lcid_ms = 0x003e; // Malay (macrolanguage)
var lcid_kk = 0x003f; // Kazakh
var lcid_ky = 0x0040; // Kirghiz
var lcid_sw = 0x0041; // Swahili (macrolanguage)
var lcid_tk = 0x0042; // Turkmen
var lcid_uz = 0x0043; // Uzbek
var lcid_tt = 0x0044; // Tatar
var lcid_bn = 0x0045; // Bengali
var lcid_pa = 0x0046; // Panjabi
var lcid_gu = 0x0047; // Gujarati
var lcid_or = 0x0048; // Oriya
var lcid_ta = 0x0049; // Tamil
var lcid_te = 0x004a; // Telugu
var lcid_kn = 0x004b; // Kannada
var lcid_ml = 0x004c; // Malayalam
var lcid_as = 0x004d; // Assamese
var lcid_mr = 0x004e; // Marathi
var lcid_sa = 0x004f; // Sanskrit
var lcid_mn = 0x0050; // Mongolian
var lcid_bo = 0x0051; // Tibetan
var lcid_cy = 0x0052; // Welsh
var lcid_km = 0x0053; // Central Khmer
var lcid_lo = 0x0054; // Lao
var lcid_gl = 0x0056; // Galician
var lcid_kok = 0x0057; // Konkani (macrolanguage)
var lcid_syr = 0x005a; // Syriac
var lcid_si = 0x005b; // Sinhala
var lcid_iu = 0x005d; // Inuktitut
var lcid_am = 0x005e; // Amharic
var lcid_tzm = 0x005f; // Central Atlas Tamazight
var lcid_ne = 0x0061; // Nepali
var lcid_fy = 0x0062; // Western Frisian
var lcid_ps = 0x0063; // Pushto
var lcid_fil = 0x0064; // Filipino
var lcid_dv = 0x0065; // Dhivehi
var lcid_ha = 0x0068; // Hausa
var lcid_yo = 0x006a; // Yoruba
var lcid_quz = 0x006b; // Cusco Quechua
var lcid_nso = 0x006c; // Pedi
var lcid_ba = 0x006d; // Bashkir
var lcid_lb = 0x006e; // Luxembourgish
var lcid_kl = 0x006f; // Kalaallisut
var lcid_ig = 0x0070; // Igbo
var lcid_ii = 0x0078; // Sichuan Yi
var lcid_arn = 0x007a; // Mapudungun
var lcid_moh = 0x007c; // Mohawk
var lcid_br = 0x007e; // Breton
var lcid_ug = 0x0080; // Uighur
var lcid_mi = 0x0081; // Maori
var lcid_oc = 0x0082; // Occitan (post 1500)
var lcid_co = 0x0083; // Corsican
var lcid_gsw = 0x0084; // Swiss German
var lcid_sah = 0x0085; // Yakut
var lcid_qut = 0x0086; //
var lcid_rw = 0x0087; // Kinyarwanda
var lcid_wo = 0x0088; // Wolof
var lcid_prs = 0x008c; // Dari
var lcid_gd = 0x0091; // Scottish Gaelic
var lcid_arSA = 0x0401; // Arabic, Saudi Arabia
var lcid_bgBG = 0x0402; // Bulgarian, Bulgaria
var lcid_caES = 0x0403; // Catalan, Spain
var lcid_zhTW = 0x0404; // Chinese, Taiwan, Province of China
var lcid_csCZ = 0x0405; // Czech, Czech Republic
var lcid_daDK = 0x0406; // Danish, Denmark
var lcid_deDE = 0x0407; // German, Germany
var lcid_elGR = 0x0408; // Modern Greek (1453-), Greece
var lcid_enUS = 0x0409; // English, United States
var lcid_esES_tradnl = 0x040a; // Spanish
var lcid_fiFI = 0x040b; // Finnish, Finland
var lcid_frFR = 0x040c; // French, France
var lcid_heIL = 0x040d; // Hebrew, Israel
var lcid_huHU = 0x040e; // Hungarian, Hungary
var lcid_isIS = 0x040f; // Icelandic, Iceland
var lcid_itIT = 0x0410; // Italian, Italy
var lcid_jaJP = 0x0411; // Japanese, Japan
var lcid_koKR = 0x0412; // Korean, Republic of Korea
var lcid_nlNL = 0x0413; // Dutch, Netherlands
var lcid_nbNO = 0x0414; // Norwegian Bokmal, Norway
var lcid_plPL = 0x0415; // Polish, Poland
var lcid_ptBR = 0x0416; // Portuguese, Brazil
var lcid_rmCH = 0x0417; // Romansh, Switzerland
var lcid_roRO = 0x0418; // Romanian, Romania
var lcid_ruRU = 0x0419; // Russian, Russian Federation
var lcid_hrHR = 0x041a; // Croatian, Croatia
var lcid_skSK = 0x041b; // Slovak, Slovakia
var lcid_sqAL = 0x041c; // Albanian, Albania
var lcid_svSE = 0x041d; // Swedish, Sweden
var lcid_thTH = 0x041e; // Thai, Thailand
var lcid_trTR = 0x041f; // Turkish, Turkey
var lcid_urPK = 0x0420; // Urdu, Pakistan
var lcid_idID = 0x0421; // Indonesian, Indonesia
var lcid_ukUA = 0x0422; // Ukrainian, Ukraine
var lcid_beBY = 0x0423; // Belarusian, Belarus
var lcid_slSI = 0x0424; // Slovenian, Slovenia
var lcid_etEE = 0x0425; // Estonian, Estonia
var lcid_lvLV = 0x0426; // Latvian, Latvia
var lcid_ltLT = 0x0427; // Lithuanian, Lithuania
var lcid_tgCyrlTJ = 0x0428; // Tajik, Cyrillic, Tajikistan
var lcid_faIR = 0x0429; // Persian, Islamic Republic of Iran
var lcid_viVN = 0x042a; // Vietnamese, Viet Nam
var lcid_hyAM = 0x042b; // Armenian, Armenia
var lcid_azLatnAZ = 0x042c; // Azerbaijani, Latin, Azerbaijan
var lcid_euES = 0x042d; // Basque, Spain
var lcid_wenDE = 0x042e; // Sorbian languages, Germany
var lcid_mkMK = 0x042f; // Macedonian, The Former Yugoslav Republic of Macedonia
var lcid_stZA = 0x0430; // Southern Sotho, South Africa
var lcid_tsZA = 0x0431; // Tsonga, South Africa
var lcid_tnZA = 0x0432; // Tswana, South Africa
var lcid_venZA = 0x0433; // South Africa
var lcid_xhZA = 0x0434; // Xhosa, South Africa
var lcid_zuZA = 0x0435; // Zulu, South Africa
var lcid_afZA = 0x0436; // Afrikaans, South Africa
var lcid_kaGE = 0x0437; // Georgian, Georgia
var lcid_foFO = 0x0438; // Faroese, Faroe Islands
var lcid_hiIN = 0x0439; // Hindi, India
var lcid_mtMT = 0x043a; // Maltese, Malta
var lcid_seNO = 0x043b; // Northern Sami, Norway
var lcid_msMY = 0x043e; // Malay (macrolanguage), Malaysia
var lcid_kkKZ = 0x043f; // Kazakh, Kazakhstan
var lcid_kyKG = 0x0440; // Kirghiz, Kyrgyzstan
var lcid_swKE = 0x0441; // Swahili (macrolanguage), Kenya
var lcid_tkTM = 0x0442; // Turkmen, Turkmenistan
var lcid_uzLatnUZ = 0x0443; // Uzbek, Latin, Uzbekistan
var lcid_ttRU = 0x0444; // Tatar, Russian Federation
var lcid_bnIN = 0x0445; // Bengali, India
var lcid_paIN = 0x0446; // Panjabi, India
var lcid_guIN = 0x0447; // Gujarati, India
var lcid_orIN = 0x0448; // Oriya, India
var lcid_taIN = 0x0449; // Tamil, India
var lcid_teIN = 0x044a; // Telugu, India
var lcid_knIN = 0x044b; // Kannada, India
var lcid_mlIN = 0x044c; // Malayalam, India
var lcid_asIN = 0x044d; // Assamese, India
var lcid_mrIN = 0x044e; // Marathi, India
var lcid_saIN = 0x044f; // Sanskrit, India
var lcid_mnMN = 0x0450; // Mongolian, Mongolia
var lcid_boCN = 0x0451; // Tibetan, China
var lcid_cyGB = 0x0452; // Welsh, United Kingdom
var lcid_kmKH = 0x0453; // Central Khmer, Cambodia
var lcid_loLA = 0x0454; // Lao, Lao People's Democratic Republic
var lcid_myMM = 0x0455; // Burmese, Myanmar
var lcid_glES = 0x0456; // Galician, Spain
var lcid_kokIN = 0x0457; // Konkani (macrolanguage), India
var lcid_mni = 0x0458; // Manipuri
var lcid_sdIN = 0x0459; // Sindhi, India
var lcid_syrSY = 0x045a; // Syriac, Syrian Arab Republic
var lcid_siLK = 0x045b; // Sinhala, Sri Lanka
var lcid_chrUS = 0x045c; // Cherokee, United States
var lcid_iuCansCA = 0x045d; // Inuktitut, Unified Canadian Aboriginal Syllabics, Canada
var lcid_amET = 0x045e; // Amharic, Ethiopia
var lcid_tmz = 0x045f; // Tamanaku
var lcid_neNP = 0x0461; // Nepali, Nepal
var lcid_fyNL = 0x0462; // Western Frisian, Netherlands
var lcid_psAF = 0x0463; // Pushto, Afghanistan
var lcid_filPH = 0x0464; // Filipino, Philippines
var lcid_dvMV = 0x0465; // Dhivehi, Maldives
var lcid_binNG = 0x0466; // Bini, Nigeria
var lcid_fuvNG = 0x0467; // Nigerian Fulfulde, Nigeria
var lcid_haLatnNG = 0x0468; // Hausa, Latin, Nigeria
var lcid_ibbNG = 0x0469; // Ibibio, Nigeria
var lcid_yoNG = 0x046a; // Yoruba, Nigeria
var lcid_quzBO = 0x046b; // Cusco Quechua, Bolivia
var lcid_nsoZA = 0x046c; // Pedi, South Africa
var lcid_baRU = 0x046d; // Bashkir, Russian Federation
var lcid_lbLU = 0x046e; // Luxembourgish, Luxembourg
var lcid_klGL = 0x046f; // Kalaallisut, Greenland
var lcid_igNG = 0x0470; // Igbo, Nigeria
var lcid_krNG = 0x0471; // Kanuri, Nigeria
var lcid_gazET = 0x0472; // West Central Oromo, Ethiopia
var lcid_tiER = 0x0473; // Tigrinya, Eritrea
var lcid_gnPY = 0x0474; // Guarani, Paraguay
var lcid_hawUS = 0x0475; // Hawaiian, United States
var lcid_soSO = 0x0477; // Somali, Somalia
var lcid_iiCN = 0x0478; // Sichuan Yi, China
var lcid_papAN = 0x0479; // Papiamento, Netherlands Antilles
var lcid_arnCL = 0x047a; // Mapudungun, Chile
var lcid_mohCA = 0x047c; // Mohawk, Canada
var lcid_brFR = 0x047e; // Breton, France
var lcid_ugCN = 0x0480; // Uighur, China
var lcid_miNZ = 0x0481; // Maori, New Zealand
var lcid_ocFR = 0x0482; // Occitan (post 1500), France
var lcid_coFR = 0x0483; // Corsican, France
var lcid_gswFR = 0x0484; // Swiss German, France
var lcid_sahRU = 0x0485; // Yakut, Russian Federation
var lcid_qutGT = 0x0486; // Guatemala
var lcid_rwRW = 0x0487; // Kinyarwanda, Rwanda
var lcid_woSN = 0x0488; // Wolof, Senegal
var lcid_prsAF = 0x048c; // Dari, Afghanistan
var lcid_pltMG = 0x048d; // Plateau Malagasy, Madagascar
var lcid_gdGB = 0x0491; // Scottish Gaelic, United Kingdom
var lcid_arIQ = 0x0801; // Arabic, Iraq
var lcid_zhCN = 0x0804; // Chinese, China
var lcid_deCH = 0x0807; // German, Switzerland
var lcid_enGB = 0x0809; // English, United Kingdom
var lcid_esMX = 0x080a; // Spanish, Mexico
var lcid_frBE = 0x080c; // French, Belgium
var lcid_itCH = 0x0810; // Italian, Switzerland
var lcid_nlBE = 0x0813; // Dutch, Belgium
var lcid_nnNO = 0x0814; // Norwegian Nynorsk, Norway
var lcid_ptPT = 0x0816; // Portuguese, Portugal
var lcid_roMO = 0x0818; // Romanian, Macao
var lcid_ruMO = 0x0819; // Russian, Macao
var lcid_srLatnCS = 0x081a; // Serbian, Latin, Serbia and Montenegro
var lcid_svFI = 0x081d; // Swedish, Finland
var lcid_urIN = 0x0820; // Urdu, India
var lcid_azCyrlAZ = 0x082c; // Azerbaijani, Cyrillic, Azerbaijan
var lcid_dsbDE = 0x082e; // Lower Sorbian, Germany
var lcid_seSE = 0x083b; // Northern Sami, Sweden
var lcid_gaIE = 0x083c; // Irish, Ireland
var lcid_msBN = 0x083e; // Malay (macrolanguage), Brunei Darussalam
var lcid_uzCyrlUZ = 0x0843; // Uzbek, Cyrillic, Uzbekistan
var lcid_bnBD = 0x0845; // Bengali, Bangladesh
var lcid_paPK = 0x0846; // Panjabi, Pakistan
var lcid_mnMongCN = 0x0850; // Mongolian, Mongolian, China
var lcid_boBT = 0x0851; // Tibetan, Bhutan
var lcid_sdPK = 0x0859; // Sindhi, Pakistan
var lcid_iuLatnCA = 0x085d; // Inuktitut, Latin, Canada
var lcid_tzmLatnDZ = 0x085f; // Central Atlas Tamazight, Latin, Algeria
var lcid_neIN = 0x0861; // Nepali, India
var lcid_quzEC = 0x086b; // Cusco Quechua, Ecuador
var lcid_tiET = 0x0873; // Tigrinya, Ethiopia
var lcid_arEG = 0x0c01; // Arabic, Egypt
var lcid_zhHK = 0x0c04; // Chinese, Hong Kong
var lcid_deAT = 0x0c07; // German, Austria
var lcid_enAU = 0x0c09; // English, Australia
var lcid_esES = 0x0c0a; // Spanish, Spain
var lcid_frCA = 0x0c0c; // French, Canada
var lcid_srCyrlCS = 0x0c1a; // Serbian, Cyrillic, Serbia and Montenegro
var lcid_seFI = 0x0c3b; // Northern Sami, Finland
var lcid_tmzMA = 0x0c5f; // Tamanaku, Morocco
var lcid_quzPE = 0x0c6b; // Cusco Quechua, Peru
var lcid_arLY = 0x1001; // Arabic, Libyan Arab Jamahiriya
var lcid_zhSG = 0x1004; // Chinese, Singapore
var lcid_deLU = 0x1007; // German, Luxembourg
var lcid_enCA = 0x1009; // English, Canada
var lcid_esGT = 0x100a; // Spanish, Guatemala
var lcid_frCH = 0x100c; // French, Switzerland
var lcid_hrBA = 0x101a; // Croatian, Bosnia and Herzegovina
var lcid_smjNO = 0x103b; // Lule Sami, Norway
var lcid_arDZ = 0x1401; // Arabic, Algeria
var lcid_zhMO = 0x1404; // Chinese, Macao
var lcid_deLI = 0x1407; // German, Liechtenstein
var lcid_enNZ = 0x1409; // English, New Zealand
var lcid_esCR = 0x140a; // Spanish, Costa Rica
var lcid_frLU = 0x140c; // French, Luxembourg
var lcid_bsLatnBA = 0x141a; // Bosnian, Latin, Bosnia and Herzegovina
var lcid_smjSE = 0x143b; // Lule Sami, Sweden
var lcid_arMA = 0x1801; // Arabic, Morocco
var lcid_enIE = 0x1809; // English, Ireland
var lcid_esPA = 0x180a; // Spanish, Panama
var lcid_frMC = 0x180c; // French, Monaco
var lcid_srLatnBA = 0x181a; // Serbian, Latin, Bosnia and Herzegovina
var lcid_smaNO = 0x183b; // Southern Sami, Norway
var lcid_arTN = 0x1c01; // Arabic, Tunisia
var lcid_enZA = 0x1c09; // English, South Africa
var lcid_esDO = 0x1c0a; // Spanish, Dominican Republic
var lcid_frWest = 0x1c0c; // French
var lcid_srCyrlBA = 0x1c1a; // Serbian, Cyrillic, Bosnia and Herzegovina
var lcid_smaSE = 0x1c3b; // Southern Sami, Sweden
var lcid_arOM = 0x2001; // Arabic, Oman
var lcid_enJM = 0x2009; // English, Jamaica
var lcid_esVE = 0x200a; // Spanish, Venezuela
var lcid_frRE = 0x200c; // French, Reunion
var lcid_bsCyrlBA = 0x201a; // Bosnian, Cyrillic, Bosnia and Herzegovina
var lcid_smsFI = 0x203b; // Skolt Sami, Finland
var lcid_arYE = 0x2401; // Arabic, Yemen
var lcid_enCB = 0x2409; // English
var lcid_esCO = 0x240a; // Spanish, Colombia
var lcid_frCG = 0x240c; // French, Congo
var lcid_srLatnRS = 0x241a; // Serbian, Latin, Serbia
var lcid_smnFI = 0x243b; // Inari Sami, Finland
var lcid_arSY = 0x2801; // Arabic, Syrian Arab Republic
var lcid_enBZ = 0x2809; // English, Belize
var lcid_esPE = 0x280a; // Spanish, Peru
var lcid_frSN = 0x280c; // French, Senegal
var lcid_srCyrlRS = 0x281a; // Serbian, Cyrillic, Serbia
var lcid_arJO = 0x2c01; // Arabic, Jordan
var lcid_enTT = 0x2c09; // English, Trinidad and Tobago
var lcid_esAR = 0x2c0a; // Spanish, Argentina
var lcid_frCM = 0x2c0c; // French, Cameroon
var lcid_srLatnME = 0x2c1a; // Serbian, Latin, Montenegro
var lcid_arLB = 0x3001; // Arabic, Lebanon
var lcid_enZW = 0x3009; // English, Zimbabwe
var lcid_esEC = 0x300a; // Spanish, Ecuador
var lcid_frCI = 0x300c; // French, Cote d'Ivoire
var lcid_srCyrlME = 0x301a; // Serbian, Cyrillic, Montenegro
var lcid_arKW = 0x3401; // Arabic, Kuwait
var lcid_enPH = 0x3409; // English, Philippines
var lcid_esCL = 0x340a; // Spanish, Chile
var lcid_frML = 0x340c; // French, Mali
var lcid_arAE = 0x3801; // Arabic, United Arab Emirates
var lcid_enID = 0x3809; // English, Indonesia
var lcid_esUY = 0x380a; // Spanish, Uruguay
var lcid_frMA = 0x380c; // French, Morocco
var lcid_arBH = 0x3c01; // Arabic, Bahrain
var lcid_enHK = 0x3c09; // English, Hong Kong
var lcid_esPY = 0x3c0a; // Spanish, Paraguay
var lcid_frHT = 0x3c0c; // French, Haiti
var lcid_arQA = 0x4001; // Arabic, Qatar
var lcid_enIN = 0x4009; // English, India
var lcid_esBO = 0x400a; // Spanish, Bolivia
var lcid_enMY = 0x4409; // English, Malaysia
var lcid_esSV = 0x440a; // Spanish, El Salvador
var lcid_enSG = 0x4809; // English, Singapore
var lcid_esHN = 0x480a; // Spanish, Honduras
var lcid_esNI = 0x4c0a; // Spanish, Nicaragua
var lcid_esPR = 0x500a; // Spanish, Puerto Rico
var lcid_esUS = 0x540a; // Spanish, United States
var lcid_bsCyrl = 0x641a; // Bosnian, Cyrillic
var lcid_bsLatn = 0x681a; // Bosnian, Latin
var lcid_srCyrl = 0x6c1a; // Serbian, Cyrillic
var lcid_srLatn = 0x701a; // Serbian, Latin
var lcid_smn = 0x703b; // Inari Sami
var lcid_azCyrl = 0x742c; // Azerbaijani, Cyrillic
var lcid_sms = 0x743b; // Skolt Sami
var lcid_zh = 0x7804; // Chinese
var lcid_nn = 0x7814; // Norwegian Nynorsk
var lcid_bs = 0x781a; // Bosnian
var lcid_azLatn = 0x782c; // Azerbaijani, Latin
var lcid_sma = 0x783b; // Southern Sami
var lcid_uzCyrl = 0x7843; // Uzbek, Cyrillic
var lcid_mnCyrl = 0x7850; // Mongolian, Cyrillic
var lcid_iuCans = 0x785d; // Inuktitut, Unified Canadian Aboriginal Syllabics
var lcid_zhHant = 0x7c04; // Chinese, Han (Traditional variant)
var lcid_nb = 0x7c14; // Norwegian Bokmal
var lcid_sr = 0x7c1a; // Serbian
var lcid_tgCyrl = 0x7c28; // Tajik, Cyrillic
var lcid_dsb = 0x7c2e; // Lower Sorbian
var lcid_smj = 0x7c3b; // Lule Sami
var lcid_uzLatn = 0x7c43; // Uzbek, Latin
var lcid_mnMong = 0x7c50; // Mongolian, Mongolian
var lcid_iuLatn = 0x7c5d; // Inuktitut, Latin
var lcid_tzmLatn = 0x7c5f; // Central Atlas Tamazight, Latin
var lcid_haLatn = 0x7c68; // Hausa, Latin
(function(document){
function CDetectFontUse()
{
this.DetectData = null;
this.TableChunkLen = 65536;
this.TableChunks = 4;
this.TableChunkMain = 0;
this.TableChunkHintEA = this.TableChunkLen;
this.TableChunkHintZH = 2 * this.TableChunkLen;
this.TableChunkHintEACS = 3 * this.TableChunkLen;
this.Init = function()
{
this.DetectData = g_memory.Alloc(this.TableChunkLen * this.TableChunks);
var _data = this.DetectData.data;
var i, j;
// ********************** 1st table *********************** //
j = 0;
for (i = 0x0000; i <= 0x007F; i++)
{
_data[i + j] = fontslot_ASCII;
}
for (i = 0x00A0; i <= 0x04FF; i++)
{
_data[i + j] = fontslot_HAnsi;
}
for (i = 0x0590; i <= 0x07BF; i++)
{
_data[i + j] = fontslot_ASCII;
}
for (i = 0x1100; i <= 0x11FF; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0x1E00; i <= 0x1EFF; i++)
{
_data[i + j] = fontslot_HAnsi;
}
for (i = 0x1F00; i <= 0x27BF; i++)
{
_data[i + j] = fontslot_HAnsi;
}
for (i = 0x2E80; i <= 0x319F; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0x3200; i <= 0x4D8F; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0x4E00; i <= 0x9FAF; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0xA000; i <= 0xA4CF; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0xAC00; i <= 0xD7AF; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0xD800; i <= 0xDFFF; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0xE000; i <= 0xF8FF; i++)
{
_data[i + j] = fontslot_HAnsi;
}
for (i = 0xF900; i <= 0xFAFF; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0xFB00; i <= 0xFB1C; i++)
{
_data[i + j] = fontslot_HAnsi;
}
for (i = 0xFB1D; i <= 0xFDFF; i++)
{
_data[i + j] = fontslot_ASCII;
}
for (i = 0xFE30; i <= 0xFE6F; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0xFE70; i <= 0xFEFE; i++)
{
_data[i + j] = fontslot_ASCII;
}
for (i = 0xFF00; i <= 0xFFEF; i++)
{
_data[i + j] = fontslot_EastAsia;
}
// ********************** 2nd table *********************** //
j = this.TableChunkHintEA;
for (i = 0x0000; i <= 0x007F; i++)
{
_data[i + j] = fontslot_ASCII;
}
for (i = 0x00A0; i <= 0x04FF; i++)
{
_data[i + j] = fontslot_HAnsi;
}
_data[0xA1 + j] = fontslot_EastAsia;
_data[0xA4 + j] = fontslot_EastAsia;
_data[0xA7 + j] = fontslot_EastAsia;
_data[0xA8 + j] = fontslot_EastAsia;
_data[0xAA + j] = fontslot_EastAsia;
_data[0xAD + j] = fontslot_EastAsia;
_data[0xAF + j] = fontslot_EastAsia;
_data[0xB0 + j] = fontslot_EastAsia;
_data[0xB1 + j] = fontslot_EastAsia;
_data[0xB2 + j] = fontslot_EastAsia;
_data[0xB3 + j] = fontslot_EastAsia;
_data[0xB4 + j] = fontslot_EastAsia;
_data[0xB6 + j] = fontslot_EastAsia;
_data[0xB7 + j] = fontslot_EastAsia;
_data[0xB8 + j] = fontslot_EastAsia;
_data[0xB9 + j] = fontslot_EastAsia;
_data[0xBA + j] = fontslot_EastAsia;
_data[0xBC + j] = fontslot_EastAsia;
_data[0xBD + j] = fontslot_EastAsia;
_data[0xBE + j] = fontslot_EastAsia;
_data[0xBF + j] = fontslot_EastAsia;
_data[0xD7 + j] = fontslot_EastAsia;
_data[0xF7 + j] = fontslot_EastAsia;
for (i = 0x02B0; i <= 0x04FF; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0x0590; i <= 0x07BF; i++)
{
_data[i + j] = fontslot_ASCII;
}
for (i = 0x1100; i <= 0x11FF; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0x1E00; i <= 0x1EFF; i++)
{
_data[i + j] = fontslot_HAnsi;
}
for (i = 0x1F00; i <= 0x1FFF; i++)
{
_data[i + j] = fontslot_HAnsi;
}
for (i = 0x2000; i <= 0x27BF; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0x2E80; i <= 0x319F; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0x3200; i <= 0x4D8F; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0x4E00; i <= 0x9FAF; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0xA000; i <= 0xA4CF; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0xAC00; i <= 0xD7AF; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0xD800; i <= 0xDFFF; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0xE000; i <= 0xF8FF; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0xF900; i <= 0xFAFF; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0xFB00; i <= 0xFB1C; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0xFB1D; i <= 0xFDFF; i++)
{
_data[i + j] = fontslot_ASCII;
}
for (i = 0xFE30; i <= 0xFE6F; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0xFE70; i <= 0xFEFE; i++)
{
_data[i + j] = fontslot_ASCII;
}
for (i = 0xFF00; i <= 0xFFEF; i++)
{
_data[i + j] = fontslot_EastAsia;
}
// ********************** 3rd table *********************** //
j = this.TableChunkHintZH;
for (i = 0x0000; i <= 0x007F; i++)
{
_data[i + j] = fontslot_ASCII;
}
for (i = 0x00A0; i <= 0x00FF; i++)
{
_data[i + j] = fontslot_HAnsi;
}
_data[0xA1 + j] = fontslot_EastAsia;
_data[0xA4 + j] = fontslot_EastAsia;
_data[0xA7 + j] = fontslot_EastAsia;
_data[0xA8 + j] = fontslot_EastAsia;
_data[0xAA + j] = fontslot_EastAsia;
_data[0xAD + j] = fontslot_EastAsia;
_data[0xAF + j] = fontslot_EastAsia;
_data[0xB0 + j] = fontslot_EastAsia;
_data[0xB1 + j] = fontslot_EastAsia;
_data[0xB2 + j] = fontslot_EastAsia;
_data[0xB3 + j] = fontslot_EastAsia;
_data[0xB4 + j] = fontslot_EastAsia;
_data[0xB6 + j] = fontslot_EastAsia;
_data[0xB7 + j] = fontslot_EastAsia;
_data[0xB8 + j] = fontslot_EastAsia;
_data[0xB9 + j] = fontslot_EastAsia;
_data[0xBA + j] = fontslot_EastAsia;
_data[0xBC + j] = fontslot_EastAsia;
_data[0xBD + j] = fontslot_EastAsia;
_data[0xBE + j] = fontslot_EastAsia;
_data[0xBF + j] = fontslot_EastAsia;
_data[0xD7 + j] = fontslot_EastAsia;
_data[0xF7 + j] = fontslot_EastAsia;
_data[0xE0 + j] = fontslot_EastAsia;
_data[0xE1 + j] = fontslot_EastAsia;
_data[0xE8 + j] = fontslot_EastAsia;
_data[0xE9 + j] = fontslot_EastAsia;
_data[0xEA + j] = fontslot_EastAsia;
_data[0xEC + j] = fontslot_EastAsia;
_data[0xED + j] = fontslot_EastAsia;
_data[0xF2 + j] = fontslot_EastAsia;
_data[0xF3 + j] = fontslot_EastAsia;
_data[0xF9 + j] = fontslot_EastAsia;
_data[0xFA + j] = fontslot_EastAsia;
_data[0xFC + j] = fontslot_EastAsia;
for (i = 0x0100; i <= 0x02AF; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0x02B0; i <= 0x04FF; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0x0590; i <= 0x07BF; i++)
{
_data[i + j] = fontslot_ASCII;
}
for (i = 0x1100; i <= 0x11FF; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0x1E00; i <= 0x1EFF; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0x1F00; i <= 0x1FFF; i++)
{
_data[i + j] = fontslot_HAnsi;
}
for (i = 0x2000; i <= 0x27BF; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0x2E80; i <= 0x319F; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0x3200; i <= 0x4D8F; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0x4E00; i <= 0x9FAF; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0xA000; i <= 0xA4CF; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0xAC00; i <= 0xD7AF; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0xD800; i <= 0xDFFF; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0xE000; i <= 0xF8FF; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0xF900; i <= 0xFAFF; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0xFB00; i <= 0xFB1C; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0xFB1D; i <= 0xFDFF; i++)
{
_data[i + j] = fontslot_ASCII;
}
for (i = 0xFE30; i <= 0xFE6F; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0xFE70; i <= 0xFEFE; i++)
{
_data[i + j] = fontslot_ASCII;
}
for (i = 0xFF00; i <= 0xFFEF; i++)
{
_data[i + j] = fontslot_EastAsia;
}
// ********************** 4rd table *********************** //
j = this.TableChunkHintEACS;
for (i = 0x0000; i <= 0x007F; i++)
{
_data[i + j] = fontslot_ASCII;
}
for (i = 0x00A0; i <= 0x00FF; i++)
{
_data[i + j] = fontslot_HAnsi;
}
_data[0xA1 + j] = fontslot_EastAsia;
_data[0xA4 + j] = fontslot_EastAsia;
_data[0xA7 + j] = fontslot_EastAsia;
_data[0xA8 + j] = fontslot_EastAsia;
_data[0xAA + j] = fontslot_EastAsia;
_data[0xAD + j] = fontslot_EastAsia;
_data[0xAF + j] = fontslot_EastAsia;
_data[0xB0 + j] = fontslot_EastAsia;
_data[0xB1 + j] = fontslot_EastAsia;
_data[0xB2 + j] = fontslot_EastAsia;
_data[0xB3 + j] = fontslot_EastAsia;
_data[0xB4 + j] = fontslot_EastAsia;
_data[0xB6 + j] = fontslot_EastAsia;
_data[0xB7 + j] = fontslot_EastAsia;
_data[0xB8 + j] = fontslot_EastAsia;
_data[0xB9 + j] = fontslot_EastAsia;
_data[0xBA + j] = fontslot_EastAsia;
_data[0xBC + j] = fontslot_EastAsia;
_data[0xBD + j] = fontslot_EastAsia;
_data[0xBE + j] = fontslot_EastAsia;
_data[0xBF + j] = fontslot_EastAsia;
_data[0xD7 + j] = fontslot_EastAsia;
_data[0xF7 + j] = fontslot_EastAsia;
for (i = 0x0100; i <= 0x02AF; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0x02B0; i <= 0x04FF; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0x0590; i <= 0x07BF; i++)
{
_data[i + j] = fontslot_ASCII;
}
for (i = 0x1100; i <= 0x11FF; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0x1E00; i <= 0x1EFF; i++)
{
_data[i + j] = fontslot_HAnsi;
}
for (i = 0x1F00; i <= 0x1FFF; i++)
{
_data[i + j] = fontslot_HAnsi;
}
for (i = 0x2000; i <= 0x27BF; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0x2E80; i <= 0x319F; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0x3200; i <= 0x4D8F; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0x4E00; i <= 0x9FAF; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0xA000; i <= 0xA4CF; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0xAC00; i <= 0xD7AF; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0xD800; i <= 0xDFFF; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0xE000; i <= 0xF8FF; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0xF900; i <= 0xFAFF; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0xFB00; i <= 0xFB1C; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0xFB1D; i <= 0xFDFF; i++)
{
_data[i + j] = fontslot_ASCII;
}
for (i = 0xFE30; i <= 0xFE6F; i++)
{
_data[i + j] = fontslot_EastAsia;
}
for (i = 0xFE70; i <= 0xFEFE; i++)
{
_data[i + j] = fontslot_ASCII;
}
for (i = 0xFF00; i <= 0xFFEF; i++)
{
_data[i + j] = fontslot_EastAsia;
}
}
this.Get_FontClass = function(nUnicode, nHint, nEastAsia_lcid, bCS, bRTL)
{
var _glyph_slot = fontslot_ASCII;
if (nHint != fonthint_EastAsia)
{
_glyph_slot = this.DetectData.data[nUnicode];
}
else
{
if (nEastAsia_lcid == lcid_zh)
_glyph_slot = this.DetectData.data[this.TableChunkHintZH + nUnicode];
else
_glyph_slot = this.DetectData.data[this.TableChunkHintEA + nUnicode];
if (_glyph_slot == fontslot_EastAsia)
return _glyph_slot;
}
if (bCS || bRTL)
return fontslot_CS;
return _glyph_slot;
}
}
window.CDetectFontUse = CDetectFontUse;
})(window.document);
var g_font_detector = new window.CDetectFontUse();
g_font_detector.Init();
\ No newline at end of file
"use strict";
/**
* User: Ilja.Kirillov
* Date: 07.11.11
* Time: 14:49
*/
var numbering_numfmt_None = 0x0000;
var numbering_numfmt_Bullet = 0x1001;
var numbering_numfmt_Decimal = 0x2002;
var numbering_numfmt_LowerRoman = 0x2003;
var numbering_numfmt_UpperRoman = 0x2004;
var numbering_numfmt_LowerLetter = 0x2005;
var numbering_numfmt_UpperLetter = 0x2006;
var numbering_numfmt_DecimalZero = 0x2007;
var numbering_lvltext_Text = 1;
var numbering_lvltext_Num = 2;
var numbering_suff_Tab = 1;
var numbering_suff_Space = 2;
var numbering_suff_Nothing = 3;
// Преобразовываем число в буквенную строку :
// 1 -> a
// 2 -> b
// ...
// 26 -> z
// 27 -> aa
// ...
// 52 -> zz
// 53 -> aaa
// ...
function Numbering_Number_To_Alpha(Num, bLowerCase)
{
var _Num = Num - 1;
var Count = (_Num - _Num % 26) / 26;
var Ost = _Num % 26;
var T = "";
var Letter;
if ( true === bLowerCase )
Letter = String.fromCharCode( Ost + 97 );
else
Letter = String.fromCharCode( Ost + 65 );
for ( var Index2 = 0; Index2 < Count + 1; Index2++ )
T += Letter;
return T;
}
// Преобразовываем число в обычную строку :
function Numbering_Number_To_String(Num)
{
return "" + Num;
}
// Преобразовываем число в римскую систему исчисления :
// 1 -> i
// 4 -> iv
// 5 -> v
// 9 -> ix
// 10 -> x
// 40 -> xl
// 50 -> l
// 90 -> xc
// 100 -> c
// 400 -> cd
// 500 -> d
// 900 -> cm
// 1000 -> m
function Numbering_Number_To_Roman(Num, bLowerCase)
{
// Переводим число Num в римскую систему исчисления
var Rims;
if ( true === bLowerCase )
Rims = [ 'm', 'cm', 'd', 'cd', 'c', 'xc', 'l', 'xl', 'x', 'ix', 'v', 'iv', 'i', ' '];
else
Rims = [ 'M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I', ' '];
var Vals = [ 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1, 0];
var T = "";
var Index2 = 0;
while ( Num > 0 )
{
while ( Vals[Index2] <= Num )
{
T += Rims[Index2];
Num -= Vals[Index2];
}
Index2++;
if ( Index2 >= Rims.length )
break;
}
return T;
}
function LvlText_Read_FromBinary(Reader)
{
var ElementType = Reader.GetLong();
var Element = null;
if ( numbering_lvltext_Num === ElementType )
Element = new CLvlText_Num();
else if ( numbering_lvltext_Text === ElementType )
Element = new CLvlText_Text();
Element.Read_FromBinary(Reader);
return Element;
}
function CLvlText_Text(Val)
{
if ( "string" == typeof(Val) )
this.Value = Val;
else
this.Value = "";
this.Type = numbering_lvltext_Text;
}
CLvlText_Text.prototype =
{
Copy : function()
{
var Obj = new CLvlText_Text( this.Value );
return Obj;
},
Write_ToBinary : function(Writer)
{
// Long : numbering_lvltext_Text
// String : Value
Writer.WriteLong( numbering_lvltext_Text );
Writer.WriteString2( this.Value );
},
Read_FromBinary : function(Reader)
{
this.Value = Reader.GetString2();
}
};
function CLvlText_Num(Lvl)
{
if ( "number" == typeof(Lvl) )
this.Value = Lvl;
else
this.Value = 0;
this.Type = numbering_lvltext_Num;
}
CLvlText_Num.prototype =
{
Copy : function()
{
var Obj = new CLvlText_Num( this.Value );
return Obj;
},
Write_ToBinary : function(Writer)
{
// Long : numbering_lvltext_Text
// Long : Value
Writer.WriteLong( numbering_lvltext_Num );
Writer.WriteLong( this.Value );
},
Read_FromBinary : function(Reader)
{
this.Value = Reader.GetLong();
}
};
function CAbstractNum(Type)
{
this.Id = g_oIdCounter.Get_NewId();
if ( "undefined" == typeof(Type) )
Type = numbering_numfmt_Bullet;
this.Lock = new CLock();
if ( false === g_oIdCounter.m_bLoad )
{
this.Lock.Set_Type( locktype_Mine, false );
CollaborativeEditing.Add_Unlock2( this );
}
this.Lvl = [];
for ( var Index = 0; Index < 9; Index++ )
{
this.Lvl[Index] = {};
var Lvl = this.Lvl[Index];
Lvl.PStyle = undefined;
Lvl.Start = 1;
Lvl.Restart = -1; // -1 - делаем нумерацию сначала всегда, 0 - никогда не начинаем нумерацию заново
Lvl.Suff = numbering_suff_Tab;
var Left = 36 * (Index + 1) * g_dKoef_pt_to_mm;
var FirstLine = -18 * g_dKoef_pt_to_mm;
Lvl.Jc = align_Left;
Lvl.Format = numbering_numfmt_Bullet;
Lvl.LvlText = [];
Lvl.ParaPr = new CParaPr();
Lvl.ParaPr.Ind.Left = Left;
Lvl.ParaPr.Ind.FirstLine = FirstLine;
var TextPr = new CTextPr();
if ( 0 == Index % 3 )
{
TextPr.FontFamily = { Name : "Symbol", Index : -1 };
Lvl.LvlText.push( new CLvlText_Text( String.fromCharCode( 0x00B7 ) ) );
}
else if ( 1 == Index % 3 )
{
TextPr.FontFamily = { Name : "Courier New", Index : -1 };
Lvl.LvlText.push( new CLvlText_Text( "o" ) );
}
else
{
TextPr.FontFamily = { Name : "Wingdings", Index : -1 };
Lvl.LvlText.push( new CLvlText_Text( String.fromCharCode( 0x00A7 ) ) );
}
Lvl.TextPr = TextPr;
}
// Добавляем данный класс в таблицу Id (обязательно в конце конструктора)
g_oTableId.Add( this, this.Id );
}
CAbstractNum.prototype =
{
Set_Id : function(newId)
{
g_oTableId.Reset_Id( this, newId, this.Id );
this.Id = newId;
},
Get_Id : function()
{
return this.Id;
},
// Копируем информацию из другой нумерации
Copy : function(AbstractNum)
{
for ( var Index = 0; Index < 9; Index++ )
{
var Lvl_new = this.Internal_CopyLvl( AbstractNum.Lvl[Index] );
var Lvl_old = this.Lvl[Index];
History.Add( this, { Type : historyitem_AbstractNum_LvlChange, Index : Index, Old : Lvl_old, New : Lvl_new } );
this.Lvl[Index] = Lvl_new;
}
},
Get_LvlByStyle : function(StyleId)
{
for ( var Index = 0; Index < 9; Index++ )
{
var Lvl = this.Lvl[Index];
if ( StyleId === Lvl.PStyle )
return Index;
}
return -1;
},
Get_Lvl : function(Lvl)
{
if ( undefined === this.Lvl[Lvl] )
return this.Lvl[0];
return this.Lvl[Lvl];
},
// Определяем многоуровненый список по умолчанию
Create_Default_Numbered : function()
{
for ( var Index = 0; Index < 9; Index++ )
{
var Lvl_old = this.Internal_CopyLvl( this.Lvl[Index] );
this.Lvl[Index] = {};
var Lvl = this.Lvl[Index];
Lvl.Start = 1;
Lvl.Restart = -1; // -1 - делаем нумерацию сначала всегда, 0 - никогда не начинаем нумерацию заново
Lvl.Suff = numbering_suff_Tab;
var Left = 36 * (Index + 1) * g_dKoef_pt_to_mm;
var FirstLine = -18 * g_dKoef_pt_to_mm;
if ( 0 == Index % 3 )
{
Lvl.Jc = align_Left;
Lvl.Format = numbering_numfmt_Decimal;
}
else if ( 1 == Index % 3 )
{
Lvl.Jc = align_Left;
Lvl.Format = numbering_numfmt_LowerLetter;
}
else
{
Lvl.Jc = align_Right;
Lvl.Format = numbering_numfmt_LowerRoman;
FirstLine = -9 * g_dKoef_pt_to_mm;
}
Lvl.LvlText = [];
Lvl.LvlText.push( new CLvlText_Num( Index ) );
Lvl.LvlText.push( new CLvlText_Text( "." ) );
Lvl.ParaPr = new CParaPr();
Lvl.ParaPr.Ind.Left = Left;
Lvl.ParaPr.Ind.FirstLine = FirstLine;
var TextPr = new CTextPr();
TextPr.FontFamily = { Name : "Times New Roman", Index : -1 };
Lvl.TextPr = TextPr;
var Lvl_new = this.Internal_CopyLvl( Lvl );
History.Add( this, { Type : historyitem_AbstractNum_LvlChange, Index : Index, Old : Lvl_old, New : Lvl_new } );
}
},
Create_Default_Multilevel_1 : function()
{
for ( var Index = 0; Index < 9; Index++ )
{
var Lvl_old = this.Internal_CopyLvl( this.Lvl[Index] );
this.Lvl[Index] = {};
var Lvl = this.Lvl[Index];
Lvl.Start = 1;
Lvl.Restart = -1;
Lvl.Suff = numbering_suff_Tab;
var Left = 18 * (Index + 1) * g_dKoef_pt_to_mm;
var FirstLine = -18 * g_dKoef_pt_to_mm;
Lvl.Jc = align_Left;
if ( 0 == Index % 3 )
{
Lvl.Format = numbering_numfmt_Decimal;
}
else if ( 1 == Index % 3 )
{
Lvl.Format = numbering_numfmt_LowerLetter;
}
else
{
Lvl.Format = numbering_numfmt_LowerRoman;
}
Lvl.LvlText = [];
Lvl.LvlText.push( new CLvlText_Num( Index ) );
Lvl.LvlText.push( new CLvlText_Text( ")" ) );
Lvl.ParaPr = new CParaPr();
Lvl.ParaPr.Ind.Left = Left;
Lvl.ParaPr.Ind.FirstLine = FirstLine;
var TextPr = new CTextPr();
TextPr.FontFamily = { Name : "Times New Roman", Index : -1 };
Lvl.TextPr = TextPr;
var Lvl_new = this.Internal_CopyLvl( Lvl );
History.Add( this, { Type : historyitem_AbstractNum_LvlChange, Index : Index, Old : Lvl_old, New : Lvl_new } );
}
},
Create_Default_Multilevel_2 : function()
{
for ( var Index = 0; Index < 9; Index++ )
{
var Lvl_old = this.Internal_CopyLvl( this.Lvl[Index] );
this.Lvl[Index] = {};
var Lvl = this.Lvl[Index];
Lvl.Start = 1;
Lvl.Restart = -1; // -1 - делаем нумерацию сначала всегда, 0 - никогда не начинаем нумерацию заново
Lvl.Suff = numbering_suff_Tab;
var Left = 0;
var FirstLine = 0;
switch ( Index )
{
case 0 :
Left = 18 * g_dKoef_pt_to_mm;
FirstLine = -18 * g_dKoef_pt_to_mm;
break;
case 1 :
Left = 39.6 * g_dKoef_pt_to_mm;
FirstLine = -21.6 * g_dKoef_pt_to_mm;
break;
case 2 :
Left = 61.2 * g_dKoef_pt_to_mm;
FirstLine = -25.2 * g_dKoef_pt_to_mm;
break;
case 3 :
Left = 86.4 * g_dKoef_pt_to_mm;
FirstLine = -32.4 * g_dKoef_pt_to_mm;
break;
case 4 :
Left = 111.6 * g_dKoef_pt_to_mm;
FirstLine = -39.6 * g_dKoef_pt_to_mm;
break;
case 5 :
Left = 136.8 * g_dKoef_pt_to_mm;
FirstLine = -46.8 * g_dKoef_pt_to_mm;
break;
case 6 :
Left = 162 * g_dKoef_pt_to_mm;
FirstLine = -54 * g_dKoef_pt_to_mm;
break;
case 7 :
Left = 187.2 * g_dKoef_pt_to_mm;
FirstLine = -61.2 * g_dKoef_pt_to_mm;
break;
case 8 :
Left = 216 * g_dKoef_pt_to_mm;
FirstLine = -72 * g_dKoef_pt_to_mm;
break;
}
Lvl.Jc = align_Left;
Lvl.Format = numbering_numfmt_Decimal;
Lvl.LvlText = [];
for ( var Index2 = 0; Index2 <= Index; Index2++ )
{
Lvl.LvlText.push( new CLvlText_Num( Index2 ) );
Lvl.LvlText.push( new CLvlText_Text( "." ) );
}
Lvl.ParaPr = new CParaPr();
Lvl.ParaPr.Ind.Left = Left;
Lvl.ParaPr.Ind.FirstLine = FirstLine;
var TextPr = new CTextPr();
TextPr.FontFamily = { Name : "Times New Roman", Index : -1 };
Lvl.TextPr = TextPr;
var Lvl_new = this.Internal_CopyLvl( Lvl );
History.Add( this, { Type : historyitem_AbstractNum_LvlChange, Index : Index, Old : Lvl_old, New : Lvl_new } );
}
},
Create_Default_Multilevel_3 : function()
{
for ( var Index = 0; Index < 9; Index++ )
{
var Lvl_old = this.Internal_CopyLvl( this.Lvl[Index] );
this.Lvl[Index] = {};
var Lvl = this.Lvl[Index];
Lvl.Start = 1;
Lvl.Restart = -1; // -1 - делаем нумерацию сначала всегда, 0 - никогда не начинаем нумерацию заново
Lvl.Suff = numbering_suff_Tab;
var Left = 18 * (Index + 1) * g_dKoef_pt_to_mm;
var FirstLine = -18 * g_dKoef_pt_to_mm;
Lvl.Format = numbering_numfmt_Bullet;
Lvl.Jc = align_Left;
if ( 0 == Index % 3 )
{
Lvl.Jc = align_Left;
}
else if ( 1 == Index % 3 )
{
Lvl.Jc = align_Left;
Lvl.Format = numbering_numfmt_LowerLetter;
}
else
{
Lvl.Jc = align_Right;
Lvl.Format = numbering_numfmt_LowerRoman;
FirstLine = -9 * g_dKoef_pt_to_mm;
}
Lvl.LvlText = [];
switch( Index )
{
case 0:
Lvl.LvlText.push( new CLvlText_Text( String.fromCharCode( 0x0076 ) ) );
break;
case 1:
Lvl.LvlText.push( new CLvlText_Text( String.fromCharCode( 0x00D8 ) ) );
break;
case 2:
Lvl.LvlText.push( new CLvlText_Text( String.fromCharCode( 0x00A7 ) ) );
break;
case 3:
Lvl.LvlText.push( new CLvlText_Text( String.fromCharCode( 0x00B7 ) ) );
break;
case 4:
Lvl.LvlText.push( new CLvlText_Text( String.fromCharCode( 0x00A8 ) ) );
break;
case 5:
Lvl.LvlText.push( new CLvlText_Text( String.fromCharCode( 0x00D8 ) ) );
break;
case 6:
Lvl.LvlText.push( new CLvlText_Text( String.fromCharCode( 0x00A7 ) ) );
break;
case 7:
Lvl.LvlText.push( new CLvlText_Text( String.fromCharCode( 0x00B7 ) ) );
break;
case 8:
Lvl.LvlText.push( new CLvlText_Text( String.fromCharCode( 0x00A8 ) ) );
break;
}
Lvl.ParaPr = new CParaPr();
Lvl.ParaPr.Ind.Left = Left;
Lvl.ParaPr.Ind.FirstLine = FirstLine;
var TextPr = new CTextPr();
if ( 3 === Index || 4 === Index || 7 === Index || 8 === Index )
TextPr.FontFamily = { Name : "Times New Roman", Index : -1 };
else
TextPr.FontFamily = { Name : "Wingdings", Index : -1 };
Lvl.TextPr = TextPr;
var Lvl_new = this.Internal_CopyLvl( Lvl );
History.Add( this, { Type : historyitem_AbstractNum_LvlChange, Index : Index, Old : Lvl_old, New : Lvl_new } );
}
},
Create_Default_Bullet : function()
{
for ( var Index = 0; Index < 9; Index++ )
{
var Lvl_old = this.Internal_CopyLvl( this.Lvl[Index] );
this.Lvl[Index] = {};
var Lvl = this.Lvl[Index];
Lvl.Start = 1;
Lvl.Restart = -1; // -1 - делаем нумерацию сначала всегда, 0 - никогда не начинаем нумерацию заново
Lvl.Suff = numbering_suff_Tab;
var Left = 36 * (Index + 1) * g_dKoef_pt_to_mm;
var FirstLine = -18 * g_dKoef_pt_to_mm;
Lvl.Jc = align_Left;
Lvl.Format = numbering_numfmt_Bullet;
Lvl.LvlText = [];
Lvl.ParaPr = new CParaPr();
Lvl.ParaPr.Ind.Left = Left;
Lvl.ParaPr.Ind.FirstLine = FirstLine;
var TextPr = new CTextPr();
if ( 0 == Index % 3 )
{
TextPr.FontFamily = { Name : "Symbol", Index : -1 };
Lvl.LvlText.push( new CLvlText_Text( String.fromCharCode( 0x00B7 ) ) );
}
else if ( 1 == Index % 3 )
{
TextPr.FontFamily = { Name : "Courier New", Index : -1 };
Lvl.LvlText.push( new CLvlText_Text( "o" ) );
}
else
{
TextPr.FontFamily = { Name : "Wingdings", Index : -1 };
Lvl.LvlText.push( new CLvlText_Text( String.fromCharCode( 0x00A7 ) ) );
}
Lvl.TextPr = TextPr;
var Lvl_new = this.Internal_CopyLvl( Lvl );
History.Add( this, { Type : historyitem_AbstractNum_LvlChange, Index : Index, Old : Lvl_old, New : Lvl_new } );
}
},
Set_Lvl_Bullet : function(iLvl, LvlText, TextPr)
{
if ( "number" != typeof(iLvl) || iLvl < 0 || iLvl >= 9 )
return;
var Lvl = this.Lvl[iLvl];
var Lvl_old = this.Internal_CopyLvl( Lvl );
Lvl.Format = numbering_numfmt_Bullet;
Lvl.LvlText = [];
Lvl.LvlText.push( new CLvlText_Text( LvlText ) );
Lvl.TextPr = TextPr;
var Lvl_new = this.Internal_CopyLvl( Lvl );
History.Add( this, { Type : historyitem_AbstractNum_LvlChange, Index : iLvl, Old : Lvl_old, New : Lvl_new } );
},
// 1) right
Set_Lvl_Numbered_1 : function(iLvl)
{
if ( "number" != typeof(iLvl) || iLvl < 0 || iLvl >= 9 )
return;
var Lvl = this.Lvl[iLvl];
var Lvl_old = this.Internal_CopyLvl( Lvl );
Lvl.Jc = align_Right;
Lvl.Format = numbering_numfmt_Decimal;
Lvl.LvlText = [];
Lvl.LvlText.push( new CLvlText_Num( iLvl ) );
Lvl.LvlText.push( new CLvlText_Text( ")" ) );
Lvl.TextPr.FontFamily = { Name : "Times New Roman", Index : -1 };
var Lvl_new = this.Internal_CopyLvl( Lvl );
History.Add( this, { Type : historyitem_AbstractNum_LvlChange, Index : iLvl, Old : Lvl_old, New : Lvl_new } );
},
// 1. right
Set_Lvl_Numbered_2 : function(iLvl)
{
if ( "number" != typeof(iLvl) || iLvl < 0 || iLvl >= 9 )
return;
var Lvl = this.Lvl[iLvl];
var Lvl_old = this.Internal_CopyLvl( Lvl );
Lvl.Jc = align_Right;
Lvl.Format = numbering_numfmt_Decimal;
Lvl.LvlText = [];
Lvl.LvlText.push( new CLvlText_Num( iLvl ) );
Lvl.LvlText.push( new CLvlText_Text( "." ) );
Lvl.TextPr.FontFamily = { Name : "Times New Roman", Index : -1 };
var Lvl_new = this.Internal_CopyLvl( Lvl );
History.Add( this, { Type : historyitem_AbstractNum_LvlChange, Index : iLvl, Old : Lvl_old, New : Lvl_new } );
},
// 1. left
Set_Lvl_Numbered_3 : function(iLvl)
{
if ( "number" != typeof(iLvl) || iLvl < 0 || iLvl >= 9 )
return;
var Lvl = this.Lvl[iLvl];
var Lvl_old = this.Internal_CopyLvl( Lvl );
Lvl.Jc = align_Left;
Lvl.Format = numbering_numfmt_Decimal;
Lvl.LvlText = [];
Lvl.LvlText.push( new CLvlText_Num( iLvl ) );
Lvl.LvlText.push( new CLvlText_Text( "." ) );
Lvl.TextPr.FontFamily = { Name : "Times New Roman", Index : -1 };
var Lvl_new = this.Internal_CopyLvl( Lvl );
History.Add( this, { Type : historyitem_AbstractNum_LvlChange, Index : iLvl, Old : Lvl_old, New : Lvl_new } );
},
// 1) left
Set_Lvl_Numbered_4 : function(iLvl)
{
if ( "number" != typeof(iLvl) || iLvl < 0 || iLvl >= 9 )
return;
var Lvl = this.Lvl[iLvl];
var Lvl_old = this.Internal_CopyLvl( Lvl );
Lvl.Jc = align_Left;
Lvl.Format = numbering_numfmt_Decimal;
Lvl.LvlText = [];
Lvl.LvlText.push( new CLvlText_Num( iLvl ) );
Lvl.LvlText.push( new CLvlText_Text( ")" ) );
Lvl.TextPr.FontFamily = { Name : "Times New Roman", Index : -1 };
var Lvl_new = this.Internal_CopyLvl( Lvl );
History.Add( this, { Type : historyitem_AbstractNum_LvlChange, Index : iLvl, Old : Lvl_old, New : Lvl_new } );
},
// I. right
Set_Lvl_Numbered_5 : function(iLvl)
{
if ( "number" != typeof(iLvl) || iLvl < 0 || iLvl >= 9 )
return;
var Lvl = this.Lvl[iLvl];
var Lvl_old = this.Internal_CopyLvl( Lvl );
Lvl.Jc = align_Right;
Lvl.Format = numbering_numfmt_UpperRoman;
Lvl.LvlText = [];
Lvl.LvlText.push( new CLvlText_Num( iLvl ) );
Lvl.LvlText.push( new CLvlText_Text( "." ) );
Lvl.TextPr.FontFamily = { Name : "Times New Roman", Index : -1 };
var Lvl_new = this.Internal_CopyLvl( Lvl );
History.Add( this, { Type : historyitem_AbstractNum_LvlChange, Index : iLvl, Old : Lvl_old, New : Lvl_new } );
},
// A. left
Set_Lvl_Numbered_6 : function(iLvl)
{
if ( "number" != typeof(iLvl) || iLvl < 0 || iLvl >= 9 )
return;
var Lvl = this.Lvl[iLvl];
var Lvl_old = this.Internal_CopyLvl( Lvl );
Lvl.Jc = align_Left;
Lvl.Format = numbering_numfmt_UpperLetter;
Lvl.LvlText = [];
Lvl.LvlText.push( new CLvlText_Num( iLvl ) );
Lvl.LvlText.push( new CLvlText_Text( "." ) );
Lvl.TextPr.FontFamily = { Name : "Times New Roman", Index : -1 };
var Lvl_new = this.Internal_CopyLvl( Lvl );
History.Add( this, { Type : historyitem_AbstractNum_LvlChange, Index : iLvl, Old : Lvl_old, New : Lvl_new } );
},
// a) left
Set_Lvl_Numbered_7 : function(iLvl)
{
if ( "number" != typeof(iLvl) || iLvl < 0 || iLvl >= 9 )
return;
var Lvl = this.Lvl[iLvl];
var Lvl_old = this.Internal_CopyLvl( Lvl );
Lvl.Jc = align_Left;
Lvl.Format = numbering_numfmt_LowerLetter;
Lvl.LvlText = [];
Lvl.LvlText.push( new CLvlText_Num( iLvl ) );
Lvl.LvlText.push( new CLvlText_Text( ")" ) );
Lvl.TextPr.FontFamily = { Name : "Times New Roman", Index : -1 };
var Lvl_new = this.Internal_CopyLvl( Lvl );
History.Add( this, { Type : historyitem_AbstractNum_LvlChange, Index : iLvl, Old : Lvl_old, New : Lvl_new } );
},
// a. left
Set_Lvl_Numbered_8 : function(iLvl)
{
if ( "number" != typeof(iLvl) || iLvl < 0 || iLvl >= 9 )
return;
var Lvl = this.Lvl[iLvl];
var Lvl_old = this.Internal_CopyLvl( Lvl );
Lvl.Jc = align_Left;
Lvl.Format = numbering_numfmt_LowerLetter;
Lvl.LvlText = [];
Lvl.LvlText.push( new CLvlText_Num( iLvl ) );
Lvl.LvlText.push( new CLvlText_Text( "." ) );
Lvl.TextPr.FontFamily = { Name : "Times New Roman", Index : -1 };
var Lvl_new = this.Internal_CopyLvl( Lvl );
History.Add( this, { Type : historyitem_AbstractNum_LvlChange, Index : iLvl, Old : Lvl_old, New : Lvl_new } );
},
// i. left
Set_Lvl_Numbered_9 : function(iLvl)
{
if ( "number" != typeof(iLvl) || iLvl < 0 || iLvl >= 9 )
return;
var Lvl = this.Lvl[iLvl];
var Lvl_old = this.Internal_CopyLvl( Lvl );
Lvl.Jc = align_Right;
Lvl.Format = numbering_numfmt_LowerRoman;
Lvl.LvlText = [];
Lvl.LvlText.push( new CLvlText_Num( iLvl ) );
Lvl.LvlText.push( new CLvlText_Text( "." ) );
Lvl.TextPr.FontFamily = { Name : "Times New Roman", Index : -1 };
var Lvl_new = this.Internal_CopyLvl( Lvl );
History.Add( this, { Type : historyitem_AbstractNum_LvlChange, Index : iLvl, Old : Lvl_old, New : Lvl_new } );
},
// X, Y, Context - параметры для рисование
// Lvl - уровень, с которого мы берем текст и настройки для текста
// NumInfo - информация о номере данного элемента в списке (массив из Lvl элементов)
// NumTextPr - рассчитанные настройки для символов нумерации (уже с учетом настроек текущего уровня)
Draw : function(X,Y, Context, Lvl, NumInfo, NumTextPr)
{
var Text = this.Lvl[Lvl].LvlText;
var OldFont = Context.GetFont();
var OldFont2 = g_oTextMeasurer.GetFont();
Context.SetFont( NumTextPr );
g_oTextMeasurer.SetFont( NumTextPr );
for ( var Index = 0; Index < Text.length; Index++ )
{
switch( Text[Index].Type )
{
case numbering_lvltext_Text:
{
Context.FillText( X, Y, Text[Index].Value );
X += g_oTextMeasurer.Measure( Text[Index].Value ).Width;
break;
}
case numbering_lvltext_Num:
{
var CurLvl = Text[Index].Value;
switch( this.Lvl[CurLvl].Format )
{
case numbering_numfmt_Bullet:
{
break;
}
case numbering_numfmt_Decimal:
{
if ( CurLvl < NumInfo.length )
{
var T = "" + ( this.Lvl[CurLvl].Start - 1 + NumInfo[CurLvl] );
for ( var Index2 = 0; Index2 < T.length; Index2++ )
{
var Char = T.charAt(Index2);
Context.FillText( X, Y, Char );
X += g_oTextMeasurer.Measure( Char ).Width;
}
}
break;
}
case numbering_numfmt_DecimalZero:
{
if ( CurLvl < NumInfo.length )
{
var T = "" + ( this.Lvl[CurLvl].Start - 1 + NumInfo[CurLvl] );
if ( 1 === T.length )
{
Context.FillText( X, Y, '0' );
X += g_oTextMeasurer.Measure( '0' ).Width;
var Char = T.charAt(0);
Context.FillText( X, Y, Char );
X += g_oTextMeasurer.Measure( Char ).Width;
}
else
{
for ( var Index2 = 0; Index2 < T.length; Index2++ )
{
var Char = T.charAt(Index2);
Context.FillText( X, Y, Char );
X += g_oTextMeasurer.Measure( Char ).Width;
}
}
}
break;
}
case numbering_numfmt_LowerLetter:
case numbering_numfmt_UpperLetter:
{
if ( CurLvl < NumInfo.length )
{
// Формат: a,..,z,aa,..,zz,aaa,...,zzz,...
var Num = this.Lvl[CurLvl].Start - 1 + NumInfo[CurLvl] - 1;
var Count = (Num - Num % 26) / 26;
var Ost = Num % 26;
var T = "";
var Letter;
if ( numbering_numfmt_LowerLetter === this.Lvl[CurLvl].Format )
Letter = String.fromCharCode( Ost + 97 );
else
Letter = String.fromCharCode( Ost + 65 );
for ( var Index2 = 0; Index2 < Count + 1; Index2++ )
T += Letter;
for ( var Index2 = 0; Index2 < T.length; Index2++ )
{
var Char = T.charAt(Index2);
Context.FillText( X, Y, Char );
X += g_oTextMeasurer.Measure( Char ).Width;
}
}
break;
}
case numbering_numfmt_LowerRoman:
case numbering_numfmt_UpperRoman:
{
if ( CurLvl < NumInfo.length )
{
var Num = this.Lvl[CurLvl].Start - 1 + NumInfo[CurLvl];
// Переводим число Num в римскую систему исчисления
var Rims;
if ( numbering_numfmt_LowerRoman === this.Lvl[CurLvl].Format )
Rims = [ 'm', 'cm', 'd', 'cd', 'c', 'xc', 'l', 'xl', 'x', 'ix', 'v', 'iv', 'i', ' '];
else
Rims = [ 'M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I', ' '];
var Vals = [ 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1, 0];
var T = "";
var Index2 = 0;
while ( Num > 0 )
{
while ( Vals[Index2] <= Num )
{
T += Rims[Index2];
Num -= Vals[Index2];
}
Index2++;
if ( Index2 >= Rims.length )
break;
}
for ( var Index2 = 0; Index2 < T.length; Index2++ )
{
var Char = T.charAt(Index2);
Context.FillText( X, Y, Char );
X += g_oTextMeasurer.Measure( T.charAt(Index2) ).Width;
}
}
break;
}
}
break;
}
}
}
Context.SetFont( OldFont );
g_oTextMeasurer.SetFont( OldFont2 );
},
Measure : function(Context, Lvl, NumInfo, NumTextPr)
{
var X = 0;
var Text = this.Lvl[Lvl].LvlText;
var OldFont = Context.GetFont();
Context.SetFont( NumTextPr );
var Ascent = Context.GetAscender();
for ( var Index = 0; Index < Text.length; Index++ )
{
switch( Text[Index].Type )
{
case numbering_lvltext_Text:
{
X += Context.Measure( Text[Index].Value ).Width;
break;
}
case numbering_lvltext_Num:
{
var CurLvl = Text[Index].Value;
switch( this.Lvl[CurLvl].Format )
{
case numbering_numfmt_Bullet:
{
break;
}
case numbering_numfmt_Decimal:
{
if ( CurLvl < NumInfo.length )
{
var T = "" + ( this.Lvl[CurLvl].Start - 1 + NumInfo[CurLvl] );
for ( var Index2 = 0; Index2 < T.length; Index2++ )
{
var Char = T.charAt(Index2);
X += Context.Measure( Char ).Width;
}
}
break;
}
case numbering_numfmt_DecimalZero:
{
if ( CurLvl < NumInfo.length )
{
var T = "" + ( this.Lvl[CurLvl].Start - 1 + NumInfo[CurLvl] );
if ( 1 === T.length )
{
X += Context.Measure( '0' ).Width;
var Char = T.charAt(0);
X += Context.Measure( Char ).Width;
}
else
{
for ( var Index2 = 0; Index2 < T.length; Index2++ )
{
var Char = T.charAt(Index2);
X += Context.Measure( Char ).Width;
}
}
}
break;
}
case numbering_numfmt_LowerLetter:
case numbering_numfmt_UpperLetter:
{
if ( CurLvl < NumInfo.length )
{
// Формат: a,..,z,aa,..,zz,aaa,...,zzz,...
var Num = this.Lvl[CurLvl].Start - 1 + NumInfo[CurLvl] - 1;
var Count = (Num - Num % 26) / 26;
var Ost = Num % 26;
var T = "";
var Letter;
if ( numbering_numfmt_LowerLetter === this.Lvl[CurLvl].Format )
Letter = String.fromCharCode( Ost + 97 );
else
Letter = String.fromCharCode( Ost + 65 );
for ( var Index2 = 0; Index2 < Count + 1; Index2++ )
T += Letter;
for ( var Index2 = 0; Index2 < T.length; Index2++ )
{
var Char = T.charAt(Index2);
X += Context.Measure( Char ).Width;
}
}
break;
}
case numbering_numfmt_LowerRoman:
case numbering_numfmt_UpperRoman:
{
if ( CurLvl < NumInfo.length )
{
var Num = this.Lvl[CurLvl].Start - 1 + NumInfo[CurLvl];
// Переводим число Num в римскую систему исчисления
var Rims;
if ( numbering_numfmt_LowerRoman === this.Lvl[CurLvl].Format )
Rims = [ 'm', 'cm', 'd', 'cd', 'c', 'xc', 'l', 'xl', 'x', 'ix', 'v', 'iv', 'i', ' '];
else
Rims = [ 'M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I', ' '];
var Vals = [ 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1, 0];
var T = "";
var Index2 = 0;
while ( Num > 0 )
{
while ( Vals[Index2] <= Num )
{
T += Rims[Index2];
Num -= Vals[Index2];
}
Index2++;
if ( Index2 >= Rims.length )
break;
}
for ( var Index2 = 0; Index2 < T.length; Index2++ )
{
var Char = T.charAt(Index2);
X += Context.Measure( T.charAt(Index2) ).Width;
}
}
break;
}
}
break;
}
}
}
Context.SetFont( OldFont );
return { Width : X, Ascent : Ascent };
},
Document_CreateFontCharMap : function(FontCharMap, Lvl, NumInfo, NumTextPr)
{
FontCharMap.StartFont( NumTextPr.FontFamily.Name, NumTextPr.Bold, NumTextPr.Italic, NumTextPr.FontSize );
var Text = this.Lvl[Lvl].LvlText;
for ( var Index = 0; Index < Text.length; Index++ )
{
switch( Text[Index].Type )
{
case numbering_lvltext_Text:
{
FontCharMap.AddChar( Text[Index].Value );
break;
}
case numbering_lvltext_Num:
{
var CurLvl = Text[Index].Value;
switch( this.Lvl[CurLvl].Format )
{
case numbering_numfmt_Bullet:
{
break;
}
case numbering_numfmt_Decimal:
{
if ( CurLvl < NumInfo.length )
{
var T = "" + ( this.Lvl[CurLvl].Start - 1 + NumInfo[CurLvl] );
for ( var Index2 = 0; Index2 < T.length; Index2++ )
{
var Char = T.charAt(Index2);
FontCharMap.AddChar( Char );
}
}
break;
}
case numbering_numfmt_DecimalZero:
{
if ( CurLvl < NumInfo.length )
{
var T = "" + ( this.Lvl[CurLvl].Start - 1 + NumInfo[CurLvl] );
if ( 1 === T.length )
{
FontCharMap.AddChar( '0' );
var Char = T.charAt(0);
FontCharMap.AddChar( Char );
}
else
{
for ( var Index2 = 0; Index2 < T.length; Index2++ )
{
var Char = T.charAt(Index2);
FontCharMap.AddChar( Char );
}
}
}
break;
}
case numbering_numfmt_LowerLetter:
case numbering_numfmt_UpperLetter:
{
if ( CurLvl < NumInfo.length )
{
// Формат: a,..,z,aa,..,zz,aaa,...,zzz,...
var Num = this.Lvl[CurLvl].Start - 1 + NumInfo[CurLvl] - 1;
var Count = (Num - Num % 26) / 26;
var Ost = Num % 26;
var T = "";
var Letter;
if ( numbering_numfmt_LowerLetter === this.Lvl[CurLvl].Format )
Letter = String.fromCharCode( Ost + 97 );
else
Letter = String.fromCharCode( Ost + 65 );
for ( var Index2 = 0; Index2 < Count + 1; Index2++ )
T += Letter;
for ( var Index2 = 0; Index2 < T.length; Index2++ )
{
var Char = T.charAt(Index2);
FontCharMap.AddChar( Char );
}
}
break;
}
case numbering_numfmt_LowerRoman:
case numbering_numfmt_UpperRoman:
{
if ( CurLvl < NumInfo.length )
{
var Num = this.Lvl[CurLvl].Start - 1 + NumInfo[CurLvl];
// Переводим число Num в римскую систему исчисления
var Rims;
if ( numbering_numfmt_LowerRoman === this.Lvl[CurLvl].Format )
Rims = [ 'm', 'cm', 'd', 'cd', 'c', 'xc', 'l', 'xl', 'x', 'ix', 'v', 'iv', 'i', ' '];
else
Rims = [ 'M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I', ' '];
var Vals = [ 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1, 0];
var T = "";
var Index2 = 0;
while ( Num > 0 )
{
while ( Vals[Index2] <= Num )
{
T += Rims[Index2];
Num -= Vals[Index2];
}
Index2++;
if ( Index2 >= Rims.length )
break;
}
for ( var Index2 = 0; Index2 < T.length; Index2++ )
{
var Char = T.charAt(Index2);
FontCharMap.AddChar( Char );
}
}
break;
}
}
break;
}
}
}
},
Document_Get_AllFontNames : function(AllFonts)
{
var Count = this.Lvl.length;
for ( var Index = 0; Index < Count; Index++ )
{
var Lvl = this.Lvl[Index];
if ( undefined != Lvl.TextPr && undefined != Lvl.TextPr.FontFamily )
AllFonts[Lvl.TextPr.FontFamily.Name] = true;
}
},
DocumentStatistics : function(Lvl, Stats)
{
var Text = this.Lvl[Lvl].LvlText;
var bWord = false;
for ( var Index = 0; Index < Text.length; Index++ )
{
var bSymbol = false;
var bSpace = false;
var bNewWord = false;
if ( numbering_lvltext_Text === Text[Index].Type && ( sp_string === Text[Index].Value || nbsp_string === Text[Index].Value ) )
{
bWord = false;
bSymbol = true;
bSpace = true;
}
else
{
if ( false === bWord )
bNewWord = true;
bWord = true;
bSymbol = true;
bSpace = false;
}
if ( true === bSymbol )
Stats.Add_Symbol( bSpace );
if ( true === bNewWord )
Stats.Add_Word();
}
if ( numbering_suff_Tab === this.Lvl[Lvl].Suff || numbering_suff_Space === this.Lvl[Lvl].Suff )
Stats.Add_Symbol( true );
},
// Применяем новые тектовые настройки к данной нумерации на заданном уровне
Apply_TextPr : function(Lvl, TextPr)
{
var CurTextPr = this.Lvl[Lvl].TextPr;
var TextPr_old = CurTextPr.Copy();
CurTextPr.Merge(TextPr);
var TextPr_new = CurTextPr.Copy();
History.Add( this, { Type : historyitem_AbstractNum_TextPrChange, Index : Lvl, Old : TextPr_old, New : TextPr_new } );
},
//-----------------------------------------------------------------------------------
// Undo/Redo функции
//-----------------------------------------------------------------------------------
// Копируем информацию о заданном уровне
Internal_CopyLvl : function(Lvl)
{
var Lvl_new = {};
Lvl_new.Start = Lvl.Start;
Lvl_new.Restart = Lvl.Restart;
Lvl_new.Suff = Lvl.Suff;
Lvl_new.Jc = Lvl.Jc;
Lvl_new.Format = Lvl.Format;
Lvl_new.LvlText = [];
for ( var Index = 0; Index < Lvl.LvlText.length; Index++ )
{
var Item = Lvl.LvlText[Index];
Lvl_new.LvlText.push( Item.Copy() );
}
Lvl_new.TextPr = Lvl.TextPr.Copy();
Lvl_new.ParaPr = Lvl.ParaPr.Copy();
return Lvl_new;
},
Internal_SetLvl : function(iLvl, Lvl_new)
{
var Lvl = this.Lvl[iLvl];
Lvl.Jc = Lvl_new.Jc;
Lvl.Format = Lvl_new.Format;
Lvl.LvlText = Lvl_new.LvlText;
Lvl.TextPr = Lvl_new.TextPr;
Lvl.ParaPr = Lvl_new.ParaPr;
},
Write_Lvl_ToBinary : function(Lvl, Writer)
{
// Long : Jc
// Long : Format
// Variable : TextPr
// Variable : ParaPr
// Long : количество элементов в LvlText
// Array of variables : массив LvlText
Writer.WriteLong( Lvl.Jc );
Writer.WriteLong( Lvl.Format );
Lvl.TextPr.Write_ToBinary(Writer);
Lvl.ParaPr.Write_ToBinary(Writer);
var Count = Lvl.LvlText.length;
Writer.WriteLong( Count );
for ( var Index = 0; Index < Count; Index++ )
Lvl.LvlText[Index].Write_ToBinary( Writer );
},
Read_Lvl_FromBinary : function(Lvl, Reader)
{
// Long : Jc
// Long : Format
// Variable : TextPr
// Variable : ParaPr
// Long : количество элементов в LvlText
// Array of variables : массив LvlText
Lvl.Jc = Reader.GetLong();
Lvl.Format = Reader.GetLong();
Lvl.TextPr = new CTextPr();
Lvl.ParaPr = new CParaPr();
Lvl.TextPr.Read_FromBinary( Reader );
Lvl.ParaPr.Read_FromBinary( Reader );
var Count = Reader.GetLong();
Lvl.LvlText = [];
for ( var Index = 0; Index < Count; Index++ )
{
var Element = LvlText_Read_FromBinary(Reader);
Lvl.LvlText.push(Element);
}
},
Undo : function(Data)
{
var Type = Data.Type;
switch ( Type )
{
case historyitem_AbstractNum_LvlChange:
{
this.Internal_SetLvl( Data.Index, Data.Old );
break;
}
case historyitem_AbstractNum_TextPrChange:
{
this.Lvl[Data.Index].TextPr = Data.Old;
break;
}
}
},
Redo : function(Data)
{
var Type = Data.Type;
switch ( Type )
{
case historyitem_AbstractNum_LvlChange:
{
this.Internal_SetLvl( Data.Index, Data.New );
break;
}
case historyitem_AbstractNum_TextPrChange:
{
this.Lvl[Data.Index].TextPr = Data.New;
break;
}
}
},
Refresh_RecalcData : function(Data)
{
var NumPr = new CNumPr();
NumPr.NumId = this.Id;
NumPr.Lvl = Data.Index;
var LogicDocument = editor.WordControl.m_oLogicDocument;
var AllParagraphs = LogicDocument.Get_AllParagraphs_ByNumbering( NumPr );
var Count = AllParagraphs.length;
for ( var Index = 0; Index < Count; Index++ )
{
var Para = AllParagraphs[Index];
Para.Refresh_RecalcData( { Type : historyitem_Paragraph_Numbering } );
}
},
//-----------------------------------------------------------------------------------
// Функции для работы с совместным редактирования
//-----------------------------------------------------------------------------------
Document_Is_SelectionLocked : function(CheckType)
{
switch ( CheckType )
{
case changestype_Paragraph_Content:
case changestype_Paragraph_Properties:
{
this.Lock.Check( this.Get_Id() );
break;
}
case changestype_Document_Content:
case changestype_Document_Content_Add:
case changestype_Image_Properties:
case changestype_Remove:
{
CollaborativeEditing.Add_CheckLock(true);
break;
}
}
},
Save_Changes : function(Data, Writer)
{
// Сохраняем изменения из тех, которые используются для Undo/Redo в бинарный файл.
// Long : тип класса
// Long : тип изменений
Writer.WriteLong( historyitem_type_AbstractNum );
var Type = Data.Type;
// Пишем тип
Writer.WriteLong( Type );
switch ( Type )
{
case historyitem_AbstractNum_LvlChange:
{
// Long : iLvl
// Variable : Lvl
Writer.WriteLong(Data.Index);
this.Write_Lvl_ToBinary( Data.New, Writer );
break;
}
case historyitem_AbstractNum_TextPrChange:
{
// Long : iLvl
// Vairable : TextPr
Writer.WriteLong(Data.Index);
Data.New.Write_ToBinary(Writer);
break;
}
}
return Writer;
},
Save_Changes2 : function(Data, Writer)
{
return false;
},
Load_Changes : function(Reader, Reader2)
{
// Сохраняем изменения из тех, которые используются для Undo/Redo в бинарный файл.
// Long : тип класса
// Long : тип изменений
var ClassType = Reader.GetLong();
if ( historyitem_type_AbstractNum != ClassType )
return;
var Type = Reader.GetLong();
switch ( Type )
{
case historyitem_AbstractNum_LvlChange:
{
// Long : iLvl
// Variable : Lvl
var iLvl = Reader.GetLong();
this.Read_Lvl_FromBinary( this.Lvl[iLvl], Reader );
break;
}
case historyitem_AbstractNum_TextPrChange:
{
// Long : iLvl
// Vairable : TextPr
var iLvl = Reader.GetLong();
this.Lvl[iLvl].TextPr = new CTextPr();
this.Lvl[iLvl].TextPr.Read_FromBinary(Reader);
break;
}
}
},
Write_ToBinary2 : function(Writer)
{
Writer.WriteLong( historyitem_type_AbstractNum );
// String : Id
// Variable[9 Lvl] : 9 уровней
Writer.WriteString2( this.Id );
for ( var Index = 0; Index < 9; Index++ )
this.Write_Lvl_ToBinary(this.Lvl[Index], Writer );
},
Read_FromBinary2 : function(Reader)
{
// String : Id
// Variable[9 Lvl] : 9 уровней
this.Id = Reader.GetString2();
for ( var Index = 0; Index < 9; Index++ )
this.Read_Lvl_FromBinary( this.Lvl[Index], Reader );
// Добавим данный список в нумерацию
var Numbering = editor.WordControl.m_oLogicDocument.Get_Numbering();
Numbering.AbstractNum[this.Id] = this;
},
Load_LinkData : function(LinkData)
{
}
};
function CNumbering()
{
this.AbstractNum = [];
this.Num = [];
}
CNumbering.prototype =
{
Create_AbstractNum : function(Type)
{
// TODO: переделать работу с ID
var AbstractNum = new CAbstractNum(Type);
var Id = AbstractNum.Get_Id();
this.AbstractNum[Id] = AbstractNum;
return Id;
},
Get_AbstractNum : function(Id)
{
return this.AbstractNum[Id];
},
Get_ParaPr : function(NumId, Lvl)
{
var AbstractId = this.AbstractNum[NumId];
if ( undefined != AbstractId )
return AbstractId.Lvl[Lvl].ParaPr;
return new CParaPr();
},
Get_Format : function(NumId, Lvl)
{
var AbstractId = this.AbstractNum[NumId];
if ( undefined != AbstractId )
return AbstractId.Lvl[Lvl].Format;
return numbering_numfmt_Bullet;
},
// Проверяем по типам Numbered и Bullet
Check_Format : function(NumId, Lvl, Type)
{
var Format = this.Get_Format( NumId, Lvl );
if ( ( 0x1000 & Format && 0x1000 & Type ) || ( 0x2000 & Format && 0x2000 & Type ) )
return true;
return false;
},
Draw : function(NumId, Lvl, X, Y, Context, NumInfo, TextPr)
{
var AbstractId = this.AbstractNum[NumId];
return AbstractId.Draw(X,Y, Context, Lvl, NumInfo, TextPr);
},
Measure : function(NumId, Lvl, Context, NumInfo, TextPr)
{
var AbstractId = this.AbstractNum[NumId];
return AbstractId.Measure( Context, Lvl, NumInfo, TextPr );
},
Document_CreateFontCharMap : function(FontCharMap, NumTextPr, NumPr, NumInfo)
{
var AbstractId = this.AbstractNum[NumPr.NumId];
AbstractId.Document_CreateFontCharMap( FontCharMap, NumPr.Lvl, NumInfo, NumTextPr );
},
Document_Get_AllFontNames : function(AllFonts)
{
for ( var Id in this.AbstractNum )
{
var AbstractNum = this.AbstractNum[Id];
AbstractNum.Document_Get_AllFontNames( AllFonts );
}
AllFonts["Symbol"] = true;
AllFonts["Courier New"] = true;
AllFonts["Wingdings"] = true;
AllFonts["Times New Roman"] = true;
}
};
var numbering_presentationnumfrmt_None = 0;
var numbering_presentationnumfrmt_Char = 1;
var numbering_presentationnumfrmt_ArabicPeriod = 100; // 1., 2., 3., ...
var numbering_presentationnumfrmt_ArabicParenR = 101; // 1), 2), 3), ...
var numbering_presentationnumfrmt_RomanUcPeriod = 102; // I., II., III., ...
var numbering_presentationnumfrmt_RomanLcPeriod = 103; // i., ii., iii., ...
var numbering_presentationnumfrmt_AlphaLcParenR = 104; // a), b), c), ...
var numbering_presentationnumfrmt_AlphaLcPeriod = 105; // a., b., c.,
var numbering_presentationnumfrmt_AlphaUcParenR = 106; // A), B), C), ...
var numbering_presentationnumfrmt_AlphaUcPeriod = 107; // A., B., C., ...
// Класс для работы с нумерацией в презентациях
function CPresentationBullet()
{
this.m_nType = numbering_presentationnumfrmt_None; // Тип
this.m_nStartAt = null; // Стартовое значение для нумерованных списков
this.m_sChar = null; // Значение для символьных списков
this.m_oColor = { r : 0, g : 0, b : 0 }; // Цвет
this.m_bColorTx = true; // Использовать ли цвет первого рана в параграфе
this.m_sFont = "Arial"; // Шрифт
this.m_bFontTx = true; // Использовать ли шрифт первого рана в параграфе
this.m_dSize = 1; // Размер шрифта, в пунктах или в процентах (зависит от флага m_bSizePct)
this.m_bSizeTx = false; // Использовать ли размер шрифта первого рана в параграфе
this.m_bSizePct = true; // Задан ли размер шрифта в процентах
this.m_oTextPr = null;
this.m_nNum = null;
this.m_sString = null;
this.Get_Type = function()
{
return this.m_nType;
};
this.Get_StartAt = function()
{
return this.m_nStartAt;
};
this.Measure = function(Context, FirstTextPr, _Num)
{
var dFontSize = FirstTextPr.FontSize;
if ( false === this.m_bSizeTx )
{
if ( true === this.m_bSizePct )
dFontSize *= this.m_dSize;
else
dFontSize = this.m_dSize;
}
var sFontName = ( true === this.m_bFontTx ? FirstTextPr.FontFamily.Name : this.m_sFont );
this.m_oTextPr =
{
FontFamily :
{
Name : sFontName,
Index : -1
},
FontSize : dFontSize,
Bold : ( this.m_nType >= numbering_presentationnumfrmt_ArabicPeriod ? FirstTextPr.Bold : false ),
Italic : ( this.m_nType >= numbering_presentationnumfrmt_ArabicPeriod ? FirstTextPr.Italic : false )
};
var Num = _Num + this.m_nStartAt - 1;
this.m_nNum = Num;
var X = 0;
var OldFont = Context.GetFont();
Context.SetFont( this.m_oTextPr );
var sT = "";
switch ( this.m_nType )
{
case numbering_presentationnumfrmt_Char:
{
if ( null != this.m_sChar )
sT = this.m_sChar;
break;
}
case numbering_presentationnumfrmt_AlphaLcParenR:
{
sT = Numbering_Number_To_Alpha( Num, true ) + ")";
break;
}
case numbering_presentationnumfrmt_AlphaLcPeriod:
{
sT = Numbering_Number_To_Alpha( Num, true ) + ".";
break;
}
case numbering_presentationnumfrmt_AlphaUcParenR:
{
sT = Numbering_Number_To_Alpha( Num, false ) + ")";
break;
}
case numbering_presentationnumfrmt_AlphaUcPeriod:
{
sT = Numbering_Number_To_Alpha( Num, false ) + ".";
break;
}
case numbering_presentationnumfrmt_ArabicParenR:
{
sT += Numbering_Number_To_String(Num) + ")";
break;
}
case numbering_presentationnumfrmt_ArabicPeriod:
{
sT += Numbering_Number_To_String(Num) + ".";
break;
}
case numbering_presentationnumfrmt_RomanLcPeriod:
{
sT += Numbering_Number_To_Roman(Num, true) + ".";
break;
}
case numbering_presentationnumfrmt_RomanUcPeriod:
{
sT += Numbering_Number_To_Roman(Num, false) + ".";
break;
}
}
this.m_sString = sT;
for ( var Index2 = 0; Index2 < sT.length; Index2++ )
{
var Char = sT.charAt(Index2);
X += Context.Measure( Char ).Width;
}
Context.SetFont( OldFont );
return { Width : X };
};
this.Copy = function()
{
var Bullet = new CPresentationBullet();
Bullet.m_nType = this.m_nType;
Bullet.m_nStartAt = this.m_nStartAt;
Bullet.m_sChar = this.m_sChar;
Bullet.m_oColor.r = this.m_oColor.r;
Bullet.m_oColor.g = this.m_oColor.g;
Bullet.m_oColor.b = this.m_oColor.b;
Bullet.m_bColorTx = this.m_bColorTx;
Bullet.m_sFont = this.m_sFont;
Bullet.m_bFontTx = this.m_bFontTx;
Bullet.m_dSize = this.m_dSize;
Bullet.m_bSizeTx = this.m_bSizeTx;
Bullet.m_bSizePct = this.m_bSizePct;
return Bullet;
};
this.Draw = function(X, Y, Context, FirstTextPr)
{
if ( null === this.m_oTextPr || null === this.m_nNum )
return;
var oColor = { r : this.m_oColor.r, g : this.m_oColor.g, b : this.m_oColor.b };
if ( true === this.m_bColorTx )
{
oColor.r = FirstTextPr.Color.r;
oColor.g = FirstTextPr.Color.g;
oColor.b = FirstTextPr.Color.b;
}
Context.p_color( oColor.r, oColor.g, oColor.b, 255 );
Context.b_color1( oColor.r, oColor.g, oColor.b, 255 );
var OldFont = Context.GetFont();
var OldFont2 = g_oTextMeasurer.GetFont();
Context.SetFont( this.m_oTextPr );
g_oTextMeasurer.SetFont( this.m_oTextPr );
var sT = this.m_sString;
for ( var Index2 = 0; Index2 < sT.length; Index2++ )
{
var Char = sT.charAt(Index2);
Context.FillText( X, Y, Char );
X += g_oTextMeasurer.Measure( Char ).Width;
}
Context.SetFont( OldFont );
g_oTextMeasurer.SetFont( OldFont2 );
};
this.Write_ToBinary = function(Writer)
{
// Long : m_nType
// Long : m_nStartAt (-1 == null)
// String : m_sChar ("" == null)
// Byte : m_oColor.r
// Byte : m_oColor.g
// Byte : m_oColor.b
// Bool : m_bColorTx
// String : m_sFont
// Bool : m_bFont
// Double : m_dSize
// Bool : m_bSizeTx
// Bool : m_bSizePct
Writer.WriteLong( this.m_nType );
Writer.WriteLong( ( null != this.m_nStartAt ? this.m_nStartAt : -1 ) );
Writer.WriteString2( ( null != this.m_sChar ? this.m_sChar : "" ) );
Writer.WriteByte( this.m_oColor.r );
Writer.WriteByte( this.m_oColor.g );
Writer.WriteByte( this.m_oColor.b );
Writer.WriteBool( this.m_bColorTx );
Writer.WriteString2( this.m_sFont );
Writer.WriteBool( this.m_bFontTx );
Writer.WriteDouble( this.m_dSize );
Writer.WriteBool( this.m_bSizeTx );
Writer.WriteBool( this.m_bSizePct );
};
this.Read_FromBinary = function(Reader)
{
// Long : m_nType
// Long : m_nStartAt (-1 == null)
// String : m_sChar ("" == null)
// Byte : m_oColor.r
// Byte : m_oColor.g
// Byte : m_oColor.b
// Bool : m_bColorTx
// String : m_sFont
// Bool : m_bFont
// Double : m_dSize
// Bool : m_bSizeTx
// Bool : m_bSizePct
this.m_nType = Reader.GetLong();
this.m_nStartAt = Reader.GetLong();
if ( -1 === this.m_nStartAt )
this.m_nStartAt = null;
this.m_sChar = Reader.GetString2();
if ( "" === this.m_sChar )
this.m_sChar = null;
this.m_oColor.r = Reader.GetByte();
this.m_oColor.g = Reader.GetByte();
this.m_oColor.b = Reader.GetByte();
this.m_bColorTx = Reader.GetBool();
this.m_sFont = Reader.GetString2();
this.m_bFontTx = Reader.GetBool();
this.m_dSize = Reader.GetDouble();
this.m_bSizeTx = Reader.GetBool();
this.m_bSizePct = Reader.GetBool();
};
};
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
"use strict";
/*function PointToSegmentDistance( px, py, x0, y0, x1, y1)
{
var vx = x1 - x0;
var vy = y1 - y0;
var wx = px - x0;
var wy = py - y0;
var
var c1 = vx*wx + vy*wy;
if ( c1 <= 0 )
return Math.sqrt(wx*wx + wy*wy);
var c2 = vx*vx + vy*vy;
if ( c2 <= c1 )
return d(P, P1)
b = c1 / c2
Pb = P0 + bv
return d(P, Pb)
} */
function HitInLine(context, px, py, x0, y0, x1, y1)
{
var l = Math.min(x0, x1);
var t = Math.min(y0, y1);
var r = Math.max(x0, x1);
var b = Math.max(y0, y1);
if(px < l || px > r || py < t || py > b)
return false;
var tx, ty, dx, dy, d;
tx=x1-x0;
ty=y1-y0;
d=1.5/Math.sqrt(tx*tx+ty*ty);
dx=-ty*d;
dy=tx*d;
context.beginPath();
context.moveTo(x0, y0);
context.lineTo(x0+dx, y0+dy);
context.lineTo(x1+dx, y1+dy);
context.lineTo(x1-dx, y1-dy);
context.lineTo(x0-dx, y0-dy);
context.closePath();
return context.isPointInPath(px, py);
}
function HitInBezier4(context, px, py, x0, y0, x1, y1, x2, y2, x3, y3)
{
var l = Math.min(x0, x1, x2, x3);
var t = Math.min(y0, y1, y2, y3);
var r = Math.max(x0, x1, x2, x3);
var b = Math.max(y0, y1, y2, y3);
if(px < l || px > r || py < t || py > b)
return false;
var tx, ty, dx, dy, d;
tx=x3-x0;
ty=y3-y0;
d=1.5/Math.sqrt(tx*tx+ty*ty);
dx=-ty*d;
dy=tx*d;
context.beginPath();
context.moveTo(x0, y0);
context.lineTo(x0+dx, y0+dy);
context.bezierCurveTo(x1+dx, y1+dy, x2+dx, y2+dy, x3+dx, y3+dy);
context.lineTo(x3-dx, y3-dy);
context.bezierCurveTo(x2-dx, y2-dy, x1-dx, y1-dy, x0-dx, y0-dy);
context.closePath();
return context.isPointInPath(px, py);
}
function HitInBezier3(context, px, py, x0, y0, x1, y1, x2, y2)
{
var l = Math.min(x0, x1, x2);
var t = Math.min(y0, y1, y2);
var r = Math.max(x0, x1, x2);
var b = Math.max(y0, y1, y2);
if(px < l || px > r || py < t || py > b)
return false;
var tx, ty, dx, dy, d;
tx=x2-x0;
ty=y2-y0;
d=1.5/Math.sqrt(tx*tx+ty*ty);
dx=-ty*d;
dy=tx*d;
context.beginPath();
context.moveTo(x0, y0);
context.lineTo(x0+dx, y0+dy);
context.quadraticCurveTo(x1+dx, y1+dy, x2+dx, y2+dy);
context.lineTo(x2-dx, y2-dy);
context.quadraticCurveTo(x1-dx, y1-dy, x0-dx, y0-dy);
context.closePath();
return context.isPointInPath(px, py);
}
This source diff could not be displayed because it is too large. You can view the blob instead.
"use strict";
function XYAdjustmentTrack(originalShape, adjIndex)
{
this.originalShape = originalShape;
this.geometry = originalShape.spPr.geometry.createDuplicate();
this.adjastment = this.geometry.ahXYLst[adjIndex];
this.shapeWidth = this.originalShape.extX;
this.shapeHeight = this.originalShape.extY;
this.xFlag = false;
this.yFlag = false;
this.refX = null;
this.refY = null;
if(this.adjastment !== null && typeof this.adjastment === "object")
{
var _ref_x = this.adjastment.gdRefX;
var _gd_lst = this.geometry.gdLst;
if(typeof _ref_x === "string" && typeof _gd_lst[_ref_x] === "number"
&& typeof this.adjastment.minX === "number" && typeof this.adjastment.maxX === "number")
{
_gd_lst[_ref_x] = this.adjastment.minX;
this.geometry.Recalculate(this.shapeWidth, this.shapeHeight);
this.minRealX = this.adjastment.posX;
_gd_lst[_ref_x] = this.adjastment.maxX;
this.geometry.Recalculate(this.shapeWidth, this.shapeHeight);
this.maxRealX = this.adjastment.posX;
this.maximalRealX = Math.max(this.maxRealX, this.minRealX);
this.minimalRealX = Math.min(this.maxRealX, this.minRealX);
this.minimalRealativeX = Math.min(this.adjastment.minX, this.adjastment.maxX);
this.maximalRealativeX = Math.max(this.adjastment.minX, this.adjastment.maxX);
if(this.maximalRealX - this.minimalRealX > 0)
{
this.coeffX = (this.adjastment.maxX - this.adjastment.minX)/(this.maxRealX - this.minRealX);
this.xFlag = true;
}
}
var _ref_y = this.adjastment.gdRefY;
if(typeof _ref_y === "string" && typeof _gd_lst[_ref_y] === "number"
&& typeof this.adjastment.minY === "number" && typeof this.adjastment.maxY === "number")
{
_gd_lst[_ref_y] = this.adjastment.minY;
this.geometry.Recalculate(this.shapeWidth, this.shapeHeight);
this.minRealY = this.adjastment.posY;
_gd_lst[_ref_y] = this.adjastment.maxY;
this.geometry.Recalculate(this.shapeWidth, this.shapeHeight);
this.maxRealY = this.adjastment.posY;
this.maximalRealY = Math.max(this.maxRealY, this.minRealY);
this.minimalRealY = Math.min(this.maxRealY, this.minRealY);
this.minimalRealativeY = Math.min(this.adjastment.minY, this.adjastment.maxY);
this.maximalRealativeY = Math.max(this.adjastment.minY, this.adjastment.maxY);
if(this.maximalRealY - this.minimalRealY > 0)
{
this.coeffY = (this.adjastment.maxY - this.adjastment.minY)/(this.maxRealY - this.minRealY);
this.yFlag = true;
}
}
if(this.xFlag)
{
this.refX = _ref_x;
}
if(this.yFlag)
{
this.refY = _ref_y;
}
}
this.overlayObject = new OverlayObject(this.geometry, originalShape.extX, originalShape.extY, originalShape.brush, originalShape.pen, originalShape.transform);
this.draw = function(overlay)
{
this.overlayObject.draw(overlay);
};
this.getBounds = function()
{
var bounds_checker = new CSlideBoundsChecker();
bounds_checker.init(Page_Width, Page_Height, Page_Width, Page_Height);
this.draw(bounds_checker);
return {l: bounds_checker.Bounds.min_x, t: bounds_checker.Bounds.min_y, r: bounds_checker.Bounds.max_x , b: bounds_checker.Bounds.max_y};
};
this.track = function(posX, posY)
{
var invert_transform = this.originalShape.invertTransform;
var _relative_x = invert_transform.TransformPointX(posX, posY);
var _relative_y = invert_transform.TransformPointY(posX, posY);
var bRecalculate = false;
if(this.xFlag)
{
var _new_x = this.adjastment.minX + this.coeffX*(_relative_x - this.minRealX);
if(_new_x <= this.maximalRealativeX && _new_x >= this.minimalRealativeX)
{
if(this.geometry.gdLst[this.adjastment.gdRefX] !== _new_x)
bRecalculate = true;
this.geometry.gdLst[this.adjastment.gdRefX] = _new_x;
}
else if( _new_x > this.maximalRealativeX)
{
if(this.geometry.gdLst[this.adjastment.gdRefX] !== this.maximalRealativeX)
bRecalculate = true;
this.geometry.gdLst[this.adjastment.gdRefX] = this.maximalRealativeX;
}
else
{
if(this.geometry.gdLst[this.adjastment.gdRefX] !== this.minimalRealativeX)
bRecalculate = true;
this.geometry.gdLst[this.adjastment.gdRefX] = this.minimalRealativeX;
}
}
if(this.yFlag)
{
var _new_y = this.adjastment.minY + this.coeffY*(_relative_y - this.minRealY);
if(_new_y <= this.maximalRealativeY && _new_y >= this.minimalRealativeY)
{
if(this.geometry.gdLst[this.adjastment.gdRefY] !== _new_y)
bRecalculate = true;
this.geometry.gdLst[this.adjastment.gdRefY] = _new_y;
}
else if(_new_y > this.maximalRealativeY)
{
if(this.geometry.gdLst[this.adjastment.gdRefY] !== this.maximalRealativeY)
bRecalculate = true;
this.geometry.gdLst[this.adjastment.gdRefY] = this.maximalRealativeY;
}
else
{
if(this.geometry.gdLst[this.adjastment.gdRefY] !== this.minimalRealativeY)
bRecalculate = true;
this.geometry.gdLst[this.adjastment.gdRefY] = this.minimalRealativeY;
}
}
if(bRecalculate)
this.geometry.Recalculate(this.shapeWidth, this.shapeHeight);
};
this.trackEnd = function()
{
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_RecalculateAfterParagraphAddUndo, null, null,
new UndoRedoDataGraphicObjects(this.originalShape.Get_Id(), new UndoRedoDataGOSingleProp(null, null)));
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_RecalculateGeometry_Undo, null, null, new UndoRedoDataGraphicObjects(this.originalShape.Id, new UndoRedoDataShapeRecalc()), null);
this.originalShape.setAdjustmentValue(this.refX, this.geometry.gdLst[this.adjastment.gdRefX], this.refY, this.geometry.gdLst[this.adjastment.gdRefY]);
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_RecalculateGeometry_Redo, null, null, new UndoRedoDataGraphicObjects(this.originalShape.Id, new UndoRedoDataShapeRecalc()), null);
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_RecalculateAfterParagraphAddRedo, null, null,
new UndoRedoDataGraphicObjects(this.originalShape.Get_Id(), new UndoRedoDataGOSingleProp(null, null)));
this.originalShape.recalculateGeometry();
this.originalShape.calculateContent();
this.originalShape.calculateTransformTextMatrix();
};
}
function PolarAdjustmentTrack(originalShape, adjIndex)
{
this.originalShape = originalShape;
this.geometry = originalShape.spPr.geometry.createDuplicate();
this.adjastment = this.geometry.ahPolarLst[adjIndex];
this.shapeWidth = this.originalShape.extX;
this.shapeHeight = this.originalShape.extY;
this.radiusFlag = false;
this.angleFlag = false;
this.refR = null;
this.refAng = null;
if(this.adjastment !== null && typeof this.adjastment === "object")
{
var _ref_r = this.adjastment.gdRefR;
var _gd_lst = this.geometry.gdLst;
if(typeof _ref_r === "string" && typeof _gd_lst[_ref_r] === "number"
&& typeof this.adjastment.minR === "number" && typeof this.adjastment.maxR === "number")
{
_gd_lst[_ref_r] = this.adjastment.minR;
this.geometry.Recalculate(this.shapeWidth, this.shapeHeight);
var _dx = this.adjastment.posX - this.shapeWidth*0.5;
var _dy = this.adjastment.posY - this.shapeWidth*0.5;
this.minRealR = Math.sqrt(_dx*_dx + _dy*_dy);
_gd_lst[_ref_r] = this.adjastment.maxR;
this.geometry.Recalculate(this.shapeWidth, this.shapeHeight);
_dx = this.adjastment.posX - this.shapeWidth*0.5;
_dy = this.adjastment.posY - this.shapeHeight*0.5;
this.maxRealR = Math.sqrt(_dx*_dx + _dy*_dy);
this.maximalRealRadius = Math.max(this.maxRealR, this.minRealR);
this.minimalRealRadius = Math.min(this.maxRealR, this.minRealR);
this.minimalRealativeRadius = Math.min(this.adjastment.minR, this.adjastment.maxR);
this.maximalRealativeRadius = Math.max(this.adjastment.minR, this.adjastment.maxR);
if(this.maximalRealRadius - this.minimalRealRadius > 0)
{
this.coeffR = (this.adjastment.maxR - this.adjastment.minR)/(this.maxRealR - this.minRealR);
this.radiusFlag = true;
}
}
var _ref_ang = this.adjastment.gdRefAng;
if(typeof _ref_ang === "string" && typeof _gd_lst[_ref_ang] === "number"
&& typeof this.adjastment.minAng === "number" && typeof this.adjastment.maxAng === "number")
{
this.angleFlag = true;
this.minimalAngle = Math.min(this.adjastment.minAng, this.adjastment.maxAng);
this.maximalAngle = Math.max(this.adjastment.minAng, this.adjastment.maxAng);
}
if(this.radiusFlag)
{
this.refR = _ref_r;
}
if(this.angleFlag)
{
this.refAng = _ref_ang;
}
}
this.overlayObject = new OverlayObject(this.geometry, this.originalShape.extX, this.originalShape.extY, this.originalShape.brush, this.originalShape.pen, this.originalShape.transform);
this.draw = function(overlay)
{
this.overlayObject.draw(overlay)
};
this.getBounds = function()
{
var bounds_checker = new CSlideBoundsChecker();
bounds_checker.init(Page_Width, Page_Height, Page_Width, Page_Height);
this.draw(bounds_checker);
return {l: bounds_checker.Bounds.min_x, t: bounds_checker.Bounds.min_y, r: bounds_checker.Bounds.max_x , b: bounds_checker.Bounds.max_y};
};
this.track = function(posX, posY)
{
var _temp_x = posX - this.xLT;
var _temp_y = posY - this.yLT;
var _sin = this.sin;
var _cos = this.cos;
var invert_transform = this.originalShape.invertTransform;
var _relative_x = invert_transform.TransformPointX(posX, posY);
var _relative_y = invert_transform.TransformPointY(posX, posY);
var _pos_x_relative_center = _relative_x - this.shapeHeight*0.5;
var _pos_y_relative_center = _relative_y - this.shapeWidth*0.5;
if(this.radiusFlag)
{
var _radius = Math.sqrt(_pos_x_relative_center*_pos_x_relative_center + _pos_y_relative_center*_pos_y_relative_center);
var _new_radius = this.adjastment.minR + this.coeffR*(_radius - this.minRealR);
if(_new_radius <= this.maximalRealativeRadius && _new_radius >= this.minimalRealativeRadius)
{
this.geometry.gdLst[this.adjastment.gdRefR] = _new_radius;
}
else if( _new_radius > this.maximalRealativeRadius)
{
this.geometry.gdLst[this.adjastment.gdRefR] = this.maximalRealativeRadius;
}
else
{
this.geometry.gdLst[this.adjastment.gdRefR] = this.minimalRealativeRadius;
}
}
if(this.angleFlag)
{
var _angle = Math.atan2(_pos_y_relative_center, _pos_x_relative_center);
while(_angle < 0)
_angle += 2*Math.PI;
while(_angle >= 2*Math.PI)
_angle -= 2*Math.PI;
_angle *= cToDeg;
if(_angle >= this.minimalAngle && _angle <= this.maximalAngle)
{
this.geometry.gdLst[this.adjastment.gdRefAng]= _angle;
}
else if(_angle >= this.maximalAngle)
{
this.geometry.gdLst[this.adjastment.gdRefAng] = this.maximalAngle;
}
else if(_angle <= this.minimalAngle)
{
this.geometry.gdLst[this.adjastment.gdRefAng] = this.minimalAngle;
}
}
this.geometry.Recalculate(this.shapeWidth, this.shapeHeight);
};
this.trackEnd = function()
{
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_RecalculateAfterParagraphAddUndo, null, null,
new UndoRedoDataGraphicObjects(this.originalShape.Get_Id(), new UndoRedoDataGOSingleProp(null, null)));
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_RecalculateGeometry_Undo, null, null, new UndoRedoDataGraphicObjects(this.originalShape.Id, new UndoRedoDataShapeRecalc()), null);
this.originalShape.setAdjustmentValue(this.refR, this.geometry.gdLst[this.adjastment.gdRefR], this.refAng, this.geometry.gdLst[this.adjastment.gdRefAng]);
this.originalShape.recalculateGeometry();
this.originalShape.calculateContent();
this.originalShape.calculateTransformTextMatrix();
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_RecalculateAfterParagraphAddRedo, null, null,
new UndoRedoDataGraphicObjects(this.originalShape.Get_Id(), new UndoRedoDataGOSingleProp(null, null)));
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_RecalculateGeometry_Redo, null, null, new UndoRedoDataGraphicObjects(this.originalShape.Id, new UndoRedoDataShapeRecalc()), null);
};
}
\ No newline at end of file
"use strict";
function MoveShapeImageTrack(originalObject)
{
this.originalObject = originalObject;
this.transform = new CMatrix();
this.x = null;
this.y = null;
this.overlayObject = new OverlayObject(this.originalObject.spPr.geometry, this.originalObject.extX, this.originalObject.extY, this.originalObject.brush, this.originalObject.pen, this.transform);
this.getOriginalBoundsRect = function()
{
return this.originalObject.getRectBounds();
};
this.track = function(dx, dy)
{
var original = this.originalObject;
this.x = original.x + dx;
this.y = original.y + dy;
this.transform.Reset();
var hc = original.extX*0.5;
var vc = original.extY*0.5;
global_MatrixTransformer.TranslateAppend(this.transform, -hc, -vc);
if(original.flipH)
global_MatrixTransformer.ScaleAppend(this.transform, -1, 1);
if(original.flipV)
global_MatrixTransformer.ScaleAppend(this.transform, 1, -1);
global_MatrixTransformer.RotateRadAppend(this.transform, -original.rot);
global_MatrixTransformer.TranslateAppend(this.transform, this.x + hc, this.y + vc);
};
this.draw = function(overlay)
{
this.overlayObject.draw(overlay);
};
this.trackEnd = function()
{
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_RecalculateTransformUndo, null, null, new UndoRedoDataGraphicObjects(this.originalObject.Id, new UndoRedoDataShapeRecalc()), null);
this.originalObject.setPosition(this.x, this.y);
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_RecalculateTransformRedo, null, null, new UndoRedoDataGraphicObjects(this.originalObject.Id, new UndoRedoDataShapeRecalc()), null);
this.originalObject.recalculateTransform();
this.originalObject.calculateTransformTextMatrix();
this.originalObject.updateDrawingBaseCoordinates();
};
}
function MoveShapeImageTrackInGroup(originalObject)
{
this.originalObject = originalObject;
this.x = null;
this.y = null;
this.transform = new CMatrix();
var pen, brush;
if(!(typeof CChartAsGroup != "undefined" && this.originalObject instanceof CChartAsGroup))
{
pen = this.originalObject.pen;
brush = this.originalObject.brush;
}
else
{
brush = new CUniFill();
brush.fill = new CSolidFill();
brush.fill.color = new CUniColor();
brush.fill.color.RGBA = {R:255, G:255, B:255, A:255};
brush.fill.color.color = new CRGBColor();
brush.fill.color.color.RGBA = {R:255, G:255, B:255, A:255};
pen = new CLn();
pen.Fill = new CUniFill();
pen.Fill.fill = new CSolidFill();
pen.Fill.fill.color = new CUniColor();
pen.Fill.fill.color.color = new CRGBColor();
}
this.overlayObject = new OverlayObject(this.originalObject.spPr.geometry, this.originalObject.extX, this.originalObject.extY, brush, pen, this.transform);
this.inv = global_MatrixTransformer.Invert(originalObject.group.transform);
this.inv.tx = 0;
this.inv.ty = 0;
this.draw = function(overlay)
{
this.overlayObject.draw(overlay);
};
this.track = function(dx, dy)
{
var dx_t = this.inv.TransformPointX(dx, dy);
var dy_t = this.inv.TransformPointY(dx, dy);
this.x = this.originalObject.x + dx_t;
this.y = this.originalObject.y + dy_t;
this.calculateTransform();
};
this.getOriginalBoundsRect = function()
{
return this.originalObject.getRectBounds();
};
this.calculateTransform = function()
{
var t = this.transform;
t.Reset();
global_MatrixTransformer.TranslateAppend(t, -this.originalObject.extX*0.5, -this.originalObject.extY*0.5);
if(this.originalObject.flipH)
{
global_MatrixTransformer.ScaleAppend(t, -1, 1);
}
if(this.originalObject.flipV)
{
global_MatrixTransformer.ScaleAppend(t, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(t, -this.originalObject.rot);
global_MatrixTransformer.TranslateAppend(t, this.x + this.originalObject.extX*0.5, this.y + this.originalObject.extY*0.5);
global_MatrixTransformer.MultiplyAppend(t, this.originalObject.group.getTransform());
};
this.trackEnd = function()
{
var scale_scale_coefficients = this.originalObject.group.getResultScaleCoefficients();
var xfrm = this.originalObject.group.spPr.xfrm;
this.originalObject.setPosition(this.x/scale_scale_coefficients.cx + xfrm.chOffX, this.y/scale_scale_coefficients.cy + xfrm.chOffY);
this.originalObject.recalculateTransform();
this.originalObject.calculateTransformTextMatrix();
}
}
function MoveGroupTrack(originalObject)
{
this.x = null;
this.y = null;
this.originalObject = originalObject;
this.transform = new CMatrix();
this.overlayObjects = [];
this.arrTransforms2 = [];
var arr_graphic_objects = originalObject.getArrGraphicObjects();
var group_invert_transform = originalObject.getInvertTransform();
for(var i = 0; i < arr_graphic_objects.length; ++i)
{
var gr_obj_transform_copy = arr_graphic_objects[i].getTransform().CreateDublicate();
global_MatrixTransformer.MultiplyAppend(gr_obj_transform_copy, group_invert_transform);
this.arrTransforms2[i] = gr_obj_transform_copy;
var pen, brush;
if(!(typeof CChartAsGroup != "undefined" && arr_graphic_objects[i] instanceof CChartAsGroup))
{
pen = arr_graphic_objects[i].pen;
brush = arr_graphic_objects[i].brush;
}
else
{
brush = new CUniFill();
brush.fill = new CSolidFill();
brush.fill.color = new CUniColor();
brush.fill.color.RGBA = {R:255, G:255, B:255, A:255};
brush.fill.color.color = new CRGBColor();
brush.fill.color.color.RGBA = {R:255, G:255, B:255, A:255};
pen = new CLn();
pen.Fill = new CUniFill();
pen.Fill.fill = new CSolidFill();
pen.Fill.fill.color = new CUniColor();
pen.Fill.fill.color.color = new CRGBColor();
}
this.overlayObjects[i] = new OverlayObject(arr_graphic_objects[i].spPr.geometry, arr_graphic_objects[i].extX, arr_graphic_objects[i].extY,
brush, pen, new CMatrix());
}
this.getOriginalBoundsRect = function()
{
return this.originalObject.getRectBounds();
};
this.track = function(dx, dy)
{
var original = this.originalObject;
this.x = original.x + dx;
this.y = original.y + dy;
this.transform.Reset();
var hc = original.extX*0.5;
var vc = original.extY*0.5;
global_MatrixTransformer.TranslateAppend(this.transform, -hc, -vc);
if(original.flipH)
global_MatrixTransformer.ScaleAppend(this.transform, -1, 1);
if(original.flipV)
global_MatrixTransformer.ScaleAppend(this.transform, 1, -1);
global_MatrixTransformer.RotateRadAppend(this.transform, -original.rot);
global_MatrixTransformer.TranslateAppend(this.transform, this.x + hc, this.y + vc);
for(var i = 0; i < this.overlayObjects.length; ++i)
{
var new_transform = this.arrTransforms2[i].CreateDublicate();
global_MatrixTransformer.MultiplyAppend(new_transform, this.transform);
this.overlayObjects[i].updateTransformMatrix(new_transform);
}
};
this.draw = function(overlay)
{
for(var i = 0; i < this.overlayObjects.length; ++i)
{
this.overlayObjects[i].draw(overlay);
}
};
this.trackEnd = function()
{
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_GroupRecalculateUndo, null, null,
new UndoRedoDataGraphicObjects(this.originalObject.Get_Id(), new UndoRedoDataGOSingleProp(null, null)));
this.originalObject.setPosition(this.x, this.y);
this.originalObject.recalculate();
this.originalObject.updateDrawingBaseCoordinates();
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_GroupRecalculateRedo, null, null,
new UndoRedoDataGraphicObjects(this.originalObject.Get_Id(), new UndoRedoDataGOSingleProp(null, null)));
};
}
function MoveTitleInChart(originalObject)
{
this.originalObject = originalObject;
this.x = null;
this.y = null;
this.transform = new CMatrix();
var pen = new CLn();
pen.Fill = new CUniFill();
pen.Fill.fill = new CSolidFill();
pen.Fill.fill.color = new CUniColor();
pen.Fill.fill.color.color = new CRGBColor();
this.overlayObject = new OverlayObject(this.originalObject.spPr.geometry, this.originalObject.extX, this.originalObject.extY, this.originalObject.brush,/* this.originalObject.pen*/pen, this.transform);
this.inv = global_MatrixTransformer.Invert(originalObject.chartGroup.transform);
this.inv.tx = 0;
this.inv.ty = 0;
this.draw = function(overlay)
{
this.overlayObject.draw(overlay);
};
this.track = function(dx, dy)
{
var dx_t = this.inv.TransformPointX(dx, dy);
var dy_t = this.inv.TransformPointY(dx, dy);
this.x = this.originalObject.x + dx_t;
this.y = this.originalObject.y + dy_t;
if(this.x + this.originalObject.extX > this.originalObject.chartGroup.extX)
this.x = this.originalObject.chartGroup.extX - this.originalObject.extX;
if(this.x < 0)
this.x = 0;
if(this.y + this.originalObject.extY > this.originalObject.chartGroup.extY)
this.y = this.originalObject.chartGroup.extY - this.originalObject.extY;
if(this.y < 0)
this.y = 0;
this.calculateTransform();
};
this.getOriginalBoundsRect = function()
{
return this.originalObject.getRectBounds();
};
this.calculateTransform = function()
{
var t = this.transform;
t.Reset();
global_MatrixTransformer.TranslateAppend(t, -this.originalObject.extX*0.5, -this.originalObject.extY*0.5);
global_MatrixTransformer.TranslateAppend(t, this.x + this.originalObject.extX*0.5, this.y + this.originalObject.extY*0.5);
global_MatrixTransformer.MultiplyAppend(t, this.originalObject.chartGroup.getTransform());
};
this.trackEnd = function()
{
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_RecalculateTransformUndo, null, null, new UndoRedoDataGraphicObjects(this.originalObject.chartGroup.Id, new UndoRedoDataShapeRecalc()), null);
this.originalObject.setPosition(this.x, this.y);
this.originalObject.chartGroup.recalculate();
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_RecalculateTransformRedo, null, null, new UndoRedoDataGraphicObjects(this.originalObject.chartGroup.Id, new UndoRedoDataShapeRecalc()), null);
}
}
function MoveTrackChart(originalObject)
{
this.originalObject = originalObject;
this.transform = new CMatrix();
this.x = null;
this.y = null;
var geometry = CreateGeometry("rect");
geometry.Init(this.originalObject.extX, this.originalObject.extY);
geometry.Recalculate(this.originalObject.extX, this.originalObject.extY);
var brush = new CUniFill();
brush.fill = new CSolidFill();
brush.fill.color = new CUniColor();
brush.fill.color.RGBA = {R:255, G:255, B:255, A:255};
brush.fill.color.color = new CRGBColor();
brush.fill.color.color.RGBA = {R:255, G:255, B:255, A:255};
var pen = new CLn();
pen.Fill = new CUniFill();
pen.Fill.fill = new CSolidFill();
pen.Fill.fill.color = new CUniColor();
pen.Fill.fill.color.color = new CRGBColor();
this.overlayObject = new OverlayObject(this.originalObject.spPr.geometry, this.originalObject.extX, this.originalObject.extY, brush, pen, this.transform);
this.getOriginalBoundsRect = function()
{
return this.originalObject.getRectBounds();
};
this.track = function(dx, dy)
{
var original = this.originalObject;
this.x = original.x + dx;
this.y = original.y + dy;
this.transform.Reset();
var hc = original.extX*0.5;
var vc = original.extY*0.5;
global_MatrixTransformer.TranslateAppend(this.transform, -hc, -vc);
global_MatrixTransformer.TranslateAppend(this.transform, this.x + hc, this.y + vc);
};
this.draw = function(overlay)
{
this.overlayObject.draw(overlay);
};
this.trackEnd = function()
{
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_RecalculateTransformUndo, null, null, new UndoRedoDataGraphicObjects(this.originalObject.Id, new UndoRedoDataShapeRecalc()), null);
this.originalObject.x = this.x;
this.originalObject.y = this.y;
this.originalObject.updateDrawingBaseCoordinates();
this.originalObject.setPosition(this.x, this.y);
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_RecalculateTransformRedo, null, null, new UndoRedoDataGraphicObjects(this.originalObject.Id, new UndoRedoDataShapeRecalc()), null);
this.originalObject.recalculateTransform();
this.originalObject.calculateTransformTextMatrix();
};
}
"use strict";
function NewShapeTrack(drawingObjects, presetGeom, startX, startY)
{
this.drawingObjects = drawingObjects;
this.presetGeom = presetGeom;
this.startX = startX;
this.startY = startY;
this.headEnd = false;
this.tailEnd = false;
this.x = null;
this.y = null;
this.extX = null;
this.extY = null;
this.flipH = null;
this.flipV = null;
this.transform = new CMatrix();
var theme = drawingObjects.getWorkbook().theme;
var color_map = GenerateDefaultColorMap().color_map;
var style;
if(presetGeom !== "textRect")
style = CreateDefaultShapeStyle();
else
style = CreateDefaultTextRectStyle();
var brush = theme.getFillStyle(style.fillRef.idx);
style.fillRef.Color.Calculate(theme, color_map, {R:0, G:0, B:0, A:255});
var RGBA = style.fillRef.Color.RGBA;
if (style.fillRef.Color.color != null)
{
if (brush.fill != null && (brush.fill.type == FILL_TYPE_SOLID || brush.fill.type == FILL_TYPE_GRAD))
{
brush.fill.color = style.fillRef.Color.createDuplicate();
}
}
var pen = theme.getLnStyle(style.lnRef.idx);
style.lnRef.Color.Calculate(theme, color_map, {R: 0 , G: 0, B: 0, A: 255});
RGBA = style.lnRef.Color.RGBA;
var final_preset = presetGeom;
var sPreset = presetGeom;
switch(sPreset)
{
case "lineWithArrow":
{
final_preset = "line";
this.tailEnd = true;
break;
}
case "lineWithTwoArrows":
{
final_preset = "line";
this.tailEnd = true;
this.headEnd = true;
break;
}
case "bentConnector5WithArrow":
{
final_preset = "bentConnector5";
this.tailEnd = true;
break;
}
case "bentConnector5WithTwoArrows":
{
final_preset = "bentConnector5";
this.tailEnd = true;
this.headEnd = true;
break;
}
case "curvedConnector3WithArrow":
{
final_preset = "curvedConnector3";
this.tailEnd = true;
break;
}
case "curvedConnector3WithTwoArrows":
{
final_preset = "curvedConnector3";
this.tailEnd = true;
this.headEnd = true;
break;
}
case "textRect":
{
final_preset = "rect";
break;
}
default :
{
final_preset = sPreset;
break;
}
}
if(presetGeom === "textRect")
{
if(presetGeom === "textRect")
{
var ln, fill;
ln = new CLn();
ln.w = 6350;
ln.Fill = new CUniFill();
ln.Fill.fill = new CSolidFill();
ln.Fill.fill.color = new CUniColor();
ln.Fill.fill.color.color = new CPrstColor();
ln.Fill.fill.color.color.id = "black";
fill = new CUniFill();
fill.fill = new CSolidFill();
fill.fill.color = new CUniColor();
fill.fill.color.color = new CSchemeColor();
fill.fill.color.color.id = 12;
pen.merge(ln);
brush.merge(fill);
}
}
else if(this.tailEnd || this.headEnd)
{
var ln;
ln = new CLn();
if(this.tailEnd)
{
ln.tailEnd = new EndArrow();
ln.tailEnd.type = LineEndType.Arrow;
ln.tailEnd.len = LineEndSize.Mid;
}
if(this.headEnd)
{
ln.headEnd = new EndArrow();
ln.headEnd.type = LineEndType.Arrow;
ln.headEnd.len = LineEndSize.Mid;
}
pen.merge(ln);
}
pen.Fill.calculate(theme, color_map, RGBA) ;
brush.calculate(theme, color_map, RGBA) ;
this.finalPreset = final_preset;
var geometry = CreateGeometry(final_preset);
geometry.Init(5, 5);
this.overlayObject = new OverlayObject(geometry, 5, 5, brush, pen, this.transform);
this.lineFlag = CheckLinePreset(final_preset);
this.isLine = this.lineFlag;
this.track = function(e, x, y)
{
this.flipH = false;
this.flipV = false;
var real_dist_x = x - this.startX;
var abs_dist_x = Math.abs(real_dist_x);
var real_dist_y = y - this.startY;
var abs_dist_y = Math.abs(real_dist_y);
if(this.isLine)
{
if(x < this.startX)
{
this.flipH = true;
}
if(y < this.startY)
{
this.flipV = true;
}
}
if(!(e.ctrlKey || e.shiftKey) || (e.CtrlKey && !e.ShiftKey && this.isLine))
{
this.extX = abs_dist_x >= MIN_SHAPE_SIZE ? abs_dist_x : (this.isLine ? 0 : MIN_SHAPE_SIZE);
this.extY = abs_dist_y >= MIN_SHAPE_SIZE ? abs_dist_y : (this.isLine ? 0 : MIN_SHAPE_SIZE);
if(real_dist_x >= 0)
{
this.x = this.startX;
}
else
{
this.x = abs_dist_x >= MIN_SHAPE_SIZE ? x : this.startX - this.extX;
}
if(real_dist_y >= 0)
{
this.y = this.startY;
}
else
{
this.y = abs_dist_y >= MIN_SHAPE_SIZE ? y : this.startY - this.extY;
}
}
else if(e.ctrlKey && !e.shiftKey)
{
if(abs_dist_x >= MIN_SHAPE_SIZE_DIV2)
{
this.x = this.startX - abs_dist_x;
this.extX = 2*abs_dist_x;
}
else
{
this.x = this.startX - MIN_SHAPE_SIZE_DIV2;
this.extX = MIN_SHAPE_SIZE;
}
if(abs_dist_y >= MIN_SHAPE_SIZE_DIV2)
{
this.y = this.startY - abs_dist_y;
this.extY = 2*abs_dist_y;
}
else
{
this.y = this.startY - MIN_SHAPE_SIZE_DIV2;
this.extY = MIN_SHAPE_SIZE;
}
}
else if(!e.ctrlKey && e.shiftKey)
{
var new_width, new_height;
var prop_coefficient = (typeof SHAPE_ASPECTS[this.presetGeom] === "number" ? SHAPE_ASPECTS[this.presetGeom] : 1);
if(abs_dist_y === 0)
{
new_width = abs_dist_x > MIN_SHAPE_SIZE ? abs_dist_x : MIN_SHAPE_SIZE;
new_height = abs_dist_x/prop_coefficient;
}
else
{
var new_aspect = abs_dist_x/abs_dist_y;
if (new_aspect >= prop_coefficient)
{
new_width = abs_dist_x;
new_height = abs_dist_x/prop_coefficient;
}
else
{
new_height = abs_dist_y;
new_width = abs_dist_y*prop_coefficient;
}
}
if(new_width < MIN_SHAPE_SIZE || new_height < MIN_SHAPE_SIZE)
{
var k_wh = new_width/new_height;
if(new_height < MIN_SHAPE_SIZE && new_width < MIN_SHAPE_SIZE)
{
if(new_height < new_width)
{
new_height = MIN_SHAPE_SIZE;
new_width = new_height*k_wh;
}
else
{
new_width = MIN_SHAPE_SIZE;
new_height = new_width/k_wh;
}
}
else if(new_height < MIN_SHAPE_SIZE)
{
new_height = MIN_SHAPE_SIZE;
new_width = new_height*k_wh;
}
else
{
new_width = MIN_SHAPE_SIZE;
new_height = new_width/k_wh;
}
}
this.extX = new_width;
this.extY = new_height;
if(real_dist_x >= 0)
this.x = this.startX;
else
this.x = this.startX - this.extX;
if(real_dist_y >= 0)
this.y = this.startY;
else
this.y = this.startY - this.extY;
if(this.isLine)
{
var angle = Math.atan2(real_dist_y, real_dist_x);
if(angle >=0 && angle <= Math.PI/8
|| angle <= 0 && angle >= -Math.PI/8
|| angle >= 7*Math.PI/8 && angle <= Math.PI )
{
this.extY = 0;
this.y = this.startY;
}
else if(angle >= 3*Math.PI/8 && angle <= 5*Math.PI/8
|| angle <= -3*Math.PI/8 && angle >= -5*Math.PI/8)
{
this.extX = 0;
this.x = this.startX;
}
}
}
else
{
var new_width, new_height;
var prop_coefficient = (typeof SHAPE_ASPECTS[this.presetGeom] === "number" ? SHAPE_ASPECTS[this.presetGeom] : 1);
if(abs_dist_y === 0)
{
new_width = abs_dist_x > MIN_SHAPE_SIZE_DIV2 ? abs_dist_x*2 : MIN_SHAPE_SIZE;
new_height = new_width/prop_coefficient;
}
else
{
var new_aspect = abs_dist_x/abs_dist_y;
if (new_aspect >= prop_coefficient)
{
new_width = abs_dist_x*2;
new_height = new_width/prop_coefficient;
}
else
{
new_height = abs_dist_y*2;
new_width = new_height*prop_coefficient;
}
}
if(new_width < MIN_SHAPE_SIZE || new_height < MIN_SHAPE_SIZE)
{
var k_wh = new_width/new_height;
if(new_height < MIN_SHAPE_SIZE && new_width < MIN_SHAPE_SIZE)
{
if(new_height < new_width)
{
new_height = MIN_SHAPE_SIZE;
new_width = new_height*k_wh;
}
else
{
new_width = MIN_SHAPE_SIZE;
new_height = new_width/k_wh;
}
}
else if(new_height < MIN_SHAPE_SIZE)
{
new_height = MIN_SHAPE_SIZE;
new_width = new_height*k_wh;
}
else
{
new_width = MIN_SHAPE_SIZE;
new_height = new_width/k_wh;
}
}
this.extX = new_width;
this.extY = new_height;
this.x = this.startX - this.extX*0.5;
this.y = this.startY - this.extY*0.5;
}
this.overlayObject.updateExtents(this.extX, this.extY);
this.transform.Reset();
var hc = this.extX * 0.5;
var vc = this.extY * 0.5;
global_MatrixTransformer.TranslateAppend(this.transform, -hc, -vc);
if (this.flipH)
global_MatrixTransformer.ScaleAppend(this.transform, -1, 1);
if (this.flipV)
global_MatrixTransformer.ScaleAppend(this.transform, 1, -1);
global_MatrixTransformer.TranslateAppend(this.transform, this.x + hc, this.y + vc);
};
this.ctrlDown = function()
{};
this.shiftDown = function()
{};
this.draw = function(overlay)
{
this.overlayObject.draw(overlay);
};
this.trackEnd = function()
{
var shape = new CShape(null, this.drawingObjects);
if(this.presetGeom !== "textRect")
shape.initDefault(this.x, this.y, this.extX, this.extY, this.flipH === true, this.flipV === true, this.finalPreset, this.tailEnd, this.headEnd);
else
shape.initDefaultTextRect(this.x, this.y, this.extX, this.extY, false, false);
shape.select(this.drawingObjects.controller);
shape.addToDrawingObjects();
this.drawingObjects.controller.curState.resultObject = shape;
};
}
function CheckLinePreset(preset)
{
return preset === "line";
}
\ No newline at end of file
"use strict";
function PolyLine (drawingObjects)
{
this.drawingObjects = drawingObjects;
this.arrPoint = [];
this.Matrix = new CMatrixL();
this.TransformMatrix = new CMatrixL();
this.style = CreateDefaultShapeStyle();
var _calculated_line;
var wb = this.drawingObjects.getWorkbook();
var _theme = wb.theme;
var colorMap = GenerateDefaultColorMap().color_map;
var RGBA = {R: 0, G: 0, B: 0, A: 255};
if(isRealObject(_theme) && typeof _theme.getLnStyle === "function"
&& isRealObject(this.style) && isRealObject(this.style.lnRef) && isRealNumber(this.style.lnRef.idx)
&& isRealObject(this.style.lnRef.Color) && typeof this.style.lnRef.Color.Calculate === "function")
{
_calculated_line = _theme.getLnStyle(this.style.lnRef.idx);
this.style.lnRef.Color.Calculate(_theme, colorMap, {R: 0 , G: 0, B: 0, A: 255});
RGBA = this.style.lnRef.Color.RGBA;
}
else
{
_calculated_line = new CLn();
}
if(isRealObject(_calculated_line.Fill))
{
_calculated_line.Fill.calculate(_theme, colorMap, RGBA) ;
}
this.pen = _calculated_line;
this.polylineForDrawer = new PolylineForDrawer(this);
this.Draw = function(graphics)
{
graphics.SetIntegerGrid(false);
graphics.transform3(this.Matrix);
var shape_drawer = new CShapeDrawer();
shape_drawer.fromShape(this, graphics);
shape_drawer.draw(this);
};
this.draw = function(g)
{
this.polylineForDrawer.Draw(g);
return;
if(this.arrPoint.length < 2)
{
return;
}
g._m(this.arrPoint[0].x, this.arrPoint[0].y);
for(var i = 1; i < this.arrPoint.length; ++i)
{
g._l(this.arrPoint[i].x, this.arrPoint[i].y);
}
g.ds();
};
this.getLeftTopPoint = function()
{
if(this.arrPoint.length < 1)
return {x: 0, y: 0};
var xMax = this.arrPoint[0].x, yMax = this.arrPoint[0].y, xMin = xMax, yMin = yMax;
var i;
for( i = 1; i<this.arrPoint.length; ++i)
{
if(this.arrPoint[i].x > xMax)
{
xMax = this.arrPoint[i].x;
}
if(this.arrPoint[i].y > yMax)
{
yMax = this.arrPoint[i].y;
}
if(this.arrPoint[i].x < xMin)
{
xMin = this.arrPoint[i].x;
}
if(this.arrPoint[i].y < yMin)
{
yMin = this.arrPoint[i].y;
}
}
return {x: xMin, y: yMin};
};
this.createShape = function(document)
{
var xMax = this.arrPoint[0].x, yMax = this.arrPoint[0].y, xMin = xMax, yMin = yMax;
var i;
var bClosed = false;
if(this.arrPoint.length > 2)
{
var dx = this.arrPoint[0].x - this.arrPoint[this.arrPoint.length-1].x;
var dy = this.arrPoint[0].y - this.arrPoint[this.arrPoint.length-1].y;
if(Math.sqrt(dx*dx +dy*dy) < this.drawingObjects.convertMetric(3, 0, 3))
{
bClosed = true;
}
}
var _n = bClosed ? this.arrPoint.length - 1 : this.arrPoint.length;
for( i = 1; i<_n; ++i)
{
if(this.arrPoint[i].x > xMax)
{
xMax = this.arrPoint[i].x;
}
if(this.arrPoint[i].y > yMax)
{
yMax = this.arrPoint[i].y;
}
if(this.arrPoint[i].x < xMin)
{
xMin = this.arrPoint[i].x;
}
if(this.arrPoint[i].y < yMin)
{
yMin = this.arrPoint[i].y;
}
}
var shape = new CShape(null, this.drawingObjects);
shape.setXfrmObject(new CXfrm());
shape.setPosition(xMin, yMin);
shape.setExtents(xMax-xMin, yMax-yMin);
shape.setStyleBinary(CreateDefaultShapeStyle());
var geometry = new CGeometry();
geometry.AddPathCommand(0, undefined, bClosed ? "norm": "none", undefined, xMax - xMin, yMax-yMin);
geometry.AddRect("l", "t", "r", "b");
geometry.AddPathCommand(1, (this.arrPoint[0].x - xMin) + "", (this.arrPoint[0].y - yMin) + "");
for(i = 1; i< _n; ++i)
{
geometry.AddPathCommand(2, (this.arrPoint[i].x - xMin) + "", (this.arrPoint[i].y - yMin) + "");
}
if(bClosed)
{
geometry.AddPathCommand(6);
}
geometry.Init( xMax-xMin, yMax-yMin);
shape.setGeometry(geometry);
shape.recalculate();
shape.addToDrawingObjects();
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_RecalculateAfterInit, null, null,
new UndoRedoDataGraphicObjects(shape.Get_Id(), new UndoRedoDataGOSingleProp(null, null)));
return shape;
}
}
function PolylineForDrawer(polyline)
{
this.polyline = polyline;
this.pen = polyline.pen;
this.brush = polyline.brush;
this.TransformMatrix = polyline.TransformMatrix;
this.Matrix = polyline.Matrix;
this.Draw = function(graphics)
{
graphics.SetIntegerGrid(false);
graphics.transform3(this.Matrix);
var shape_drawer = new CShapeDrawer();
shape_drawer.fromShape(this, graphics);
shape_drawer.draw(this);
};
this.draw = function(g)
{
g._e();
if(this.polyline.arrPoint.length < 2)
{
return;
}
g._m(this.polyline.arrPoint[0].x, this.polyline.arrPoint[0].y);
for(var i = 1; i < this.polyline.arrPoint.length; ++i)
{
g._l(this.polyline.arrPoint[i].x, this.polyline.arrPoint[i].y);
}
g.ds();
};
}
\ No newline at end of file
"use strict";
var TRANSLATE_HANDLE_NO_FLIP = [];
TRANSLATE_HANDLE_NO_FLIP[0] = 0;
TRANSLATE_HANDLE_NO_FLIP[1] = 1;
TRANSLATE_HANDLE_NO_FLIP[2] = 2;
TRANSLATE_HANDLE_NO_FLIP[3] = 3;
TRANSLATE_HANDLE_NO_FLIP[4] = 4;
TRANSLATE_HANDLE_NO_FLIP[5] = 5;
TRANSLATE_HANDLE_NO_FLIP[6] = 6;
TRANSLATE_HANDLE_NO_FLIP[7] = 7;
var TRANSLATE_HANDLE_FLIP_H = [];
TRANSLATE_HANDLE_FLIP_H[0] = 2;
TRANSLATE_HANDLE_FLIP_H[1] = 1;
TRANSLATE_HANDLE_FLIP_H[2] = 0;
TRANSLATE_HANDLE_FLIP_H[3] = 7;
TRANSLATE_HANDLE_FLIP_H[4] = 6;
TRANSLATE_HANDLE_FLIP_H[5] = 5;
TRANSLATE_HANDLE_FLIP_H[6] = 4;
TRANSLATE_HANDLE_FLIP_H[7] = 3;
var TRANSLATE_HANDLE_FLIP_V = [];
TRANSLATE_HANDLE_FLIP_V[0] = 6;
TRANSLATE_HANDLE_FLIP_V[1] = 5;
TRANSLATE_HANDLE_FLIP_V[2] = 4;
TRANSLATE_HANDLE_FLIP_V[3] = 3;
TRANSLATE_HANDLE_FLIP_V[4] = 2;
TRANSLATE_HANDLE_FLIP_V[5] = 1;
TRANSLATE_HANDLE_FLIP_V[6] = 0;
TRANSLATE_HANDLE_FLIP_V[7] = 7;
var TRANSLATE_HANDLE_FLIP_H_AND_FLIP_V = [];
TRANSLATE_HANDLE_FLIP_H_AND_FLIP_V[0] = 4;
TRANSLATE_HANDLE_FLIP_H_AND_FLIP_V[1] = 5;
TRANSLATE_HANDLE_FLIP_H_AND_FLIP_V[2] = 6;
TRANSLATE_HANDLE_FLIP_H_AND_FLIP_V[3] = 7;
TRANSLATE_HANDLE_FLIP_H_AND_FLIP_V[4] = 0;
TRANSLATE_HANDLE_FLIP_H_AND_FLIP_V[5] = 1;
TRANSLATE_HANDLE_FLIP_H_AND_FLIP_V[6] = 2;
TRANSLATE_HANDLE_FLIP_H_AND_FLIP_V[7] = 3;
var SHAPE_ASPECTS = {};
SHAPE_ASPECTS["can"] = 3616635/4810125;
SHAPE_ASPECTS["moon"] = 0.5;
SHAPE_ASPECTS["leftBracket"] = 0.08;
SHAPE_ASPECTS["rightBracket"] = 0.08;
SHAPE_ASPECTS["leftBrace"] = 0.17;
SHAPE_ASPECTS["rightBrace"] = 0.17;
//TODO:
var MIN_SHAPE_SIZE = 1.27;//размер меньше которого нельзя уменшить автофигуру или картинку по горизонтали или вертикали
var MIN_SHAPE_SIZE_DIV2 = MIN_SHAPE_SIZE/2.0;
var MIN_ANGLE = 0.07;
function ResizeTrackShapeImage(originalObject, cardDirection)
{
this.originalObject = originalObject;
this.numberHandle = originalObject.getNumByCardDirection(cardDirection);
var numberHandle = this.numberHandle;
this.flipH = originalObject.flipH;
this.flipV = originalObject.flipV;
var _flip_h = originalObject.flipH;
var _flip_v = originalObject.flipV;
var _half_height = originalObject.extY*0.5;
var _half_width = originalObject.extX*0.5;
var _sin = Math.sin(originalObject.rot);
var _cos = Math.cos(originalObject.rot);
var _translated_num_handle;
if(!_flip_h && !_flip_v)
{
_translated_num_handle = numberHandle;
}
else if(_flip_h && !_flip_v)
{
_translated_num_handle = TRANSLATE_HANDLE_FLIP_H[numberHandle];
}
else if(!_flip_h && _flip_v)
{
_translated_num_handle = TRANSLATE_HANDLE_FLIP_V[numberHandle];
}
else
{
_translated_num_handle = TRANSLATE_HANDLE_FLIP_H_AND_FLIP_V[numberHandle];
}
this.bAspect = numberHandle % 2 === 0;
this.aspect = this.bAspect === true ? this.originalObject.getAspect(_translated_num_handle) : 0;
this.sin = _sin;
this.cos = _cos;
this.translatetNumberHandle = _translated_num_handle;
switch (_translated_num_handle)
{
case 0:
case 1:
{
this.fixedPointX = (_half_width*_cos - _half_height*_sin) + _half_width + originalObject.x;
this.fixedPointY = (_half_width*_sin + _half_height*_cos) + _half_height + originalObject.y;
break;
}
case 2:
case 3:
{
this.fixedPointX = (-_half_width*_cos - _half_height*_sin) + _half_width + originalObject.x;
this.fixedPointY = (-_half_width*_sin + _half_height*_cos) + _half_height + originalObject.y;
break;
}
case 4:
case 5:
{
this.fixedPointX = (-_half_width*_cos + _half_height*_sin) + _half_width + originalObject.x;
this.fixedPointY = (-_half_width*_sin - _half_height*_cos) + _half_height + originalObject.y;
break;
}
case 6:
case 7:
{
this.fixedPointX = (_half_width*_cos + _half_height*_sin) + _half_width + originalObject.x;
this.fixedPointY = (_half_width*_sin - _half_height*_cos) + _half_height + originalObject.y;
break;
}
}
this.mod = this.translatetNumberHandle % 4;
this.centerPointX = originalObject.x + _half_width;
this.centerPointY = originalObject.y + _half_height;
//this.lineFlag = originalObject.checkLine();
this.originalExtX = originalObject.extX;
this.originalExtY = originalObject.extY;
this.originalFlipH = _flip_h;
this.originalFlipV = _flip_v;
this.usedExtX = this.originalExtX === 0 ? (/*this.lineFlag ? this.originalExtX :*/ 0.01) : this.originalExtX;
this.usedExtY = this.originalExtY === 0 ? (/*this.lineFlag ? this.originalExtY :*/ 0.01) : this.originalExtY;
this.resizedExtX = this.originalExtX;
this.resizedExtY = this.originalExtY;
this.resizedflipH = _flip_h;
this.resizedflipV = _flip_v;
this.resizedPosX = originalObject.x;
this.resizedPosY = originalObject.y;
this.resizedRot = originalObject.rot;
this.transform = originalObject.transform.CreateDublicate();
this.geometry = originalObject.spPr.geometry.createDuplicate();
this.brush = originalObject.brush;
this.pen = originalObject.pen;
this.isLine = originalObject.spPr.geometry && originalObject.spPr.geometry.preset === "line";
this.bChangeCoef = this.translatetNumberHandle % 2 === 0 && this.originalFlipH !== this.originalFlipV;
this.overlayObject = new OverlayObject(this.geometry, this.resizedExtX, this.resizedExtY, this.brush, this.pen, this.transform);
this.track = function(kd1, kd2, e)
{
if(!e.ctrlKey)
this.resize(kd1, kd2, e.shiftKey);
else
this.resizeRelativeCenter(kd1, kd2, e.shiftKey)
};
this.resize = function(kd1, kd2, ShiftKey)
{
var _cos = this.cos;
var _sin = this.sin;
var _real_height, _real_width;
var _abs_height, _abs_width;
var _new_resize_half_width;
var _new_resize_half_height;
var _new_used_half_width;
var _new_used_half_height;
var _temp;
if(ShiftKey === true && this.bAspect === true)
{
var _new_aspect = this.aspect*(Math.abs(kd1/ kd2));
if (_new_aspect >= this.aspect)
kd2 = Math.abs(kd1)*(kd2 >= 0 ? 1 : -1 );
else
kd1 = Math.abs(kd2)*(kd1 >= 0 ? 1 : -1);
}
if(this.bChangeCoef)
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
switch (this.translatetNumberHandle)
{
case 0:
case 1:
{
if(this.translatetNumberHandle === 0)
{
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.isLine ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0 )
{
this.resizedflipH = !this.originalFlipH;
}
else
this.resizedflipH = this.originalFlipH;
}
if(this.translatetNumberHandle === 1)
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.isLine ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0 )
{
this.resizedflipV = !this.originalFlipV;
if(this.isLine && ShiftKey)
{
this.resizedflipH = !this.originalFlipH;
}
}
else
{
this.resizedflipV = this.originalFlipV;
if(this.isLine && ShiftKey && this.resizedflipH !== this.originalFlipH)
{
this.resizedflipV = !this.originalFlipV;
}
}
_new_resize_half_width = this.resizedExtX*0.5;
_new_resize_half_height = this.resizedExtY*0.5;
if(this.resizedflipH !== this.originalFlipH)
{
_new_used_half_width = -_new_resize_half_width;
}
else
{
_new_used_half_width = _new_resize_half_width;
}
if(this.resizedflipV !== this.originalFlipV)
{
_new_used_half_height = -_new_resize_half_height;
}
else
{
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (-_new_used_half_width*_cos + _new_used_half_height*_sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (-_new_used_half_width*_sin - _new_used_half_height*_cos) - _new_resize_half_height;
break;
}
case 2:
case 3:
{
if(this.translatetNumberHandle === 2)
{
_temp = kd2;
kd2 = kd1;
kd1 = _temp;
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.isLine ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0 )
this.resizedflipV = !this.originalFlipV;
else
this.resizedflipV = this.originalFlipV;
}
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.isLine ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0 )
{
this.resizedflipH = !this.originalFlipH;
if(this.isLine && ShiftKey)
{
this.resizedflipV = !this.originalFlipV;
}
}
else
{
this.resizedflipH = this.originalFlipH;
if(this.isLine && ShiftKey && this.resizedflipV !== this.originalFlipV)
{
this.resizedflipH = !this.originalFlipH;
}
}
_new_resize_half_width = this.resizedExtX*0.5;
_new_resize_half_height = this.resizedExtY*0.5;
if(this.resizedflipH !== this.originalFlipH)
{
_new_used_half_width = -_new_resize_half_width;
}
else
{
_new_used_half_width = _new_resize_half_width;
}
if(this.resizedflipV !== this.originalFlipV)
{
_new_used_half_height = -_new_resize_half_height;
}
else
{
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (_new_used_half_width*_cos + _new_used_half_height*_sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (_new_used_half_width*_sin - _new_used_half_height*_cos) - _new_resize_half_height;
break;
}
case 4:
case 5:
{
if(this.translatetNumberHandle === 4)
{
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.isLine ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0 )
this.resizedflipH = !this.originalFlipH;
else
this.resizedflipH = this.originalFlipH;
}
else
{
_temp = kd2;
kd2 = kd1;
kd1 = _temp;
}
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.isLine ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0 )
{
this.resizedflipV = !this.originalFlipV;
if(this.isLine && ShiftKey)
{
this.resizedflipH = !this.originalFlipH;
}
}
else
{
this.resizedflipV = this.originalFlipV;
if(this.isLine && ShiftKey && this.resizedflipH !== this.originalFlipH)
{
this.resizedflipV = !this.originalFlipV;
}
}
_new_resize_half_width = this.resizedExtX*0.5;
_new_resize_half_height = this.resizedExtY*0.5;
if(this.resizedflipH !== this.originalFlipH)
{
_new_used_half_width = -_new_resize_half_width;
}
else
{
_new_used_half_width = _new_resize_half_width;
}
if(this.resizedflipV !== this.originalFlipV)
{
_new_used_half_height = -_new_resize_half_height;
}
else
{
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (_new_used_half_width*_cos - _new_used_half_height*_sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (_new_used_half_width*_sin + _new_used_half_height*_cos) - _new_resize_half_height;
break;
}
case 6:
case 7:
{
if(this.translatetNumberHandle === 6)
{
_real_height = this.usedExtY*kd1;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.isLine ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0 )
this.resizedflipV = !this.originalFlipV;
else
this.resizedflipV = this.originalFlipV;
}
else
{
_temp = kd2;
kd2 = kd1;
kd1 = _temp;
}
_real_width = this.usedExtX*kd2;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.isLine ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0 )
{
this.resizedflipH = !this.originalFlipH;
if(this.isLine && ShiftKey)
{
this.resizedflipV = !this.originalFlipV;
}
}
else
{
this.resizedflipH = this.originalFlipH;
if(this.isLine && ShiftKey && this.resizedflipV !== this.originalFlipV)
{
this.resizedflipH = !this.originalFlipH;
}
}
_new_resize_half_width = this.resizedExtX*0.5;
_new_resize_half_height = this.resizedExtY*0.5;
if(this.resizedflipH !== this.originalFlipH)
{
_new_used_half_width = -_new_resize_half_width;
}
else
{
_new_used_half_width = _new_resize_half_width;
}
if(this.resizedflipV !== this.originalFlipV)
{
_new_used_half_height = -_new_resize_half_height;
}
else
{
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (-_new_used_half_width*_cos - _new_used_half_height*_sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (-_new_used_half_width*_sin + _new_used_half_height*_cos) - _new_resize_half_height;
break;
}
}
this.geometry.Recalculate(this.resizedExtX, this.resizedExtY);
this.overlayObject.updateExtents(this.resizedExtX, this.resizedExtY);
var _transform = this.transform;
_transform.Reset();
var _horizontal_center = this.resizedExtX*0.5;
var _vertical_center = this.resizedExtY*0.5;
global_MatrixTransformer.TranslateAppend(_transform, -_horizontal_center, -_vertical_center);
if(this.resizedflipH)
{
global_MatrixTransformer.ScaleAppend(_transform, -1, 1);
}
if(this.resizedflipV)
{
global_MatrixTransformer.ScaleAppend(_transform, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(_transform, -this.resizedRot);
global_MatrixTransformer.TranslateAppend(_transform, this.resizedPosX, this.resizedPosY);
global_MatrixTransformer.TranslateAppend(_transform, _horizontal_center, _vertical_center);
};
this.resizeRelativeCenter = function(kd1, kd2, shiftKey)
{
if(this.isLine)
{
this.resize(kd1, kd2, shiftKey);
return;
}
kd1 = 2*kd1 - 1;
kd2 = 2*kd2 - 1;
var _real_height, _real_width;
var _abs_height, _abs_width;
if(shiftKey === true && this.bAspect === true)
{
var _new_aspect = this.aspect*(Math.abs(kd1/ kd2));
if (_new_aspect >= this.aspect)
kd2 = Math.abs(kd1)*(kd2 >= 0 ? 1 : -1 );
else
kd1 = Math.abs(kd2)*(kd1 >= 0 ? 1 : -1);
}
var _temp;
if(this.bChangeCoef)
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
if(this.mod === 0 || this.mod === 1)
{
if(this.mod === 0)
{
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE ? _abs_width : MIN_SHAPE_SIZE;
this.resizedflipH = _real_width < 0 ? !this.originalFlipH : this.originalFlipH;
}
else
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE ? _abs_height : MIN_SHAPE_SIZE;
this.resizedflipV = _real_height < 0 ? !this.originalFlipV : this.originalFlipV;
}
else
{
if(this.mod === 2)
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE ? _abs_height : MIN_SHAPE_SIZE;
this.resizedflipV = _real_height < 0 ? !this.originalFlipV : this.originalFlipV;
}
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE ? _abs_width : MIN_SHAPE_SIZE;
this.resizedflipH = _real_width < 0 ? !this.originalFlipH : this.originalFlipH;
}
this.resizedPosX = this.centerPointX - this.resizedExtX*0.5;
this.resizedPosY = this.centerPointY - this.resizedExtY*0.5;
this.geometry.Recalculate(this.resizedExtX, this.resizedExtY);
this.overlayObject.updateExtents(this.resizedExtX, this.resizedExtY);
var _transform = this.transform;
_transform.Reset();
var _horizontal_center = this.resizedExtX*0.5;
var _vertical_center = this.resizedExtY*0.5;
global_MatrixTransformer.TranslateAppend(_transform, -_horizontal_center, -_vertical_center);
if(this.resizedflipH)
{
global_MatrixTransformer.ScaleAppend(_transform, -1, 1);
}
if(this.resizedflipV)
{
global_MatrixTransformer.ScaleAppend(_transform, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(_transform, -this.resizedRot);
global_MatrixTransformer.TranslateAppend(_transform, this.resizedPosX, this.resizedPosY);
global_MatrixTransformer.TranslateAppend(_transform, _horizontal_center, _vertical_center);
};
this.draw = function(overlay)
{
this.overlayObject.draw(overlay);
};
this.getBounds = function()
{
var bounds_checker = new CSlideBoundsChecker();
bounds_checker.init(Page_Width, Page_Height, Page_Width, Page_Height);
this.draw(bounds_checker);
return {l: bounds_checker.Bounds.min_x, t: bounds_checker.Bounds.min_y, r: bounds_checker.Bounds.max_x , b: bounds_checker.Bounds.max_y};
};
this.getBoundsRect = function()
{
var t = this.transform;
var max_x, min_x, max_y, min_y;
min_x = t.TransformPointX(0, 0);
max_x = min_x;
min_y = t.TransformPointY(0, 0);
max_y = min_y;
var arr = [{x: this.resizedExtX, y: 0}, {x: this.resizedExtX, y: this.resizedExtY}, {x: 0, y: this.resizedExtY}];
var t_x, t_y;
for(var i = 0; i < arr.length; ++i)
{
var p = arr[i];
t_x = t.TransformPointX(p.x, p.y);
t_y = t.TransformPointY(p.x, p.y);
if(t_x < min_x)
min_x = t_x;
if(t_x > max_x)
max_x = t_x;
if(t_y < min_y)
min_y = t_y;
if(t_y > max_y)
max_y = t_y;
}
return {l: min_x, t: min_y, r: max_x, b: max_y};
};
this.trackEnd = function()
{
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_RecalculateTransformUndo, null, null, new UndoRedoDataGraphicObjects(this.originalObject.Id, new UndoRedoDataShapeRecalc()), null);
this.originalObject.setPosition(this.resizedPosX, this.resizedPosY);
this.originalObject.setExtents(this.resizedExtX, this.resizedExtY);
this.originalObject.setFlips(this.resizedflipH, this.resizedflipV);
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_RecalculateTransformRedo, null, null, new UndoRedoDataGraphicObjects(this.originalObject.Id, new UndoRedoDataShapeRecalc()), null);
this.originalObject.recalculateTransform();
this.originalObject.calculateContent();
this.originalObject.calculateTransformTextMatrix();
var bounds_rect = this.originalObject.getRectBounds();
var check_position = this.originalObject.drawingObjects.checkGraphicObjectPosition(bounds_rect.minX, bounds_rect.minY, bounds_rect.maxX - bounds_rect.minX, bounds_rect.maxY - bounds_rect.minY);
if(!check_position.result)
{
this.originalObject.setPosition(this.resizedPosX + check_position.x, this.resizedPosY + check_position.y);
this.originalObject.recalculateTransform();
this.originalObject.calculateContent();
this.originalObject.calculateTransformTextMatrix();
}
this.originalObject.updateDrawingBaseCoordinates();
};
}
function ResizeTrackShapeImageInGroup(originalObject, cardDirection)
{
this.originalObject = originalObject;
this.numberHandle = originalObject.getNumByCardDirection(cardDirection);
var numberHandle = this.numberHandle;
this.flipH = originalObject.flipH;
this.flipV = originalObject.flipV;
var _flip_h = originalObject.flipH;
var _flip_v = originalObject.flipV;
var _half_height = originalObject.extY*0.5;
var _half_width = originalObject.extX*0.5;
var _sin = Math.sin(originalObject.rot);
var _cos = Math.cos(originalObject.rot);
var _translated_num_handle;
if(!_flip_h && !_flip_v)
{
_translated_num_handle = numberHandle;
}
else if(_flip_h && !_flip_v)
{
_translated_num_handle = TRANSLATE_HANDLE_FLIP_H[numberHandle];
}
else if(!_flip_h && _flip_v)
{
_translated_num_handle = TRANSLATE_HANDLE_FLIP_V[numberHandle];
}
else
{
_translated_num_handle = TRANSLATE_HANDLE_FLIP_H_AND_FLIP_V[numberHandle];
}
this.bAspect = numberHandle % 2 === 0;
this.aspect = this.bAspect === true ? this.originalObject.getAspect(_translated_num_handle) : 0;
this.sin = _sin;
this.cos = _cos;
this.translatetNumberHandle = _translated_num_handle;
switch (_translated_num_handle)
{
case 0:
case 1:
{
this.fixedPointX = (_half_width*_cos - _half_height*_sin) + _half_width + originalObject.x;
this.fixedPointY = (_half_width*_sin + _half_height*_cos) + _half_height + originalObject.y;
break;
}
case 2:
case 3:
{
this.fixedPointX = (-_half_width*_cos - _half_height*_sin) + _half_width + originalObject.x;
this.fixedPointY = (-_half_width*_sin + _half_height*_cos) + _half_height + originalObject.y;
break;
}
case 4:
case 5:
{
this.fixedPointX = (-_half_width*_cos + _half_height*_sin) + _half_width + originalObject.x;
this.fixedPointY = (-_half_width*_sin - _half_height*_cos) + _half_height + originalObject.y;
break;
}
case 6:
case 7:
{
this.fixedPointX = (_half_width*_cos + _half_height*_sin) + _half_width + originalObject.x;
this.fixedPointY = (_half_width*_sin - _half_height*_cos) + _half_height + originalObject.y;
break;
}
}
this.mod = this.translatetNumberHandle % 4;
this.centerPointX = originalObject.x + _half_width;
this.centerPointY = originalObject.y + _half_height;
//this.lineFlag = originalObject.checkLine();
this.originalExtX = originalObject.extX;
this.originalExtY = originalObject.extY;
this.originalFlipH = _flip_h;
this.originalFlipV = _flip_v;
this.usedExtX = this.originalExtX === 0 ? (/*this.lineFlag ? this.originalExtX :*/ 0.01) : this.originalExtX;
this.usedExtY = this.originalExtY === 0 ? (/*this.lineFlag ? this.originalExtY :*/ 0.01) : this.originalExtY;
this.resizedExtX = this.originalExtX;
this.resizedExtY = this.originalExtY;
this.resizedflipH = _flip_h;
this.resizedflipV = _flip_v;
this.resizedPosX = originalObject.x;
this.resizedPosY = originalObject.y;
this.resizedRot = originalObject.rot;
this.transform = originalObject.transform.CreateDublicate();
this.geometry = originalObject.spPr.geometry.createDuplicate();
var pen, brush;
if(!(typeof CChartAsGroup != "undefined" && originalObject instanceof CChartAsGroup))
{
pen = originalObject.pen;
brush = originalObject.brush;
}
else
{
brush = new CUniFill();
brush.fill = new CSolidFill();
brush.fill.color = new CUniColor();
brush.fill.color.RGBA = {R:255, G:255, B:255, A:255};
brush.fill.color.color = new CRGBColor();
brush.fill.color.color.RGBA = {R:255, G:255, B:255, A:255};
pen = new CLn();
pen.Fill = new CUniFill();
pen.Fill.fill = new CSolidFill();
pen.Fill.fill.color = new CUniColor();
pen.Fill.fill.color.color = new CRGBColor();
}
this.brush = brush;
this.pen = pen;
this.bChangeCoef = this.translatetNumberHandle % 2 === 0 && this.originalFlipH !== this.originalFlipV;
this.overlayObject = new OverlayObject(this.geometry, this.resizedExtX, this.resizedExtY, this.brush, this.pen, this.transform);
this.track = function(kd1, kd2, e)
{
if(!e.ctrlKey)
this.resize(kd1, kd2, e.shiftKey);
else
this.resizeRelativeCenter(kd1, kd2, e.shiftKey)
};
this.resize = function(kd1, kd2, shiftKey)
{
var _cos = this.cos;
var _sin = this.sin;
var _real_height, _real_width;
var _abs_height, _abs_width;
var _new_resize_half_width;
var _new_resize_half_height;
var _new_used_half_width;
var _new_used_half_height;
var _temp;
if(shiftKey === true && this.bAspect === true)
{
var _new_aspect = this.aspect*(Math.abs(kd1/ kd2));
if (_new_aspect >= this.aspect)
kd2 = Math.abs(kd1)*(kd2 >= 0 ? 1 : -1 );
else
kd1 = Math.abs(kd2)*(kd1 >= 0 ? 1 : -1);
}
if(this.bChangeCoef)
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
switch (this.translatetNumberHandle)
{
case 0:
case 1:
{
if(this.translatetNumberHandle === 0)
{
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0)
this.resizedflipH = !this.originalFlipH;
else
this.resizedflipH = this.originalFlipH;
}
if(this.translatetNumberHandle === 1)
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0)
this.resizedflipV = !this.originalFlipV;
else
this.resizedflipV = this.originalFlipV;
_new_resize_half_width = this.resizedExtX*0.5;
_new_resize_half_height = this.resizedExtY*0.5;
if(this.resizedflipH !== this.originalFlipH)
{
_new_used_half_width = -_new_resize_half_width;
}
else
{
_new_used_half_width = _new_resize_half_width;
}
if(this.resizedflipV !== this.originalFlipV)
{
_new_used_half_height = -_new_resize_half_height;
}
else
{
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (-_new_used_half_width*_cos + _new_used_half_height*_sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (-_new_used_half_width*_sin - _new_used_half_height*_cos) - _new_resize_half_height;
break;
}
case 2:
case 3:
{
if(this.translatetNumberHandle === 2)
{
_temp = kd2;
kd2 = kd1;
kd1 = _temp;
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0)
this.resizedflipV = !this.originalFlipV;
else
this.resizedflipV = this.originalFlipV;
}
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0)
this.resizedflipH = !this.originalFlipH;
else
this.resizedflipH = this.originalFlipH;
_new_resize_half_width = this.resizedExtX*0.5;
_new_resize_half_height = this.resizedExtY*0.5;
if(this.resizedflipH !== this.originalFlipH)
{
_new_used_half_width = -_new_resize_half_width;
}
else
{
_new_used_half_width = _new_resize_half_width;
}
if(this.resizedflipV !== this.originalFlipV)
{
_new_used_half_height = -_new_resize_half_height;
}
else
{
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (_new_used_half_width*_cos + _new_used_half_height*_sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (_new_used_half_width*_sin - _new_used_half_height*_cos) - _new_resize_half_height;
break;
}
case 4:
case 5:
{
if(this.translatetNumberHandle === 4)
{
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0)
this.resizedflipH = !this.originalFlipH;
else
this.resizedflipH = this.originalFlipH;
}
else
{
_temp = kd2;
kd2 = kd1;
kd1 = _temp;
}
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0)
this.resizedflipV = !this.originalFlipV;
else
this.resizedflipV = this.originalFlipV;
_new_resize_half_width = this.resizedExtX*0.5;
_new_resize_half_height = this.resizedExtY*0.5;
if(this.resizedflipH !== this.originalFlipH)
{
_new_used_half_width = -_new_resize_half_width;
}
else
{
_new_used_half_width = _new_resize_half_width;
}
if(this.resizedflipV !== this.originalFlipV)
{
_new_used_half_height = -_new_resize_half_height;
}
else
{
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (_new_used_half_width*_cos - _new_used_half_height*_sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (_new_used_half_width*_sin + _new_used_half_height*_cos) - _new_resize_half_height;
break;
}
case 6:
case 7:
{
if(this.translatetNumberHandle === 6)
{
_real_height = this.usedExtY*kd1;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0)
this.resizedflipV = !this.originalFlipV;
else
this.resizedflipV = this.originalFlipV;
}
else
{
_temp = kd2;
kd2 = kd1;
kd1 = _temp;
}
_real_width = this.usedExtX*kd2;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0)
this.resizedflipH = !this.originalFlipH;
else
this.resizedflipH = this.originalFlipH;
_new_resize_half_width = this.resizedExtX*0.5;
_new_resize_half_height = this.resizedExtY*0.5;
if(this.resizedflipH !== this.originalFlipH)
{
_new_used_half_width = -_new_resize_half_width;
}
else
{
_new_used_half_width = _new_resize_half_width;
}
if(this.resizedflipV !== this.originalFlipV)
{
_new_used_half_height = -_new_resize_half_height;
}
else
{
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (-_new_used_half_width*_cos - _new_used_half_height*_sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (-_new_used_half_width*_sin + _new_used_half_height*_cos) - _new_resize_half_height;
break;
}
}
this.geometry.Recalculate(this.resizedExtX, this.resizedExtY);
this.overlayObject.updateExtents(this.resizedExtX, this.resizedExtY);
var _transform = this.transform;
_transform.Reset();
var _horizontal_center = this.resizedExtX*0.5;
var _vertical_center = this.resizedExtY*0.5;
global_MatrixTransformer.TranslateAppend(_transform, -_horizontal_center, -_vertical_center);
if(this.resizedflipH)
{
global_MatrixTransformer.ScaleAppend(_transform, -1, 1);
}
if(this.resizedflipV)
{
global_MatrixTransformer.ScaleAppend(_transform, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(_transform, -this.resizedRot);
global_MatrixTransformer.TranslateAppend(_transform, this.resizedPosX, this.resizedPosY);
global_MatrixTransformer.TranslateAppend(_transform, _horizontal_center, _vertical_center);
global_MatrixTransformer.MultiplyAppend(_transform, this.originalObject.group.getTransform());
};
this.resizeRelativeCenter = function(kd1, kd2, shiftKey)
{
kd1 = 2*kd1 - 1;
kd2 = 2*kd2 - 1;
var _real_height, _real_width;
var _abs_height, _abs_width;
if(shiftKey === true && this.bAspect === true)
{
var _new_aspect = this.aspect*(Math.abs(kd1/ kd2));
if (_new_aspect >= this.aspect)
kd2 = Math.abs(kd1)*(kd2 >= 0 ? 1 : -1 );
else
kd1 = Math.abs(kd2)*(kd1 >= 0 ? 1 : -1);
}
var _temp;
if(this.bChangeCoef)
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
if(this.mod === 0 || this.mod === 1)
{
if(this.mod === 0)
{
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE ? _abs_width : MIN_SHAPE_SIZE;
this.resizedflipH = _real_width < 0 ? !this.originalFlipH : this.originalFlipH;
}
else
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE ? _abs_height : MIN_SHAPE_SIZE;
this.resizedflipV = _real_height < 0 ? !this.originalFlipV : this.originalFlipV;
}
else
{
if(this.mod === 2)
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE ? _abs_height : MIN_SHAPE_SIZE;
this.resizedflipV = _real_height < 0 ? !this.originalFlipV : this.originalFlipV;
}
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE ? _abs_width : MIN_SHAPE_SIZE;
this.resizedflipH = _real_width < 0 ? !this.originalFlipH : this.originalFlipH;
}
this.resizedPosX = this.centerPointX - this.resizedExtX*0.5;
this.resizedPosY = this.centerPointY - this.resizedExtY*0.5;
this.geometry.Recalculate(this.resizedExtX, this.resizedExtY);
this.overlayObject.updateExtents(this.resizedExtX, this.resizedExtY);
var _transform = this.transform;
_transform.Reset();
var _horizontal_center = this.resizedExtX*0.5;
var _vertical_center = this.resizedExtY*0.5;
global_MatrixTransformer.TranslateAppend(_transform, -_horizontal_center, -_vertical_center);
if(this.resizedflipH)
{
global_MatrixTransformer.ScaleAppend(_transform, -1, 1);
}
if(this.resizedflipV)
{
global_MatrixTransformer.ScaleAppend(_transform, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(_transform, -this.resizedRot);
global_MatrixTransformer.TranslateAppend(_transform, this.resizedPosX, this.resizedPosY);
global_MatrixTransformer.TranslateAppend(_transform, _horizontal_center, _vertical_center);
global_MatrixTransformer.MultiplyAppend(_transform, this.originalObject.group.getTransform());
};
this.draw = function(overlay)
{
this.overlayObject.draw(overlay);
};
this.getBounds = function()
{
var bounds_checker = new CSlideBoundsChecker();
bounds_checker.init(Page_Width, Page_Height, Page_Width, Page_Height);
this.draw(bounds_checker);
return {l: bounds_checker.Bounds.min_x, t: bounds_checker.Bounds.min_y, r: bounds_checker.Bounds.max_x , b: bounds_checker.Bounds.max_y};
};
this.getBoundsRect = function()
{
var t = this.transform;
var max_x, min_x, max_y, min_y;
min_x = t.TransformPointX(0, 0);
max_x = min_x;
min_y = t.TransformPointY(0, 0);
max_y = min_y;
var arr = [{x: this.resizedExtX, y: 0}, {x: this.resizedExtX, y: this.resizedExtY}, {x: 0, y: this.resizedExtY}];
var t_x, t_y;
for(var i = 0; i < arr.length; ++i)
{
var p = arr[i];
t_x = t.TransformPointX(p.x, p.y);
t_y = t.TransformPointY(p.x, p.y);
if(t_x < min_x)
min_x = t_x;
if(t_x > max_x)
max_x = t_x;
if(t_y < min_y)
min_y = t_y;
if(t_y > max_y)
max_y = t_y;
}
return {l: min_x, t: min_y, r: max_x, b: max_y};
};
this.trackEnd = function()
{
var scale_scale_coefficients = this.originalObject.group.getResultScaleCoefficients();
var xfrm = this.originalObject.group.spPr.xfrm;
this.originalObject.setPosition(this.resizedPosX/scale_scale_coefficients.cx + xfrm.chOffX, this.resizedPosY/scale_scale_coefficients.cy + xfrm.chOffY);
this.originalObject.setExtents(this.resizedExtX/scale_scale_coefficients.cx, this.resizedExtY/scale_scale_coefficients.cy);
this.originalObject.setFlips(this.resizedflipH, this.resizedflipV);
this.originalObject.recalculateTransform();
this.originalObject.calculateContent();
this.originalObject.calculateTransformTextMatrix();
};
}
function ResizeTrackGroup(originalObject, cardDirection, parentTrack)
{
this.original = originalObject;
this.originalObject = originalObject;
this.parentTrack = parentTrack;
var numberHandle;
if(isRealNumber(cardDirection))
{
this.numberHandle = originalObject.getNumByCardDirection(cardDirection);
numberHandle = this.numberHandle;
}
this.x = originalObject.x;
this.y = originalObject.y;
this.extX = originalObject.extX;
this.extY = originalObject.extY;
this.rot = originalObject.rot;
this.flipH = originalObject.flipH;
this.flipV = originalObject.flipV;
this.transform = originalObject.transform.CreateDublicate();
this.bSwapCoef = !(this.rot < Math.PI*0.25 || this.rot>Math.PI*1.75 || (this.rot>Math.PI*0.75 && this.rot<Math.PI*1.25));
this.childs = [];
var a = originalObject.spTree;
for(var i = 0; i < a.length; ++i)
{
if(a[i].isGroup())
this.childs[i] = new ResizeTrackGroup(a[i], null, this);
else
this.childs[i] = new ShapeForResizeInGroup(a[i], this);
}
if(typeof numberHandle === "number")
{
var _translated_num_handle;
var _flip_h = this.flipH;
var _flip_v = this.flipV;
var _sin = Math.sin(this.rot);
var _cos = Math.cos(this.rot);
var _half_width = this.extX*0.5;
var _half_height = this.extY*0.5;
if(!_flip_h && !_flip_v)
{
_translated_num_handle = numberHandle;
}
else if(_flip_h && !_flip_v)
{
_translated_num_handle = TRANSLATE_HANDLE_FLIP_H[numberHandle];
}
else if(!_flip_h && _flip_v)
{
_translated_num_handle = TRANSLATE_HANDLE_FLIP_V[numberHandle];
}
else
{
_translated_num_handle = TRANSLATE_HANDLE_FLIP_H_AND_FLIP_V[numberHandle];
}
this.bAspect = numberHandle % 2 === 0;
this.aspect = this.bAspect === true ? this.original.getAspect(_translated_num_handle) : 0;
this.sin = _sin;
this.cos = _cos;
this.translatetNumberHandle = _translated_num_handle;
switch (_translated_num_handle)
{
case 0:
case 1:
{
this.fixedPointX = (_half_width*_cos - _half_height*_sin) + _half_width + this.x;
this.fixedPointY = (_half_width*_sin + _half_height*_cos) + _half_height + this.y;
break;
}
case 2:
case 3:
{
this.fixedPointX = (-_half_width*_cos - _half_height*_sin) + _half_width + this.x;
this.fixedPointY = (-_half_width*_sin + _half_height*_cos) + _half_height + this.y;
break;
}
case 4:
case 5:
{
this.fixedPointX = (-_half_width*_cos + _half_height*_sin) + _half_width + this.x;
this.fixedPointY = (-_half_width*_sin - _half_height*_cos) + _half_height + this.y;
break;
}
case 6:
case 7:
{
this.fixedPointX = (_half_width*_cos + _half_height*_sin) + _half_width + this.x;
this.fixedPointY = (_half_width*_sin - _half_height*_cos) + _half_height + this.y;
break;
}
}
this.mod = this.translatetNumberHandle % 4;
this.centerPointX = this.x + _half_width;
this.centerPointY = this.y + _half_height;
this.lineFlag = false;
this.originalExtX = this.extX;
this.originalExtY = this.extY;
this.originalFlipH = _flip_h;
this.originalFlipV = _flip_v;
this.usedExtX = this.originalExtX === 0 ? (/*this.lineFlag ? this.originalExtX :*/ 0.01) : this.originalExtX;
this.usedExtY = this.originalExtY === 0 ? (/*this.lineFlag ? this.originalExtY :*/ 0.01) : this.originalExtY;
this.resizedExtX = this.originalExtX;
this.resizedExtY = this.originalExtY;
this.resizedflipH = _flip_h;
this.resizedflipV = _flip_v;
this.resizedPosX = this.x;
this.resizedPosY = this.y;
this.resizedRot = this.rot;
this.bChangeCoef = this.translatetNumberHandle % 2 === 0 && this.originalFlipH !== this.originalFlipV;
}
if(this.parentTrack)
{
this.centerDistX = this.x + this.extX*0.5 - this.parentTrack.extX*0.5;
this.centerDistY = this.y + this.extY*0.5 - this.parentTrack.extY*0.5;
}
this.track = function(kd1, kd2, e)
{
if(!e.ctrlKey)
this.resize(kd1, kd2, e.shiftKey);
else
this.resizeRelativeCenter(kd1, kd2, e.shiftKey)
};
this.resize = function(kd1, kd2, shiftKey)
{
var _cos = this.cos;
var _sin = this.sin;
var _real_height, _real_width;
var _abs_height, _abs_width;
var _new_resize_half_width;
var _new_resize_half_height;
var _new_used_half_width;
var _new_used_half_height;
var _temp;
if(shiftKey === true && this.bAspect === true)
{
var _new_aspect = this.aspect*(Math.abs(kd1/ kd2));
if (_new_aspect >= this.aspect)
kd2 = Math.abs(kd1)*(kd2 >= 0 ? 1 : -1 );
else
kd1 = Math.abs(kd2)*(kd1 >= 0 ? 1 : -1);
}
if(this.bChangeCoef)
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
switch (this.translatetNumberHandle)
{
case 0:
case 1:
{
if(this.translatetNumberHandle === 0)
{
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0)
this.resizedflipH = !this.originalFlipH;
else
this.resizedflipH = this.originalFlipH;
}
if(this.translatetNumberHandle === 1)
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0)
this.resizedflipV = !this.originalFlipV;
else
this.resizedflipV = this.originalFlipV;
_new_resize_half_width = this.resizedExtX*0.5;
_new_resize_half_height = this.resizedExtY*0.5;
if(this.resizedflipH !== this.originalFlipH)
{
_new_used_half_width = -_new_resize_half_width;
}
else
{
_new_used_half_width = _new_resize_half_width;
}
if(this.resizedflipV !== this.originalFlipV)
{
_new_used_half_height = -_new_resize_half_height;
}
else
{
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (-_new_used_half_width*_cos + _new_used_half_height*_sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (-_new_used_half_width*_sin - _new_used_half_height*_cos) - _new_resize_half_height;
break;
}
case 2:
case 3:
{
if(this.translatetNumberHandle === 2)
{
_temp = kd2;
kd2 = kd1;
kd1 = _temp;
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0)
this.resizedflipV = !this.originalFlipV;
else
this.resizedflipV = this.originalFlipV;
}
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0)
this.resizedflipH = !this.originalFlipH;
else
this.resizedflipH = this.originalFlipH;
_new_resize_half_width = this.resizedExtX*0.5;
_new_resize_half_height = this.resizedExtY*0.5;
if(this.resizedflipH !== this.originalFlipH)
{
_new_used_half_width = -_new_resize_half_width;
}
else
{
_new_used_half_width = _new_resize_half_width;
}
if(this.resizedflipV !== this.originalFlipV)
{
_new_used_half_height = -_new_resize_half_height;
}
else
{
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (_new_used_half_width*_cos + _new_used_half_height*_sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (_new_used_half_width*_sin - _new_used_half_height*_cos) - _new_resize_half_height;
break;
}
case 4:
case 5:
{
if(this.translatetNumberHandle === 4)
{
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0)
this.resizedflipH = !this.originalFlipH;
else
this.resizedflipH = this.originalFlipH;
}
else
{
_temp = kd2;
kd2 = kd1;
kd1 = _temp;
}
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0)
this.resizedflipV = !this.originalFlipV;
else
this.resizedflipV = this.originalFlipV;
_new_resize_half_width = this.resizedExtX*0.5;
_new_resize_half_height = this.resizedExtY*0.5;
if(this.resizedflipH !== this.originalFlipH)
{
_new_used_half_width = -_new_resize_half_width;
}
else
{
_new_used_half_width = _new_resize_half_width;
}
if(this.resizedflipV !== this.originalFlipV)
{
_new_used_half_height = -_new_resize_half_height;
}
else
{
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (_new_used_half_width*_cos - _new_used_half_height*_sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (_new_used_half_width*_sin + _new_used_half_height*_cos) - _new_resize_half_height;
break;
}
case 6:
case 7:
{
if(this.translatetNumberHandle === 6)
{
_real_height = this.usedExtY*kd1;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0)
this.resizedflipV = !this.originalFlipV;
else
this.resizedflipV = this.originalFlipV;
}
else
{
_temp = kd2;
kd2 = kd1;
kd1 = _temp;
}
_real_width = this.usedExtX*kd2;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0)
this.resizedflipH = !this.originalFlipH;
else
this.resizedflipH = this.originalFlipH;
_new_resize_half_width = this.resizedExtX*0.5;
_new_resize_half_height = this.resizedExtY*0.5;
if(this.resizedflipH !== this.originalFlipH)
{
_new_used_half_width = -_new_resize_half_width;
}
else
{
_new_used_half_width = _new_resize_half_width;
}
if(this.resizedflipV !== this.originalFlipV)
{
_new_used_half_height = -_new_resize_half_height;
}
else
{
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (-_new_used_half_width*_cos - _new_used_half_height*_sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (-_new_used_half_width*_sin + _new_used_half_height*_cos) - _new_resize_half_height;
break;
}
}
this.x = this.resizedPosX;
this.y = this.resizedPosY;
this.extX = this.resizedExtX;
this.extY = this.resizedExtY;
this.flipH = this.resizedflipH;
this.flipV = this.resizedflipV;
var _transform = this.transform;
_transform.Reset();
var _horizontal_center = this.resizedExtX*0.5;
var _vertical_center = this.resizedExtY*0.5;
global_MatrixTransformer.TranslateAppend(_transform, -_horizontal_center, -_vertical_center);
if(this.resizedflipH)
{
global_MatrixTransformer.ScaleAppend(_transform, -1, 1);
}
if(this.resizedflipV)
{
global_MatrixTransformer.ScaleAppend(_transform, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(_transform, -this.resizedRot);
global_MatrixTransformer.TranslateAppend(_transform, this.resizedPosX, this.resizedPosY);
global_MatrixTransformer.TranslateAppend(_transform, _horizontal_center, _vertical_center);
var xfrm = this.original.spPr.xfrm;
var kw = this.resizedExtX/xfrm.extX;
var kh = this.resizedExtY/xfrm.extY;
for(var i = 0; i < this.childs.length; ++i)
{
var cur_child = this.childs[i];
cur_child.updateSize(kw, kh);
}
};
this.resizeRelativeCenter = function(kd1, kd2, shiftKey)
{
kd1 = 2*kd1 - 1;
kd2 = 2*kd2 - 1;
var _real_height, _real_width;
var _abs_height, _abs_width;
if(shiftKey === true && this.bAspect === true)
{
var _new_aspect = this.aspect*(Math.abs(kd1/ kd2));
if (_new_aspect >= this.aspect)
kd2 = Math.abs(kd1)*(kd2 >= 0 ? 1 : -1 );
else
kd1 = Math.abs(kd2)*(kd1 >= 0 ? 1 : -1);
}
var _temp;
if(this.bChangeCoef)
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
if(this.mod === 0 || this.mod === 1)
{
if(this.mod === 0)
{
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_width : MIN_SHAPE_SIZE;
this.resizedflipH = _real_width < 0 ? !this.originalFlipH : this.originalFlipH;
}
else
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_height : MIN_SHAPE_SIZE;
this.resizedflipV = _real_height < 0 ? !this.originalFlipV : this.originalFlipV;
}
else
{
if(this.mod === 2)
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_height : MIN_SHAPE_SIZE;
this.resizedflipV = _real_height < 0 ? !this.originalFlipV : this.originalFlipV;
}
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_width : MIN_SHAPE_SIZE;
this.resizedflipH = _real_width < 0 ? !this.originalFlipH : this.originalFlipH;
}
this.resizedPosX = this.centerPointX - this.resizedExtX*0.5;
this.resizedPosY = this.centerPointY - this.resizedExtY*0.5;
this.x = this.resizedPosX;
this.y = this.resizedPosY;
this.extX = this.resizedExtX;
this.extY = this.resizedExtY;
this.flipH = this.resizedflipH;
this.flipV = this.resizedflipV;
var _transform = this.transform;
_transform.Reset();
var _horizontal_center = this.resizedExtX*0.5;
var _vertical_center = this.resizedExtY*0.5;
global_MatrixTransformer.TranslateAppend(_transform, -_horizontal_center, -_vertical_center);
if(this.resizedflipH)
{
global_MatrixTransformer.ScaleAppend(_transform, -1, 1);
}
if(this.resizedflipV)
{
global_MatrixTransformer.ScaleAppend(_transform, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(_transform, -this.resizedRot);
global_MatrixTransformer.TranslateAppend(_transform, this.resizedPosX, this.resizedPosY);
global_MatrixTransformer.TranslateAppend(_transform, _horizontal_center, _vertical_center);
var xfrm = this.original.spPr.xfrm;
var kw = this.resizedExtX/xfrm.extX;
var kh = this.resizedExtY/xfrm.extY;
for(var i = 0; i< this.childs.length; ++i)
{
this.childs[i].updateSize(kw, kh);
}
};
this.updateSize = function(kw, kh)
{
var _kw, _kh;
if(this.bSwapCoef)
{
_kw = kh;
_kh = kw;
}
else
{
_kw = kw;
_kh = kh;
}
var xfrm = this.original.spPr.xfrm;
this.extX = xfrm.extX*_kw;
this.extY = xfrm.extY*_kh;
this.x = this.centerDistX*kw + this.parentTrack.extX*0.5 - this.extX*0.5;
this.y = this.centerDistY*kh + this.parentTrack.extY*0.5 - this.extY*0.5;
this.transform.Reset();
var t = this.transform;
global_MatrixTransformer.TranslateAppend(t, -this.extX*0.5, -this.extY*0.5);
if(xfrm.flipH == null ? false : xfrm.flipH)
{
global_MatrixTransformer.ScaleAppend(t, -1, 1);
}
if(xfrm.flipV == null ? false : xfrm.flipV)
{
global_MatrixTransformer.ScaleAppend(t, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(t, xfrm.rot == null ? 0 : -xfrm.rot);
global_MatrixTransformer.TranslateAppend(t, this.x + this.extX*0.5, this.y+this.extY*0.5);
global_MatrixTransformer.MultiplyAppend(t, this.parentTrack.transform);
for(var i = 0; i < this.childs.length; ++i)
{
this.childs[i].updateSize(_kw, _kh);
}
};
this.draw = function(graphics)
{
for(var i = 0; i < this.childs.length; ++i)
{
this.childs[i].draw(graphics);
}
};
this.getBoundsRect = function()
{
var t = this.transform;
var min_x, max_x, min_y, max_y;
min_x = t.TransformPointX(0, 0);
max_x = min_x;
min_y = t.TransformPointY(0, 0);
max_y = min_y;
var arr = [{x: this.extX, y: 0}, {x: this.extX, y: this.extY}, {x: 0, y: this.extY}];
var t_x, t_y;
for(var i = 0; i < arr.length; ++i)
{
var p = arr[i];
t_x = t.TransformPointX(p.x, p.y);
t_y = t.TransformPointY(p.x, p.y);
if(t_x < min_x)
min_x = t_x;
if(t_x > max_x)
max_x = t_x;
if(t_y < min_y)
min_y = t_y;
if(t_y > max_y)
max_y = t_y;
}
return {l: min_x, t: min_y, r: max_x, b: max_y};};
this.trackEnd = function()
{
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_GroupRecalculateUndo, null, null,
new UndoRedoDataGraphicObjects(this.originalObject.Get_Id(), new UndoRedoDataGOSingleProp(null, null)));
this.original.normalize();
this.original.setPosition(this.x, this.y);
this.original.setExtents(this.extX, this.extY);
this.original.setChildExtents(this.extX, this.extY);
this.original.setFlips(this.flipH, this.flipV);
for(var i = 0; i < this.childs.length; ++i)
{
this.childs[i].trackEnd();
}
if(this.parentTrack == null)
this.original.recalculateTransform();
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_GroupRecalculateRedo, null, null,
new UndoRedoDataGraphicObjects(this.originalObject.Get_Id(), new UndoRedoDataGOSingleProp(null, null)));
};
}
function ShapeForResizeInGroup(originalObject, parentTrack)
{
this.originalObject = originalObject;
this.parentTrack = parentTrack;
this.x = originalObject.x;
this.y = originalObject.y;
this.extX = originalObject.extX;
this.extY = originalObject.extY;
this.rot = isRealNumber(originalObject.rot) ? originalObject.rot : 0;
this.flipH = originalObject.flipH === true;
this.flipV = originalObject.flipV === true;
this.transform = originalObject.transform.CreateDublicate();
this.bSwapCoef = !(this.rot < Math.PI*0.25 || this.rot>Math.PI*1.75 || (this.rot>Math.PI*0.75 && this.rot<Math.PI*1.25));
this.centerDistX = this.x + this.extX*0.5 - this.parentTrack.extX*0.5;
this.centerDistY = this.y + this.extY*0.5 - this.parentTrack.extY*0.5;
this.geometry = originalObject.spPr.geometry !== null ? originalObject.spPr.geometry.createDuplicate() : null;
if(this.geometry)
{
this.geometry.Recalculate(this.extX, this.extY);
}
var pen, brush;
if(!(typeof CChartAsGroup != "undefined" && originalObject instanceof CChartAsGroup))
{
pen = originalObject.pen;
brush = originalObject.brush;
}
else
{
brush = new CUniFill();
brush.fill = new CSolidFill();
brush.fill.color = new CUniColor();
brush.fill.color.RGBA = {R:255, G:255, B:255, A:255};
brush.fill.color.color = new CRGBColor();
brush.fill.color.color.RGBA = {R:255, G:255, B:255, A:255};
pen = new CLn();
pen.Fill = new CUniFill();
pen.Fill.fill = new CSolidFill();
pen.Fill.fill.color = new CUniColor();
pen.Fill.fill.color.color = new CRGBColor();
}
this.overlayObject = new OverlayObject(this.geometry, this.extX, this.extY, brush, pen, this.transform);
this.updateSize = function(kw, kh)
{
var _kw, _kh;
if(this.bSwapCoef)
{
_kw = kh;
_kh = kw;
}
else
{
_kw = kw;
_kh = kh;
}
this.extX = this.originalObject.extX*_kw;
this.extY = this.originalObject.extY*_kh;
this.x = this.centerDistX*kw + this.parentTrack.extX*0.5 - this.extX*0.5;
this.y = this.centerDistY*kh + this.parentTrack.extY*0.5 - this.extY*0.5;
if(this.geometry)
{
this.geometry.Recalculate(this.extX, this.extY);
}
this.transform.Reset();
var t = this.transform;
global_MatrixTransformer.TranslateAppend(t, -this.extX*0.5, -this.extY*0.5);
if(this.flipH)
{
global_MatrixTransformer.ScaleAppend(t, -1, 1);
}
if(this.flipV)
{
global_MatrixTransformer.ScaleAppend(t, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(t, -this.rot);
global_MatrixTransformer.TranslateAppend(t, this.x + this.extX*0.5, this.y+this.extY*0.5);
global_MatrixTransformer.MultiplyAppend(t, this.parentTrack.transform);
};
this.draw = function(overlay)
{
this.overlayObject.draw(overlay);
};
this.getBounds = function()
{
var bounds_checker = new CSlideBoundsChecker();
bounds_checker.init(Page_Width, Page_Height, Page_Width, Page_Height);
this.draw(bounds_checker);
return {l: bounds_checker.Bounds.min_x, t: bounds_checker.Bounds.min_y, r: bounds_checker.Bounds.max_x , b: bounds_checker.Bounds.max_y};
};
this.trackEnd = function()
{
this.originalObject.setPosition(this.x, this.y);
this.originalObject.setExtents(this.extX, this.extY);
if(this.originalObject.spPr.geometry !== null)
this.originalObject.spPr.geometry.Recalculate(this.extX, this.extY);
};
this.updateTransform = function()
{
this.transform.Reset();
var t = this.transform;
global_MatrixTransformer.TranslateAppend(t, -this.extX*0.5, -this.extY*0.5);
if(this.flipH)
{
global_MatrixTransformer.ScaleAppend(t, -1, 1);
}
if(this.flipV)
{
global_MatrixTransformer.ScaleAppend(t, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(t, -this.rot);
global_MatrixTransformer.TranslateAppend(t, this.x + this.extX*0.5, this.y+this.extY*0.5);
if(this.parentTrack)
global_MatrixTransformer.MultiplyAppend(t, this.parentTrack.transform);
};
}
function ResizeTrackChart(originalObject, cardDirection)
{
this.originalObject = originalObject;
this.numberHandle = originalObject.getNumByCardDirection(cardDirection);
var numberHandle = this.numberHandle;
this.flipH = false;
this.flipV = false;
var _flip_h = false;
var _flip_v = false;
var _half_height = originalObject.extY*0.5;
var _half_width = originalObject.extX*0.5;
var _sin = Math.sin(0);
var _cos = Math.cos(0);
var _translated_num_handle;
if(!_flip_h && !_flip_v)
{
_translated_num_handle = numberHandle;
}
else if(_flip_h && !_flip_v)
{
_translated_num_handle = TRANSLATE_HANDLE_FLIP_H[numberHandle];
}
else if(!_flip_h && _flip_v)
{
_translated_num_handle = TRANSLATE_HANDLE_FLIP_V[numberHandle];
}
else
{
_translated_num_handle = TRANSLATE_HANDLE_FLIP_H_AND_FLIP_V[numberHandle];
}
this.bAspect = numberHandle % 2 === 0;
this.aspect = this.bAspect === true ? this.originalObject.getAspect(_translated_num_handle) : 0;
this.sin = _sin;
this.cos = _cos;
this.translatetNumberHandle = _translated_num_handle;
switch (_translated_num_handle)
{
case 0:
case 1:
{
this.fixedPointX = (_half_width*_cos - _half_height*_sin) + _half_width + originalObject.x;
this.fixedPointY = (_half_width*_sin + _half_height*_cos) + _half_height + originalObject.y;
break;
}
case 2:
case 3:
{
this.fixedPointX = (-_half_width*_cos - _half_height*_sin) + _half_width + originalObject.x;
this.fixedPointY = (-_half_width*_sin + _half_height*_cos) + _half_height + originalObject.y;
break;
}
case 4:
case 5:
{
this.fixedPointX = (-_half_width*_cos + _half_height*_sin) + _half_width + originalObject.x;
this.fixedPointY = (-_half_width*_sin - _half_height*_cos) + _half_height + originalObject.y;
break;
}
case 6:
case 7:
{
this.fixedPointX = (_half_width*_cos + _half_height*_sin) + _half_width + originalObject.x;
this.fixedPointY = (_half_width*_sin - _half_height*_cos) + _half_height + originalObject.y;
break;
}
}
this.mod = this.translatetNumberHandle % 4;
this.centerPointX = originalObject.x + _half_width;
this.centerPointY = originalObject.y + _half_height;
//this.lineFlag = originalObject.checkLine();
this.originalExtX = originalObject.extX;
this.originalExtY = originalObject.extY;
this.originalFlipH = _flip_h;
this.originalFlipV = _flip_v;
this.usedExtX = this.originalExtX === 0 ? (/*this.lineFlag ? this.originalExtX :*/ 0.01) : this.originalExtX;
this.usedExtY = this.originalExtY === 0 ? (/*this.lineFlag ? this.originalExtY :*/ 0.01) : this.originalExtY;
this.resizedExtX = this.originalExtX;
this.resizedExtY = this.originalExtY;
this.resizedflipH = _flip_h;
this.resizedflipV = _flip_v;
this.resizedPosX = originalObject.x;
this.resizedPosY = originalObject.y;
this.resizedRot = 0;
this.transform = originalObject.transform.CreateDublicate();
this.geometry = originalObject.spPr.geometry.createDuplicate();
this.brush = originalObject.brush;
this.pen = originalObject.pen;
this.geometry = CreateGeometry("rect");
this.geometry.Init(this.originalObject.extX, this.originalObject.extY);
this.geometry.Recalculate(this.originalObject.extX, this.originalObject.extY);
this.brush = new CUniFill();
this.brush.fill = new CSolidFill();
this.brush.fill.color = new CUniColor();
this.brush.fill.color.RGBA = {R:255, G:255, B:255, A:255};
this.brush.fill.color.color = new CRGBColor();
this.brush.fill.color.color.RGBA = {R:255, G:255, B:255, A:255};
this.pen = new CLn();
this.pen.Fill = new CUniFill();
this.pen.Fill.fill = new CSolidFill();
this.pen.Fill.fill.color = new CUniColor();
this.pen.Fill.fill.color.color = new CRGBColor();
this.bChangeCoef = this.translatetNumberHandle % 2 === 0 && this.originalFlipH !== this.originalFlipV;
this.overlayObject = new OverlayObject(this.geometry, this.resizedExtX, this.resizedExtY, this.brush, this.pen, this.transform);
this.track = function(kd1, kd2, e)
{
if(!e.ctrlKey)
this.resize(kd1, kd2, e.shiftKey);
else
this.resizeRelativeCenter(kd1, kd2, e.shiftKey)
};
this.resize = function(kd1, kd2, shiftKey)
{
var _cos = this.cos;
var _sin = this.sin;
var _real_height, _real_width;
var _abs_height, _abs_width;
var _new_resize_half_width;
var _new_resize_half_height;
var _new_used_half_width;
var _new_used_half_height;
var _temp;
if(shiftKey === true && this.bAspect === true)
{
var _new_aspect = this.aspect*(Math.abs(kd1/ kd2));
if (_new_aspect >= this.aspect)
kd2 = Math.abs(kd1)*(kd2 >= 0 ? 1 : -1 );
else
kd1 = Math.abs(kd2)*(kd1 >= 0 ? 1 : -1);
}
if(this.bChangeCoef)
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
switch (this.translatetNumberHandle)
{
case 0:
case 1:
{
if(this.translatetNumberHandle === 0)
{
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0)
this.resizedflipH = !this.originalFlipH;
else
this.resizedflipH = this.originalFlipH;
}
if(this.translatetNumberHandle === 1)
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0)
this.resizedflipV = !this.originalFlipV;
else
this.resizedflipV = this.originalFlipV;
_new_resize_half_width = this.resizedExtX*0.5;
_new_resize_half_height = this.resizedExtY*0.5;
if(this.resizedflipH !== this.originalFlipH)
{
_new_used_half_width = -_new_resize_half_width;
}
else
{
_new_used_half_width = _new_resize_half_width;
}
if(this.resizedflipV !== this.originalFlipV)
{
_new_used_half_height = -_new_resize_half_height;
}
else
{
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (-_new_used_half_width*_cos + _new_used_half_height*_sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (-_new_used_half_width*_sin - _new_used_half_height*_cos) - _new_resize_half_height;
break;
}
case 2:
case 3:
{
if(this.translatetNumberHandle === 2)
{
_temp = kd2;
kd2 = kd1;
kd1 = _temp;
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0)
this.resizedflipV = !this.originalFlipV;
else
this.resizedflipV = this.originalFlipV;
}
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0)
this.resizedflipH = !this.originalFlipH;
else
this.resizedflipH = this.originalFlipH;
_new_resize_half_width = this.resizedExtX*0.5;
_new_resize_half_height = this.resizedExtY*0.5;
if(this.resizedflipH !== this.originalFlipH)
{
_new_used_half_width = -_new_resize_half_width;
}
else
{
_new_used_half_width = _new_resize_half_width;
}
if(this.resizedflipV !== this.originalFlipV)
{
_new_used_half_height = -_new_resize_half_height;
}
else
{
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (_new_used_half_width*_cos + _new_used_half_height*_sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (_new_used_half_width*_sin - _new_used_half_height*_cos) - _new_resize_half_height;
break;
}
case 4:
case 5:
{
if(this.translatetNumberHandle === 4)
{
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0)
this.resizedflipH = !this.originalFlipH;
else
this.resizedflipH = this.originalFlipH;
}
else
{
_temp = kd2;
kd2 = kd1;
kd1 = _temp;
}
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0)
this.resizedflipV = !this.originalFlipV;
else
this.resizedflipV = this.originalFlipV;
_new_resize_half_width = this.resizedExtX*0.5;
_new_resize_half_height = this.resizedExtY*0.5;
if(this.resizedflipH !== this.originalFlipH)
{
_new_used_half_width = -_new_resize_half_width;
}
else
{
_new_used_half_width = _new_resize_half_width;
}
if(this.resizedflipV !== this.originalFlipV)
{
_new_used_half_height = -_new_resize_half_height;
}
else
{
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (_new_used_half_width*_cos - _new_used_half_height*_sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (_new_used_half_width*_sin + _new_used_half_height*_cos) - _new_resize_half_height;
break;
}
case 6:
case 7:
{
if(this.translatetNumberHandle === 6)
{
_real_height = this.usedExtY*kd1;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0)
this.resizedflipV = !this.originalFlipV;
else
this.resizedflipV = this.originalFlipV;
}
else
{
_temp = kd2;
kd2 = kd1;
kd1 = _temp;
}
_real_width = this.usedExtX*kd2;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0)
this.resizedflipH = !this.originalFlipH;
else
this.resizedflipH = this.originalFlipH;
_new_resize_half_width = this.resizedExtX*0.5;
_new_resize_half_height = this.resizedExtY*0.5;
if(this.resizedflipH !== this.originalFlipH)
{
_new_used_half_width = -_new_resize_half_width;
}
else
{
_new_used_half_width = _new_resize_half_width;
}
if(this.resizedflipV !== this.originalFlipV)
{
_new_used_half_height = -_new_resize_half_height;
}
else
{
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (-_new_used_half_width*_cos - _new_used_half_height*_sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (-_new_used_half_width*_sin + _new_used_half_height*_cos) - _new_resize_half_height;
break;
}
}
this.geometry.Recalculate(this.resizedExtX, this.resizedExtY);
this.overlayObject.updateExtents(this.resizedExtX, this.resizedExtY);
var _transform = this.transform;
_transform.Reset();
var _horizontal_center = this.resizedExtX*0.5;
var _vertical_center = this.resizedExtY*0.5;
global_MatrixTransformer.TranslateAppend(_transform, -_horizontal_center, -_vertical_center);
if(this.resizedflipH)
{
global_MatrixTransformer.ScaleAppend(_transform, -1, 1);
}
if(this.resizedflipV)
{
global_MatrixTransformer.ScaleAppend(_transform, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(_transform, -this.resizedRot);
global_MatrixTransformer.TranslateAppend(_transform, this.resizedPosX, this.resizedPosY);
global_MatrixTransformer.TranslateAppend(_transform, _horizontal_center, _vertical_center);
};
this.resizeRelativeCenter = function(kd1, kd2, shiftKey)
{
kd1 = 2*kd1 - 1;
kd2 = 2*kd2 - 1;
var _real_height, _real_width;
var _abs_height, _abs_width;
if(shiftKey === true && this.bAspect === true)
{
var _new_aspect = this.aspect*(Math.abs(kd1/ kd2));
if (_new_aspect >= this.aspect)
kd2 = Math.abs(kd1)*(kd2 >= 0 ? 1 : -1 );
else
kd1 = Math.abs(kd2)*(kd1 >= 0 ? 1 : -1);
}
var _temp;
if(this.bChangeCoef)
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
if(this.mod === 0 || this.mod === 1)
{
if(this.mod === 0)
{
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE ? _abs_width : MIN_SHAPE_SIZE;
this.resizedflipH = _real_width < 0 ? !this.originalFlipH : this.originalFlipH;
}
else
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE ? _abs_height : MIN_SHAPE_SIZE;
this.resizedflipV = _real_height < 0 ? !this.originalFlipV : this.originalFlipV;
}
else
{
if(this.mod === 2)
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE ? _abs_height : MIN_SHAPE_SIZE;
this.resizedflipV = _real_height < 0 ? !this.originalFlipV : this.originalFlipV;
}
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE ? _abs_width : MIN_SHAPE_SIZE;
this.resizedflipH = _real_width < 0 ? !this.originalFlipH : this.originalFlipH;
}
this.resizedPosX = this.centerPointX - this.resizedExtX*0.5;
this.resizedPosY = this.centerPointY - this.resizedExtY*0.5;
this.geometry.Recalculate(this.resizedExtX, this.resizedExtY);
this.overlayObject.updateExtents(this.resizedExtX, this.resizedExtY);
var _transform = this.transform;
_transform.Reset();
var _horizontal_center = this.resizedExtX*0.5;
var _vertical_center = this.resizedExtY*0.5;
global_MatrixTransformer.TranslateAppend(_transform, -_horizontal_center, -_vertical_center);
if(this.resizedflipH)
{
global_MatrixTransformer.ScaleAppend(_transform, -1, 1);
}
if(this.resizedflipV)
{
global_MatrixTransformer.ScaleAppend(_transform, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(_transform, -this.resizedRot);
global_MatrixTransformer.TranslateAppend(_transform, this.resizedPosX, this.resizedPosY);
global_MatrixTransformer.TranslateAppend(_transform, _horizontal_center, _vertical_center);
};
this.draw = function(overlay)
{
this.overlayObject.draw(overlay);
};
this.getBounds = function()
{
var bounds_checker = new CSlideBoundsChecker();
bounds_checker.init(Page_Width, Page_Height, Page_Width, Page_Height);
this.draw(bounds_checker);
return {l: bounds_checker.Bounds.min_x, t: bounds_checker.Bounds.min_y, r: bounds_checker.Bounds.max_x , b: bounds_checker.Bounds.max_y};
};
this.getBoundsRect = function()
{
var t = this.transform;
var max_x, min_x, max_y, min_y;
min_x = t.TransformPointX(0, 0);
max_x = min_x;
min_y = t.TransformPointY(0, 0);
max_y = min_y;
var arr = [{x: this.resizedExtX, y: 0}, {x: this.resizedExtX, y: this.resizedExtY}, {x: 0, y: this.resizedExtY}];
var t_x, t_y;
for(var i = 0; i < arr.length; ++i)
{
var p = arr[i];
t_x = t.TransformPointX(p.x, p.y);
t_y = t.TransformPointY(p.x, p.y);
if(t_x < min_x)
min_x = t_x;
if(t_x > max_x)
max_x = t_x;
if(t_y < min_y)
min_y = t_y;
if(t_y > max_y)
max_y = t_y;
}
return {l: min_x, t: min_y, r: max_x, b: max_y};
};
this.trackEnd = function()
{
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_RecalculateTransformUndo, null, null, new UndoRedoDataGraphicObjects(this.originalObject.Id, new UndoRedoDataShapeRecalc()), null);
this.originalObject.x = this.resizedPosX;
this.originalObject.y = this.resizedPosY;
this.originalObject.extX = this.resizedExtX;
this.originalObject.extY = this.resizedExtY;
this.originalObject.setPosition(this.resizedPosX, this.resizedPosY);
this.originalObject.setExtents(this.resizedExtX, this.resizedExtY);
this.originalObject.updateDrawingBaseCoordinates();
// this.originalObject.setFlips(this.resizedflipH, this.resizedflipV);
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_RecalculateTransformRedo, null, null, new UndoRedoDataGraphicObjects(this.originalObject.Id, new UndoRedoDataShapeRecalc()), null);
this.originalObject.recalculate();
/*this.originalObject.recalculateTransform();
this.originalObject.calculateContent();
this.originalObject.calculateTransformTextMatrix();
*/ var bounds_rect = this.originalObject.getRectBounds();
var check_position = this.originalObject.drawingObjects.checkGraphicObjectPosition(bounds_rect.minX, bounds_rect.minY, bounds_rect.maxX - bounds_rect.minX, bounds_rect.maxY - bounds_rect.minY);
if(!check_position.result)
{
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_RecalculateTransformUndo, null, null, new UndoRedoDataGraphicObjects(this.originalObject.Id, new UndoRedoDataShapeRecalc()), null);
this.originalObject.setPosition(this.resizedPosX + check_position.x, this.resizedPosY + check_position.y);
this.originalObject.x = this.resizedPosX+ check_position.x;
this.originalObject.y = this.resizedPosY+ check_position.y;
this.originalObject.updateDrawingBaseCoordinates();
this.originalObject.recalculate();
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_RecalculateTransformRedo, null, null, new UndoRedoDataGraphicObjects(this.originalObject.Id, new UndoRedoDataShapeRecalc()), null);
}
};
}
"use strict";
function OverlayObject(geometry, extX, extY, brush, pen, transform)
//({check_bounds: function(){},brush: this.originalShape.brush, pen: this.originalShape.pen, ext:{cx:this.originalShape.absExtX, cy:this.originalShape.absExtY}, geometry: this.geometry, TransformMatrix: this.originalShape.transform})
{
this.geometry = geometry;
this.ext = {};
this.ext.cx = extX;
this.ext.cy = extY;
this.brush = brush;
this.pen = pen;
this.TransformMatrix = transform;
this.shapeDrawer = new CShapeDrawer();
this.updateTransform = function(extX, extY, transform)
{
this.ext.cx = extX;
this.ext.cy = extY;
this.transform = transform;
};
this.updateExtents = function(extX, extY)
{
this.ext.cx = extX;
this.ext.cy = extY;
this.geometry.Recalculate(extX, extY);
};
this.updateTransformMatrix = function(transform)
{
this.TransformMatrix = transform;
};
this.draw = function(overlay)
{
overlay.SaveGrState();
overlay.SetIntegerGrid(false);
overlay.transform3(this.TransformMatrix, false);
this.shapeDrawer.fromShape2(this, overlay, this.geometry);
this.shapeDrawer.draw(this.geometry);
overlay.RestoreGrState();
};
this.check_bounds = function(boundsChecker)
{
if(this.geometry)
{
this.geometry.check_bounds(boundsChecker);
}
else
{
boundsChecker._s();
boundsChecker._m(0, 0);
boundsChecker._l(this.ext.cx, 0);
boundsChecker._l(this.ext.cx, this.ext.cy);
boundsChecker._l(0, this.ext.cy);
boundsChecker._z();
boundsChecker._e();
}
}
}
function RotateTrackShapeImage(originalObject)
{
this.originalObject = originalObject;
this.transform = originalObject.transform.CreateDublicate();
this.overlayObject = new OverlayObject(originalObject.spPr.geometry, originalObject.extX, originalObject.extY, originalObject.brush, originalObject.pen, this.transform);
this.angle = originalObject.rot;
this.draw = function(overlay)
{
this.overlayObject.draw(overlay);
};
this.track = function(angle, e)
{
var new_rot = angle + this.originalObject.rot;
while(new_rot < 0)
new_rot += 2*Math.PI;
while(new_rot >= 2*Math.PI)
new_rot -= 2*Math.PI;
if(new_rot < MIN_ANGLE || new_rot > 2*Math.PI - MIN_ANGLE)
new_rot = 0;
if(Math.abs(new_rot-Math.PI*0.5) < MIN_ANGLE)
new_rot = Math.PI*0.5;
if(Math.abs(new_rot-Math.PI) < MIN_ANGLE)
new_rot = Math.PI;
if(Math.abs(new_rot-1.5*Math.PI) < MIN_ANGLE)
new_rot = 1.5*Math.PI;
if(e.shiftKey)
new_rot = (Math.PI/12)*Math.floor(12*new_rot/(Math.PI));
this.angle = new_rot;
var hc, vc;
hc = this.originalObject.extX*0.5;
vc = this.originalObject.extY*0.5;
this.transform.Reset();
global_MatrixTransformer.TranslateAppend(this.transform, -hc, -vc);
if(this.originalObject.flipH)
global_MatrixTransformer.ScaleAppend(this.transform, -1, 1);
if(this.originalObject.flipV)
global_MatrixTransformer.ScaleAppend(this.transform, 1, -1);
global_MatrixTransformer.RotateRadAppend(this.transform, -this.angle);
global_MatrixTransformer.TranslateAppend(this.transform, this.originalObject.x + hc, this.originalObject.y + vc);
};
this.trackEnd = function()
{
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_RecalculateTransformUndo, null, null, new UndoRedoDataGraphicObjects(this.originalObject.Id, new UndoRedoDataShapeRecalc()), null);
this.originalObject.setRotate(this.angle);
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_RecalculateTransformRedo, null, null, new UndoRedoDataGraphicObjects(this.originalObject.Id, new UndoRedoDataShapeRecalc()), null);
this.originalObject.recalculateTransform();
this.originalObject.calculateContent();
this.originalObject.calculateTransformTextMatrix();
}
}
function RotateTrackShapeImageInGroup(originalObject)
{
this.originalObject = originalObject;
this.transform = originalObject.transform.CreateDublicate();
this.overlayObject = new OverlayObject(originalObject.spPr.geometry, originalObject.extX, originalObject.extY, originalObject.brush, originalObject.pen, this.transform);
this.angle = originalObject.rot;
var full_flip_h = this.originalObject.getFullFlipH();
var full_flip_v = this.originalObject.getFullFlipV();
this.signum = !full_flip_h && !full_flip_v || full_flip_h && full_flip_v ? 1 : -1;
this.draw = function(overlay)
{
this.overlayObject.draw(overlay);
};
this.track = function(angle, e)
{
var new_rot = this.signum*angle + this.originalObject.rot;
while(new_rot < 0)
new_rot += 2*Math.PI;
while(new_rot >= 2*Math.PI)
new_rot -= 2*Math.PI;
if(new_rot < MIN_ANGLE || new_rot > 2*Math.PI - MIN_ANGLE)
new_rot = 0;
if(Math.abs(new_rot-Math.PI*0.5) < MIN_ANGLE)
new_rot = Math.PI*0.5;
if(Math.abs(new_rot-Math.PI) < MIN_ANGLE)
new_rot = Math.PI;
if(Math.abs(new_rot-1.5*Math.PI) < MIN_ANGLE)
new_rot = 1.5*Math.PI;
if(e.shiftKey)
new_rot = (Math.PI/12)*Math.floor(12*new_rot/(Math.PI));
this.angle = new_rot;
var hc, vc;
hc = this.originalObject.extX*0.5;
vc = this.originalObject.extY*0.5;
this.transform.Reset();
global_MatrixTransformer.TranslateAppend(this.transform, -hc, -vc);
if(this.originalObject.flipH)
global_MatrixTransformer.ScaleAppend(this.transform, -1, 1);
if(this.originalObject.flipV)
global_MatrixTransformer.ScaleAppend(this.transform, 1, -1);
global_MatrixTransformer.RotateRadAppend(this.transform, -this.angle);
global_MatrixTransformer.TranslateAppend(this.transform, this.originalObject.x + hc, this.originalObject.y + vc);
global_MatrixTransformer.MultiplyAppend(this.transform, this.originalObject.group.getTransform());
};
this.trackEnd = function()
{
this.originalObject.setRotate(this.angle);
this.originalObject.recalculateTransform();
this.originalObject.calculateContent();
this.originalObject.calculateTransformTextMatrix();
}
}
function RotateTrackGroup(originalObject)
{
this.originalObject = originalObject;
this.transform = originalObject.transform.CreateDublicate();
this.overlayObjects = [];
this.arrTransforms = [];
this.arrTransforms2 = [];
var arr_graphic_objects = originalObject.getArrGraphicObjects();
var group_invert_transform = originalObject.getInvertTransform();
for(var i = 0; i < arr_graphic_objects.length; ++i)
{
var gr_obj_transform_copy = arr_graphic_objects[i].getTransform().CreateDublicate();
global_MatrixTransformer.MultiplyAppend(gr_obj_transform_copy, group_invert_transform);
this.arrTransforms2[i] = gr_obj_transform_copy;
this.overlayObjects[i] = new OverlayObject(arr_graphic_objects[i].spPr.geometry, arr_graphic_objects[i].extX, arr_graphic_objects[i].extY,
arr_graphic_objects[i].brush, arr_graphic_objects[i].pen, arr_graphic_objects[i].transform.CreateDublicate());
}
this.angle = originalObject.rot;
this.draw = function(overlay)
{
for(var i = 0; i < this.overlayObjects.length; ++i)
{
this.overlayObjects[i].draw(overlay);
}
};
this.track = function(angle, e)
{
var new_rot = angle + this.originalObject.rot;
while(new_rot < 0)
new_rot += 2*Math.PI;
while(new_rot >= 2*Math.PI)
new_rot -= 2*Math.PI;
if(new_rot < MIN_ANGLE || new_rot > 2*Math.PI - MIN_ANGLE)
new_rot = 0;
if(Math.abs(new_rot-Math.PI*0.5) < MIN_ANGLE)
new_rot = Math.PI*0.5;
if(Math.abs(new_rot-Math.PI) < MIN_ANGLE)
new_rot = Math.PI;
if(Math.abs(new_rot-1.5*Math.PI) < MIN_ANGLE)
new_rot = 1.5*Math.PI;
if(e.shiftKey)
new_rot = (Math.PI/12)*Math.floor(12*new_rot/(Math.PI));
this.angle = new_rot;
var hc, vc;
hc = this.originalObject.extX*0.5;
vc = this.originalObject.extY*0.5;
this.transform.Reset();
global_MatrixTransformer.TranslateAppend(this.transform, -hc, -vc);
if(this.originalObject.flipH)
global_MatrixTransformer.ScaleAppend(this.transform, -1, 1);
if(this.originalObject.flipV)
global_MatrixTransformer.ScaleAppend(this.transform, 1, -1);
global_MatrixTransformer.RotateRadAppend(this.transform, -this.angle);
global_MatrixTransformer.TranslateAppend(this.transform, this.originalObject.x + hc, this.originalObject.y + vc);
for(var i = 0; i < this.overlayObjects.length; ++i)
{
var new_transform = this.arrTransforms2[i].CreateDublicate();
global_MatrixTransformer.MultiplyAppend(new_transform, this.transform);
this.overlayObjects[i].updateTransformMatrix(new_transform);
}
};
this.trackEnd = function()
{
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_GroupRecalculateUndo, null, null,
new UndoRedoDataGraphicObjects(this.originalObject.Get_Id(), new UndoRedoDataGOSingleProp(null, null)));
this.originalObject.setRotate(this.angle);
this.originalObject.recalculate();
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_GroupRecalculateRedo, null, null,
new UndoRedoDataGraphicObjects(this.originalObject.Get_Id(), new UndoRedoDataGOSingleProp(null, null)));
}
}
\ No newline at end of file
"use strict";
var K=1/4;
var mt=0, lt=1, cb=2, cl=3;
function SplineCommandMoveTo(x, y)
{
this.id = 0;
this.x = x;
this.y = y;
}
function SplineCommandLineTo(x, y)
{
this.id = 1;
this.x = x;
this.y = y;
this.changeLastPoint = function(x, y)
{
this.x = x;
this.y = y;
}
}
function SplineCommandBezier(x1, y1, x2, y2, x3, y3)
{
this.id = 2;
this.x1 = x1;
this.y1 = y1;
this.x2 = x2;
this.y2 = y2;
this.x3 = x3;
this.y3 = y3;
this.changeLastPoint = function(x, y)
{
this.x3 = x;
this.y3 = y;
this.x2 = this.x1 + (this.x3 - this.x1)*0.5;
this.y2 = this.y1 + (this.y3 - this.y1)*0.5;
}
}
function Spline(drawingObjects)
{
this.path = [];
this.drawingObjects = drawingObjects;
this.Matrix = new CMatrix();
this.TransformMatrix = new CMatrix();
this.style = CreateDefaultShapeStyle();
var _calculated_line;
var _theme = drawingObjects.getWorkbook().theme;
var colorMap = GenerateDefaultColorMap().color_map;
var RGBA = {R: 0, G: 0, B: 0, A: 255};
if(isRealObject(_theme) && typeof _theme.getLnStyle === "function"
&& isRealObject(this.style) && isRealObject(this.style.lnRef) && isRealNumber(this.style.lnRef.idx)
&& isRealObject(this.style.lnRef.Color) && typeof this.style.lnRef.Color.Calculate === "function")
{
_calculated_line = _theme.getLnStyle(this.style.lnRef.idx);
this.style.lnRef.Color.Calculate(_theme, colorMap, {R: 0 , G: 0, B: 0, A: 255});
RGBA = this.style.lnRef.Color.RGBA;
}
else
{
_calculated_line = new CLn();
}
if(isRealObject(_calculated_line.Fill))
{
_calculated_line.Fill.calculate(_theme, colorMap, RGBA) ;
}
this.pen = _calculated_line;
this.splineForDraw = new SplineForDrawer(this);
this.Draw = function(graphics)
{
graphics.SetIntegerGrid(false);
graphics.transform3(this.Matrix);
var shape_drawer = new CShapeDrawer();
shape_drawer.fromShape(this, graphics);
shape_drawer.draw(this);
};
this.draw = function(g)
{
this.splineForDraw.Draw(g);
return;
for(var i = 0; i < this.path.length; ++i)
{
var lastX, lastY;
switch (this.path[i].id )
{
case 0 :
{
g._m(this.path[i].x, this.path[i].y);
lastX = this.path[i].x;
lastY = this.path[i].y;
break;
}
case 1 :
{
g._l(this.path[i].x, this.path[i].y);
lastX = this.path[i].x;
lastY = this.path[i].y;
break;
}
case 2 :
{
g._c(this.path[i].x1, this.path[i].y1, this.path[i].x2, this.path[i].y2, this.path[i].x3, this.path[i].y3);
lastX = this.path[i].x3;
lastY = this.path[i].y3;
break;
}
}
}
g.ds();
};
this.getLeftTopPoint = function()
{
if(this.path.length < 1)
return {x: 0, y: 0};
var min_x = this.path[0].x;
var max_x = min_x;
var min_y = this.path[0].y;
var max_y = min_y;
var last_x = this.path[0].x, last_y = this.path[0].y;
for(var index = 1; index < this.path.length; ++index)
{
var path_command = this.path[index];
if(path_command.id === 1)
{
if(min_x > path_command.x)
min_x = path_command.x;
if(max_x < path_command.x)
max_x = path_command.x;
if(min_y > path_command.y)
min_y = path_command.y;
if(max_y < path_command.y)
max_y = path_command.y;
}
else
{
var bezier_polygon = partition_bezier4(last_x, last_y, path_command.x1, path_command.y1, path_command.x2, path_command.y2, path_command.x3, path_command.y3, APPROXIMATE_EPSILON);
for(var point_index = 1; point_index < bezier_polygon.length; ++point_index)
{
var cur_point = bezier_polygon[point_index];
if(min_x > cur_point.x)
min_x = cur_point.x;
if(max_x < cur_point.x)
max_x = cur_point.x;
if(min_y > cur_point.y)
min_y = cur_point.y;
if(max_y < cur_point.y)
max_y = cur_point.y;
}
}
}
return {x: min_x, y: min_y};
};
this.createShape = function(drawingObjects)
{
var xMax = this.path[0].x, yMax = this.path[0].y, xMin = xMax, yMin = yMax;
var i;
var bClosed = false;
if(this.path.length > 2)
{
var dx = this.path[0].x - this.path[this.path.length-1].x3;
var dy = this.path[0].y - this.path[this.path.length-1].y3;
if(Math.sqrt(dx*dx +dy*dy) < 3)
{
bClosed = true;
this.path[this.path.length-1].x3 = this.path[0].x;
this.path[this.path.length-1].y3 = this.path[0].y;
if(this.path.length > 3)
{
var vx = (this.path[1].x3 - this.path[this.path.length-2].x3)/6;
var vy = (this.path[1].y3 - this.path[this.path.length-2].y3)/6;
}
else
{
vx = -(this.path[1].y3 - this.path[0].y)/6;
vy = (this.path[1].x3 - this.path[0].x)/6;
}
this.path[1].x1 = this.path[0].x +vx;
this.path[1].y1 = this.path[0].y +vy;
this.path[this.path.length-1].x2 = this.path[0].x -vx;
this.path[this.path.length-1].y2 = this.path[0].y -vy;
}
}
var min_x = this.path[0].x;
var max_x = min_x;
var min_y = this.path[0].y;
var max_y = min_y;
var last_x = this.path[0].x, last_y = this.path[0].y;
for(var index = 1; index < this.path.length; ++index)
{
var path_command = this.path[index];
if(path_command.id === 1)
{
if(min_x > path_command.x)
min_x = path_command.x;
if(max_x < path_command.x)
max_x = path_command.x;
if(min_y > path_command.y)
min_y = path_command.y;
if(max_y < path_command.y)
max_y = path_command.y;
last_x = path_command.x;
last_y = path_command.y;
}
else
{
var bezier_polygon = partition_bezier4(last_x, last_y, path_command.x1, path_command.y1, path_command.x2, path_command.y2, path_command.x3, path_command.y3, APPROXIMATE_EPSILON);
for(var point_index = 1; point_index < bezier_polygon.length; ++point_index)
{
var cur_point = bezier_polygon[point_index];
if(min_x > cur_point.x)
min_x = cur_point.x;
if(max_x < cur_point.x)
max_x = cur_point.x;
if(min_y > cur_point.y)
min_y = cur_point.y;
if(max_y < cur_point.y)
max_y = cur_point.y;
last_x = path_command.x3;
last_y = path_command.y3;
}
}
}
xMin = min_x;
xMax = max_x;
yMin = min_y;
yMax = max_y;
var shape = new CShape(null, this.drawingObjects);
shape.setXfrmObject(new CXfrm());
shape.setPosition(xMin, yMin);
shape.setExtents(xMax-xMin, yMax-yMin);
shape.setStyleBinary(CreateDefaultShapeStyle());
var geometry = new CGeometry();
geometry.AddPathCommand(0, undefined, bClosed ? "norm": "none", undefined, xMax - xMin, yMax-yMin);
geometry.AddRect("l", "t", "r", "b");
for(i = 0; i< this.path.length; ++i)
{
switch (this.path[i].id)
{
case 0 :
{
geometry.AddPathCommand(1, (this.path[i].x - xMin) + "", (this.path[i].y - yMin) + "");
break;
}
case 1 :
{
geometry.AddPathCommand(2, (this.path[i].x - xMin) + "", (this.path[i].y - yMin) + "");
break;
}
case 2:
{
geometry.AddPathCommand(5, (this.path[i].x1 - xMin) + "", (this.path[i].y1 - yMin) + "", (this.path[i].x2 - xMin) + "", (this.path[i].y2 - yMin) + "", (this.path[i].x3 - xMin) + "", (this.path[i].y3 - yMin) + "");
break;
}
}
}
if(bClosed)
{
geometry.AddPathCommand(6);
}
geometry.Init( xMax-xMin, yMax-yMin);
shape.setGeometry(geometry);
shape.recalculate();
shape.addToDrawingObjects();
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_RecalculateAfterInit, null, null,
new UndoRedoDataGraphicObjects(shape.Get_Id(), new UndoRedoDataGOSingleProp(null, null)));
return shape;
};
this.addPathCommand = function(pathCommand)
{
this.path.push(pathCommand);
}
}
function SplineForDrawer(spline)
{
this.spline = spline;
this.pen = spline.pen;
this.brush = spline.brush;
this.TransformMatrix = spline.TransformMatrix;
this.Matrix = spline.Matrix;
this.Draw = function(graphics)
{
graphics.SetIntegerGrid(false);
graphics.transform3(this.Matrix);
var shape_drawer = new CShapeDrawer();
shape_drawer.fromShape(this, graphics);
shape_drawer.draw(this);
};
this.draw = function(g)
{
g._e();
for(var i = 0; i < this.spline.path.length; ++i)
{
var lastX, lastY;
switch (this.spline.path[i].id )
{
case 0 :
{
g._m(this.spline.path[i].x, this.spline.path[i].y);
lastX = this.spline.path[i].x;
lastY = this.spline.path[i].y;
break;
}
case 1 :
{
g._l(this.spline.path[i].x, this.spline.path[i].y);
lastX = this.spline.path[i].x;
lastY = this.spline.path[i].y;
break;
}
case 2 :
{
g._c(this.spline.path[i].x1, this.spline.path[i].y1, this.spline.path[i].x2, this.spline.path[i].y2, this.spline.path[i].x3, this.spline.path[i].y3);
lastX = this.spline.path[i].x3;
lastY = this.spline.path[i].y3;
break;
}
}
}
g.ds();
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment