int RichTxt::GetVertMove(int pos, int gx, RichContext rc, int dir) const { ASSERT(dir == -1 || dir == 1); if(GetPartCount() == 0) return -1; int pi; int p = pos; if(pos >= 0) { pi = FindPart(p); pos -= p; } else { pi = dir > 0 ? 0 : GetPartCount() - 1; p = -1; pos = 0; } while(pi < GetPartCount()) { int q = IsTable(pi) ? GetTable(pi).GetVertMove(p, gx, rc, dir) : Get(pi, rc.styles).GetVertMove(p, gx, rc.page, dir); if(q >= 0) return q + pos; if(dir > 0) pos += GetPartLength(pi) + 1; p = -1; pi += dir; if(pi < 0) break; if(dir < 0) pos -= GetPartLength(pi) + 1; } return -1; }
void RichPara::Mid(int pos) { int i = FindPart(pos); part.Remove(0, i); if(pos) { ASSERT(part[0].IsText()); part[0].text = part[0].text.Mid(pos); } cacheid = 0; }
void RichPara::Trim(int pos) { int i = FindPart(pos); if(pos) { ASSERT(part[i].IsText()); part[i].text.Trim(pos); part.SetCount(i + 1); } else part.SetCount(i); cacheid = 0; }
/*! * \brief * Redirects a part request to the map file server if the request is valid. * * \param connection * The connection the redirect is to be sent to. * * \param request_info * Pointer to the request information sent to the server by the client. * * Redirects a part request to the map file server if the request is valid. * * \remarks * A client error status code is sent to the client if the request is incomplete, or if the map/part was not found. */ static void ProcessMapPartDownloadReferral(mg_connection* connection, std::string map_name, std::string part_name) { const mg_request_info* request_info = mg_get_request_info(connection); // remove the extension from the map name std::string::size_type extension_offset = std::string::npos; if((extension_offset = map_name.find(Cache::K_MAP_FILE_EXTENSION)) != std::string::npos) map_name.resize(extension_offset); else if((extension_offset = map_name.find(Cache::K_MAP_FILE_EXTENSION_YELO)) != std::string::npos) map_name.resize(extension_offset); // look for the part in the part definition c_map_element* map_element = FindMap(map_name.c_str()); if(!map_element) { // the part was not found so respond with the file not found status code SendResponse(connection, Enums::_http_status_code_client_error_not_found); return; } if(!map_element->Lock()) { // the part was not found so respond with the file not found status code SendResponse(connection, Enums::_http_status_code_client_error_request_timeout); return; } const c_part_element* part_element = FindPart(map_element, part_name.c_str()); if(part_element) { // the part element exists, so respond with a redirect to the part file c_http_header response_headers; response_headers.AddHeader("Content-Type", "text/html"); response_headers.AddHeader("Content-Length", "0"); response_headers.AddHeader("Location", part_element->m_redirect_address.c_str()); SendResponse(connection, Enums::_http_status_code_redirection_found, &response_headers); } else { // the part was not found so respond with the file not found status code SendResponse(connection, Enums::_http_status_code_client_error_not_found); } map_element->Unlock(); }
struct L3PartS *LoadRC() { extern struct L3PartS *FindPart(int Internal, char *DatName); extern int LoadPart(struct L3PartS * PartPtr, int IsModel, char *ReferencingDatfile); struct L3PartS *PartPtr; PartPtr = FindPart(0, "ldconfig.ldr"); if (PartPtr) if (LoadPart(PartPtr, false, NULL) != 2) return(PartPtr); PartPtr = FindPart(0, "ldliterc.dat"); if (!PartPtr) return NULL; //partnum not found //if (LoadPart(PartPtr, false, Parts[0].DatName) == 2) if (LoadPart(PartPtr, false, NULL) == 2) { return NULL; } return(PartPtr); }
String MessageData::GetHTMLBody() const { shared_ptr<MimeBody> pPart = FindPart("text/html"); if (pPart) { if (m_bEncodeFields) return pPart->GetUnicodeText(); else return pPart->GetRawText(); } return ""; }
RichTxt& RichTxt::GetText0(int& pos, bool update) { if(update) Invalidate(); int p = pos; int pi = FindPart(p); if(IsTable(pi)) { RichTable& tab = part[pi].Get<RichTable>(); Point cl = tab.FindCell(p); if(update) { tab.InvalidateRefresh(cl); SetRefresh(pi); } pos = p; return tab[cl].text.GetText0(pos, update); } return *this; }
void MessageData::SetBody(const String &sBody) { shared_ptr<MimeBody> pPart = FindPart("text/plain"); if (!pPart) pPart = CreatePart("text/plain"); String sModifiedBody = sBody; if (sModifiedBody.Right(2) != _T("\r\n")) { // Add carriage return. sModifiedBody += "\r\n"; } // Set the text to the part if (m_bEncodeFields) pPart->SetUnicodeText(sModifiedBody); else pPart->SetRawText(sModifiedBody); }
void MessageData::SetHTMLBody(const String &sNewVal) { shared_ptr<MimeBody> pHTMLPart = FindPart("text/html"); if (!pHTMLPart) { // Create a new part. pHTMLPart = CreatePart("text/html"); } String sModifiedBody = sNewVal; if (sModifiedBody.Right(2) != _T("\r\n")) { // Add carriage return. sModifiedBody += "\r\n"; } // Set the text to the part if (m_bEncodeFields) pHTMLPart->SetUnicodeText(sModifiedBody); else pHTMLPart->SetRawText(sModifiedBody); }
bool RichText::GetInvalid(PageY& top, PageY& bottom, const Rect& page, int sell, int selh, int osell, int oselh) const { Mutex::Lock __(mutex); int spi = 0; int rtype = r_type; if(sell != selh || osell != oselh) { if(sell != osell) { if(rtype == NONE) { spi = FindPart(sell); rtype = spi == FindPart(osell) ? SPARA : ALL; } else rtype = ALL; } if(selh != oselh) { if(rtype == NONE) { spi = FindPart(selh); rtype = spi == FindPart(oselh) ? SPARA : ALL; } else rtype = ALL; } } bottom = top = PageY(0, page.top); if(rtype == NONE) { bottom = top; return false; } if(rtype == ALL) { bottom = GetHeight(page); return true; } #if 0 RichContext rc = Context(page, PageY(0, 0)); if(rtype == SPARA) { rc.py = top = GetPartPageY(spi, rc); bottom = GetNextPageY(spi, rc); return true; } #endif RichContext begin; if(rtype == SPARA) { // selection changed within single paragraph RichContext rc = GetPartContext(spi, Context(page)); top = rc.py; bottom = GetAdvanced(spi, rc, begin).py; return true; } RichContext rc = GetPartContext(r_parti, Context(page)); top = rc.py; if(rtype == PARA) { if(IsTable(r_parti)) switch(GetTable(r_parti).GetInvalid(top, bottom, rc)) { case -1: return false; case 0: return true; default: bottom = GetHeight(page); return true; } else { Sync(r_parti, rc); const Para& pp = part[r_parti].Get<Para>(); if(r_paraocx == pp.ccx && r_paraocy == Sum(pp.linecy, 0) + pp.ruler + pp.before + pp.after && r_keep == pp.keep && r_keepnext == pp.keepnext && r_newpage == pp.newpage) { bottom = GetAdvanced(r_parti, rc, begin).py; return true; } } } bottom = GetHeight(page); return true; }