├── LICENSE
├── README.md
├── example.html
├── lib
├── d3.js
└── jquery-2.1.3.js
├── reports
├── OrdersWithDrillthrough.rdlc
├── OrdersWithSubreport.rdlc
└── ReportWithCustomAssembly.rdlc
└── src
├── rdljs.core.js
├── rdljs.js
├── rdljs.plugin.abstract.js
├── rdljs.plugin.html.css
├── rdljs.plugin.html.js
├── rdljs.plugin.svg.js
└── rdljs.util.js
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 andreventuravale
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # rdljs - ( deprecated due to lack of tests )
2 |
3 | TODO:
4 |
5 | - [ ] rewrite with TDD;
6 | - [ ] find good report samples for integrated tests;
7 |
8 | ---
9 |
10 | A lightweight javascript library for Microsoft RDL/RDLC reporting rendering
11 |
12 | ---
13 |
14 | This is a work in progress project, waiting for contributors...
15 |
16 | I didn't have much time to set the things up for testing, so to see a demo just point your webserver to the top level folder and access the "example.html" file...
17 |
18 | Currently I'm using this chrome extension as a nice and practical way to serve the content: https://github.com/kzahel/web-server-chrome
19 |
--------------------------------------------------------------------------------
/example.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | ReportWithCustomAssembly
25 | OrdersWithDrillthrough
26 | OrdersWithSubreport
27 |
28 |
29 |
30 |
31 |
32 | Load
33 |
34 |
94 |
95 |
96 |
--------------------------------------------------------------------------------
/reports/OrdersWithDrillthrough.rdlc:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | SQL
7 |
8 |
9 | c78adb91-67d9-4585-9468-62c614ea5707
10 |
11 |
12 |
13 |
14 |
15 |
16 | OrderID
17 | System.Int32
18 |
19 |
20 | OrderDate
21 | System.DateTime
22 |
23 |
24 | RequiredDate
25 | System.DateTime
26 |
27 |
28 | ShippedDate
29 | System.DateTime
30 |
31 |
32 | ShipVia
33 | System.Int32
34 |
35 |
36 | Freight
37 | System.Decimal
38 |
39 |
40 | ShipName
41 | System.String
42 |
43 |
44 | ShipAddress
45 | System.String
46 |
47 |
48 | ShipCity
49 | System.String
50 |
51 |
52 | ShipRegion
53 | System.String
54 |
55 |
56 | ShipPostalCode
57 | System.String
58 |
59 |
60 | ShipCountry
61 | System.String
62 |
63 |
64 | CompanyName
65 | System.String
66 |
67 |
68 | ContactName
69 | System.String
70 |
71 |
72 | ContactTitle
73 | System.String
74 |
75 |
76 | Address
77 | System.String
78 |
79 |
80 | City
81 | System.String
82 |
83 |
84 | Region
85 | System.String
86 |
87 |
88 | PostalCode
89 | System.String
90 |
91 |
92 | Country
93 | System.String
94 |
95 |
96 | Phone
97 | System.String
98 |
99 |
100 | Fax
101 | System.String
102 |
103 |
104 |
105 | DummyDataSource
106 | /* Local Query */
107 | true
108 |
109 |
110 | DataSet1
111 | C:\Users\cephalin\Desktop\ReportViewerWebSamples\SupplyingData\OrderData.xsd
112 | Orders
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 | 6.125in
123 |
124 |
125 |
126 |
127 | 4.5in
128 |
129 |
130 |
131 |
132 |
133 |
134 | true
135 | true
136 |
137 |
138 |
139 |
140 | Invoice
141 |
145 |
146 |
147 |
148 |
149 |
150 | textbox1
151 | 0.31746cm
152 | 6.66667cm
153 | 0.95238cm
154 | 3.1746cm
155 |
161 |
162 |
163 | true
164 | true
165 |
166 |
167 |
168 |
169 | =Fields!OrderID.Value
170 |
171 |
172 |
173 |
176 |
177 |
178 | OrderID
179 | 1.5873cm
180 | 2.53968cm
181 | 0.63492cm
182 | 3.80953cm
183 | 1
184 |
190 |
191 |
192 | true
193 | true
194 |
195 |
196 |
197 |
198 | Order ID:
199 |
200 |
201 |
202 |
203 |
204 |
205 | textbox2
206 | 1.5873cm
207 | 0.31746cm
208 | 0.63492cm
209 | 1.90476cm
210 | 2
211 |
217 |
218 |
219 | true
220 | true
221 |
222 |
223 |
224 |
225 | Order Date:
226 |
227 |
228 |
229 |
230 |
231 |
232 | textbox3
233 | 0.625in
234 | 3.125in
235 | 0.25in
236 | 0.875in
237 | 3
238 |
244 |
245 |
246 | true
247 | true
248 |
249 |
250 |
251 |
252 | =Fields!OrderDate.Value
253 |
256 |
257 |
258 |
261 |
262 |
263 | OrderDate
264 | 0.625in
265 | 4in
266 | 0.25in
267 | 1.75in
268 | 4
269 |
275 |
276 |
277 |
278 |
279 | true
280 | true
281 |
282 |
283 |
284 |
285 | Bill To:
286 |
289 |
290 |
291 |
292 |
293 |
294 | textbox4
295 | 0.125in
296 | 0.125in
297 | 0.25in
298 | 0.625in
299 |
305 |
306 |
307 | true
308 | true
309 |
310 |
311 |
312 |
313 | =Fields!ContactName.Value
314 |
315 |
316 |
317 |
318 |
319 |
320 | ContactName
321 | 0.125in
322 | 0.875in
323 | 0.25in
324 | 1.875in
325 | 1
326 |
332 |
333 |
334 | true
335 | true
336 |
337 |
338 |
339 |
340 | =Fields!ContactTitle.Value
341 |
342 |
343 |
344 |
345 |
346 |
347 | 0.375in
348 | 0.875in
349 | 0.25in
350 | 1.875in
351 | 2
352 |
358 |
359 |
360 | true
361 | true
362 |
363 |
364 |
365 |
366 | =Fields!CompanyName.Value
367 |
368 |
369 |
370 |
371 |
372 |
373 | 0.625in
374 | 0.875in
375 | 0.25in
376 | 1.875in
377 | 3
378 |
384 |
385 |
386 | true
387 | true
388 |
389 |
390 |
391 |
392 | =Fields!Address.Value
393 |
394 |
395 |
396 |
397 |
398 |
399 | 0.875in
400 | 0.875in
401 | 0.25in
402 | 1.875in
403 | 4
404 |
410 |
411 |
412 | true
413 | true
414 |
415 |
416 |
417 |
418 | =Fields!City.Value
419 |
420 |
421 |
422 |
423 |
424 |
425 | 1.125in
426 | 0.875in
427 | 0.25in
428 | 1.875in
429 | 5
430 |
436 |
437 |
438 | true
439 | true
440 |
441 |
442 |
443 |
444 | =Fields!Country.Value
445 |
446 |
447 |
448 |
449 |
450 |
451 | 1.375in
452 | 0.875in
453 | 0.25in
454 | 1.875in
455 | 6
456 |
462 |
463 |
464 | ContentsOnly
465 | 1in
466 | 0.125in
467 | 1.75in
468 | 2.875in
469 | 5
470 |
473 |
474 |
475 |
476 |
477 |
478 |
479 | true
480 | true
481 |
482 |
483 |
484 |
485 | Ship To:
486 |
489 |
490 |
491 |
492 |
493 |
494 | 0.125in
495 | 0.125in
496 | 0.25in
497 | 0.625in
498 |
504 |
505 |
506 | true
507 | true
508 |
509 |
510 |
511 |
512 | =Fields!ShipName.Value
513 |
514 |
515 |
516 |
517 |
518 |
519 | 0.125in
520 | 0.875in
521 | 0.25in
522 | 1.875in
523 | 1
524 |
530 |
531 |
532 | true
533 | true
534 |
535 |
536 |
537 |
538 | =Fields!ShipAddress.Value
539 |
540 |
541 |
542 |
543 |
544 |
545 | 0.375in
546 | 0.875in
547 | 0.25in
548 | 1.875in
549 | 2
550 |
556 |
557 |
558 | true
559 | true
560 |
561 |
562 |
563 |
564 | =Fields!ShipCity.Value
565 |
566 |
567 |
568 |
569 |
570 |
571 | 0.625in
572 | 0.875in
573 | 0.25in
574 | 1.875in
575 | 3
576 |
582 |
583 |
584 | true
585 | true
586 |
587 |
588 |
589 |
590 | =Fields!ShipCountry.Value
591 |
592 |
593 |
594 |
595 |
596 |
597 | 0.875in
598 | 0.875in
599 | 0.25in
600 | 1.875in
601 | 4
602 |
608 |
609 |
610 | ContentsOnly
611 | 1in
612 | 3.125in
613 | 1.75in
614 | 2.875in
615 | 6
616 |
619 |
620 |
621 |
622 |
623 | true
624 | true
625 |
626 |
627 |
628 |
629 | See order details
630 |
631 |
632 |
633 |
634 | OrderDetails
635 |
636 |
637 | =Fields!OrderID.Value
638 |
639 |
640 |
641 |
642 |
643 |
644 |
649 |
650 |
651 |
652 |
653 |
654 | Textbox5
655 | 2.81944in
656 | 0.125in
657 | 0.30208in
658 | 2.08667in
659 | 7
660 |
663 |
664 | 2pt
665 | 2pt
666 | 2pt
667 | 2pt
668 |
669 |
670 |
671 | true
672 |
673 |
674 |
675 |
676 |
677 |
678 |
679 |
680 |
681 |
682 |
683 |
684 |
685 |
686 |
687 |
688 |
689 |
690 | =Fields!OrderID.Value
691 |
692 |
693 | Between
694 |
695 |
696 | Output
697 | true
698 |
699 |
700 |
701 | DataSet1_Orders
702 |
703 | End
704 |
705 | 4.5in
706 | 6.125in
707 |
708 |
709 |
710 | 4.5in
711 |
712 |
713 | 6.25in
714 |
715 | 1in
716 | 1in
717 | 1in
718 | 1in
719 |
720 |
721 | en-US
722 | true
723 | 985ccb24-b139-4b4d-92b5-c472b8ad689e
724 | Inch
725 |
--------------------------------------------------------------------------------
/reports/OrdersWithSubreport.rdlc:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | SQL
7 |
8 |
9 | c78adb91-67d9-4585-9468-62c614ea5707
10 |
11 |
12 |
13 |
14 |
15 |
16 | OrderID
17 | System.Int32
18 |
19 |
20 | OrderDate
21 | System.DateTime
22 |
23 |
24 | RequiredDate
25 | System.DateTime
26 |
27 |
28 | ShippedDate
29 | System.DateTime
30 |
31 |
32 | ShipVia
33 | System.Int32
34 |
35 |
36 | Freight
37 | System.Decimal
38 |
39 |
40 | ShipName
41 | System.String
42 |
43 |
44 | ShipAddress
45 | System.String
46 |
47 |
48 | ShipCity
49 | System.String
50 |
51 |
52 | ShipRegion
53 | System.String
54 |
55 |
56 | ShipPostalCode
57 | System.String
58 |
59 |
60 | ShipCountry
61 | System.String
62 |
63 |
64 | CompanyName
65 | System.String
66 |
67 |
68 | ContactName
69 | System.String
70 |
71 |
72 | ContactTitle
73 | System.String
74 |
75 |
76 | Address
77 | System.String
78 |
79 |
80 | City
81 | System.String
82 |
83 |
84 | Region
85 | System.String
86 |
87 |
88 | PostalCode
89 | System.String
90 |
91 |
92 | Country
93 | System.String
94 |
95 |
96 | Phone
97 | System.String
98 |
99 |
100 | Fax
101 | System.String
102 |
103 |
104 |
105 | DummyDataSource
106 | /* Local Query */
107 | true
108 |
109 |
110 | DataSet1
111 | C:\Users\cephalin\Desktop\ReportViewerWebSamples\SupplyingData\OrderData.xsd
112 | Orders
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 | 6.125in
123 |
124 |
125 |
126 |
127 | 4.5in
128 |
129 |
130 |
131 |
132 |
133 |
134 | true
135 | true
136 |
137 |
138 |
139 |
140 | Invoice
141 |
145 |
146 |
147 |
148 |
149 |
150 | textbox1
151 | 0.31746cm
152 | 6.66667cm
153 | 0.95238cm
154 | 3.1746cm
155 |
161 |
162 |
163 | true
164 | true
165 |
166 |
167 |
168 |
169 | =Fields!OrderID.Value
170 |
171 |
172 |
173 |
176 |
177 |
178 | OrderID
179 | 1.5873cm
180 | 2.53968cm
181 | 0.63492cm
182 | 3.80953cm
183 | 1
184 |
190 |
191 |
192 | true
193 | true
194 |
195 |
196 |
197 |
198 | Order ID:
199 |
200 |
201 |
202 |
203 |
204 |
205 | textbox2
206 | 1.5873cm
207 | 0.31746cm
208 | 0.63492cm
209 | 1.90476cm
210 | 2
211 |
217 |
218 |
219 | OrderDetails
220 |
221 |
222 | =Fields!OrderID.Value
223 |
224 |
225 | true
226 | 2.875in
227 | 0.125in
228 | 1.5in
229 | 5.875in
230 | 3
231 |
232 |
233 |
234 | true
235 | true
236 |
237 |
238 |
239 |
240 | Order Date:
241 |
242 |
243 |
244 |
245 |
246 |
247 | textbox3
248 | 0.625in
249 | 3.125in
250 | 0.25in
251 | 0.875in
252 | 4
253 |
259 |
260 |
261 | true
262 | true
263 |
264 |
265 |
266 |
267 | =Fields!OrderDate.Value
268 |
271 |
272 |
273 |
276 |
277 |
278 | OrderDate
279 | 0.625in
280 | 4in
281 | 0.25in
282 | 1.75in
283 | 5
284 |
290 |
291 |
292 |
293 |
294 | true
295 | true
296 |
297 |
298 |
299 |
300 | Bill To:
301 |
304 |
305 |
306 |
307 |
308 |
309 | textbox4
310 | 0.125in
311 | 0.125in
312 | 0.25in
313 | 0.625in
314 |
320 |
321 |
322 | true
323 | true
324 |
325 |
326 |
327 |
328 | =Fields!ContactName.Value
329 |
330 |
331 |
332 |
333 |
334 |
335 | ContactName
336 | 0.125in
337 | 0.875in
338 | 0.25in
339 | 1.875in
340 | 1
341 |
347 |
348 |
349 | true
350 | true
351 |
352 |
353 |
354 |
355 | =Fields!ContactTitle.Value
356 |
357 |
358 |
359 |
360 |
361 |
362 | 0.375in
363 | 0.875in
364 | 0.25in
365 | 1.875in
366 | 2
367 |
373 |
374 |
375 | true
376 | true
377 |
378 |
379 |
380 |
381 | =Fields!CompanyName.Value
382 |
383 |
384 |
385 |
386 |
387 |
388 | 0.625in
389 | 0.875in
390 | 0.25in
391 | 1.875in
392 | 3
393 |
399 |
400 |
401 | true
402 | true
403 |
404 |
405 |
406 |
407 | =Fields!Address.Value
408 |
409 |
410 |
411 |
412 |
413 |
414 | 0.875in
415 | 0.875in
416 | 0.25in
417 | 1.875in
418 | 4
419 |
425 |
426 |
427 | true
428 | true
429 |
430 |
431 |
432 |
433 | =Fields!City.Value
434 |
435 |
436 |
437 |
438 |
439 |
440 | 1.125in
441 | 0.875in
442 | 0.25in
443 | 1.875in
444 | 5
445 |
451 |
452 |
453 | true
454 | true
455 |
456 |
457 |
458 |
459 | =Fields!Country.Value
460 |
461 |
462 |
463 |
464 |
465 |
466 | 1.375in
467 | 0.875in
468 | 0.25in
469 | 1.875in
470 | 6
471 |
477 |
478 |
479 | ContentsOnly
480 | 1in
481 | 0.125in
482 | 1.75in
483 | 2.875in
484 | 6
485 |
488 |
489 |
490 |
491 |
492 |
493 |
494 | true
495 | true
496 |
497 |
498 |
499 |
500 | Ship To:
501 |
504 |
505 |
506 |
507 |
508 |
509 | 0.125in
510 | 0.125in
511 | 0.25in
512 | 0.625in
513 |
519 |
520 |
521 | true
522 | true
523 |
524 |
525 |
526 |
527 | =Fields!ShipName.Value
528 |
529 |
530 |
531 |
532 |
533 |
534 | 0.125in
535 | 0.875in
536 | 0.25in
537 | 1.875in
538 | 1
539 |
545 |
546 |
547 | true
548 | true
549 |
550 |
551 |
552 |
553 | =Fields!ShipAddress.Value
554 |
555 |
556 |
557 |
558 |
559 |
560 | 0.375in
561 | 0.875in
562 | 0.25in
563 | 1.875in
564 | 2
565 |
571 |
572 |
573 | true
574 | true
575 |
576 |
577 |
578 |
579 | =Fields!ShipCity.Value
580 |
581 |
582 |
583 |
584 |
585 |
586 | 0.625in
587 | 0.875in
588 | 0.25in
589 | 1.875in
590 | 3
591 |
597 |
598 |
599 | true
600 | true
601 |
602 |
603 |
604 |
605 | =Fields!ShipCountry.Value
606 |
607 |
608 |
609 |
610 |
611 |
612 | 0.875in
613 | 0.875in
614 | 0.25in
615 | 1.875in
616 | 4
617 |
623 |
624 |
625 | ContentsOnly
626 | 1in
627 | 3.125in
628 | 1.75in
629 | 2.875in
630 | 7
631 |
634 |
635 |
636 |
637 |
638 | true
639 |
640 |
641 |
642 |
643 |
644 |
645 |
646 |
647 |
648 |
649 |
650 |
651 |
652 |
653 |
654 |
655 |
656 |
657 | =Fields!OrderID.Value
658 |
659 |
660 | Between
661 |
662 |
663 | Output
664 | true
665 |
666 |
667 |
668 | DataSet1_Orders
669 |
670 | End
671 |
672 | 4.5in
673 | 6.125in
674 |
675 |
676 |
677 | 4.5in
678 |
679 |
680 | 6.25in
681 |
682 | 1in
683 | 1in
684 | 1in
685 | 1in
686 |
687 |
688 | en-US
689 | true
690 | 985ccb24-b139-4b4d-92b5-c472b8ad689e
691 | Inch
692 |
--------------------------------------------------------------------------------
/reports/ReportWithCustomAssembly.rdlc:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | true
7 | true
8 |
9 |
10 |
11 |
12 | =MyLibrary.ExternalContent.GetFileContent(Parameters!FilePath.Value)
13 |
14 |
15 |
16 |
19 |
20 |
21 | Textbox1
22 | 0.62583in
23 | 0.205in
24 | 0.25in
25 | 3.90625in
26 |
30 | 2pt
31 |
32 | 2pt
33 | 2pt
34 | 2pt
35 | 2pt
36 |
37 |
38 |
39 | true
40 | true
41 |
42 |
43 |
44 |
45 | =MyLibrary.ExternalContent.GetPage(New Uri(Parameters!PageUrl.Value))
46 | HTML
47 |
48 |
49 |
50 |
51 |
52 |
53 | Textbox4
54 | 1.46958in
55 | 0.205in
56 | 0.25in
57 | 3.90625in
58 | 1
59 |
63 | 2pt
64 |
65 | 2pt
66 | 2pt
67 | 2pt
68 | 2pt
69 |
70 |
71 |
72 | true
73 | true
74 |
75 |
76 |
77 |
78 | File content
79 |
84 |
85 |
86 |
87 |
88 |
89 | Textbox5
90 | 0.34389in
91 | 0.205in
92 | 0.25in
93 | 1.38542in
94 | 2
95 |
98 |
99 | 2pt
100 | 2pt
101 | 2pt
102 | 2pt
103 |
104 |
105 |
106 | true
107 | true
108 |
109 |
110 |
111 |
112 | Parsed Web page text
113 |
118 |
119 |
120 |
121 |
122 |
123 | Textbox5
124 | 1.18764in
125 | 0.205in
126 | 0.25in
127 | 1.93751in
128 | 3
129 |
132 |
133 | 2pt
134 | 2pt
135 | 2pt
136 | 2pt
137 |
138 |
139 |
140 | 2.0625in
141 |
142 |
143 |
144 |
145 | String
146 | ReportParameter1
147 |
148 |
149 | String
150 | ReportParameter1
151 |
152 |
153 | 6.5in
154 |
155 | 1in
156 | 1in
157 | 1in
158 | 1in
159 |
160 |
161 |
162 | MyLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=8c2c2092eea1f1ab
163 | System.Net, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
164 |
165 | 88f6a36b-bd4a-4123-86e1-c917157a7486
166 | Inch
167 |
--------------------------------------------------------------------------------
/src/rdljs.core.js:
--------------------------------------------------------------------------------
1 | // (function () {
2 |
3 | Function.prototype.extend = function (extension) {
4 | if (typeof extension !== 'object') throw 'invalid argument: extension';
5 | var base = this.prototype;
6 | extension["super"] = base;
7 | for (var property in base) {
8 | extension[property] = extension[property] || base[property];
9 | }
10 | return extension;
11 | };
12 |
13 | Function.prototype.delegateTo = function (context) {
14 | var fn = this;
15 | return function () {
16 | return fn.apply(context, arguments);
17 | };
18 | };
19 |
20 | Function.prototype.invokeLater = function () {
21 | var ctx = Function.prototype.invokeLater;
22 | ctx.count = ctx.count || 1;
23 | setTimeout(this, ctx.count * 10);
24 | ctx.count++;
25 | };
26 |
27 | rdl = {
28 |
29 | isPromise: function (object) {
30 | return typeof object.done === 'function'
31 | && typeof object.fail === 'function'
32 | && typeof object.always === 'function';
33 | },
34 |
35 | randomId: function () {
36 | return "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx".replace(/x/g, function () {
37 | return Math.random().toString(16).slice(2, 3);
38 | });
39 | },
40 |
41 | parseXml: function (xml) {
42 |
43 | if (typeof xml !== 'string') throw 'invalid argument: xml';
44 |
45 | xml = xml
46 | // fix empty tags
47 | .replace(/<([^>\s]+)([^>]*)\/>/gm, "<$1$2>$1>")
48 | // turn the XML tag to comment
49 | .replace(/<\?/gm, '')
50 | // make the RDL namespace explicit, in order to prevent conflicts with HTML
51 | .replace(/]*)xmlns="([^"]+)"([^>]*)>/m, '')
52 | // point the elements to RDL explicit namespace
53 | .replace(/<\/([^\:>]+)>/gm, '')
54 | .replace(/<([^!\?])([^\:>]*)(\s|>)/gm, '")
57 | .css("display", "none")
58 | .appendTo("body")
59 | .contents();
60 |
61 | doc.get(0).write(xml);
62 |
63 | return doc.find("rdl\\:Report");
64 | },
65 |
66 | rendererFor: function (format) {
67 |
68 | if (typeof format !== 'string') throw 'invalid argument: format';
69 |
70 | var renderer = $renderers[format];
71 |
72 | if (!renderer) throw 'invalid or no loaded renderer: ' + format;
73 |
74 | return renderer;
75 | },
76 |
77 | makeReport: function (xml) {
78 |
79 | if (typeof xml !== 'string') throw 'invalid argument: xml';
80 |
81 | var dom = rdl.parseXml(xml);
82 |
83 | var report = new RdlReport().init(dom);
84 |
85 | return report;
86 | }
87 | };
88 |
89 | // })();
90 |
--------------------------------------------------------------------------------
/src/rdljs.js:
--------------------------------------------------------------------------------
1 | ///
2 | ///
3 |
4 | // (function () {
5 |
6 | var $renderers = {};
7 |
8 | (RdlElement = function () { }).prototype = {
9 | view: function () {
10 | return this.node;
11 | }
12 | };
13 |
14 | (RdlStyleableElement = function () { }).prototype = RdlElement.extend({
15 |
16 | left: function () { return this.dom.find("> rdl\\:Left").html() || ""; },
17 |
18 | top: function () { return this.dom.find("> rdl\\:Top").html() || ""; },
19 |
20 | width: function () { return this.dom.find("> rdl\\:Width").html() || ""; },
21 |
22 | height: function () { return this.dom.find("> rdl\\:Height").html() || ""; },
23 |
24 | style: function () {
25 |
26 | return this._style = this._style || function () {
27 |
28 | var node = this.dom.find("> rdl\\:Style");
29 |
30 | var data = {
31 |
32 | border: {
33 | color: node.find("> rdl\\:Border > rdl\\:Color").html() || "black"
34 | , style: node.find("> rdl\\:Border > rdl\\:Style").html()
35 | , width: node.find("> rdl\\:Border > rdl\\:Width").html()
36 | }
37 |
38 | , backgroundColor: node.find("> rdl\\:BackgroundColor").html()
39 |
40 | , color: node.find("> rdl\\:Color").html()
41 |
42 | , fontFamily: node.find("> rdl\\:FontFamily").html()
43 | , fontSize: node.find("> rdl\\:FontSize").html()
44 | , fontWeight: node.find("> rdl\\:FontWeight").html()
45 | , verticalAlign: node.find("> rdl\\:VerticalAlign").html()
46 |
47 | , padding: {
48 | left: node.find("> rdl\\:PaddingLeft").html()
49 | , right: node.find("> rdl\\:PaddingLeft").html()
50 | , top: node.find("> rdl\\:PaddingLeft").html()
51 | , bottom: node.find("> rdl\\:PaddingLeft").html()
52 | }
53 |
54 | , textAlign: node.find("> rdl\\:TextAlign").html()
55 | };
56 |
57 | return data;
58 |
59 | }.call(this);
60 | }
61 | });
62 |
63 | (RdlReportItem = function () { }).prototype = RdlStyleableElement.extend({
64 |
65 | init: function (container, dom) {
66 | this.container = container;
67 | this.dom = dom;
68 | return this;
69 | },
70 |
71 | load: function (renderer) {
72 | throw 'not implemented: RdlReportItem.load()';
73 | }
74 | });
75 |
76 | RdlReportItem.create = function (body, dom) {
77 |
78 | if (dom.is("rdl\\:TextBox")) return new RdlTextBox().init(body, dom);
79 | else if (dom.is("rdl\\:Rectangle")) return new RdlRectangle().init(body, dom);
80 | else if (dom.is("rdl\\:Line")) return new RdlLine().init(body, dom);
81 | else if (dom.is("rdl\\:Tablix")) return new RdlTablix().init(body, dom);
82 | else if (dom.is("rdl\\:Image")) return new RdlImage().init(body, dom);
83 | else if (dom.is("rdl\\:ColSpan")) return new RdlColumnSpan().init(body, dom);
84 |
85 | throw 'not implemented item: ' + dom.get(0).tagName;
86 | };
87 |
88 | (RdlContainer = function () { }).prototype = RdlStyleableElement.extend({
89 |
90 | init: function () {
91 | this.items = [];
92 | return this;
93 | },
94 |
95 | height: function () { return this.dom.find("> rdl\\:Height").html() || ""; },
96 |
97 | loadContent: function (renderer) {
98 |
99 | this.dom
100 |
101 | .find("> rdl\\:ReportItems > *")
102 |
103 | .each(function (i, element) {
104 |
105 | var item = RdlReportItem.create(this, $(element));
106 |
107 | this.items.push(item);
108 |
109 | item.load(renderer);
110 |
111 | }.delegateTo(this));
112 |
113 | return this;
114 | }
115 | });
116 |
117 | (RdlTextRun = function () { }).prototype = RdlStyleableElement.extend({
118 | init: function (paragraph, dom) {
119 | this.paragraph = paragraph;
120 | this.dom = dom;
121 | return this;
122 | },
123 | });
124 |
125 | (RdlParagraph = function () { }).prototype = RdlStyleableElement.extend({
126 | init: function (textBox, dom) {
127 | this.textBox = textBox;
128 | this.dom = dom;
129 | this.textRuns = [];
130 | return this;
131 | },
132 | });
133 |
134 | (RdlTextBox = function () { }).prototype = RdlReportItem.extend({
135 |
136 | init: function () {
137 | this.super.init.apply(this, arguments);
138 | this.paragraphs = [];
139 | return this;
140 | },
141 |
142 | load: function (renderer) {
143 |
144 | renderer.beginTextBox(this);
145 |
146 | this.dom
147 |
148 | .find("> rdl\\:Paragraphs > rdl\\:Paragraph")
149 |
150 | .each(function () {
151 |
152 | var paragraph = new RdlParagraph().init(this, $(arguments[1]));
153 |
154 | this.paragraphs.push(paragraph);
155 |
156 | renderer.beginParagraph(paragraph);
157 |
158 | $(arguments[1])
159 |
160 | .find("> rdl\\:TextRuns > rdl\\:TextRun")
161 |
162 | .each(function () {
163 |
164 | var textRun = new RdlTextRun().init(paragraph, $(arguments[1]));
165 |
166 | paragraph.textRuns.push(textRun);
167 |
168 | renderer.beginTextRun(textRun);
169 |
170 | renderer.endTextRun(textRun);
171 |
172 | }.delegateTo(this));
173 |
174 | renderer.endParagraph(paragraph);
175 |
176 | }.delegateTo(this));
177 |
178 | renderer.endTextBox(this);
179 |
180 | return this;
181 | }
182 | });
183 |
184 | (RdlShape = function () { }).prototype = RdlReportItem.extend({
185 |
186 | });
187 |
188 | (RdlRectangle = function () { }).prototype = RdlShape.extend({
189 |
190 | init: function () {
191 | this.super.init.apply(this, arguments);
192 | return this;
193 | },
194 |
195 | load: function (renderer) {
196 |
197 | renderer.beginRectangle(this);
198 |
199 | renderer.endRectangle(this);
200 |
201 | return this;
202 | }
203 | });
204 |
205 | (RdlEmbeddedImage = function () { }).prototype = RdlElement.extend({
206 |
207 | init: function (image, dom) {
208 | this.image = image;
209 | this.dom = dom;
210 | return this;
211 | },
212 |
213 | data: function () { return this.dom.find("> rdl\\:ImageData").html(); },
214 |
215 | mimeType: function () { return this.dom.find("> rdl\\:MIMEType").html(); },
216 | });
217 |
218 | (RdlImage = function () { }).prototype = RdlReportItem.extend({
219 |
220 | init: function () {
221 | this.super.init.apply(this, arguments);
222 | return this;
223 | },
224 |
225 | name: function () { return this.dom.attr("Name"); },
226 |
227 | embeddedImage: function () {
228 |
229 | return this._embeddedImage = this._embeddedImage || function () {
230 |
231 | // TODO: create embeddedImages in RdlReport prototype
232 | var dom = this.container.dom.closest("rdl\\:Report")
233 | .find("rdl\\:EmbeddedImage[Name='" + this.value() + "']");
234 |
235 | return new RdlEmbeddedImage().init(this, dom);
236 |
237 | }.call(this);
238 | },
239 |
240 | sizing: function () { return this.dom.find("> rdl\\:Sizing").html(); },
241 |
242 | source: function () { return this.dom.find("> rdl\\:Source").html(); },
243 |
244 | value: function () { return this.dom.find("> rdl\\:Value").html(); },
245 |
246 | load: function (renderer) {
247 |
248 | renderer.beginImage(this);
249 |
250 | renderer.endImage(this);
251 |
252 | return this;
253 | }
254 | });
255 |
256 | (RdlColumnSpan = function () { }).prototype = RdlReportItem.extend({
257 |
258 | init: function () {
259 | this.super.init.apply(this, arguments);
260 | return this;
261 | },
262 |
263 | span: function () { return parseInt(this.dom.html() || "0"); },
264 |
265 | load: function (renderer) {
266 |
267 | renderer.beginColumnSpan(this);
268 |
269 | renderer.endColumnSpan(this);
270 |
271 | return this;
272 | }
273 | });
274 |
275 | (RdlLine = function () { }).prototype = RdlShape.extend({
276 |
277 | init: function () {
278 | this.super.init.apply(this, arguments);
279 | return this;
280 | },
281 |
282 | load: function (renderer) {
283 |
284 | renderer.beginLine(this);
285 |
286 | renderer.endLine(this);
287 |
288 | return this;
289 | }
290 | });
291 |
292 | (RdlTablixCell = function () { }).prototype = RdlContainer.extend({
293 |
294 | init: function (row, dom, index) {
295 | this.row = row;
296 | this.dom = dom;
297 | this.index = index;
298 | this.contents = [];
299 | return this;
300 | },
301 |
302 | load: function (renderer) {
303 |
304 | renderer.beginTablixCell(this);
305 |
306 | this.dom
307 |
308 | .find("> rdl\\:CellContents > *")
309 |
310 | .each(function (i, element) {
311 |
312 | var item = RdlReportItem.create(this, $(element));
313 |
314 | this.contents.push(item);
315 |
316 | item.load(renderer);
317 |
318 | }.delegateTo(this));
319 |
320 | renderer.endTablixCell(this);
321 | }
322 | });
323 |
324 | (RdlTablixColumn = function () { }).prototype = RdlElement.extend({
325 |
326 | init: function (tablixBody, dom, index) {
327 | this.tablixBody = tablixBody;
328 | this.dom = dom;
329 | this.index = index;
330 | return this;
331 | },
332 |
333 | width: function () { return this.dom.find("> rdl\\:Width").html(); },
334 |
335 | load: function (renderer) {
336 |
337 | renderer.beginTablixColumn(this);
338 |
339 | renderer.endTablixColumn(this);
340 |
341 | return this;
342 | }
343 | });
344 |
345 | (RdlTablixRow = function () { }).prototype = RdlElement.extend({
346 |
347 | init: function (tablixBody, dom, index) {
348 | this.tablixBody = tablixBody;
349 | this.dom = dom;
350 | this.index = index;
351 | this.cells = [];
352 | return this;
353 | },
354 |
355 | height: function () { return this.dom.find("> rdl\\:Height").html(); },
356 |
357 | load: function (renderer) {
358 |
359 | renderer.beginTablixRow(this);
360 |
361 | this.dom
362 | .find("> rdl\\:TablixCells > rdl\\:TablixCell")
363 | .each(function (i, element) {
364 |
365 | this.cells.push(
366 | new RdlTablixCell()
367 | .init(this, $(element), i)
368 | .load(renderer)
369 | );
370 |
371 | }.delegateTo(this));
372 |
373 | renderer.endTablixRow(this);
374 |
375 | return this;
376 | }
377 | });
378 |
379 | (RdlTablixBody = function () { }).prototype = RdlElement.extend({
380 |
381 | init: function (tablix, dom) {
382 | this.tablix = tablix;
383 | this.dom = dom;
384 | this.columns = [];
385 | this.rows = [];
386 | return this;
387 | },
388 |
389 | load: function (renderer) {
390 |
391 | renderer.beginTablixBody(this);
392 |
393 | this.dom
394 | .find("> rdl\\:TablixColumns > rdl\\:TablixColumn")
395 | .each(function (i, element) {
396 | this.columns.push(
397 | new RdlTablixColumn()
398 | .init(this, $(element), i)
399 | .load(renderer)
400 | );
401 | }.delegateTo(this));
402 |
403 | this.dom
404 | .find("> rdl\\:TablixRows > rdl\\:TablixRow")
405 | .each(function (i, element) {
406 | this.rows.push(new RdlTablixRow().init(this, $(element), i).load(renderer));
407 | }.delegateTo(this));
408 |
409 | renderer.endTablixBody(this);
410 |
411 | return this;
412 | }
413 | });
414 |
415 | (RdlTablix = function () { }).prototype = RdlReportItem.extend({
416 |
417 | load: function (renderer) {
418 |
419 | renderer.beginTablix(this);
420 |
421 | this.myBody = new RdlTablixBody().init(this, this.dom.find("> rdl\\:TablixBody")).load(renderer);
422 |
423 | var report = this.container.section.report;
424 |
425 | var dataSet = report.dataResolver.resolve(this.dataSetName(), report.inputData());
426 |
427 | if (rdl.isPromise(dataSet)) {
428 |
429 | dataSet.done(function (result) {
430 |
431 | this.render(renderer, result);
432 |
433 | }.delegateTo(this));
434 |
435 | } else {
436 |
437 | this.render(renderer, dataSet);
438 | }
439 |
440 | renderer.endTablix(this);
441 |
442 | return this;
443 | },
444 |
445 | dataSetName: function () { return this.dom.find("> rdl\\:DataSetName").html(); },
446 |
447 | render: function (renderer, dataSet) {
448 |
449 | $(dataSet).each(function (rowDataIndex, data) {
450 |
451 | $(this.myBody.rows).each(function (rowIndex, row) {
452 |
453 | renderer.beginTablixDataRow(this, rowIndex, row, data);
454 |
455 | $(this.myBody.columns).each(function (columnIndex, column) {
456 |
457 | renderer.beginTablixDataColumn(this, rowIndex, row, columnIndex, column, data);
458 |
459 | var cell = row.cells[columnIndex];
460 |
461 | renderer.beginTablixDataCell(this, rowIndex, row, columnIndex, column, cell, data);
462 |
463 | renderer.endTablixDataCell(this, rowIndex, row, columnIndex, column, cell, data);
464 |
465 | renderer.endTablixDataColumn(this, rowIndex, row, columnIndex, column, data);
466 |
467 | }.delegateTo(this));
468 |
469 | renderer.endTablixDataRow(this, rowIndex, row, data);
470 |
471 | }.delegateTo(this));
472 |
473 | }.delegateTo(this));
474 | }
475 | });
476 |
477 | (RdlReportBody = function () { }).prototype = RdlContainer.extend({
478 |
479 | init: function (section, dom) {
480 | this.super.init.apply(this, arguments);
481 | this.section = section;
482 | this.dom = dom;
483 | return this;
484 | },
485 |
486 | load: function (renderer) {
487 |
488 | renderer.beginBody(this);
489 |
490 | this.loadContent(renderer);
491 |
492 | renderer.endBody(this);
493 |
494 | this.section.report.updateBox(renderer, this.view());
495 |
496 | return this;
497 | }
498 | });
499 |
500 | (RdlReportPageHeader = function () { }).prototype = RdlContainer.extend({
501 |
502 | init: function (page, dom) {
503 | this.super.init.apply(this, arguments);
504 | this.page = page;
505 | this.dom = dom;
506 | return this;
507 | },
508 |
509 | load: function (renderer) {
510 |
511 | renderer.beginPageHeader(this);
512 |
513 | this.loadContent(renderer);
514 |
515 | renderer.endPageHeader(this);
516 |
517 | return this;
518 | }
519 | });
520 |
521 | (RdlReportPage = function () { }).prototype = RdlElement.extend({
522 |
523 | init: function (section, dom) {
524 | this.section = section;
525 | this.dom = dom;
526 | return this;
527 | },
528 |
529 | load: function (renderer) {
530 |
531 | this.header = new RdlReportPageHeader()
532 | .init(this, this.dom.find("> rdl\\:PageHeader"));
533 |
534 | renderer.beginPage(this);
535 |
536 | this.header.load(renderer);
537 |
538 | renderer.endPage(this);
539 |
540 | return this;
541 | }
542 | });
543 |
544 | (RdlReportSection = function () { }).prototype = RdlElement.extend({
545 |
546 | init: function (report, dom) {
547 | this.report = report;
548 | this.dom = dom;
549 | return this;
550 | },
551 |
552 | width: function () { return this.dom.find("> rdl\\:Width").html(); },
553 |
554 | load: function (renderer) {
555 |
556 | this.page = new RdlReportPage().init(this, this.dom.find("> rdl\\:Page"));
557 |
558 | this.body = new RdlReportBody().init(this, this.dom.find("> rdl\\:Body"));
559 |
560 | renderer.beginSection(this);
561 |
562 | this.page.load(renderer);
563 |
564 | this.body.load(renderer);
565 |
566 | renderer.endSection(this);
567 |
568 | this.report.updateBox(renderer, this.view());
569 |
570 | return this;
571 | }
572 | });
573 |
574 | (RdlDataResolver = function () { }).prototype = {
575 |
576 | init: function (report, callback) {
577 | this.report = report;
578 | this.callback = callback;
579 | return this;
580 | },
581 |
582 | resolve: function (dataSetName, inputData) {
583 |
584 | var deferred = $.Deferred();
585 |
586 | var resultData = this.callback(dataSetName, inputData);
587 |
588 | if (resultData) {
589 |
590 | if (rdl.isPromise(resultData)) {
591 |
592 | resultData.done(function (asyncResultData) {
593 |
594 | deferred.resolve(asyncResultData);
595 | });
596 |
597 | } else {
598 |
599 | deferred.resolve(resultData);
600 | }
601 | }
602 |
603 | return deferred.promise();
604 | }
605 | };
606 |
607 | (RdlDataSetQuery = function () { }).prototype = RdlElement.extend({
608 |
609 | init: function (dataSet, dom) {
610 | this.dataSet = dataSet;
611 | this.dom = dom;
612 | return this;
613 | },
614 |
615 | commandText: function () { return this.dom.find("> rdl\\:CommandText").html(); },
616 |
617 | commandType: function () { return this.dom.find("> rdl\\:CommandType").html(); },
618 |
619 | dataSourceName: function () { return this.dom.find("> rdl\\:DataSourceName").html(); },
620 |
621 | load: function () {
622 |
623 | return this;
624 | }
625 | });
626 |
627 | (RdlDataSet = function () { }).prototype = RdlElement.extend({
628 |
629 | init: function (report, dom) {
630 | this.report = report;
631 | this.dom = dom;
632 | return this;
633 | },
634 |
635 | load: function () {
636 |
637 | this.query = new RdlDataSetQuery().init(this, this.dom.find("> rdl\\:Query")).load();
638 |
639 | return this;
640 | }
641 | });
642 |
643 | (RdlValue = function () { }).prototype = RdlValue.extend({
644 |
645 | init: function (dom) {
646 | this.dom = dom;
647 | return this;
648 | },
649 |
650 | isNil: function () { return this.dom.is("[xsi\\:nil='true']"); }
651 | });
652 |
653 | (RdlParameter = function () { }).prototype = RdlElement.extend({
654 |
655 | init: function (report, dom, index) {
656 | this.report = report;
657 | this.dom = dom;
658 | this.index = index;
659 | return this;
660 | },
661 |
662 | name: function () { return this.dom.attr("Name"); },
663 |
664 | allowBlank: function () { return this.dom.find("> rdl\\:AllowBlank").html() == "true"; },
665 |
666 | dataType: function () { return this.dom.find("> rdl\\:DataType").html(); },
667 |
668 | defaultValues: function () {
669 |
670 | return this._defaultValues || (this._defaultValues = function () {
671 |
672 | return this.dom.find("> rdl\\:DefaultValue > rdl\\:Values > rdl\\:Value").map(function (i, element) {
673 |
674 | return new RdlValue().init($(element));
675 |
676 | }.delegateTo(this));
677 |
678 | }.call(this));
679 | },
680 |
681 | nullable: function () { return this.dom.find("> rdl\\:Nullable").html(); },
682 |
683 | value: function (value) { return arguments.length ? (this._value = value) : this._value; }
684 | });
685 |
686 | (RdlReport = function () { }).prototype = RdlElement.extend({
687 |
688 | init: function (dom) {
689 | this.dom = dom;
690 | this.sections = [];
691 | this.dataSets = {};
692 | return this;
693 | },
694 |
695 | updateBox: function (renderer, node) {
696 |
697 | (function () {
698 |
699 | renderer.updateReportBox(this, node);
700 |
701 | }).delegateTo(this).invokeLater();
702 | },
703 |
704 | findDataSet: function (dataSetName) {
705 |
706 | var dom = this.dom.find("> rdl\\:DataSets > rdl\\:DataSet[Name='" + dataSetName + "']");
707 |
708 | if (!dom.length)
709 | throw 'dataset not found: ' + dataSetName;
710 |
711 | return this.dataSets[dataSetName] || (this.dataSets[dataSetName] = new RdlDataSet().init(this, dom).load());
712 | },
713 |
714 | dataResolver: function (callback) {
715 |
716 | if (callback)
717 | this.dataResolver = new RdlDataResolver().init(this, callback);
718 | else
719 | return this.dataResolver;
720 | },
721 |
722 | findParameter: function (name) {
723 |
724 | return this._parameters[name];
725 | },
726 |
727 | inputParameters: function () {
728 |
729 | return this._parameters || (this._parameters = function () {
730 |
731 | this._parameters = [];
732 |
733 | this.dom.find("> rdl\\:ReportParameters > rdl\\:ReportParameter").map(function (i, element) {
734 |
735 | this._parameters[i] = new RdlParameter().init(this, $(element), i);
736 | this._parameters[this._parameters[i].name()] = this._parameters[i];
737 |
738 | }.delegateTo(this));
739 |
740 | return this._parameters;
741 |
742 | }.call(this));
743 | },
744 |
745 | inputData: function () {
746 |
747 | var data = {};
748 |
749 | $(this._parameters).each(function (i, param) {
750 | data[param.name()] = param.value();
751 | });
752 |
753 | return data;
754 | },
755 |
756 | load: function (renderer) {
757 |
758 | this.id = this.dom.find("> rd\\:ReportID").html();
759 |
760 | renderer.beginReport(this);
761 |
762 | var sectionsDoms = this.dom.find("> rdl\\:ReportSections > rdl\\:ReportSection");
763 |
764 | if (sectionsDoms.length == 0) {
765 |
766 | var sectionDom = $(" ").appendTo(this.dom);
767 |
768 | this.dom.find("> rdl\\:Body,> rdl\\:Page").appendTo(sectionDom);
769 |
770 | this.dom.find("> rdl\\:Width").appendTo(sectionDom);
771 |
772 | this.sections.push(
773 | new RdlReportSection()
774 | .init(this, sectionDom)
775 | .load(renderer)
776 | );
777 |
778 | } else {
779 |
780 | sectionsDoms.each(function (i, element) {
781 |
782 | this.sections.push(
783 | new RdlReportSection()
784 | .init(this, $(element))
785 | .load(renderer)
786 | );
787 |
788 | }.delegateTo(this));
789 | }
790 |
791 | renderer.endReport(this);
792 |
793 | return this;
794 | }
795 | });
796 |
797 | // })();
798 |
--------------------------------------------------------------------------------
/src/rdljs.plugin.abstract.js:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | // (function () {
4 |
5 | Renderer = function () {
6 | };
7 |
8 | Renderer.prototype = {
9 |
10 | init: function () {
11 | /* do initialization */
12 | return this;
13 | },
14 |
15 | beginReport: function () { },
16 | updateReportBox: function (view) { },
17 | endReport: function () { },
18 |
19 | beginSection: function () { },
20 | endSection: function () { },
21 |
22 | beginBody: function () { },
23 | endBody: function () { },
24 |
25 | beginPage: function () { },
26 | endPage: function () { },
27 |
28 | beginPageHeader: function () { },
29 | endPageHeader: function () { },
30 |
31 | beginTextBox: function () { },
32 | endTextBox: function () { },
33 |
34 | beginParagraph: function () { },
35 | endParagraph: function () { },
36 |
37 | beginTextRun: function () { },
38 | endTextRun: function () { },
39 |
40 | beginRectangle: function () { },
41 | endRectangle: function () { },
42 |
43 | beginLine: function () { },
44 | endLine: function () { },
45 |
46 | beginTablix: function () { },
47 | endTablix: function () { },
48 |
49 | beginTablixBody: function () { },
50 | endTablixBody: function () { },
51 |
52 | beginTablixColumn: function () { },
53 | endTablixColumn: function () { },
54 |
55 | beginTablixRow: function () { },
56 | endTablixRow: function () { },
57 |
58 | beginTablixCell: function () { },
59 | endTablixCell: function () { },
60 |
61 | beginTablixDataRow: function (rowIndex, row, data) { },
62 | beginTablixDataColumn: function (rowIndex, row, columnIndex, column, data) { },
63 | beginTablixDataCell: function (rowIndex, row, columnIndex, column, cell, data) { },
64 | endTablixDataCell: function (rowIndex, row, columnIndex, column, cell, data) { },
65 | endTablixDataColumn: function (rowIndex, row, columnIndex, column, data) { },
66 | endTablixDataRow: function (rowIndex, row, data) { },
67 |
68 | beginImage: function () { },
69 | endImage: function () { }
70 | };
71 |
72 | // },)();
73 |
--------------------------------------------------------------------------------
/src/rdljs.plugin.html.css:
--------------------------------------------------------------------------------
1 | /*
2 | CSS reset of HTML plugin
3 | */
4 |
5 | .rdl-report {
6 | /*background: teal;*/
7 | }
8 |
9 | .rdl-page {
10 | /*background: red;*/
11 | }
12 |
13 | .rdl-textbox {
14 | overflow: hidden;
15 | }
16 |
17 | .rdl-paragraph {
18 | padding: 0 0 0 0;
19 | margin: 0 0 0 0;
20 | font-family: arial;
21 | font-size: 10pt;
22 | }
23 |
--------------------------------------------------------------------------------
/src/rdljs.plugin.html.js:
--------------------------------------------------------------------------------
1 | ///
2 | ///
3 |
4 | // (function () {
5 |
6 | HtmlRenderer = function () {
7 | };
8 |
9 | HtmlRenderer.prototype = Renderer.extend({
10 |
11 | init: function () {
12 | return this;
13 | },
14 |
15 | applyStyle: function (element) {
16 |
17 | element.node
18 | .css("color", element.style().color)
19 | .css("background", element.style().backgroundColor)
20 | .css("font-family", element.style().fontFamily)
21 | .css("font-size", element.style().fontSize)
22 | .css("font-weight", element.style().fontWeight)
23 | .css("border", element.style().border.width + " " + element.style().border.style + " " + element.style().border.color)
24 | .css("color", element.style().color)
25 | .css("padding-left", element.style().padding.left)
26 | .css("padding-top", element.style().padding.top)
27 | .css("padding-right", element.style().padding.right)
28 | .css("padding-bottom", element.style().padding.bottom);
29 | },
30 |
31 | originOf: function (element) {
32 | if (element.container instanceof RdlReportPageHeader) {
33 | return {
34 | left: 0,
35 | top: 0
36 | };
37 | } else {
38 | var left = 0;
39 | var top = 0;
40 | try {
41 | if (element.container.section) {
42 | top += element.container.section.page.header.height().toPixels()
43 | }
44 | return {
45 | left: left,
46 | top: top
47 | };
48 | } catch (e) {
49 | debugger
50 | }
51 | }
52 | },
53 |
54 | sizeFor: function (element) {
55 | if (element.container instanceof RdlReportPageHeader) {
56 | return {
57 | width: 0,
58 | height: 0
59 | };
60 | } else {
61 | return {
62 | width: element.container.section.width(),
63 | height: element.container.height()
64 | };
65 | }
66 | },
67 |
68 | beginReport: function (element) {
69 |
70 | element.node = $("
")
71 | .addClass("rdl rdl-report")
72 | //.css("width", "0")
73 | //.css("height", "0")
74 | .appendTo("body");
75 | },
76 |
77 | updateReportBox: function (element, view) {
78 |
79 | //var w = Math.max(
80 | // element.node.outerWidth(true),
81 | // view.outerWidth(true)
82 | //);
83 |
84 | //var h = Math.max(
85 | // element.node.outerHeight(true),
86 | // view.outerHeight(true)
87 | //);
88 |
89 | //element.node
90 | // .css("width", w)
91 | // .css("height", h);
92 | },
93 |
94 | endReport: function (element) { },
95 |
96 | beginSection: function (element) {
97 |
98 | element.node = $("
")
99 | .addClass("rdl rdl-section")
100 | .appendTo(element.report.node)
101 | .css("width", element.width())
102 | .css("height", "100%")
103 | .css("background", "transparent");
104 | },
105 |
106 | endSection: function (element) { },
107 |
108 | beginBody: function (element) {
109 |
110 | element.node = $("
")
111 | .addClass("rdl rdl-body")
112 | .appendTo(element.section.node)
113 | .css("height", element.height())
114 | .css("width", "100%")
115 | .css("background", "transparent");
116 | },
117 |
118 | endBody: function (element) {
119 | },
120 |
121 | beginPage: function (element) {
122 | },
123 |
124 | endPage: function (element) {
125 | },
126 |
127 | beginPageHeader: function (element) {
128 |
129 | element.node = $("
")
130 | .addClass("rdl rdl-page")
131 | .appendTo(element.page.section.node)
132 | .css("height", element.height())
133 | .css("width", "100%")
134 | .css("background", "transparent");
135 |
136 | element.page.section.node.insertAfter(".rdl-body");
137 | },
138 |
139 | endPageHeader: function (element) {
140 | },
141 |
142 | beginTextBox: function (element) {
143 |
144 | element.node = $("
")
145 | .addClass("rdl rdl-textbox")
146 | .appendTo(element.container.node);
147 |
148 | if (element.container instanceof RdlTablixCell) {
149 |
150 | var w = element.container.row.tablixBody.columns[element.container.index].width().toPixels();
151 | var h = element.container.row.height().toPixels();
152 |
153 | element.node
154 | .css("width", w - element.style().padding.left.toPixels() - element.style().padding.right.toPixels())
155 | .css("height", h - element.style().padding.top.toPixels() - element.style().padding.bottom.toPixels());
156 |
157 | } else {
158 |
159 | var origin = this.originOf(element);
160 |
161 | element.node
162 | .css("position", "absolute")
163 | .css("left", element.left())
164 | .css("top", origin.top + element.top().toPixels())
165 | .css("width", element.width())
166 | .css("height", element.height());
167 | }
168 |
169 | this.applyStyle(element);
170 | },
171 |
172 | endTextBox: function (element) {
173 | },
174 |
175 | beginParagraph: function (element) {
176 |
177 | element.node =
178 | $("
")
179 | .addClass("rdl rdl-paragraph")
180 | .css("text-align", element.style().textAlign)
181 | .appendTo(element.textBox.node);
182 |
183 | this.applyStyle(element);
184 | },
185 |
186 | endParagraph: function (element) {
187 |
188 | if (!element.node.text())
189 | element.node.html(" ");
190 | },
191 |
192 | beginTextRun: function (element) {
193 |
194 | element.text = $(element.dom).find("> rdl\\:Value").html();
195 |
196 | var html = element.text;
197 |
198 | html
199 | .replace(/[^\r\n]+/g, '\n')
200 | .replace(/\n/g, ' ');
201 |
202 | element.node =
203 | $(" ")
204 | .addClass("rdl rdl-textrun")
205 | .appendTo(element.paragraph.node)
206 | .html(html);
207 |
208 | this.applyStyle(element);
209 | },
210 |
211 | endTextRun: function (element) {
212 | },
213 |
214 | beginRectangle: function (element) {
215 |
216 | var origin = this.originOf(element);
217 |
218 | element.node = $("
")
219 | .addClass("rdl rdl-rectangle")
220 | .appendTo(element.container.node)
221 | .css("position", "absolute")
222 | .css("left", element.left())
223 | .css("top", origin.top + element.top().toPixels())
224 | .css("width", element.width() || "100%")
225 | .css("height", element.height() || "100%");
226 |
227 | if(!element.width() && !element.height())
228 | element.node.css("position", "relative");
229 | else
230 | element.node.css("position", "absolute");
231 |
232 | this.applyStyle(element);
233 | },
234 |
235 | endRectangle: function (element) { },
236 |
237 | beginLine: function (element) {
238 |
239 | var origin = this.originOf(element);
240 | var size = this.sizeFor(element);
241 |
242 | element.node = d3.select(element.container.node.get(0))
243 | .append("svg")
244 | .style("position", "absolute")
245 | //.style("left", "0")
246 | //.style("top", "0")
247 | .style("width", size.width)
248 | .style("height", size.height)
249 | .append("line")
250 | .attr("x1", element.left().toPixels())
251 | .attr("y1", origin.top + element.top().toPixels())
252 | .attr("x2", element.left().toPixels() + element.width().toPixels())
253 | .attr("y2", origin.top + element.top().toPixels() + element.height().toPixels())
254 | .attr("stroke", element.style().border.color)
255 | .attr("stroke-width", element.style().border.width);
256 | },
257 |
258 | endLine: function (element) {
259 | },
260 |
261 | beginTablix: function (element) {
262 |
263 | var origin = this.originOf(element);
264 |
265 | element.node = $("")
266 | .addClass("rdl rdl-tablix")
267 | .appendTo(element.container.node)
268 | .attr("border", "0")
269 | .attr("cellpadding", "0")
270 | .attr("cellspacing", "0")
271 | .css("position", "absolute")
272 | .css("left", element.left())
273 | .css("top", origin.top + element.top().toPixels())
274 | .css("width", element.width())
275 | .css("height", element.height());
276 |
277 | this.applyStyle(element);
278 | },
279 |
280 | endTablix: function (element) {
281 | },
282 |
283 | beginTablixBody: function (element) {
284 |
285 | element.node = element.tablix.node.find("tbody");
286 | },
287 |
288 | endTablixBody: function (element) {
289 | },
290 |
291 | beginTablixColumn: function (element) {
292 |
293 | element.node = $(" ")
294 | .appendTo(element.tablixBody.tablix.node.find("colgroup"))
295 | .css("width", element.width());
296 | },
297 |
298 | endTablixColumn: function (element) {
299 | },
300 |
301 | beginTablixRow: function (element) {
302 |
303 | element.node = $(" ")
304 | .hide()
305 | .appendTo(element.tablixBody.node)
306 | .css("height", element.height());
307 | },
308 |
309 | endTablixRow: function (element) {
310 | },
311 |
312 | beginTablixCell: function (element) {
313 |
314 | element.node = $(" ")
315 | .appendTo(element.row.node);
316 |
317 | this.applyStyle(element);
318 | },
319 |
320 | endTablixCell: function (element) {
321 | },
322 |
323 | beginTablixDataRow: function (element, rowIndex, row, data) {
324 |
325 | var tr = row.node.clone(false);
326 |
327 | tr.show().appendTo(row.node.parent());
328 | },
329 |
330 | beginTablixDataColumn: function (element, rowIndex, row, columnIndex, column, data) {
331 |
332 | },
333 |
334 | beginTablixDataCell: function (element, rowIndex, row, columnIndex, column, cell, data) {
335 | },
336 |
337 | endTablixDataCell: function (element, rowIndex, row, columnIndex, column, cell, data) {
338 | },
339 |
340 | endTablixDataColumn: function (element, rowIndex, row, columnIndex, column, data) {
341 | },
342 |
343 | endTablixDataRow: function (element, rowIndex, row, data) {
344 | },
345 |
346 | beginImage: function (element) {
347 |
348 | var src;
349 |
350 | if (element.source() == "Embedded") {
351 | src = "data:" + element.embeddedImage().mimeType() + ";base64," + element.embeddedImage().data();
352 | }
353 |
354 | element.node = $(" ")
355 | .addClass("rdl rdl-image")
356 | .attr("src", src)
357 | .appendTo(element.container.node);
358 |
359 | var origin = this.originOf(element);
360 |
361 | element.node
362 | .css("position", "absolute")
363 | .css("left", element.left())
364 | .css("top", origin.top + element.top().toPixels())
365 | .css("width", element.width())
366 | .css("height", element.height());
367 |
368 | this.applyStyle(element);
369 | },
370 |
371 | endImage: function (element) {
372 | },
373 |
374 | beginColumnSpan: function (element) {
375 |
376 | if (element.container instanceof RdlTablixCell) {
377 |
378 | element.container.node.attr("colspan", element.span());
379 |
380 | } else {
381 |
382 | throw new "not implemented";
383 | }
384 | },
385 |
386 | endColumnSpan: function (element) {
387 | }
388 | });
389 |
390 | $renderers["html"] = new HtmlRenderer().init();
391 |
392 | // })();
393 |
--------------------------------------------------------------------------------
/src/rdljs.plugin.svg.js:
--------------------------------------------------------------------------------
1 | ///
2 | ///
3 |
4 | // (function () {
5 |
6 | SvgRenderer = function () {
7 | };
8 |
9 | SvgRenderer.prototype = Renderer.extend({
10 |
11 | init: function () {
12 | return this;
13 | },
14 |
15 | beginReport: function () {
16 |
17 | this.node = d3.select("body")
18 | .append("svg")
19 | .style("background", "silver");
20 | },
21 |
22 | updateReportBox: function (view) {
23 |
24 | var w = Math.max(
25 | this.node.node().getBBox().width
26 | view.node().getBBox().width
27 | );
28 |
29 | var h = Math.max(
30 | this.node.node().getBBox().height
31 | view.node().getBBox().height
32 | );
33 |
34 | this.node
35 | .attr("width", w)
36 | .attr("height", h);
37 | },
38 |
39 | endReport: function () { },
40 |
41 | beginSection: function () {
42 |
43 | this.node = this.report.node
44 | .append("rect")
45 | .attr("width", this.width())
46 | .attr("height", "100%")
47 | .attr("fill", "transparent");
48 | },
49 |
50 | endSection: function () { },
51 |
52 | beginBody: function () {
53 |
54 | this.node = this.section.report.node
55 | .append("rect")
56 | .attr("height", this.height())
57 | .attr("width", "100%")
58 | .attr("fill", "transparent");
59 | },
60 |
61 | endBody: function () { },
62 |
63 | beginPage: function () { },
64 |
65 | endPage: function () { },
66 |
67 | beginTextBox: function () {
68 |
69 | this.dy = 0;
70 | this.dx = 0;
71 |
72 | this.node = this.body.section.report.node
73 | .append("text")
74 | .attr("x", this.left())
75 | .attr("y", this.top())
76 | .attr("width", this.width())
77 | .attr("height", this.height())
78 | .style("fill", this.style().color);
79 | },
80 |
81 | endTextBox: function () {
82 | },
83 |
84 | beginParagraph: function () {
85 |
86 | this.text = "";
87 | },
88 |
89 | endParagraph: function () {
90 |
91 | this.node =
92 | this.textBox.node
93 | .append("tspan")
94 | .attr("dy", this.dy)
95 | .attr("dx", this.dx)
96 | .text(this.text);
97 |
98 | this.dy += this.node.node().getBBox().height;
99 | this.dx = -this.node.node().getBBox().width;
100 | },
101 |
102 | beginTextRun: function () {
103 |
104 | var text = $(this.dom).find("> rdl\\:Value").html();
105 |
106 | this.paragraph.text += text;
107 | },
108 |
109 | endTextRun: function () {
110 | },
111 |
112 | beginRectangle: function () { },
113 | endRectangle: function () { },
114 |
115 | beginLine: function () { },
116 | endLine: function () { },
117 |
118 | beginTablix: function () { },
119 | endTablix: function () { }
120 | });
121 |
122 | $renderers["svg"] = new SvgRenderer().init();
123 |
124 | // })();
125 |
--------------------------------------------------------------------------------
/src/rdljs.util.js:
--------------------------------------------------------------------------------
1 | // (function () {
2 |
3 | function toPixels() {
4 |
5 | var element;
6 |
7 | try {
8 |
9 | toPixels.container = toPixels.container || (function () {
10 |
11 | var iframe = $("")
12 | .hide()
13 | .appendTo("body");
14 |
15 | var contents = iframe.contents();
16 |
17 | var metas = $("
").append($("head > meta").clone()).html();
18 |
19 | contents.get(0).write("" + metas + "");
20 |
21 | return contents.find("body");
22 | })();
23 |
24 | element = $("
")
25 | .appendTo(toPixels.container)
26 | .css("width", this);
27 |
28 | var pixels = element.outerWidth(true);
29 |
30 | return pixels;
31 |
32 | } finally {
33 |
34 | element.remove();
35 | }
36 | };
37 |
38 | String.prototype.toPixels = toPixels;
39 |
40 | // })();
41 |
--------------------------------------------------------------------------------