Skip to main content
Inspiring
July 14, 2014
Answered

How to change pasteboard size

  • July 14, 2014
  • 1 reply
  • 3216 views

I'm trying to change the size of the pasteboard in code, in the same way that a user would change it via Guides and Pasteboard Preferences.

The code I have at the moment seems to change the values displayed in the preferences dialog for "Horizontal margins" and "Vertical margins", but doesn't actually change the visible pasteboard.

Any ideas on what I'm doing wrong?

IDocument* doc = Utils<ILayoutUIUtils>()->GetFrontDocument();

InterfacePtr<IPasteboardPrefs> pasteboardPrefs(static_cast<IPasteboardPrefs>(::QueryPreferences(IID_IPASTEBOARDPREFERENCES, doc)));

pasteboardPrefs->SetPasteboardBorder(newXVal, newYVal);

I've also tried an "apply" command I found, in follow up to the above code, but it made no difference:

InterfacePtr<ICommand> setPasteboardCmd(CmdUtils::CreateCommand(kSetPasteboardPrefsCmdBoss));

if (setPasteboardCmd) {

    CmdUtils::ProcessCommand(setPasteboardCmd);

}


Thanks in advance

This topic has been closed for replies.
Correct answer Bartek_Kropaczewski

Hi

I haven't checked that first example but definatelly you're missing pointer to IPastebordPrefs, coz you cannot cast IPasteboardPrefs to InterfacePtr (should be IPasteboardPrefs*)

Using command should works fine. You need to remember to pass new point and UIDRef of the edited document

        InterfacePtr<ICommand> setPasteboardCmd(CmdUtils::CreateCommand(kSetPasteboardPrefsCmdBoss));

        InterfacePtr<IPMPointData> thePointData(setPasteboardCmd, UseDefaultIID());

        InterfacePtr<IUIDData> theUIDData(setPasteboardCmd, UseDefaultIID());

          thePointData-Set(newPoint);

          theUIDData-Set(::GetUIDRef(iYourDoc));

     CmdUtils::ProcessCommand(setPasteboardCmd);

Regards

Bartek

1 reply

Bartek_Kropaczewski
Bartek_KropaczewskiCorrect answer
Inspiring
July 14, 2014

Hi

I haven't checked that first example but definatelly you're missing pointer to IPastebordPrefs, coz you cannot cast IPasteboardPrefs to InterfacePtr (should be IPasteboardPrefs*)

Using command should works fine. You need to remember to pass new point and UIDRef of the edited document

        InterfacePtr<ICommand> setPasteboardCmd(CmdUtils::CreateCommand(kSetPasteboardPrefsCmdBoss));

        InterfacePtr<IPMPointData> thePointData(setPasteboardCmd, UseDefaultIID());

        InterfacePtr<IUIDData> theUIDData(setPasteboardCmd, UseDefaultIID());

          thePointData-Set(newPoint);

          theUIDData-Set(::GetUIDRef(iYourDoc));

     CmdUtils::ProcessCommand(setPasteboardCmd);

Regards

Bartek

LizWAuthor
Inspiring
July 15, 2014

Thanks, that's working. Strangely, I have the pointer you mentioned in my code, but it didn't copy through... I may have deleted by mistake.

Do you know if there's any documentation / comments / samples etc that would have let me know what data this command expects? i.e. the IPMPointData and the IUIDData?

I couldn't find any clues as to it's usage, hence posting here. Would be handy to know if I missed some key information so I can work it out myself next time!

Thanks

Liz

Bartek_Kropaczewski
Inspiring
July 15, 2014

Sure.

As I wrote IUIDData need UIDRef of the document pointer

     InterfacePtr<IDocument> iDoc(Utils<ILayoutUIUtils>()->GetFrontDocument(), UseDefaultIID());

     InterfacePtr<IUIDData> theUIDData(setPasteboardCmd, UseDefaultIID());

     theUIDData->Set(::GetUIDRef(iDoc));


IPMPoint data is a distance from the outer edge of the page to the edge of the pasteboard. Distance in points.


     PMReal theXValue = 612.0; // distance from the right/left edge to the pasteboard

     PMReal theYValue = 81.0; // distance from the top/bottom edge to the pasteboard

     InterfacePtr<IPMPointData> thePointData(setPasteboardCmd, UseDefaultIID());

     thePointData->Set(PMPoint(theXValue, theYValue));


Unfortunatelly i don't know why the X value is equal -500 in new document. And i couldn't find any samples.

I have read only documentation of kSetPasteboardPrefsCmdBoss.


Regards

Bartek