Example #1
0
bool BookmarksModel::removeBookmark(WebView* view)
{
    return removeBookmark(bookmarkId(view->url()));
}
bool IE_Exp_OpenXML_Listener::populate(fl_ContainerLayout* /* sfh */, const PX_ChangeRecord* pcr)
{	
	switch (pcr->getType())
	{
		case PX_ChangeRecord::PXT_InsertSpan:
		{
			const PX_ChangeRecord_Span* pcrs = static_cast<const PX_ChangeRecord_Span*>(pcr);
			PT_BufIndex buffer = pcrs->getBufIndex();
			const UT_UCSChar* pData = pdoc->getPointer(buffer);		

			if(*pData == UCS_FF)
			{
				paragraph->setPageBreak();
				return true;
			}

			UT_UCS4String str(pData, pcrs->getLength());
			OXML_SharedElement shared_element_text(new OXML_Element_Text(str.utf8_str(), str.length()));

			OXML_Element_Run* element_run = new OXML_Element_Run(getNextId());
			OXML_SharedElement shared_element_run(static_cast<OXML_Element*>(element_run));

			//add run properties 
			PT_AttrPropIndex api = pcr->getIndexAP();			
			const PP_AttrProp* pAP = NULL;
			bool bHaveProp = pdoc->getAttrProp(api,&pAP);

			if(bHaveProp && pAP)
			{
				const gchar* szValue;
				const gchar* szName;
				size_t propCount = pAP->getPropertyCount();
				
				size_t i;
				for(i=0; i<propCount; i++)
				{
					if(pAP->getNthProperty(i, szName, szValue))
					{
						if(element_run->setProperty(szName, szValue) != UT_OK)
							return false;		
					}
				}
			}
			
			if(bInHyperlink)
			{
				//make sure hyperlinks are blue and underlined
				if(element_run->setProperty("text-decoration", "underline") != UT_OK)
					return false;
				if(element_run->setProperty("color", "0000FF") != UT_OK) 
					return false;
				if(hyperlink->appendElement(shared_element_run) != UT_OK)
					return false;
			}
			else
			{
				if(paragraph->appendElement(shared_element_run) != UT_OK)
					return false;
			}
			return element_run->appendElement(shared_element_text) == UT_OK;
		}
		case PX_ChangeRecord::PXT_InsertObject:
		{
			const PX_ChangeRecord_Object * pcro = static_cast<const PX_ChangeRecord_Object *> (pcr);
			PT_AttrPropIndex api = pcr->getIndexAP();			
			const PP_AttrProp* pAP = NULL;
			bool bHaveProp = pdoc->getAttrProp(api,&pAP);

			const gchar* szValue;
			const gchar* szName;

			switch (pcro->getObjectType())
			{
				case PTO_Field:
				{
					fd_Field* field = pcro->getField();
					
					switch(field->getFieldType())
					{
						case fd_Field::FD_ListLabel:
						{

							OXML_Element_List* element_list = new OXML_Element_List(getNextId(), paragraph);
							OXML_SharedElement shared_element_list(static_cast<OXML_Element*>(element_list));

							if(bHaveProp && pAP)
							{
								size_t propCount = pAP->getPropertyCount();
				
								size_t i;
								for(i=0; i<propCount; i++)
								{
									if(pAP->getNthProperty(i, szName, szValue))
									{
										//TODO: Take the debug message out when we are done
										UT_DEBUGMSG(("List Property %s=%s\n", szName, szValue));
										if(element_list->setProperty(szName, szValue) != UT_OK)
											return false;		
									}
								}

								size_t attrCount = pAP->getAttributeCount();

								for(i=0; i<attrCount; i++)
								{
									if(pAP->getNthAttribute(i, szName, szValue))
									{
										//TODO: Take the debug message out when we are done
										UT_DEBUGMSG(("List Attribute: %s=%s\n", szName, szValue));	
										if(element_list->setAttribute(szName, szValue) != UT_OK)
											return false;		
									}
								}
							}

							return paragraph->appendElement(shared_element_list) == UT_OK;			
						}
						
						default:
						{
							UT_UTF8String value = field->getValue(); // getValue() can return NULL
							OXML_Element_Field* element_field = new OXML_Element_Field(getNextId(), field->getFieldType(), value.utf8_str());
							OXML_SharedElement shared_element_field(static_cast<OXML_Element*>(element_field));

							if(bHaveProp && pAP)
							{
								size_t propCount = pAP->getPropertyCount();
				
								size_t i;
								for(i=0; i<propCount; i++)
								{
									if(pAP->getNthProperty(i, szName, szValue))
									{
										//TODO: Take the debug message out when we are done
										UT_DEBUGMSG(("Field Property %s=%s\n", szName, szValue));
										if(element_field->setProperty(szName, szValue) != UT_OK)
											return false;		
									}
								}

								size_t attrCount = pAP->getAttributeCount();

								for(i=0; i<attrCount; i++)
								{
									if(pAP->getNthAttribute(i, szName, szValue))
									{
										//TODO: Take the debug message out when we are done
										UT_DEBUGMSG(("Field Attribute: %s=%s\n", szName, szValue));	
										if(element_field->setAttribute(szName, szValue) != UT_OK)
											return false;		
									}
								}
							}

							return paragraph->appendElement(shared_element_field) == UT_OK;			
						}
						
					}		
				}

				case PTO_Hyperlink:
				{
					if(bInHyperlink)
					{
						bInHyperlink = false;
						return true;
					}

					bInHyperlink = true;

					hyperlink = new OXML_Element_Hyperlink(getNextId());
					OXML_SharedElement shared_element_hyperlink(static_cast<OXML_Element*>(hyperlink));

					if(bHaveProp && pAP)
					{
						size_t propCount = pAP->getPropertyCount();
				
						size_t i;
						for(i=0; i<propCount; i++)
						{
							if(pAP->getNthProperty(i, szName, szValue))
							{
								//TODO: Take the debug message out when we are done
								UT_DEBUGMSG(("Hyperlink Property %s=%s\n", szName, szValue));
								if(hyperlink->setProperty(szName, szValue) != UT_OK)
									return false;		
							}
						}

						size_t attrCount = pAP->getAttributeCount();

						for(i=0; i<attrCount; i++)
						{
							if(pAP->getNthAttribute(i, szName, szValue))
							{
								//TODO: Take the debug message out when we are done
								UT_DEBUGMSG(("Hyperlink Attribute: %s=%s\n", szName, szValue));	
								if(hyperlink->setAttribute(szName, szValue) != UT_OK)
									return false;		
							}
						}
					}

					return paragraph->appendElement(shared_element_hyperlink) == UT_OK;
				}

				case PTO_Image:			
				{
					OXML_Element_Run* element_run = new OXML_Element_Run(getNextId());
					OXML_SharedElement shared_element_run(static_cast<OXML_Element*>(element_run));

					if(paragraph->appendElement(shared_element_run) != UT_OK)
						return false;

					OXML_Element_Image* element_image = new OXML_Element_Image(getNextId());
					OXML_SharedElement shared_element_image(static_cast<OXML_Element*>(element_image));					

					if(bHaveProp && pAP)
					{
						size_t propCount = pAP->getPropertyCount();
				
						size_t i;
						for(i=0; i<propCount; i++)
						{
							if(pAP->getNthProperty(i, szName, szValue))
							{
								//TODO: Take the debug message out when we are done
								UT_DEBUGMSG(("Image Property %s=%s\n", szName, szValue));
								if(element_image->setProperty(szName, szValue) != UT_OK)
									return false;		
							}
						}

						size_t attrCount = pAP->getAttributeCount();

						for(i=0; i<attrCount; i++)
						{
							if(pAP->getNthAttribute(i, szName, szValue))
							{
								//TODO: Take the debug message out when we are done
								UT_DEBUGMSG(("Image Attribute: %s=%s\n", szName, szValue));	
								if(element_image->setAttribute(szName, szValue) != UT_OK)
									return false;		
							}
						}
					}
					return element_run->appendElement(shared_element_image) == UT_OK;
				}

				case PTO_Bookmark:
				{
					if(bHaveProp && pAP)
					{
						if(!pAP->getAttribute("name", szValue))
						{
							UT_DEBUGMSG(("FRT:OpenXML exporter bookmark without name attribute\n"));
							return true;
						}
						std::string bookmarkName(szValue);

						if(!pAP->getAttribute("type", szValue))
						{
							UT_DEBUGMSG(("FRT:OpenXML exporter bookmark without type attribute\n"));
							return true;
						}
						std::string bookmarkType(szValue);

						std::string bookmarkId("");
						if(!bookmarkType.compare("start"))
						{
							bookmarkId = getNextId();
							document->setBookmarkName(bookmarkId, bookmarkName);
						}
						else if(!bookmarkType.compare("end"))
						{
							bookmarkId = document->getBookmarkId(bookmarkName);
						}
						else
						{
							UT_DEBUGMSG(("FRT:OpenXML exporter bookmark with invalid type attribute=%s\n", bookmarkType.c_str()));
							return true;
						}							

						OXML_Element_Bookmark* bookmark = new OXML_Element_Bookmark(bookmarkId);
						bookmark->setName(bookmarkId);
						OXML_SharedElement shared_element_bookmark(static_cast<OXML_Element*>(bookmark));

						size_t propCount = pAP->getPropertyCount();
				
						size_t i;
						for(i=0; i<propCount; i++)
						{
							if(pAP->getNthProperty(i, szName, szValue))
							{
								//TODO: Take the debug message out when we are done
								UT_DEBUGMSG(("Bookmark Property %s=%s\n", szName, szValue));
								if(bookmark->setProperty(szName, szValue) != UT_OK)
									return false;		
							}
						}

						size_t attrCount = pAP->getAttributeCount();

						for(i=0; i<attrCount; i++)
						{
							if(pAP->getNthAttribute(i, szName, szValue))
							{
								//TODO: Take the debug message out when we are done
								UT_DEBUGMSG(("Bookmark Attribute: %s=%s\n", szName, szValue));	
								if(bookmark->setAttribute(szName, szValue) != UT_OK)
									return false;		
							}
						}
						return paragraph->appendElement(shared_element_bookmark) == UT_OK;
					}
					return true;
				}
				default:
					return true;
			}

		}
		case PX_ChangeRecord::PXT_InsertFmtMark:
		default:
			return true;
	}
	return true;
}
Example #3
0
bool BookmarksModel::removeBookmark(const QUrl &url)
{
    return removeBookmark(bookmarkId(url));
}