Copy link to clipboard
Copied
Hi everyone,
I was autoflowing an overset page item programmatically, but noticed that autoflowing doesn't apply the ObjectStyle of the overset page item.
So I thought I'd iterate through all the boxes created by AutoFlow and give them an object name and style.
On the name no problem, but as regards the object style I have some problems.
I have no idea how to get and how to give a box an object style.
I've tried something like this, but was unsuccessful.
InterfacePtr<ICommand> applyObjectStyleCmd(CmdUtils::CreateCommand(kApplyObjectStyleCmdBoss));
if(!applyObjectStyleCmd)
break;
applyObjectStyleCmd->SetItemList(listOfPageItemToApplyObjectStyle);
InterfacePtr<IUIDData> UIDData(applyObjectStyleCmd, UseDefaultIID());
if(!UIDData)
break;
UIDData->Set(DATABASE, UIDStyle);
if(CmdUtils::ProcessCommand(applyObjectStyleCmd) != kSuccess)
break;listOfPageItemToApplyObjectStyle --> rapresent all the page item created by autoflow
UIDStyle --> rapresent the style that i want to appy to boxes, I set it simply by looking for it by name, but I would like the page item to be overset
Stefano
This is my solution:
/// GET Object Style from pageItemA and SET to pageItemB
ErrorCode function(UIDRef pageItem_A, UIDRef pageItem_B)
{
ErrorCode result = kFailure;
do
{
// ----- GET OBJECT STYLE -----
InterfacePtr<IGraphicFrameData> graphicFrameData_A(pageItem_A, UseDefaultIID());
if(!graphicFrameData_A)
break;
/// UIDStyle Of pageItemA
InterfacePtr<IPersistUIDData> persistUIDData(graphicFrameData_A, IID_IPERSISTOBJE...
Copy link to clipboard
Copied
This is my solution:
/// GET Object Style from pageItemA and SET to pageItemB
ErrorCode function(UIDRef pageItem_A, UIDRef pageItem_B)
{
ErrorCode result = kFailure;
do
{
// ----- GET OBJECT STYLE -----
InterfacePtr<IGraphicFrameData> graphicFrameData_A(pageItem_A, UseDefaultIID());
if(!graphicFrameData_A)
break;
/// UIDStyle Of pageItemA
InterfacePtr<IPersistUIDData> persistUIDData(graphicFrameData_A, IID_IPERSISTOBJECTSTYLEDATA);
if(!persistUIDData)
break;
UID UIDStyle = persistUIDData->GetUID();
if(UIDStyle == kInvalidUID)
break;
// ----- SET OBJECT STYLE -----
InterfacePtr<IGraphicFrameData> graphicFrameData_B(pageItem_B, UseDefaultIID());
if(!graphicFrameData_B)
break;
/// UIDListOfPageItemToApplyObjStyle: List fill of UID of PageItem belonging to kSplineItemBoss, otherwise ApplyObjectStyleToUIDList don't apply the ObjectStyle
UIDList UIDListOfPageItemToApplyObjStyle;
UIDListOfPageItemToApplyObjStyle.push_back(GetUID(graphicFrameData_B));
/// I haven't clue of how use categoriesToOverride, so i left it empty and it works anyway
K2Vector<ClassID> categoriesToOverride;
categoriesToOverride.push_back(kInvalidClass);
result = Utils<Facade::IObjectStylesFacade>()->ApplyObjectStyleToUIDList(UIDListOfPageItemToApplyObjStyle, CONTEXT->GetContextWorkspace(), UIDStyle, categoriesToOverride, false);
}while(false);
return result;
}
If anyone has more elegant solutions feel free to share it.
Stefano
Copy link to clipboard
Copied
edit
Find more inspiration, events, and resources on the new Adobe Community
Explore Now