What is the DataFormats.Html structire for PPT?

D

David Thielen

Hi;

I have drag & drop (drag from my AddIn, drop in Office) working great
on Word & Excel. On PPT I am having 2 problems:

1) it always drops it in the upper left corner of the slide rather
than where I last had the caret.

2) When dropping a table plus a paragraph, all I get is the paragraph.

Is there some special requirements of the text inside the
<!--StartFragment--> ... <!--EndFragment--> part?

thanks - dave

david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
J

\Ji Zhou [MSFT]\

Hello Dave,

1)I write the following codes and test in my side,
private void label1_MouseDown(object sender, MouseEventArgs e)
{
string data = "test";
if (e.Button == MouseButtons.Left)
{
this.DoDragDrop(new DataObject(data), DragDropEffects.Copy);
}
}
When I click the left button on a label in the custom task pane, the codes
call the DoDragDrop. And I drag and drop it onto the PowerPoint slide. It
generates a text box at the caret location. So I did not see the dropped
content goes to the upper left concern as you mentioned. Am I
misunderstanding your scenario? If yes, please feel free to correct me.

2)If you are creating a custom class that implements the IDataObject
interface by yourself. Would you like to post the codes of your DataObject
implementation? That will be helpful for me to understand the scenario and
have future test/investigation. If you do not want to post the codes in
public, would you mind sending it to me at (e-mail address removed). Thank you!

Have a good day!

Best regards,
Ji Zhou ([email protected], remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/default.aspx?target=assistance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
D

David Thielen

TEXT, CSV, & RTF drop all do fine. Your example below is TEXT. But for
HTML I get this problem. The link Glen Millar talks about how to
format what is dropped but I am following that and still get a
problem.

My guess is it is what is inside and outside the fragment - but I
don't know what PPT wants for that.

thanks - dave


Hello Dave,

1)I write the following codes and test in my side,
private void label1_MouseDown(object sender, MouseEventArgs e)
{
string data = "test";
if (e.Button == MouseButtons.Left)
{
this.DoDragDrop(new DataObject(data), DragDropEffects.Copy);
}
}
When I click the left button on a label in the custom task pane, the codes
call the DoDragDrop. And I drag and drop it onto the PowerPoint slide. It
generates a text box at the caret location. So I did not see the dropped
content goes to the upper left concern as you mentioned. Am I
misunderstanding your scenario? If yes, please feel free to correct me.

2)If you are creating a custom class that implements the IDataObject
interface by yourself. Would you like to post the codes of your DataObject
implementation? That will be helpful for me to understand the scenario and
have future test/investigation. If you do not want to post the codes in
public, would you mind sending it to me at (e-mail address removed). Thank you!

Have a good day!

Best regards,
Ji Zhou ([email protected], remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/default.aspx?target=assistance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
J

\Ji Zhou [MSFT]\

Hello Dave,

I think the PowerPoint just wants a html string in the <!--StartFragment-->
and <!--EndFragment-->. In my side, I have used,
"<Table><TR><TD>Item 6</TD><TD>Item 7</TD></TR><TR><TD>Item 10</TD><TD>Item
11</TD></TR></Table>"

The following codes can let the end user drag and drop a table into the
PowerPoint slide.

private void label1_MouseDown(object sender, MouseEventArgs e)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
string htmlFragment = "<Table><TR><TD>Item 6</TD><TD>Item
7</TD></TR><TR><TD>Item 10</TD><TD>Item 11</TD></TR></Table>";
// Builds the CF_HTML header. See format specification here:
//
http://msdn.microsoft.com/library/default.asp?url=/workshop/networking/clipb
oard/htmlclipboard.asp

// The string contains index references to other spots in the
string, so we need placeholders so we can compute the offsets.
// The <<<<<<<_ strings are just placeholders. We'll backpatch
them actual values afterwards.
// The string layout (<<<) also ensures that it can't appear in
the body of the html because the <
// character must be escaped.
string header =
@"Format:HTML Format
Version:1.0
StartHTML:<<<<<<<1
EndHTML:<<<<<<<2
StartFragment:<<<<<<<3
EndFragment:<<<<<<<4
StartSelection:<<<<<<<3
EndSelection:<<<<<<<3
";

string pre =
@"<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0
Transitional//EN"">
<HTML><HEAD></HEAD><BODY><!--StartFragment-->";

string post = @"<!--EndFragment--></BODY></HTML>";

sb.Append(header);
int startHTML = sb.Length;

sb.Append(pre);
int fragmentStart = sb.Length;

sb.Append(htmlFragment);
int fragmentEnd = sb.Length;

sb.Append(post);
int endHTML = sb.Length;

// Backpatch offsets
sb.Replace("<<<<<<<1", To8DigitString(startHTML));
sb.Replace("<<<<<<<2", To8DigitString(endHTML));
sb.Replace("<<<<<<<3", To8DigitString(fragmentStart));
sb.Replace("<<<<<<<4", To8DigitString(fragmentEnd));
Clipboard.Clear();
Clipboard.SetText(sb.ToString(), TextDataFormat.Html);

if (e.Button == MouseButtons.Left)
{
this.DoDragDrop(new
DataObject(DataFormats.Html,sb.ToString()), DragDropEffects.Copy);


Globals.ThisAddIn.Application.ActiveWindow.Selection.ShapeRange.Top = 20;

Globals.ThisAddIn.Application.ActiveWindow.Selection.ShapeRange.Left = 20;
}

And now, I can see your problem, but not exactly same with yours. In my
side, when dragging and dropping, the dropped table always goes to the
center of the slide instead of the upper left corner. Is this the problem
you are concerning now?

I find that we can set the ShapeRange's location by setting the Top and
Left property as in the above codes. But it seems a difficult thing to get
the PowerPoint coordinate from the caret cursor location. I am doing some
more research on this and will update to you as soon as I found an approach.

Have a good day!

Best regards,
Ji Zhou ([email protected], remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/default.aspx?target=assistance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
D

David Thielen

J

\Ji Zhou [MSFT]\

Hello Dave,

Setting the Left and Top can move the shape to a specified location
according to the slide. But after some future investigation, I think this
way is also blocked because it is indeed an impossible thing to convert the
screen coordinate to the PowerPoint coordinate. I am now trying to consult
in some internal powerpoint discussion groups to see if anyone else have
some other ideas on this. I will get back to you as soon as if I get new
found.

Thank you!

Best regards,
Ji Zhou ([email protected], remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
 
D

David Thielen

thank you very much. I look forward to getting this - being able to
drop tables into PPT will be very cool.

thanks - dave


Hello Dave,

Setting the Left and Top can move the shape to a specified location
according to the slide. But after some future investigation, I think this
way is also blocked because it is indeed an impossible thing to convert the
screen coordinate to the PowerPoint coordinate. I am now trying to consult
in some internal powerpoint discussion groups to see if anyone else have
some other ideas on this. I will get back to you as soon as if I get new
found.

Thank you!

Best regards,
Ji Zhou ([email protected], remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.


david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 
D

David Thielen

Any info yet?

thanks - dave


Hello Dave,

Setting the Left and Top can move the shape to a specified location
according to the slide. But after some future investigation, I think this
way is also blocked because it is indeed an impossible thing to convert the
screen coordinate to the PowerPoint coordinate. I am now trying to consult
in some internal powerpoint discussion groups to see if anyone else have
some other ideas on this. I will get back to you as soon as if I get new
found.

Thank you!

Best regards,
Ji Zhou ([email protected], remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.


david@[email protected]
Windward Reports -- http://www.WindwardReports.com
me -- http://dave.thielen.com

Cubicle Wars - http://www.windwardreports.com/film.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top