3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/asposediagramjava/Text/applycustomstylesheet.rb', line 3
def initialize()
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
diagram = Rjb::import('com.aspose.diagram.Diagram').new(data_dir + "Drawing.vsd")
shapes = diagram.getPages().getPage(0).getShapes()
i = 0
while i < shapes.getCount()
shape = shapes.get(i)
if shape.getNameU() == "Process"
source_shape = shape
break
end
i +=1
end
stylesheets = diagram.getStyleSheets()
j = 0
while j < stylesheets.getCount()
stylesheet = stylesheets.get(j)
if stylesheet.getName() == "Basic"
custom_stylesheet = stylesheet
break
end
j +=1
end
if source_shape != nil && custom_stylesheet != nil
source_shape.setTextStyle(custom_stylesheet)
source_shape.setFillStyle(custom_stylesheet)
source_shape.setLineStyle(custom_stylesheet)
end
diagram.save(data_dir + "ApplyCustomStyleSheet.vdx", Rjb::import('com.aspose.diagram.SaveFileFormat').VDX)
puts "Applied custom stylesheet to a visio diagram."
end
|