Skip to content

fixed issus on linux #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions Common/OfficeDrawing/Record.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,20 @@ virtual public bool DoAutomaticVerifyReadToEnd

public void VerifyReadToEnd()
{
long streamPos = this.Reader.BaseStream.Position;
long streamLen = this.Reader.BaseStream.Length;
try
{
long streamPos = this.Reader.BaseStream.Position;
long streamLen = this.Reader.BaseStream.Length;

if (streamPos != streamLen)
if (streamPos != streamLen)
{
TraceLogger.DebugInternal("Record {3} didn't read to end: (stream position: {1} of {2})\n{0}",
this, streamPos, streamLen, this.GetIdentifier());
}
}
catch (Exception)
{
TraceLogger.DebugInternal("Record {3} didn't read to end: (stream position: {1} of {2})\n{0}",
this, streamPos, streamLen, this.GetIdentifier());

}
}

Expand Down Expand Up @@ -295,6 +302,7 @@ public static Record ReadRecord(BinaryReader reader)
TraceLogger.DebugInternal(e.InnerException.ToString());
throw e.InnerException;
}

}
else
{
Expand Down
1 change: 0 additions & 1 deletion Common/OfficeDrawing/RegularContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public RegularContainer(BinaryReader _reader, uint size, uint typeCode, uint ver
while (readSize < this.BodySize)
{
Record child = null;

try
{
child = Record.ReadRecord(this.Reader);
Expand Down
4 changes: 2 additions & 2 deletions Common/OpenXmlLib/OpenXmlPartContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public virtual string TargetDirectoryAbsolute
path = resolvedPath.Substring(rootPath.Length + 1);
}
}

path = path.Replace("/", "\\");
if (path == "ppt\\slides\\media") return "ppt\\media";
if (path == "ppt\\slideLayouts\\media") return "ppt\\media";
if (path == "ppt\\notesSlides\\media") return "ppt\\media";
Expand Down Expand Up @@ -211,7 +211,7 @@ protected virtual void WriteRelationshipPart(OpenXmlWriter writer)
{
//reform the URI path for Word
//Word does not accept forward slahes in the path of a local file
writer.WriteAttributeString("Target", "file:///" + rel.TargetUri.AbsolutePath.Replace("/", "\\"));
writer.WriteAttributeString("Target", "file:///" + rel.TargetUri.AbsolutePath);
}
else
{
Expand Down
9 changes: 2 additions & 7 deletions Common/StructuredStorage/Common/InternalBitConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,8 @@ internal string ToString(byte[] value)
Array.Reverse(value);
}

var enc = new UnicodeEncoding();
string result = enc.GetString(value);
if (result.Contains("\0"))
{
result = result.Remove(result.IndexOf("\0"));
}
return result;
string result = Encoding.Unicode.GetString(value);
return result.TrimEnd('\0');
}


Expand Down
2 changes: 1 addition & 1 deletion Ppt/PptFileFormat/FontEntityAtom.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public FontEntityAtom(BinaryReader _reader, uint size, uint typeCode, uint versi

var facename = this.Reader.ReadBytes(64);
this.TypeFace = Encoding.Unicode.GetString(facename);
this.TypeFace = this.TypeFace.Substring(0, this.TypeFace.IndexOf("\0"));
this.TypeFace = this.TypeFace.TrimEnd('\0');

//TODO: read other flags

Expand Down
4 changes: 2 additions & 2 deletions Ppt/PresentationMLMapping/ShapeTreeMapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1450,14 +1450,14 @@ public void Apply(ShapeContainer container, string footertext, string headertext
{
var bytes = this.so.OptionsByID[ShapeOptions.PropertyId.gtextUNICODE].opComplex;
string sText = Encoding.Unicode.GetString(bytes);
if (sText.Contains("\0")) sText = sText.Substring(0, sText.IndexOf("\0"));
if (sText.Contains("\0")) sText = sText.TrimEnd('\0');
this._writer.WriteStartElement("a", "r", OpenXmlNamespaces.DrawingML);

if (this.so.OptionsByID.ContainsKey(ShapeOptions.PropertyId.gtextFont))
{
bytes = this.so.OptionsByID[ShapeOptions.PropertyId.gtextFont].opComplex;
string sFont = Encoding.Unicode.GetString(bytes);
if (sFont.Contains("\0")) sFont = sFont.Substring(0, sFont.IndexOf("\0"));
if (sFont.Contains("\0")) sFont = sFont.TrimEnd('\0');

this._writer.WriteStartElement("a", "rPr", OpenXmlNamespaces.DrawingML);
if (this.so.OptionsByID.ContainsKey(ShapeOptions.PropertyId.gtextSize))
Expand Down
4 changes: 2 additions & 2 deletions Ppt/PresentationMLMapping/TextMapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ private void writeP(ParagraphRun p, MasterTextPropRun tp, ShapeOptions so, TextR
else if (!defaultStyle.PRuns[tp.indentLevel].BulletCharPresent)
{
this._writer.WriteStartElement("a", "buChar", OpenXmlNamespaces.DrawingML);
this._writer.WriteAttributeString("char", "");
this._writer.WriteAttributeString("char", "?");
this._writer.WriteEndElement(); //buChar
}

Expand Down Expand Up @@ -1186,7 +1186,7 @@ private void writeP(ParagraphRun p, MasterTextPropRun tp, ShapeOptions so, TextR
else if (!bulletWritten && !p.BulletCharPresent)
{
this._writer.WriteStartElement("a", "buChar", OpenXmlNamespaces.DrawingML);
this._writer.WriteAttributeString("char", "");
this._writer.WriteAttributeString("char", "?");
this._writer.WriteEndElement(); //buChar
}
}
Expand Down