void insert(int mx, int my, int msize) { if(size == msize) { filled = 0xF; return; } int csize = size>>1, i = 0; if(mx >= x+csize) i |= 1; if(my >= y+csize) i |= 2; if(csize == msize) { filled |= (1 << i); return; } if(!child[i]) child[i] = new QuadNode(i&1 ? x+csize : x, i&2 ? y+csize : y, csize); child[i]->insert(mx, my, msize); loopj(4) if(child[j]) { if(child[j]->filled == 0xF) { DELETEP(child[j]); filled |= (1 << j); } } }
/*! * This method oborts the current visual drag. */ void FV_VisualDragText::abortDrag(void) { if(m_pAutoScrollTimer != NULL) { m_pAutoScrollTimer->stop(); DELETEP(m_pAutoScrollTimer); } m_bSelectedRow = false; bool bDidCopy = m_bDoingCopy; m_bDoingCopy = false; m_bNotDraggingImage = false; clearCursor(); UT_DEBUGMSG(("Abort Drag! \n")); if(m_iVisualDragMode != FV_VisualDrag_DRAGGING) { // // we didn't actually drag anything. Just release the selection. // setMode(FV_VisualDrag_NOT_ACTIVE); return; } getGraphics()->setClipRect(&m_recCurFrame); m_pView->updateScreen(false); getGraphics()->setClipRect(NULL); setMode(FV_VisualDrag_NOT_ACTIVE); if(!bDidCopy) { m_pView->cmdUndo(1); } return; }
GlobSessionPacket::~GlobSessionPacket() { for (size_t i=0; i<m_pPackets.size(); ++i) { DELETEP( m_pPackets[i] ); } }
static void Google_removeFromMenus() { // First we need to get a pointer to the application itself. XAP_App *pApp = XAP_App::getApp(); // remove the edit method EV_EditMethodContainer* pEMC = pApp->getEditMethodContainer() ; EV_EditMethod * pEM = ev_EditMethod_lookup ( "AbiGoogle_invoke" ) ; pEMC->removeEditMethod ( pEM ) ; DELETEP( pEM ) ; // now remove crap from the menus int frameCount = pApp->getFrameCount(); XAP_Menu_Factory * pFact = pApp->getMenuFactory(); pFact->removeMenuItem("Main",NULL,Google_MenuLabel); pFact->removeMenuItem("contextText",NULL,Google_MenuLabel); for(int i = 0;i < frameCount;++i) { // Get the current frame that we're iterating through. XAP_Frame* pFrame = pApp->getFrame(i); pFrame->rebuildMenus(); } }
HWND AP_Win32LeftRuler::createWindow(HWND hwndContainer, UT_uint32 left, UT_uint32 top, UT_uint32 height) { XAP_Win32App * app = static_cast<XAP_Win32App *>(XAP_App::getApp()); m_hwndLeftRuler = UT_CreateWindowEx(0, s_LeftRulerWndClassName, NULL, WS_CHILD | WS_VISIBLE, left, top, s_iFixedWidth, height, hwndContainer, NULL, app->getInstance(), NULL); UT_return_val_if_fail (m_hwndLeftRuler,0); SWL(m_hwndLeftRuler, this); DELETEP(m_pG); GR_Win32AllocInfo ai(GetDC(m_hwndLeftRuler), m_hwndLeftRuler); GR_Win32Graphics * pG = (GR_Win32Graphics *)XAP_App::getApp()->newGraphics(ai); m_pG = pG; UT_return_val_if_fail (pG, 0); pG->init3dColors(); RECT rSize; GetClientRect(m_hwndLeftRuler,&rSize); setHeight(rSize.bottom); setWidth(rSize.right); return m_hwndLeftRuler; }
AP_Dialog_Lists::~AP_Dialog_Lists(void) { DELETEP(m_pListsPreview); for(UT_uint32 i=0; i<4; i++) { DELETEP(m_pFakeLayout[i]); const pf_Frag_Strux_Block * pFSB = static_cast<const pf_Frag_Strux_Block *>(m_pFakeSdh[i]); DELETEP(pFSB); } // What do we do about the fakeAutoNum in the Document pDoc? // Maybe we need another constrcutor DELETEP(m_pFakeAuto); UNREFP(m_pFakeDoc); }
void AP_UnixDialog_FormatFrame::runModeless(XAP_Frame * pFrame) { // Build the window's widgets and arrange them m_windowMain = _constructWindow(); UT_return_if_fail(m_windowMain); // Populate the window's data items _populateWindowData(); _connectSignals(); abiSetupModelessDialog(GTK_DIALOG(m_windowMain), pFrame, this, BUTTON_CLOSE); // *** this is how we add the gc for Column Preview *** // attach a new graphics context to the drawing area UT_return_if_fail(m_wPreviewArea && m_wPreviewArea->window); // make a new Unix GC DELETEP (m_pPreviewWidget); GR_UnixCairoAllocInfo ai(m_wPreviewArea); m_pPreviewWidget = (GR_UnixCairoGraphics*) XAP_App::getApp()->newGraphics(ai); // Todo: we need a good widget to query with a probable // Todo: non-white (i.e. gray, or a similar bgcolor as our parent widget) // Todo: background. This should be fine m_pPreviewWidget->init3dColors(m_wPreviewArea->style); // let the widget materialize _createPreviewFromGC(m_pPreviewWidget, static_cast<UT_uint32>(m_wPreviewArea->allocation.width), static_cast<UT_uint32>(m_wPreviewArea->allocation.height)); m_pFormatFramePreview->draw(); startUpdater(); }
bool AP_CocoaToolbar_StyleCombo::repopulate(void) { // repopulate the vector from the current document // If ithere is one present AD_Document * pAD_Doc = m_pFrame->getCurrentDoc(); if(!pAD_Doc) { return false; } // clear anything that's already there m_vecContents.clear(); m_pDocument = static_cast<PD_Document *>(pAD_Doc); UT_GenericVector<PD_Style*>* pStyles = NULL; m_pDocument->enumStyles(pStyles); UT_uint32 nStyles = pStyles->getItemCount(); for (UT_uint32 k = 0; k < nStyles; k++) { const PD_Style * pStyle; pStyle = pStyles->getNthItem(k); if(pStyle) { m_vecContents.addItem(pStyle->getName()); } } DELETEP(pStyles); return true; }
/*! * Create the preview from the Graphics Context provided by the platform code. \param gc the Platform Graphics Context cast into the a XP handle. \param width the width of the gc \param height the height of the gc */ void AP_Dialog_Lists::_createPreviewFromGC(GR_Graphics* gc, UT_uint32 width, UT_uint32 height) { UT_return_if_fail (gc); m_iWidth = width; m_iHeight = height; // g_free any attached preview DELETEP(m_pListsPreview); m_pListsPreview = new AP_Lists_preview(gc, this); UT_return_if_fail (m_pListsPreview); m_pListsPreview->setWindowSize(width, height); // // Generate the fake layout pointers and autonum we need for the // preview // generateFakeLabels(); m_isListAtPoint = getBlock()->isListItem(); if(m_isListAtPoint == false) { m_NewListType = NOT_A_LIST; } }
bool GR_VectorImage::convertFromBuffer(const UT_ByteBuf* pBB, const std::string& /*mimetype*/, UT_sint32 iDisplayWidth, UT_sint32 iDisplayHeight) { setDisplaySize ( iDisplayWidth, iDisplayHeight ); DELETEP(m_pBB_Image); m_pBB_Image = new UT_ByteBuf; bool bCopied = m_pBB_Image->append(pBB->getPointer(0), pBB->getLength()); if (!bCopied) DELETEP(m_pBB_Image); return bCopied; }
/** * Unregister the OpenDocument plugin */ ABI_BUILTIN_FAR_CALL int abi_plugin_unregister (XAP_ModuleInfo * mi) { mi->name = 0; mi->desc = 0; mi->version = 0; mi->author = 0; mi->usage = 0; IE_Imp::unregisterImporter (pImp_sniffer); DELETEP(pImp_sniffer); IE_Exp::unregisterExporter (pExp_sniffer); DELETEP(pExp_sniffer); return 1; }
void ODe_AbiDocListener::_handleListenerImplAction() { switch (m_listenerImplAction.getAction()) { case ODe_ListenerAction::ACTION_PUSH: m_implStack.push_back( ODe_AbiDocListener::StackCell(m_pCurrentImpl, m_deleteCurrentWhenPop)); m_pCurrentImpl = m_listenerImplAction.getListenerImpl(); m_deleteCurrentWhenPop = m_listenerImplAction.deleteWhenPop(); UT_ASSERT(m_pCurrentImpl); break; case ODe_ListenerAction::ACTION_POP: if (m_deleteCurrentWhenPop) { DELETEP(m_pCurrentImpl); } else { m_pCurrentImpl = NULL; } if (m_implStack.getItemCount() > 0) { StackCell stackCell; stackCell = m_implStack.getLastItem(); m_pCurrentImpl = stackCell.m_pListenerImpl; m_deleteCurrentWhenPop = stackCell.m_deleteWhenPop; m_implStack.pop_back(); } break; } }
UT_Error IE_Exp_Text::_writeDocument(void) { // Don't call base method if user cancels encoding dialog if (!(!m_bIsEncoded || m_bExplicitlySetEncoding || _doEncodingDialog(m_szEncoding))) return UT_SAVE_CANCELLED; // TODO If we're going to the clipboard and the OS supports unicode, set encoding. // TODO Only supports Windows so far. // TODO Should use a finer-grain technique than IsWinNT() since Win98 supports unicode clipboard. if (getDocRange()) { #ifdef WIN32 if (UT_IsWinNT()) _setEncoding(XAP_EncodingManager::get_instance()->getNativeUnicodeEncodingName()); #endif } m_pListener = _constructListener(); if (!m_pListener) return UT_IE_NOMEMORY; if (getDocRange()) getDoc()->tellListenerSubset(static_cast<PL_Listener *>(m_pListener),getDocRange()); else getDoc()->tellListener(static_cast<PL_Listener *>(m_pListener)); DELETEP(m_pListener); return ((m_error) ? UT_IE_COULDNOTWRITE : UT_OK); }
BOOL CALLBACK AP_Win32Dialog_GenericInput::s_dlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_INITDIALOG: { AP_Win32Dialog_GenericInput* pThis = (AP_Win32Dialog_GenericInput *)lParam; UT_return_val_if_fail(pThis, false); SetWindowLongPtrW(hWnd,DWLP_USER,lParam); return pThis->_onInitDialog(hWnd,wParam,lParam); } case WM_COMMAND: { AP_Win32Dialog_GenericInput* pThis = (AP_Win32Dialog_GenericInput *)GetWindowLongPtrW(hWnd,DWLP_USER); UT_return_val_if_fail(pThis, false); return pThis->_onCommand(hWnd,wParam,lParam); } case WM_DESTROY: { AP_Win32Dialog_GenericInput* pThis = (AP_Win32Dialog_GenericInput *)GetWindowLongPtrW(hWnd,DWLP_USER); UT_return_val_if_fail(pThis, false); DELETEP(pThis->m_pWin32Dialog); return true; } default: // Message not processed - Windows should take care of it return false; } }
UT_Error IE_Exp_EPUB::EPUB3_writeStructure() { m_oebpsDir = m_baseTempDir + G_DIR_SEPARATOR_S; m_oebpsDir += "OEBPS"; UT_go_directory_create(m_oebpsDir.c_str(), NULL); std::string indexPath = m_oebpsDir + G_DIR_SEPARATOR_S; indexPath += "index.xhtml"; // Exporting document to XHTML using HTML export plugin char *szIndexPath = (char*) g_malloc(strlen(indexPath.c_str()) + 1); strcpy(szIndexPath, indexPath.c_str()); IE_Exp_HTML_WriterFactory *pWriterFactory = new IE_Exp_EPUB_EPUB3WriterFactory(); m_pHmtlExporter = new IE_Exp_HTML(getDoc()); m_pHmtlExporter->setWriterFactory(pWriterFactory); m_pHmtlExporter->suppressDialog(true); m_pHmtlExporter->setProps( "embed-css:no;html4:no;use-awml:no;declare-xml:yes;add-identifiers:yes;"); m_pHmtlExporter->set_SplitDocument(m_exp_opt.bSplitDocument); m_pHmtlExporter->set_MathMLRenderPNG(m_exp_opt.bRenderMathMLToPNG); m_pHmtlExporter->writeFile(szIndexPath); g_free(szIndexPath); DELETEP(pWriterFactory); return UT_OK; }
IE_Exp_HTML_NavigationHelper::IE_Exp_HTML_NavigationHelper( PD_Document* pDocument, const UT_UTF8String &baseName) : IE_TOCHelper(pDocument), m_suffix(""), m_minTOCLevel(0), m_minTOCIndex(0), m_baseName(UT_go_basename_from_uri(baseName.utf8_str())) { m_suffix = strchr(m_baseName, '.'); m_minTOCLevel = 10; for (int i = 0; i < getNumTOCEntries(); i++) { int currentLevel = 10; getNthTOCEntry(i, ¤tLevel); if (currentLevel < m_minTOCLevel) { m_minTOCLevel = currentLevel; m_minTOCIndex = i; } } IE_Exp_HTML_BookmarkListener * bookmarkListener = new IE_Exp_HTML_BookmarkListener(pDocument, this); pDocument->tellListener(bookmarkListener); DELETEP(bookmarkListener); }
AP_UnixLeftRuler::~AP_UnixLeftRuler(void) { GtkWidget * toplevel = static_cast<XAP_UnixFrameImpl *>(m_pFrame->getFrameImpl())->getTopLevelWindow(); if (toplevel && g_signal_handler_is_connected(G_OBJECT(toplevel), m_iBackgroundRedrawID)) { g_signal_handler_disconnect(G_OBJECT(toplevel),m_iBackgroundRedrawID); } DELETEP(m_pG); }
UT_Error IE_ImpGraphic_BMP::_convertGraphic(UT_ByteBuf * pBB) { UT_Error err; InitializePrivateClassData(); /* Read Header Data */ if ((err = Read_BMP_Header(pBB))) return err; if ((err = Initialize_PNG())) return err; /* Read Palette, if no palette set Header accordingly */ if(m_iBitsPerPlane < 24) { if ((err = Convert_BMP_Pallet(pBB))) return err; } else { UT_uint16 bitsPerChannel; UT_uint16 colorType; if (m_iBitsPerPlane == 24) { bitsPerChannel = 8; colorType = PNG_COLOR_TYPE_RGB; } else if (m_iBitsPerPlane == 32) { bitsPerChannel = 8; colorType = PNG_COLOR_TYPE_RGB_ALPHA; } else if (m_iBitsPerPlane == 48) { bitsPerChannel = 16; colorType = PNG_COLOR_TYPE_RGB; } else if (m_iBitsPerPlane == 64) { bitsPerChannel = 16; colorType = PNG_COLOR_TYPE_RGB_ALPHA; } else { // wow! this is one impression graphic coming at us. // i would have though 64 bits of RGBA glory would // hold us for a while, but alas, we are obsolete... return UT_ERROR; } png_set_IHDR ( m_pPNG, m_pPNGInfo, m_iWidth, m_iHeight, bitsPerChannel, colorType, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT ); } if ((err = Convert_BMP(pBB))) return err; /* Clean Up Memory Used */ // FREEP(m_pPNGInfo->palette); DELETEP(pBB); png_destroy_write_struct(&m_pPNG, &m_pPNGInfo); return UT_OK; }
AP_Dialog_Paragraph::~AP_Dialog_Paragraph(void) { FREEP(m_pageLeftMargin); FREEP(m_pageRightMargin); DELETEP(m_paragraphPreview); UT_VECTOR_PURGEALL(sControlData *, m_vecProperties); }
GR_EmbedManager::~GR_EmbedManager() { UT_sint32 i = 0; for(i=0; i<m_vecSnapshots.getItemCount(); i++) { GR_EmbedView * pEView = m_vecSnapshots.getNthItem(i); DELETEP(pEView); } }
void XAP_Dialog_Insert_Symbol::_createSymbolFromGC(GR_Graphics * gc, UT_uint32 width, UT_uint32 height) { UT_ASSERT(gc); DELETEP(m_DrawSymbol); m_DrawSymbol = new XAP_Draw_Symbol(gc); UT_ASSERT(m_DrawSymbol); m_DrawSymbol->setWindowSize(width, height); }
/** * Clear the state stack. */ void ODi_StreamListener::_clear () { if (m_pCurrentState && m_deleteCurrentWhenPop) { DELETEP(m_pCurrentState); } else { m_pCurrentState = NULL; } UT_sint32 i; ODi_StreamListener::StackCell cell; for (i=0; i < m_stateStack.getItemCount(); i++) { cell = m_stateStack.getNthItem(i); if (cell.m_deleteWhenPop) { DELETEP(cell.m_pState); } } m_stateStack.clear(); }
void removefromsystem(rpgobj *o) { removefromworld(o); o->decontain(); if(pointingat==o) pointingat = NULL; if(selected==o) selected = NULL; resetstack(); DELETEP(o); }
ABI_FAR_CALL int abi_plugin_unregister (XAP_ModuleInfo * mi) { mi->name = 0; mi->desc = 0; mi->version = 0; mi->author = 0; mi->usage = 0; IE_Imp::unregisterImporter (m_impSniffer); delete m_impSniffer; m_impSniffer = 0; IE_Imp::unregisterImporter (m_impCSniffer); delete m_impCSniffer; m_impCSniffer = 0; pGOChartManager->removeContextualMenu (); XAP_App * pApp = XAP_App::getApp(); pApp->unRegisterEmbeddable(pGOChartManager->getObjectType()); DELETEP(pGOChartManager); GSList *l = mime_types; while (l) { if (go_components_support_clipboard ((const char*)l->data)) pApp->deleteClipboardFmt((const char*)l->data); l = l->next; } std::list<std::string>::iterator i, end = uids.end(); for (i = uids.begin(); i != end; i++) pApp->unRegisterEmbeddable((*i).c_str()); uids.clear(); if (pGOComponentManager) { pApp->unRegisterEmbeddable(pGOComponentManager->getObjectType()); DELETEP(pGOComponentManager); } AbiGOffice_removeFromMenus(); go_component_set_default_command_context (NULL); g_object_unref (cc); go_plugins_shutdown(); libgoffice_shutdown(); return 1; }
void TelepathyAccountHandler::handleMessage(DTubeBuddyPtr pBuddy, const std::string& packet_str) { UT_DEBUGMSG(("TelepathyAccountHandler::handleMessage()\n")); UT_return_if_fail(pBuddy); AbiCollabSessionManager* pManager = AbiCollabSessionManager::getManager(); UT_return_if_fail(pManager); TelepathyChatroomPtr pChatroom = pBuddy->getChatRoom(); UT_return_if_fail(pChatroom); // construct the packet Packet* pPacket = _createPacket(packet_str, pBuddy); UT_return_if_fail(pPacket); switch (pPacket->getClassType()) { case PCT_GetSessionsEvent: { if (pChatroom->isLocallyControlled()) { // return only the session that belongs to the chatroom that the buddy is in GetSessionsResponseEvent gsre; gsre.m_Sessions[pChatroom->getSessionId()] = pChatroom->getDocName(); send(&gsre, pBuddy); } else UT_DEBUGMSG(("Ignoring GetSessionsEvent, we are not controlling session '%s'\n", pChatroom->getSessionId().utf8_str())); break; } case PCT_GetSessionsResponseEvent: { // check if we received 1 (and only 1) session, and join it // immediately if that is the case GetSessionsResponseEvent* gsre = static_cast<GetSessionsResponseEvent*>( pPacket ); UT_return_if_fail(gsre->m_Sessions.size() == 1); std::map<UT_UTF8String,UT_UTF8String>::iterator it=gsre->m_Sessions.begin(); DocHandle* pDocHandle = new DocHandle((*it).first, (*it).second); // store the session id pChatroom->setSessionId(pDocHandle->getSessionId()); // join the session UT_DEBUGMSG(("Got a running session (%s - %s), let's join it immediately\n", pDocHandle->getSessionId().utf8_str(), pDocHandle->getName().utf8_str())); pManager->joinSessionInitiate(pBuddy, pDocHandle); DELETEP(pDocHandle); break; } default: // let the default handler handle it AccountHandler::handleMessage(pPacket, pBuddy); break; } }
UT_Error AbiCollabSessionManager::deserializeDocument(PD_Document** pDoc, const std::string& document, bool isEncodedBase64) { UT_return_val_if_fail(pDoc, UT_ERROR); UT_Error res = UT_ERROR; // really bad abuse of std::string's below, but more efficient than copying // the whole buffer (which could be massive) into a temporary buffer GsfInput *source; if (isEncodedBase64) { char* base64gzBuf = const_cast<char*>(document.c_str()); size_t gzbufLen = gsf_base64_decode_simple((guint8*)base64gzBuf, strlen(base64gzBuf)); char* gzBuf = base64gzBuf; source = gsf_input_memory_new((guint8*)gzBuf, gzbufLen, false); } else { // string contains raw zipped data source = gsf_input_memory_new((guint8*)document.c_str(), document.size(), false); } if (source) { GsfInput *gzabwBuf = gsf_input_gzip_new (source, NULL); // todo: don't pass null here, but check for errors if (gzabwBuf) { bool create = (*pDoc == NULL); if (create) { UT_DEBUGMSG(("Creating a new document in AbiCollabSessionManager::deserializeDocument()\n")); (*pDoc) = new PD_Document(); (*pDoc)->createRawDocument(); } IE_Imp* imp = (IE_Imp*)new IE_Imp_AbiWord_1(*pDoc); imp->importFile(gzabwBuf); // todo: check for errors (*pDoc)->repairDoc(); if (create) (*pDoc)->finishRawCreation(); DELETEP(imp); g_object_unref(G_OBJECT(gzabwBuf)); res = UT_OK; } else { UT_ASSERT(UT_SHOULD_NOT_HAPPEN); } g_object_unref(G_OBJECT(source)); } else { UT_ASSERT(UT_SHOULD_NOT_HAPPEN); } return res; }
location::~location() { if(src) sourcescheduler::instance().releasesource(src); if(cfg) cfg->ondetach(); if(ref) { ref->detach(); DELETEP(ref); } }
AP_Win32LeftRuler::~AP_Win32LeftRuler(void) { DELETEP(m_pG); if (m_hwndLeftRuler) { if (IsWindow(m_hwndLeftRuler)) DestroyWindow(m_hwndLeftRuler); } }
bool GR_CharWidthsCache::addFont (const GR_Font* pFont) { GR_CharWidths* content = pFont->newFontWidths(); bool added = m_pFontHash->insert(pFont->hashKey(), content); if (!added) { UT_DEBUGMSG(("cache font add failed.\n")); DELETEP(content); } return added; }
/*! * Delete renderer specified by uid */ void GR_EmbedManager::releaseEmbedView(UT_sint32 uid) { if((m_vecSnapshots.getItemCount() == 0) || (uid >= m_vecSnapshots.getItemCount())) { return; } GR_EmbedView * pEView = m_vecSnapshots.getNthItem(uid); DELETEP(pEView); m_vecSnapshots.setNthItem(uid,NULL,NULL); }