Changing page size, unexpected behavior, CC
Hi, having an issue with transformations after changing the page. In a nut shell if I get the pasteboard transformation of PMPoint(0,0) before a page size change the result is exactly as expected, the page origin in the pasteboard. After I change the page size using kSetPageSetupPrefsCmdBoss and run the same tranformation the retuned value is the same as before changing the page size.
Below is some quick code and output to illustrate. PageSizing:;DoYourThing() get called and does the intial transformation, prints the output in InspectTransformation(), then calls ChangePageSize() and recalls InspectTransformation().
void PageSizing::DoYourThing()
{
IDocument* theFrontDoc = Utils<ILayoutUIUtils>()->GetFrontDocument();
if (theFrontDoc == nil) { cout << "Need a doc." << endl; return; }
fDoc = theFrontDoc;
GetPageSpreadRefs(1); // Get the UIDRef of 1st apge and spread
if (fPageRef == UIDRef::gNull) { cout << "Invalid page UIDRef." << endl; return; }
if (fSpreadRef == UIDRef::gNull) { cout << "Invalid spread UIDRef." << endl; return; }
cout << "Before Page Size Change." << endl;
InspectTranforms();
bool16 sizeChangeResult = ChangePageSize();
if (sizeChangeResult) {
cout << "After Page Size Change." << endl;
InspectTranforms();
}
}
void PageSizing::InspectTranforms()
{
do {
PMPoint leftTopPage(0, 0); // Page coords
InterfacePtr<IGeometry> pageGeo(fPageRef, UseDefaultIID());
PMMatrix page2Pb = ::InnerToPasteboardMatrix(pageGeo);
PMRect pageBoundsInPasteboard = pageGeo->GetStrokeBoundingBox(page2Pb);
PMPoint pageOriginInPasteboard = pageBoundsInPasteboard.LeftTop();
Helper::PrintPoint(pageOriginInPasteboard, "Page origin in paste board.");
InterfacePtr<ITransform> pageTransform(fPageRef, UseDefaultIID());
PMPoint leftTopInPasteboard = leftTopPage;
::TransformInnerPointToPasteboard(pageTransform, &leftTopInPasteboard);
Helper::PrintPoint(leftTopInPasteboard, "Transformed point (0,0) in pasteboard coords.");
} while (kFalse);
}
bool16 PageSizing::ChangePageSize()
{
bool16 retval = kFalse;
do {
InterfacePtr<IPageSetupPrefs> docPrefs(fDoc->GetDocWorkSpace(), UseDefaultIID());
if (docPrefs == nil) { cout << "Nil IPageSetupPrefs" << endl; break; }
InterfacePtr<ICommand> pageSizeCmd(CmdUtils::CreateCommand(kSetPageSetupPrefsCmdBoss));
if (pageSizeCmd == nil) { cout << "Nil command" << endl; break; }
InterfacePtr<IDocSetupCmdData> cmdData(pageSizeCmd, IID_IDOCSETUPCMDDATA);
if (cmdData == nil) { cout << "Nil command data" << endl; break; }
PMPageSize currPgSz = docPrefs->GetPageSizePref(); // 612, 792
PMPageSize newPgSz(currPgSz.OutputWidth() + 50, currPgSz.OutputHeight() + 50);
DocPageBinding binding = Utils<ILayoutUtils>()->GetDocumentPageBinding(::GetUIDRef(fDoc));
cmdData->SetDocSetupCmdData( ::GetUIDRef(fDoc),
newPgSz,
docPrefs->GetNumPagesPref(),
docPrefs->GetPagesPerSpreadPref(),
docPrefs->GetWideOrientationPref(),
binding);
ErrorCode ec = CmdUtils::ProcessCommand(pageSizeCmd);
retval = (ec == kSuccess);
if (! retval) { cout << "Resize page command failed." << endl; }
} while (kFalse);
return retval;
}
The output

As you can see the page origin is different after the page size command but the transform returns the same value for 0,0.
Am I missing something on the transformations or the page size command?
Thanks for any help. Mike