in my Power Point add-in I am loading .svg file within slide using this code
Slide activeSlide = Globals.ThisAddIn.Application.ActiveWindow.View.Slide;
PowerPoint.Shape ppPicture = activeSlide.Shapes.AddPicture(testImageUrl, MsoTriState.msoTrue, MsoTriState.msoTrue, 0, 0);
ppPicture.LinkFormat.SourceFullName = testImageUrl;
then I need to ungroup this file, like it happens when clicking mouse right button and selecting menu point "Convert to Shape".
ppPicture.Ungroup();
throws System.UnauthorizedAccessException: 'This member can only be accessed for a group.'
So how can I do it ?
Related
On the Column Visibility example on https://vaadin.com/docs/latest/ds/components/grid/#column-visibility the code shows a class ColumnToggleContextMenu which isn't part of the Vaadin API however it seems to somehow adjust how the button is hooked so that it can be left clicked rather than the default right click for a context menu. With that in mind the code below will only show the context menu on a right click, I cannot get it to work like the example code. My code is:
Button showHideColumnsButton = new Button("Show/Hide Columns");
showHideColumnsButton.addThemeVariants(ButtonVariant.LUMO_TERTIARY);
ContextMenu contextMenu = new ContextMenu(showHideColumnsButton);
for(Grid.Column column : grid.getColumns()) {
contextMenu.addItem(getColumnName(column), e -> showHideColumn(column));
}
I'm considering using a MenuBar instead to see if that will work but I'd prefer to figure out how to use a Button if possible as that seems more appropriate (mainly because it allows the checkbox to show if a column is visible or hidden).
In order to make the context menu to open on left click use setOpenOnClick(true):
Button showHideColumnsButton = new Button("Show/Hide Columns");
showHideColumnsButton.addThemeVariants(ButtonVariant.LUMO_TERTIARY);
ContextMenu contextMenu = new ContextMenu(showHideColumnsButton);
contextMenu.setOpenOnClick(true)
for(Grid.Column column : grid.getColumns()) {
contextMenu.addItem(getColumnName(column), e -> showHideColumn(column));
}
I am trying to make an image picker component in LibreOffice.
I have a dialog that is dynamically filled with images. When the user clicks on one images, it should be selected and the dialog should be closed.
The problem is that the number of images is variable. So I need to enable scrolling in the dialog (so that the user can navigate through all images).
There seems to be some properties on the dialog object (Scrollbars, Scroll width, Scroll height, etc)
However, I cannot find a way to use them anywhere.
Any ideas?
The scrollbar is one of the Controls available through the dialog box editor. That is the easier way to put a ScrollBar on a dialog box. Just insert it like any other control. There is a harder way via DialogModel.addControl but that seems non-essential to answering this question.
If you add a scrollbar to the dialog box and run the dialog box, you will find it does nothing by default. The functionality (apparently) must be written into a macro. The appropriate triggering event is the While Adjusting event on the ScrollBar object, although it does not trigger the macro simply with the "Test Mode" function in the dialog editor. Running the dialog box through a macro triggers the While Adjusting event when the scroll arrows are triggered, when the slider area is clicked to move the slider, and when the slider itself is dragged. The Object variable returned by the scrollbar event contains a property .Value which is an absolute value between 0 and the EventObject.Model.ScrollValueMax, which allows you to manipulate the other objects on the page manually based on the position of the slider.
Yes, that's right, manipulate objects manually. The sole example I found, from the LibreOffice 4.5 SDK, does precisely this. Of course, it is not as bad as it sounds, because one can iterate through all of the objects on the page by reading the array Dialog.getControls(). In any event, the secret sauce of the example provided in the SDK is to define Static variables to save the initial positions of all of the objects you manipulate with the scrollbar and then simply index those initial positions based on a ratio derived from the scrollbar Value divided by the ScrollValueMax.
Here is a very simple working example of how to scroll. This requires a saved Dialog1 in the Standard library of your document, which contains an object ScrollBar1 (a vertical scrollbar) and Label1 anywhere in the dialog. The ScrollBar1 must be configured to execute the macro ScrBar subroutine (below) on the While Adjusting event. Open the dialog by executing the OpenDialog macro and the scrollbar will move the Label1 control up and down in proportion to the page.
Sub OpenDialog
DialogLibraries.LoadLibrary("Standard")
oVariable = DialogLibraries.Standard.Dialog1
oDialog1 = CreateUnoDialog( oVariable )
oDialog1.Execute()
End Sub
Sub ScrBar (oEventObj As Object)
Static bInit As Boolean
Static PositionLbl1Y0 As Long
oSrc = oEventObj.Source
oSrcModel = oSrc.Model
scrollRatio = oEventObj.Value / oSrcModel.ScrollValueMax
oContx = oSrc.Context
oContxModl = oContx.Model
oLbl1 = oContx.getControl("Label1")
oLbl1Model = oLbl1.Model
REM on initialization remember the position of the label
If bInit = False Then
bInit = True
PositionLbl1Y0 = oLbl1Model.PositionY
End If
oLbl1Model.PositionY = PositionLbl1Y0 - (scrollRatio * oContx.Size.Height)
End Sub
The example provided by the SDK does not run on my setup, but the principles are sound.
There appears to be a second improvised method closer to the functionality one might expect. This method uses the DialogModel.scrollTop property. The property appears to iterate the entire box up or down as a scroll based on the user input. There are two problems using this methodology, however. First, unless you put the scrollbar somewhere else, the scroll bar will scroll away along with the rest of the page. You will need to adjust the location of the scrollbar precisely to compensate for/negate the scrolling of the entire page. In the example below I tried but did not perfect this. Second, the property seems to miss inputs with frequency and easily goes out of alignment/ enters a maladjusted state. Perhaps you can overcome these limitations. Here is the example, relying on the same setup described above.
Sub ScrBar (oEventObj As Object)
Static scrollPos
oSrc = oEventObj.Source
oSrcModel = oSrc.Model
scrollRatio = oEventObj.Value / oSrcModel.ScrollValueMax
If IsEmpty(scrollPos) = False Then
scrollDiff = oEventObj.Value - scrollPos
Else
scrollDiff = oEventObj.Value
End If
scrollPos = oEventObj.Value
oContx = oSrc.Context
oContxModl = oContx.Model
oContxModl.scrollTop = scrollDiff * -1
oSrcModel.PositionY=(scrollRatio * oContx.Size.Height/5) * -1
End Sub
This (sort of) will scroll the contents of the entire dialog box, within limits and with the caveats noted above.
I have a simple custom cursor code that loads a cursor from my Content folder to a Texutre2D, and then simply draws it on Draw. How can I program the image to change when I hold right click and then switch back to default when I release right click?
You have to load both your textures in two Texture2D variables, then simply check in your Update the state of the right button.
if (mouse.RightButton == ButtonState.Pressed)
cursorTexture = pressedTexture;
else
cursorTexture = releasedTexture;
Of course, cursorTexture is the one you have to draw.
I am creating sidebar images with the help of TRzGroup. I already have created TRzGroup with caption Print Now and added item named Print to it. I am planning to add a small printer icon image at the left hand side of the menu item as shown in figure at bottom. How it can be done ?
object RzGroup2: TRzGroup
Items = <
item
Caption = 'Print'
ImageIndex = 4
OnClick = RzGroup2Items0Click
end>
Opened = True
OpenedHeight = 47
DividerVisible = False
SmallImages = ImageList1
Special = True
Caption = 'Print Now'
ParentColor = False
end
While this code is extracted from somewhere in the code SmallImage attribute is assigned to ImageList1. I assume it is for image menu. I checked at object inspector there is SmallImages property but not sure how to create ImageList1 and assign to SmallImages.
Drop a TImageList from the Delphi component palette (Win32 page) onto your form (or in a data module used by the form). Double-click that new TImageList, click the Add button on the ImageList Editor that appears, and add images. Close the `ImageList Editor'.
Go back to your form. Click on the RzGroup2 item, and drop down the list in the Object Inspector for the SmallImages property, and choose the imagelist you added in the first step.
Set the ImageIndex of the Print item to the appropriate index in the ImageList you assigned to the RzGroup in the previous step.
I have a tree control that implements drag and drop. I use an overridden OnStartDrag() to get my own TDragObjectEx that shows an image while dragging. This works perfectly within the tree control, but as soon as I leave the tree control the image disappears. The cursor stays though.
I tried implementing OnDragOver, to reset the image but that does not appear to work.
Any hints on this? I am using C++ builder 2010, but delphi would do the same thing.
Update:
Found setting csDisplayDragImage on each control in the form controls, and in form itself solves this issue. Is there some automated way to have csDisplayDragImage set in an entire form rather than have to set it manually in Create for each item?
void __fastcall TForm1::FormCreate(TObject *Sender)
{
ControlStyle << csDisplayDragImage;
RMU->ControlStyle << csDisplayDragImage;
Button1->ControlStyle << csDisplayDragImage;
}
If I remember correct, you have to include the [csDisplayDragImage] flag in the "ControlStyle" of controls of which you want drag images to be seen when sth. is being dragged over them..
Update: setting "AlwaysShowDragImages" of the DragObject causes the drag image to be displayed all across the desktop.
Evidently, each control that's going to display the drag image needs to have the csDisplayDragImage control style set. You can add that flag to a control and all its chilren with a simple function:
void AddDisplayDragImageStyle(TControl* ctl)
{
ctl->ControlStyle << csDisplayDragImage;
TWinControl* win = dynamic_cast<TWinControl*>(ctl);
if (win)
for (int i = 0; i < win->ControlCount; ++i)
AddDisplayDragImageStyle(win->Controls[i]);
}
Have the form call that on itself: AddDisplayDragImageStyle(this).