Removing the image placeholder (picture) in Word using OpenXML - image

I have a Word file that I'm manipulating with OpenXML. I have nothing but a picture content control there and I have successfully added a picture ("content") into that picture content control.
Now everything is otherwise fine, but I don't have a slightest clue of how to remove the placeholder picture. That is, I have that "little icon with monitor, sun and mountain" there right in the middle of my inserted picture. You know, the icon that you see when you insert a picture content control. I can take the count of content controls thru VBA and it says there's exactly one, so there's not two controls on top of each other.
If I delete the target content control (with remove-method), the entire content control (including the correctly set picture) gets deleted.
Is there something like "placeholderimage.Hide"-method or something that I should use?
I set the content to the picture like this:
DocumentFormat.OpenXml.Drawing.Blip blip = targetpicturecontrol.Descendants<DocumentFormat.OpenXml.Drawing.Blip>().FirstOrDefault();
blip.Embed = mainPart.GetIdOfPart(imagePart);

This code hides (or removes, whatever) the place holder
private static void RemovePlaceHolder(SdtProperties targetproperties)
{
Appearance appearance = new Appearance();
appearance.Val = new EnumValue<SdtAppearance>();
SdtAppearance sdtAppearance = new SdtAppearance();
sdtAppearance = SdtAppearance.Hidden;
appearance.Val.Value = sdtAppearance;
targetproperties.AppendChild(appearance);
}

Related

Qtruby ListWidgetItem has blank icon after adding data

I am working on a GUI using qtruby. I have a ListWidget that I am filling with ListWidgetItems. So far these have just contained the text that I wanted to display and everything worked fine. I wanted these items to also hold some hidden data to use when they are clicked on. I used ListWidgetItem.setData() to set the data and I can get the data from it when it is clicked just fine. However once I add the data the text being displayed is now shifted over to the right about 4 spaces. When I click on it a little dotted box appears around the text but not the space that was added. It looks like it is a space for an icon but I have not set any icon and I don't want one. How do I get rid of this extra space so that items containing data are lined up with everything?
The code is very straight forward:
item = Qt::ListWidgetItem.new( #grain_strings[index] )
item.setFont( #font )
# TODO this is causing the text to be indented, removing it removes the indent
item.setData( 1, Qt::Variant.from_value( grain.type ) )
#item_list.insertItem( #end_of_grains+1, item )
The first argument to setData is the role number and for some reason you chose to set it to 1. The documentation says: "The data to be rendered as a decoration in the form of an icon. (QColor, QIcon or QPixmap)". So you are telling Qt to display an icon but you are not giving it a valid icon object.
Try setting the role to Qt::UserRole, which is "The first role that can be used for application-specific purposes." I am not sure how to access that constant from Ruby. If it is not provided by the qtruby gem, you could use 0x100 I suppose.

adding a default note to powerpoint

I want to modify powerpoint so that the notes section always contains a static text. specifically I want to add
<tags></tags>
to the notes section of every slide created. I was hoping for an easy way to to do this on the master slide, but so far Dr. Google hasn't shown me how. I tried just adding it to the Notes Master but that didn't work.
I'm open to programmatic solutions, but would rather have a settings based solution if it exists.
How do I add text to every slide's note section upon slide creation?
"notes section" could mean different things. If you want some text to appear on every notes PAGE, where it'll appear on all printed notes, you just need to add it to the notes master.
If you want it to appear in the notes text that's part of every notes page (and also appears in the notes pane beneath the slide in Normal view), I don't think it's possible, at least not w/o having an installed add-in.
I have researched this a lot as well, but there doesn't seem to be any way of adding predefined text to the Notes area under the slide in the Slide Master.
You can do it with a macro after the presentation is created. Instead of using "[tag]" & "[/tag]", you can use something easier to type like "/1" and "\1", then use the macro to find and replace your "numbered" tags with the text equivalents.
Something like this:
Dim aSlide as Slide
Dim noteShp as Shape
For each aSlide in ActivePresentation.Slides
For Each noteShp In aSlide.NotesPage.Shapes
If noteShp.PlaceholderFormat.Type = ppPlaceholderBody Then
If noteShp.HasTextFrame Then
If noteShp.TextFrame.HasText Then
noteShp.TextFrame.TextRange.Text = Replace(noteShp.TextFrame.TextRange.Text, "/1", "<tag>")
noteShp.TextFrame.TextRange.Text = Replace(noteShp.TextFrame.TextRange.Text, "\1", "<\tag>")
End if
End If
End If
End If
Next
Next
I am doing exactly the same thing as you are.
I use html style tags in the notes section (the area underneath the slide in Normal View) to organize information and automatically create supporting documentation for the presentation.
Right now, I am doing it by manually by pasting the tags into the Note area under each slide, but if anyone knows how to pre-populate the Note area each time a new slide is added (by modifying the Slide Master settings - not the Notes Master), that would be fantastic.
Looking forward to see if anyone has a solution to this!

Change the colour of WinJS.UI.BackButton (Win 8.1 back button)

I'm getting started with Windows 8 App development using WinJS. I'm using the Light UI theme but I have set up a darker area on the left of the page (where the black back button is) and the issue is: you can't see the button.
I've trawled through the MSDN pages and the most I could find is how to style a button which doesn't actually explain how to change the colour of an actual asset.
http://msdn.microsoft.com/en-us/library/windows/apps/jj835822.aspx
I've also tried adding: win-ui-light and win-ui-dark classes to the button with no success.
I wondered if someone could point me in the right direction?
Many thanks for your time
Chris
First of all you have to delete the link tag that contain UI css by default and add it to document head , Dynamically.see below code :
var uistyle;
// call when your app load or resume.
function onappopen(){
uistyle = document.createElement('link');
uistyle.href = "//Microsoft.WinJS.2.0/css/ui-dark.css";
uistyle.rel = "stylesheet";
uistyle.id = "UIstyle";
document.head.appendChild(uistyle);}
// call when you want to change UI Style.
function UIstyle(UIbool){
if(UIbool=='light'){ uistyle.href = "//Microsoft.WinJS.2.0/css/ui-light.css";}
else {uistyle.href = "//Microsoft.WinJS.2.0/css/ui-dark.css";}}
Like: UIstyle('light'); for light UI in Windows 8 or "UIstyle()" for dark;
I used the DOM Explorer to find the buttons default values and overwrite them. It was the child element that needed to be overwritten: .win-back

How to fix overlapping objects on the stage in AS3

I have a flash game where I have a picture designed to be the textbox for a prompt and textbox inside with the relevant text but the textbox is being hidden by the image. Anyone know how to make is so that the textbox is guaranteed to be on top or whatever I need to do to keep this from happening?
The other answer using setChildIndex will definitely work, however, I think a different design approach is really what you should be doing to remove the headache altogether.
For example in a game I might have different layers such as :
backgroundLayer
gameLayer
interfaceLayer
Those 3 Sprite layers would get added to the stage in that order. I would then add display objects to the appropriate layers. So anything I added to the backgroundLayer or gameLayer would ALWAYS be 'behind' my user interface on the interfaceLayer.
That allows you to not have to worry about the layering constantly. The answer with setChildIndex will fix the problem for that moment, but should something else be added to the container it will overlap your textbox, which is something I don't assume you want.
here's an example :
var backgroundLayer:Sprite = new Sprite;
var gameLayer:Sprite = new Sprite;
var interfaceLayer:Sprite = new Sprite;
addChild(backgroundLayer);
addChild(gameLayer);
addChild(interfaceLayer);
now, whatever you add to interfaceLayer, will ALWAYS be on top of objects you add to gameLayer or backgroundLayer.
So in the case of your text box, just add it to your interfaceLayer and any other objects you want behind it, you add to the gameLayer or backgroundLayer.
The order of adding display objects to display object containers effect their z-order, in other words the front to back order. The last added display object becomes the frontmost. So the child index of the children of a display object container is important for drawing of overlapped children.
If you put picture and text on the same DisplayObjectContainer such as a MovieClip:
Lets say your DisplayObjectContainer is mc.
And your textbox is txt
Please try this:
mc.setChildIndex(txt, mc.numChildren-1);

How do I let the user copy arbitrary text?

I have an app, where I generate text (about 500 characters), and I would like the user to have some means of copying that text for use outside of the application.
I don't want to use any capabilities for this app (like web, or contacts).
Here's what I've tried (and why it's failed)
TextBox. IsReadOnly = true; SelectAll();
Can't SelectAll a read only text box
Turn off read only, hide the SIP
Can't hide the SIP on a (non-read-only) TextBox that the user is interacting with (I want to enable the user to copy, so needs to interact with the control)
allow edits, show sip, SelectAll()
The "copy" icon doesn't appear unless the user chose to select text
On selection changed (actually changed), SelectAll()
The "copy" icon doesn't appear unless the user selected the text? The copy icon appears erratically, nothing I would call an acceptable user experience.
So at this point, I'm quite far from what I want in a user experience, and I still don't have anything that works. Any suggestions?
Some other possible ways to answer my question include:
"How do I force the copy button to appear above text I programatically selected?"
"How do I change the selection behavior of a tap in a text box?"
Afaik there are some limitations to the Windows Phone 7 Clipboard:
Works only in TextBox and can only copy text upon users wish
Text is only kept until device gets locked. If your device gets locked, the clipboard will be wiped clean
Even if you try Clipboard.SetText Method, you will notice the SecurityException if you call this method without the users interaction. This is to keep the users data under control so that no rogue app can copy unrecognized Text.
But you could try Matt Laceys WP7Clipboard. It saves the clipboard content inside an image and can even copy bitmaps.
Try restyling the textbox as per http://mobileworld.appamundi.com/blogs/peterfoot/archive/2011/02/08/copyable-textblock-for-windows-phone.aspx
Here's what I eventually got mostly working
private void Export(StackPanel stacker)
{
var exportHeader = new TextBlock();
exportHeader.Text = "Export";
stacker.Children.Add(exportHeader);
var exportBox = new TextBox();
stacker.Children.Add(exportBox);
//exportBox.IsReadOnly = true; // hides SIP, but causes an exception with SelectAll() (pre-Mango, I haven't tried on Mango yet)
exportBox.FontSize = 1;
exportBox.Text = textToExport;
exportBox.GotFocus += new System.Windows.RoutedEventHandler((send, ev) =>
{
((TextBox)send).SelectAll();
});
exportBox.Focus();
}
Apparently, making the font size 1 makes the difference here, maybe because all of the text can appear on the screen at once? Who knows.
I accepted this answer, because no one else posted a better solution. I would appreciate a better solution. If you can get the SIP to go away, that would be awesome.

Resources