Skip to content

Commit 9241a8e

Browse files
authored
Merge pull request #23 from sabir-aspose/main
Support for creating word shapes with fill options and separate word elements to element wise classes
2 parents 2b55e2a + d4b48ad commit 9241a8e

File tree

10 files changed

+1956
-1557
lines changed

10 files changed

+1956
-1557
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ var document = new Openize.Words.Document();
2626
document.Save("word.docx");
2727
Console.WriteLine("Empty word document created !!!");
2828
```
29+
For more details please check [word readme](Word/README.md).
2930

3031
### Create an Empty Excel Spreadsheet
3132
```csharp

Word/OoxmData.cs

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -75,28 +75,36 @@ internal void Insert(FF.IElement newElement, int position, Document doc)
7575
switch (newElement)
7676
{
7777
case FF.Paragraph ffPara:
78-
var wpPara = _ooxmlDoc.CreateParagraph(ffPara);
78+
//var wpPara = _ooxmlDoc.CreateParagraph(ffPara);
79+
var wpPara = OoxmlParagraph.CreateInstance(
80+
_ooxmlDoc.IDs, _ooxmlDoc.NumberingPart).CreateParagraph(ffPara);
7981
elements.ElementAt(position).InsertBeforeSelf(wpPara);
8082
break;
8183

8284

8385
case FF.Table ffTable:
84-
var wpTable = _ooxmlDoc.CreateTable(ffTable);
86+
var wpTable = OoxmlTable.CreateInstance(
87+
_ooxmlDoc.IDs, _ooxmlDoc.NumberingPart).CreateTable(ffTable);
8588
elements.ElementAt(position).InsertBeforeSelf(wpTable);
8689
break;
8790

8891
case FF.Image ffImage:
89-
var wpImage = _ooxmlDoc.CreateImage(ffImage, staticDoc.MainDocumentPart);
92+
//var wpImage = _ooxmlDoc.CreateImage(ffImage, staticDoc.MainDocumentPart);
93+
var wpImage = OoxmlImage.CreateInstance(
94+
_ooxmlDoc.MainPart).CreateImage(ffImage);
9095
elements.ElementAt(position).InsertBeforeSelf(wpImage);
9196
break;
9297

9398
case FF.Shape ffShape:
94-
var wpShape = _ooxmlDoc.CreateShape(ffShape);
99+
//var wpShape = _ooxmlDoc.CreateShape(ffShape);
100+
var wpShape = OoxmlShape.CreateInstance().CreateShape(ffShape);
95101
elements.ElementAt(position).InsertBeforeSelf(wpShape);
96102
break;
97103

98104
case FF.GroupShape ffGroupShape:
99-
var wpGroupShape = _ooxmlDoc.CreateGroupShape(ffGroupShape);
105+
//var wpGroupShape = _ooxmlDoc.CreateGroupShape(ffGroupShape);
106+
var wpGroupShape = OoxmlGroupShape.CreateInstance().
107+
CreateGroupShape(ffGroupShape);
100108
elements.ElementAt(position).InsertBeforeSelf(wpGroupShape);
101109
break;
102110
}
@@ -137,26 +145,34 @@ internal void Update(FF.IElement newElement, int position, Document doc)
137145
switch (newElement)
138146
{
139147
case FF.Paragraph ffPara:
140-
var wpPara = _ooxmlDoc.CreateParagraph(ffPara);
148+
//var wpPara = _ooxmlDoc.CreateParagraph(ffPara);
149+
var wpPara = OoxmlParagraph.CreateInstance(
150+
_ooxmlDoc.IDs, _ooxmlDoc.NumberingPart).CreateParagraph(ffPara);
141151
enumerable1.ElementAt(position).InsertBeforeSelf(wpPara);
142152
break;
143153

144154
case FF.Table ffTable:
145-
var wpTable = _ooxmlDoc.CreateTable(ffTable);
155+
var wpTable = OoxmlTable.CreateInstance(
156+
_ooxmlDoc.IDs, _ooxmlDoc.NumberingPart).CreateTable(ffTable);
146157
enumerable1.ElementAt(position).InsertBeforeSelf(wpTable);
147158
break;
148159
case FF.Image ffImage:
149-
var wpImage = _ooxmlDoc.CreateImage(ffImage, staticDoc.MainDocumentPart);
160+
//var wpImage = _ooxmlDoc.CreateImage(ffImage, staticDoc.MainDocumentPart);
161+
var wpImage = OoxmlImage.CreateInstance(
162+
_ooxmlDoc.MainPart).CreateImage(ffImage);
150163
enumerable1.ElementAt(position).InsertBeforeSelf(wpImage);
151164
break;
152165

153166
case FF.Shape ffShape:
154-
var wpShape = _ooxmlDoc.CreateShape(ffShape);
167+
//var wpShape = _ooxmlDoc.CreateShape(ffShape);
168+
var wpShape = OoxmlShape.CreateInstance().CreateShape(ffShape);
155169
enumerable1.ElementAt(position).InsertBeforeSelf(wpShape);
156170
break;
157171

158172
case FF.GroupShape ffGroupShape:
159-
var wpGroupShape = _ooxmlDoc.CreateGroupShape(ffGroupShape);
173+
//var wpGroupShape = _ooxmlDoc.CreateGroupShape(ffGroupShape);
174+
var wpGroupShape = OoxmlGroupShape.CreateInstance().
175+
CreateGroupShape(ffGroupShape);
160176
elements.ElementAt(position).InsertBeforeSelf(wpGroupShape);
161177
break;
162178
}
@@ -224,28 +240,36 @@ internal void Append(FF.IElement newElement, Document doc)
224240
switch (newElement)
225241
{
226242
case FF.Paragraph ffPara:
227-
var wpPara = _ooxmlDoc.CreateParagraph(ffPara);
243+
//var wpPara = _ooxmlDoc.CreateParagraph(ffPara);
244+
var wpPara = OoxmlParagraph.CreateInstance(
245+
_ooxmlDoc.IDs, _ooxmlDoc.NumberingPart).CreateParagraph(ffPara);
228246
if (lastSectionProperties != null) staticDoc.MainDocumentPart.Document.Body.InsertBefore(wpPara, lastSectionProperties);
229247
else staticDoc.MainDocumentPart.Document.Body.Append(wpPara);
230248
break;
231249
case FF.Table ffTable:
232-
var wpTable = _ooxmlDoc.CreateTable(ffTable);
250+
var wpTable = OoxmlTable.CreateInstance(
251+
_ooxmlDoc.IDs, _ooxmlDoc.NumberingPart).CreateTable(ffTable);
233252
if (lastSectionProperties != null) staticDoc.MainDocumentPart.Document.Body.InsertBefore(wpTable, lastSectionProperties);
234253
else staticDoc.MainDocumentPart.Document.Body.Append(wpTable);
235254
break;
236255
case FF.Image ffImage:
237-
var wpImage = _ooxmlDoc.CreateImage(ffImage, staticDoc.MainDocumentPart);
256+
//var wpImage = _ooxmlDoc.CreateImage(ffImage, staticDoc.MainDocumentPart);
257+
var wpImage = OoxmlImage.CreateInstance(
258+
_ooxmlDoc.MainPart).CreateImage(ffImage);
238259
if (lastSectionProperties != null) staticDoc.MainDocumentPart.Document.Body.InsertBefore(wpImage, lastSectionProperties);
239260
else staticDoc.MainDocumentPart.Document.Body.Append(wpImage);
240261
break;
241262
case FF.Shape ffShape:
242-
var wpShape = _ooxmlDoc.CreateShape(ffShape);
263+
//var wpShape = _ooxmlDoc.CreateShape(ffShape);
264+
var wpShape = OoxmlShape.CreateInstance().CreateShape(ffShape);
243265
if (lastSectionProperties != null) staticDoc.MainDocumentPart.Document.Body.InsertBefore(wpShape, lastSectionProperties);
244266
else staticDoc.MainDocumentPart.Document.Body.Append(wpShape);
245267
break;
246268

247269
case FF.GroupShape ffGroupShape:
248-
var wpGroupShape = _ooxmlDoc.CreateGroupShape(ffGroupShape);
270+
//var wpGroupShape = _ooxmlDoc.CreateGroupShape(ffGroupShape);
271+
var wpGroupShape = OoxmlGroupShape.CreateInstance().
272+
CreateGroupShape(ffGroupShape);
249273
if (lastSectionProperties != null) staticDoc.MainDocumentPart.Document.Body.InsertBefore(wpGroupShape, lastSectionProperties);
250274
else staticDoc.MainDocumentPart.Document.Body.Append(wpGroupShape);
251275
break;

0 commit comments

Comments
 (0)