├── .gitignore
├── .idea
├── .gitignore
├── compiler.xml
├── encodings.xml
├── jarRepositories.xml
├── misc.xml
└── vcs.xml
├── README.md
├── RuanZhuCode.iml
├── pom.xml
├── src
├── main
│ └── java
│ │ └── cn
│ │ └── devmeteor
│ │ └── ruanzhucode
│ │ └── App.java
└── test
│ └── java
│ └── cn
│ └── devmeteor
│ └── ruanzhucode
│ └── AppTest.java
├── template
└── template.docx
└── 软件著作权代码文档生成器v1.0.0源代码.docx
/.gitignore:
--------------------------------------------------------------------------------
1 | /target/
2 |
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Datasource local storage ignored files
5 | /../../../../:\Idea\RuanZhuCode\.idea/dataSources/
6 | /dataSources.local.xml
7 | # Editor-based HTTP Client requests
8 | /httpRequests/
9 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/jarRepositories.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # RuanZhuCode
2 |
3 | 使用Java语言编写的软著代码文档生成器,填写相关信息,运行代码就可以直接生成Word文档,由于暂未找到截取前后30页的方案,需要手动截取,其他均符合申请软件著作权的要求,项目根目录下的文档就是使用本程序生成。
--------------------------------------------------------------------------------
/RuanZhuCode.iml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 | 4.0.0
6 |
7 | cn.devmeteor
8 | RuanZhuCode
9 | 1.1
10 |
11 | RuanZhuCode
12 |
13 | http://www.example.com
14 |
15 |
16 | UTF-8
17 | 1.7
18 | 1.7
19 |
20 |
21 |
22 |
23 | junit
24 | junit
25 | 4.11
26 | test
27 |
28 |
29 | org.apache.poi
30 | poi
31 | 4.1.2
32 |
33 |
34 | org.apache.poi
35 | ooxml-schemas
36 | 1.4
37 |
38 |
39 | org.apache.poi
40 | poi-ooxml-schemas
41 | 4.1.2
42 |
43 |
44 | org.apache.xmlbeans
45 | xmlbeans
46 | 3.1.0
47 |
48 |
49 | org.apache.poi
50 | poi-examples
51 | 4.1.2
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 | maven-clean-plugin
61 | 3.1.0
62 |
63 |
64 |
65 | maven-resources-plugin
66 | 3.0.2
67 |
68 |
69 | maven-compiler-plugin
70 | 3.8.0
71 |
72 |
73 | maven-surefire-plugin
74 | 2.22.1
75 |
76 |
77 | maven-jar-plugin
78 | 3.0.2
79 |
80 |
81 | maven-install-plugin
82 | 2.5.2
83 |
84 |
85 | maven-deploy-plugin
86 | 2.8.2
87 |
88 |
89 |
90 | maven-site-plugin
91 | 3.7.1
92 |
93 |
94 | maven-project-info-reports-plugin
95 | 3.0.0
96 |
97 |
98 |
99 |
100 |
101 |
--------------------------------------------------------------------------------
/src/main/java/cn/devmeteor/ruanzhucode/App.java:
--------------------------------------------------------------------------------
1 | package cn.devmeteor.ruanzhucode;
2 |
3 |
4 | import org.apache.poi.xwpf.usermodel.XWPFDocument;
5 | import org.apache.poi.xwpf.usermodel.XWPFParagraph;
6 | import org.apache.poi.xwpf.usermodel.XWPFRun;
7 |
8 | import java.io.File;
9 | import java.io.FileInputStream;
10 | import java.io.FileOutputStream;
11 | import java.io.IOException;
12 | import java.text.SimpleDateFormat;
13 | import java.util.*;
14 |
15 |
16 | public class App {
17 |
18 | private static final String name = "软件著作权代码文档生成器";
19 | private static final String version = "v1.0.0";
20 | private static final String sourcePath = "F:\\Idea\\RuanZhuCode";
21 | private static final String outputPath = "F:\\Idea\\RuanZhuCode";
22 | private static final String[] myExcludeFiles = new String[]{"F:\\Idea\\RuanZhuCode\\RuanZhuCode.iml","F:\\Idea\\RuanZhuCode\\README.md"};
23 | private static final String[] myExcludeDirs = new String[]{"F:\\Idea\\RuanZhuCode\\target","F:\\Idea\\RuanZhuCode\\.idea","F:\\Idea\\RuanZhuCode\\src\\test"};
24 | private static final String[] additionalFiles = new String[]{};
25 | private static final String[] additionalDirs = new String[]{};
26 |
27 |
28 | public static void main(String[] args) throws IOException {
29 | List excludeDirs = Arrays.asList(myExcludeDirs);
30 | String[] audios = new String[]{"mp3", "wav", "aif", "aiff", "mp1", "mp2", "ra", "ram", "mid", "rmi", "m4a", "wma", "cda", "ogg", "ape", "flac", "aac", "ac3", "mmf", "amr", "m4r", "wavpack"};
31 | String[] videos = new String[]{"avi", "mov", "qt", "asf", "rm", "rmvb", "navi", "divx", ",mp4", "mpeg", "mpg", "flv", "mkv", "3gp", "wmv", "vob", "swf"};
32 | String[] images = new String[]{"webp", "jpg", "png", "ico", "bmp", "gif", "tif", "tga", "pcx", "jpeg", "exif", "fpx", "svg", "psd", "cdr", "pcd", "dxf", "ufo", "eps", "ai", "hdri", "raw", "wmf", "flic", "emf"};
33 | String[] docs = new String[]{"doc", "docx", "xls", "ppt", "pptx", "pdf"};
34 | String[] executable = new String[]{"exe", "apk", "ipa", "app"};
35 | String[] zips = new String[]{"zip", "rar", "arj", "z", "tar", "gz", "iso", "jar"};
36 | List excludeFiles = new ArrayList<>();
37 | excludeFiles.addAll(Arrays.asList(audios));
38 | excludeFiles.addAll(Arrays.asList(videos));
39 | excludeFiles.addAll(Arrays.asList(images));
40 | excludeFiles.addAll(Arrays.asList(docs));
41 | excludeFiles.addAll(Arrays.asList(executable));
42 | excludeFiles.addAll(Arrays.asList(zips));
43 | excludeFiles.addAll(Arrays.asList(myExcludeFiles));
44 | File root = new File(sourcePath);
45 | Queue dirQueue = new ArrayDeque<>();
46 | dirQueue.add(root);
47 | for (String additional : additionalDirs)
48 | dirQueue.add(new File(additional));
49 | List files = new ArrayList<>();
50 | while (!dirQueue.isEmpty()) {
51 | File dir = dirQueue.poll();
52 | for (File f : dir.listFiles()) {
53 | if (f.isDirectory() && !excludeDirs.contains(f.getAbsolutePath()) && !f.getName().equals(".git"))
54 | dirQueue.add(f);
55 | else if (f.isFile() && !matchExclude(f, excludeFiles))
56 | files.add(f);
57 | }
58 | }
59 | for (String additional : additionalFiles)
60 | files.add(new File(additional));
61 | String s = "\n ";
62 | for (File file : files) {
63 | Scanner scanner = new Scanner(new FileInputStream(file),"UTF-8");
64 | while (scanner.hasNext())
65 | s += scanner.nextLine() + "\n";
66 | scanner.close();
67 | }
68 | System.out.println(s);
69 | s = s.replaceAll("(? runs = doc.getHeaderList().get(1).getParagraphs().get(1).getRuns();
74 | runs.get(0).setText(name,0);
75 | runs.get(1).setText(version,0);
76 | Scanner scanner = new Scanner(s);
77 | int total = 0;
78 | while (scanner.hasNext()) {
79 | total++;
80 | scanner.nextLine();
81 | }
82 | System.out.println("总计:" + total + "行");
83 | scanner = new Scanner(s);
84 | while (scanner.hasNext()) {
85 | XWPFParagraph p1 = doc.createParagraph();
86 | XWPFRun r1 = p1.createRun();
87 | r1.setFontFamily("等线 (西文正文)");
88 | r1.setFontSize(10);
89 | r1.setText(scanner.nextLine());
90 | }
91 | scanner.close();
92 | doc.getDocument().getBody().removeP(0);
93 | FileOutputStream out = new FileOutputStream(outputPath + "/" + name + version + "源代码.docx");
94 | doc.getProperties().getCoreProperties().setCreator("软件著作权代码文档生成器");
95 | doc.getProperties().getCoreProperties().setLastModifiedByUser("软件著作权代码文档生成器");
96 | doc.getProperties().getCoreProperties().setRevision("1");
97 | doc.getProperties().getCoreProperties().setModified(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
98 | doc.write(out);
99 | out.close();
100 | }
101 |
102 |
103 | private static boolean matchExclude(File f, List excludeList) {
104 | for (String e : excludeList)
105 | if (f.getAbsolutePath().equals(e) || f.getName().equals(".gitignore") || f.getName().endsWith("." + e.toLowerCase()))
106 | return true;
107 | return false;
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/src/test/java/cn/devmeteor/ruanzhucode/AppTest.java:
--------------------------------------------------------------------------------
1 | package cn.devmeteor.ruanzhucode;
2 |
3 | import static org.junit.Assert.assertTrue;
4 |
5 | import org.junit.Test;
6 |
7 | /**
8 | * Unit test for simple App.
9 | */
10 | public class AppTest
11 | {
12 | /**
13 | * Rigorous Test :-)
14 | */
15 | @Test
16 | public void shouldAnswerWithTrue()
17 | {
18 | assertTrue( true );
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/template/template.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevMeteor/RuanZhuCode/95cfb13f206b7c3273e813c930f5740403fb0bda/template/template.docx
--------------------------------------------------------------------------------
/软件著作权代码文档生成器v1.0.0源代码.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DevMeteor/RuanZhuCode/95cfb13f206b7c3273e813c930f5740403fb0bda/软件著作权代码文档生成器v1.0.0源代码.docx
--------------------------------------------------------------------------------