//----------------------------------------------------------------------------------------
// FetchAdsFileFromPath
//----------------------------------------------------------------------------------------
bool
ZMFileUtils::FetchAdsFileFromPath(
	const PMString&						parentPath,
	ZMPMStringSList &					oAdsList,
	const PMString&						inFilePrefix) const
{
	LogFunctionEnterExit;
	
	IZPLog_Str_( thisFileLA, enLT_DebugInfo, "From path : %s", parentPath.GrabCString());
	SDKFileHelper fileHelper(parentPath);
	IDFile fileId = fileHelper.GetIDFile();
	PlatformFileSystemIterator iter;
	if(!iter.IsDirectory(fileId))
		return false;

	iter.SetStartingPath(fileId);

	Utils<IZMAdFileFacade> adFileUtil;
	bool result = false;
	IDFile xmlIdFile;

	PMString filter(inFilePrefix);
	filter.Append("*.xml");
	filter.InsertW(FileUtils::GetDirectorySeperator(), 0);
	IZPLog_Str_( thisFileLA, enLT_DebugInfo, "File filter : %s", filter.GrabCString());

	bool16 hasNext = iter.FindFirstFile(xmlIdFile, filter);

	while(hasNext) {
		SDKFileHelper xmlFileHelper(xmlIdFile);
		
		PMString xmlFileName = xmlIdFile.GetFileName();
		if(ValidPath(xmlFileName))
		{
#ifdef MACINTOSH
			PMString extStr(".xml");
			extStr.SetTranslatable(kFalse);
			if (! VerifyPrefixAndSuffix(xmlFileName, inFilePrefix, extStr))
			{
				hasNext= iter.FindNextFile(xmlIdFile);
				continue;
			}
#endif
			
			PMString xmlFullPath (parentPath);
			xmlFullPath.Append(FileUtils::GetDirectorySeperator());
			xmlFullPath.Append(xmlFileName);

			if (adFileUtil->CanBeValidXMLFile(xmlFullPath))
			{
				oAdsList.push_back(new PMString(xmlIdFile.GetFileName()));
				result = true;
			}
		}

		hasNext= iter.FindNextFile(xmlIdFile);
	}

	return result;
}
示例#2
0
//----------------------------------------------------------------------------------------
// MakeAdID
//----------------------------------------------------------------------------------------
PMString
IZMAdMgr::MakeAdID(
	const PMString &				inAdFileID,
	const PMString &				inAdID)
{
	PMString adID = inAdFileID;
	adID.Append( FileUtils::GetDirectorySeperator());
	adID.Append( inAdID);
	return adID;
}
//----------------------------------------------------------------------------------------
// FetchEditionsFromPath
//----------------------------------------------------------------------------------------
bool
ZMFileUtils::FetchEditionsFromPath(
	const PMString&						parentPath,
	ZMstEditionSList &					oEditionList) const
{
	LogFunctionEnterExit;
	
	IZPLog_Str_( thisFileLA, enLT_DebugInfo, "From path : %s", parentPath.GrabCString());
	SDKFileHelper fileHelper(parentPath);
	IDFile fileId = fileHelper.GetIDFile();
	PlatformFileSystemIterator iter;
	if(!iter.IsDirectory(fileId))
		return false;

	InterfacePtr<const IWorkspace> iWorkspace(gSession->QueryWorkspace());
	InterfacePtr<const IZMPrefs> workspacePrefs( iWorkspace, UseDefaultIID() );
	ASSERT( workspacePrefs );
	
	const PMString & filePrefixName = workspacePrefs->GetAdFileNamePrefix();
	IZPLog_Str_( thisFileLA, enLT_DebugInfo, "File prefix name : %s", filePrefixName.GrabCString());
	
	bool result = false;
	ZMPMStringSList editionList;
	this->GetAllDirectoryNames(parentPath, editionList);
	ZMPMStringSListCIter editionIter = editionList.begin();
	ZMPMStringSListCIter editionIterEnd = editionList.end();
	for(; editionIter != editionIterEnd; ++editionIter)
	{
		stEdition *currEdition = new stEdition();
		StPtrDeleter<stEdition> autoDel( currEdition, true );

		const PMString edition(**editionIter);
		PMString editionFullPath (parentPath);
		editionFullPath.Append(FileUtils::GetDirectorySeperator());
		editionFullPath.Append(edition);

		if (this->FetchAdsFileFromPath(editionFullPath, currEdition->mXmlFiles, filePrefixName))
		{
			result = true;
			currEdition->mName = edition;
			oEditionList.push_back(currEdition);
			autoDel.Forget();
		}
	}

	return result;
}
//----------------------------------------------------------------------------------------
// PreProcessWSResponse
//----------------------------------------------------------------------------------------
bool
CZPWSResponseHandler::PreProcessWSResponse(
	const IZPSoapRequest *			inSoapRequest,
	AZPSoapResponse *				inResponse,
	ZPWSError						inStatus)
{
	LogFunctionEnterExit;
	if( inStatus != eWSErr_Success )
	{
		//Show Error
#if 0
		PMString errorMessage( "Server Error:");
		errorMessage.Append("\n");
		errorMessage.Append( inResponse->GetErrorDescription() );
		errorMessage.Append("\n");
		errorMessage.Append( inResponse->GetErrorDetails());
#ifdef DEBUG
		errorMessage.Append("\n");
		errorMessage.Append( "Error code: " );
		errorMessage.AppendNumber( inStatus );
#endif
		CAlert::InformationAlert(errorMessage);
#else
		PMString errorDetail ( inResponse->GetErrorDetails() );
#ifdef DEBUG
		errorDetail.Append("\n");
		errorDetail.Append( "Error code: " );
		errorDetail.AppendNumber( inStatus );
#endif
		Utils<IZPAlertUtils>()->ShowAlert( "Server Error:", inResponse->GetErrorDescription(), errorDetail );
#endif
		return false;
	}
	return true;
	//TODO: error handing for each response
	//like logout, network error etc.
}
void MyPlugin2SelectionObserver::HandleSelectionChanged(const ISelectionMessage* selectionMessage)
{
	// get selection manager for active selection.
	ISelectionManager* iSelectionManager = Utils<ISelectionUtils>()->GetActiveSelection();
	return;
	//get pointer to textSelectionSuite using selection manager OR fCurrentSelection.
	InterfacePtr<ITextSelectionSuite> iTextSelectionSuite(iSelectionManager, UseDefaultIID());
	CAlert::InformationAlert("Selection** changed..");
	if (iTextSelectionSuite) {
		//get pointer to integrator target text using textSelectionSuite.
		//Use to  Return a list of interfaces from the "concrete selection"
		InterfacePtr<const IIntegratorTarget> iIntegratorTarget_text(iTextSelectionSuite, UseDefaultIID());
		if (iIntegratorTarget_text == nil)
			return;
		RangeData rangeData(0, RangeData::kLeanForward);
		UIDRef textRef;
		PMString tagName;
		PMString childCountString = "xml child count-";
		PMString tagUIDString = "UID of TAG -";
		UID tagUID;
		TextIndex startPosXML = 0, endPosXML = 0;
		int startIndexSelection;
		int endIndexSelection;
		// Return a list of interfaces from the "concrete selection"
		//auto_ptr automatically makes clean up of objects.
		std::auto_ptr<IIntegratorTarget::TargetSuiteCollection> selectionSuites_text(iIntegratorTarget_text->GetTarget(ITextTarget::kDefaultIID));
		for (IIntegratorTarget::TargetSuiteCollection::size_type i = 0; i < selectionSuites_text->size(); i++)
		{
			//Get target text.
			ITextTarget* target = (ITextTarget*)selectionSuites_text->at(i).get();
			if (!target)
				continue;
			// extract range from target text.
			rangeData = target->GetRange();
			
			// get start and end index of range selected.
			 startIndexSelection = rangeData.Start(nil);
			 endIndexSelection = rangeData.End();
		

			// get text model for target text.
			InterfacePtr<ITextModel>textModel(target->QueryTextModel());
			
			// get UIDRef of text model.
			textRef	= target->GetTextModel();

			// query xml reference data for text model.
			IXMLReferenceData *xmlReferenceData = Utils<IXMLUtils>()->QueryXMLReferenceData(textRef);
			if (xmlReferenceData)
			{
				// get xml reference from xml reference data.
				XMLReference xmlRef = xmlReferenceData->GetReference();
			
				// obtain xml element from xml reference
				InterfacePtr<IIDXMLElement> xmlElement(xmlRef.Instantiate());
				if (xmlElement != nil) {
					childCountString.AppendNumber(xmlElement->GetChildCount());
					XMLReference childRef = xmlElement->GetNthChild(0);
					InterfacePtr<IIDXMLElement> childXMLElement(childRef.Instantiate());
					if (childXMLElement != nil){
						tagUID = childXMLElement->GetTagUID();
						tagName = childXMLElement->GetTagString();
						Utils<IXMLUtils>()->GetElementMarkerPositions(childXMLElement, &startPosXML, &endPosXML);
					}
		    	}

			}
							
		} // for end
		int length = rangeData.Length();
		if (length >= 1) {
			PMString textFrameContentLength = "selected content length-";
			textFrameContentLength.AppendNumber(length);
			PMString srtPosString = "Start Position XML tag-";
			PMString endPosString = "End postion XML tag-";
			PMString srtPosSelString = "Start Position of Selection-";
			PMString endPosSelString = "End postion Selection-";
			srtPosString.AppendNumber(startPosXML);
			endPosString.AppendNumber(endPosXML);
			srtPosSelString.AppendNumber(startIndexSelection);
			endPosSelString.AppendNumber(endIndexSelection);
			CAlert::InformationAlert(textFrameContentLength);
			CAlert::InformationAlert(childCountString);
			CAlert::InformationAlert(tagName);
			CAlert::InformationAlert(srtPosString);
			CAlert::InformationAlert(endPosString);
			CAlert::InformationAlert(srtPosSelString);
			CAlert::InformationAlert(endPosSelString);

			if (startPosXML <= startIndexSelection && endPosXML >= endIndexSelection) {
				CAlert::InformationAlert("Selection inside tag- "+tagName);
			}
			else
			{
				CAlert::WarningAlert("Selection not inside tag- " + tagName);
			}
		}
	}
	// --------:: Table selection ::---------
	InterfacePtr<ITableSelectionSuite> iTableSelectionSuite(fCurrentSelection, UseDefaultIID());
	if (iTableSelectionSuite == nil)
		return;

	InterfacePtr<const IIntegratorTarget> iIntegratorTarget_table(iTableSelectionSuite, UseDefaultIID());
	if (iIntegratorTarget_table == nil)
		return;

	UIDRef 	tableUIDRef;
	GridArea tableGridArea;
	PMString PMRowCount = "Total no of rows-";
	PMString PMColCount = "Total no of cols-";
	std::auto_ptr<IIntegratorTarget::TargetSuiteCollection> selectionSuites_table(iIntegratorTarget_table->GetTarget(ITableTarget::kDefaultIID));
	for (IIntegratorTarget::TargetSuiteCollection::size_type i = 0; i < selectionSuites_table->size(); i++)
	{
		ITableTarget* target = (ITableTarget*)selectionSuites_table->at(i).get();
		if (!target)
			continue;
		tableUIDRef = target->GetModel();
		if (tableUIDRef != UIDRef(nil, kInvalidUID))
		{
			CAlert::WarningAlert("Table selection occured");
			tableGridArea = target->GetRange();
		}
		InterfacePtr<ITableModel>tableModel(target->QueryModel());
		if (tableModel != nil) {
			RowRange totalRows = tableModel->GetTotalRows();
			ColRange totalCols = tableModel->GetTotalCols();
			int rowCount = totalRows.count;
			int colCount = totalCols.count;
			PMRowCount.AppendNumber(rowCount);
			PMColCount.AppendNumber(colCount);
			CAlert::InformationAlert(PMRowCount);
			CAlert::InformationAlert(PMColCount);

			InterfacePtr<ITableLayout> tableLayout(tableModel, UseDefaultIID());
			if (tableLayout == nil) {
				break;
			}
			CAlert::InformationAlert("table layout present");
			ITableLayout::frame_iterator frameIter = tableLayout->begin_frame_iterator();
			CAlert::InformationAlert("Frame Iterator ppresent");
			
			CAlert::InformationAlert("Frame Iterator present");
			
			InterfacePtr<ITableFrame> tableFrame(frameIter->QueryFrame());
			CAlert::InformationAlert("table frame ppresent");
			if (tableFrame == nil){
				break;
			}
			CAlert::InformationAlert("table frame present");
			UIDRef tableContainerUIDRef = tableFrame->GetFrameRef();
			if (tableContainerUIDRef == nil){
				break;
			}
			CAlert::InformationAlert("table container UIDRef present");
			InterfacePtr<IFrameType> frameType(tableContainerUIDRef, UseDefaultIID());
			//if (frameType == nil) {
				//break;
			//}
			CAlert::InformationAlert("container frame present");
			PMString textFrameType = "Is container , text frame-";   // TYPE OF TEXT FRAME
			
		//	bool isTextFrame = frameType->IsTextFrame();
			CAlert::InformationAlert("Is text frame success");

			if (true) {
				textFrameType.Append("YES");
				CAlert::InformationAlert(textFrameType);
			}
			else {
				textFrameType.Append("NO");
				CAlert::InformationAlert(textFrameType);
			}
		}
	}
	
};