Add layout empty presentation - openxml

I do not get the "addnewpart" methods. Should it be used just for the first document creation or just when I try to add a slide or slide layout?
Anyone knows how to add a new slidelayout? I could not findout on google, and I get the error :cannot add a new part to the parent...
I made a full presentation in Matlab using just XML, and I find openxml very, very frustrating :(

OK I found where to put it!
SlidelayoutPart is accepted in slidemasterpart.
`Pa.PresentationPart PresPart = this.PresentationDoc.AddPresentationPart();
PresPart.Presentation =new P.Presentation();
//add minimal info
this.AddBasic(PresPart);
//Generate Master
Pa.SlideMasterPart slideMasterPart = PresPart.AddNewPart<Pa.SlideMasterPart>("rId1");
GenerateMaster(slideMasterPart);
//Add slideLayout
Pa.SlideLayoutPart SlideLayoutTemp=slideMasterPart.AddNewPart<Pa.SlideLayoutPart>("rId1");
Pa.SlideLayoutPart SP=GenerateSlideLayout(SlideLayoutTemp, "Blank");
SP.AddPart(slideMasterPart); // don't forget to link the layout to the master!
//Add Theme
Pa.ThemePart themePart1 = slideMasterPart.AddNewPart<Pa.ThemePart>("rId5");
GenerateTheme(themePart1);
//Presentation
AddSlidePart(PresPart, "Blank")`

Related

How do I clear an element before rendering?

I have inherited an older project using jquery.
I am modernising the code.
In particular this $(selector).html("<h1>lol</h1>"); which as far as I understand is a full replacement of the selectors content.
I always end up with an error if I try to render to a cleared element.
This code:
const appDiv: HTMLElement = document.getElementById('app');
appDiv.innerHTML = `<h1>TypeScript Starter</h1>`;
// trying to replace jquery $(selector).html("<h1>lol</h1>");
appDiv.innerHTML = '';
render(html`<h1>lol</h1>`, appDiv);
appDiv.innerHTML = '';
render(html`<h1>lol</h1>`, appDiv);
Or see my stackblitz
I always get the following error:
Error in lit-html.js (93:55)
Cannot read properties of null (reading 'insertBefore')
Do you know what I am missing? 🧐
Thanks!
Note: This is a duplicate of my question (and based on a suggested technique) from a closed Lit Github Issue
Note: Maybe I am talking rubbish. I can't find a clear answer if render REPLACES content or APPENDS content. A concrete answer on that would be fine!
Lit v1 will clear the container before rendering the first time. Lit v2 will not.
Only clear the existing container content once before using render. After that render will correctly update content from previous render calls.
const appDiv: HTMLElement = document.getElementById('app');
appDiv.innerHTML = `<h1>TypeScript Starter</h1>`;
// trying to replace jquery $(selector).html("<h1>lol</h1>");
appDiv.innerHTML = '';
render(html`<h1>lol</h1>`, appDiv);
render(html`<h1>lol2</h1>`, appDiv);

trying to access Thunderbird-tabmail does not work

I want to open a new tab with a gloda conversation from inside calendar code.
I receive an error from error console:
window not defined (or document not defined), depending on which of the two I use to Access tabmail:
let tabmail = window.document.getElementById("tabmail");
let tabmail = document.getElementById("tabmail");
The code works fine if the js file is included in an overlay xul-file.
But I want to use it outside of xul in my code.
Somewhere in my calendar code (in my 'addevent'), the same code throws the error.
This code is originally called from a rightclick on an email, but several layers deep into calendar code.
In MDN, I read that window is global? So what do I Need to do to add an tab?
This part works if tabmail is properly referenced:
tabmail.openTab("glodaList", {
collection: queryCollection,
message: aCollection.items[0],
title: tabTitle,
background: false
});
So how do I get a reference for tabmail?
Any help is appreciated.
after trying and looking through code for really some time before posting, it took only ca. 20 minutes to accidentally find the solution after submitting the question..
While browsing mailutils on mxr for something else, I found the solution in some function:
mail3PaneWindow = Services.wm.getMostRecentWindow("mail:3pane");
if (mail3PaneWindow) var tabmail = mail3PaneWindow.document.getElementById("tabmail");

Keeping track of text position on pdf using FPDF and GetY

I am trying to keep track of the current Y position on a PDF page created using FPDF so that I can correctly start a new page ensuring tables do not cross a page break. Firstly am I right in using GetY to monitor this and if so what is the correct syntax. I am trying
$currentYposition = GetY();
but it does not seem to work. Any advice?
No idea why this works - but it does:
If you just grab Y after the call, it seems to be the value before the MultiCell.
Grabbing it before and after and taking the difference gives you the height.
$oldY = $this->getY();
$this->MultiCell(150, 4, utf8_decode($description), 0, "L");
$newY = $this->getY();
$multiCellHeight = $newY-$oldY;
This one worked for me.
$y = $pdf->GetY();
I came to this question when programming in python and using the fpdf module. I'll post in case anyone else need this, I could not find this solution in the official documentation but for me following worked:
from fpdf import FPDF
pdf = FPDF()
pdf.add_page()
current_y = FPDF.get_y(pdf)

CQ5.5: getting Style of a target page

I've been working on this for sometime now, and I keep running into a wall. I think I'm close, but I figured someone out here in the land of SO might have some deeper insight if not a better way of doing what I'm trying to do.
Basically lets look at this scenario. I have a logo w/ some text that can be set from a few different places. If we look at the setup here is what it looks like.
Hiearchy:
Homepage [has designPath]
- Child Microsite Page [has designPath]
- Logo Component
Logic Flow (in logo component):
if properties.get("logoText") {
use this
} else if currentStyle.get("logoTextFromStyle") {
use this
} else if parentStyle.get("logoTextFromGlobal") {
use this
} else {
be blank
}
My query is with how to get the "parentStyle" of this page. Looking at the docs here: http://dev.day.com/docs/en/cq/5-5/javadoc/com/day/cq/wcm/api/designer/Style.html
I've been able to come up with the fact that I can get a Style object from the "designer" object made available via defineObjects. This is defined with the other utility objects like "pageManager, resourceUtil, resource, currentPage, etc".
With that being said this doesn't seem to work.
//assuming we have getting homePage earlier and it is a valid cq Page resource
Resource homePageResource.slingRequest.getResourceResolver().getResource(homePage.getPath());
Style homePageStyle = designer.getStyle(homePageResource);
at this point homePageStyle is null. To do some more testing I i tried passing currentPage.getPath() instead of homePage.getPath(). I assumed this would give me the currentPage resource and would in end yield the currentStyle object. This also resulted in a null Style object. From this I think I can safely conclude I'm passing the incorrect resource type.
I attempted to load the the cq:designPath into the resource hoping to get a Designer resourceType but to no avail.
I am curious if anyone has run into this problem before. I apologize if I've gone into too much detail, but I wanted to lay out the "why" to my question as well, just in case there was a better way overall of accomplishing this.
I've figured out how to return the style. Here is the rundown of what I did.
//get your page object
Page targetPage = pageManager.getPage("/path/to/target");
//get the Design object of the target page
Design homePageDesign = designer.getDesign(homePage);
//extract the style from the design using the design path
Style homePageStyle = homePageDesign.getStyle(homePageDesign.getPath());
it's very interesting the definition of "getStyle" is a little different from the designer.getStyle vs a Design.getStyle. designer.getStyle asks for a resource whereas Design.getStyle will take the path to a Design "cell" and return the appropriate Style.
I did some testing and it looks like it does work with inherited Styles/Designs. So if my cq:designPath is set at level 1 and I look up a page on at level 2 they will return the Design/Style at the cq:designPath set at level 1.
I hope this helps someone else down the way.
I tried this approach but was not getting the Styles in the Style object.
When we do this:
Design homePageDesign = designer.getDesign(homePage);
In this Design object we get the path till the project node i.e etc/design/myproject
After this if we try to extract the Style from the design path we do not get it.
However I implemented it in a different way.
In the design object, we also get the complete JSON of designs for(etc/design/myproject).
Get the sling:resourceType of the target page and get the value after last index of "/".
Check if this JSON contains the last value. If it contains, you can get your styles, i.e. image, etc.

Launching a custom view from a custom model. Zend_possible?

You have to promise not to giggle, but my situation is following:
Instead of using partials and helpers and other similar tools that we use already, we want to use a custom view outside all frames and borders of the actual application. Basically, we need at this point to load clean HTML into a variable upon a certain reaction a model. That is monkeys business and can be done by virtually anyone without using a keyboard.
The problem is that the HTML pages that we want to create are supposed to be quite extensive and are a trainwreck to debug/maintain/expand due to the inate "return $arrlglllgll;" approach. To make a smooth and humane script, we would very much love to use the .phtml style with clean html mixed up with php injections without actually rendering it.
Is that possible and how?
I am currently struggling with
$mailView = new Zend_View();
$mailView->setScriptPath('/Templates');
echo($mailView->render('test.php'));
die;
Where test.php is a file I have been trying to reach with any means and corelations imaginable, but ultimately failed every time due to
exception 'Zend_View_Exception' with message 'script 'test.php' not found in path (\library\Extras\Controller\Action\Helpers\)' in \library\Zend\View\Abstract.php:875
Stack trace: blablabla
Loading a custom view from a controller is butt-easy, just provide the relative path and you're set, but it seems that I cannot find anything if I shoot from within a library. Any advice?
In case anybody wonders, this is a lot easier than I ever thought it to be...
// Set the view
$layout = new Zend_Layout();
$view = $layout->getView();
// Send inherited custom parameters
$view->params = $params;
You can thus use the $view as a real view and load any $view->helper as you please.
To save rendered view, type...
$savingParameter = $view->render('controller/subfolder/' . $page . '.phtml');
TADAA