void tag_obj_in_region(int xmin, int ymin, int xmax, int ymax) { sel_ellipse(xmin, ymin, xmax, ymax); sel_line(xmin, ymin, xmax, ymax); sel_spline(xmin, ymin, xmax, ymax); sel_text(xmin, ymin, xmax, ymax); sel_arc(xmin, ymin, xmax, ymax); sel_compound(xmin, ymin, xmax, ymax); }
/* * Class: org_coolreader_crengine_ReaderView * Method: updateSelectionInternal * Signature: (Lorg/coolreader/crengine/Selection;)V */ JNIEXPORT void JNICALL Java_org_coolreader_crengine_ReaderView_updateSelectionInternal (JNIEnv * _env, jobject _this, jobject _sel) { CRJNIEnv env(_env); ReaderViewNative * p = getNative(_env, _this); CRObjectAccessor sel(_env, _sel); CRStringField sel_startPos(sel, "startPos"); CRStringField sel_endPos(sel, "endPos"); CRStringField sel_text(sel, "text"); CRStringField sel_chapter(sel, "chapter"); CRIntField sel_startX(sel, "startX"); CRIntField sel_startY(sel, "startY"); CRIntField sel_endX(sel, "endX"); CRIntField sel_endY(sel, "endY"); CRIntField sel_percent(sel, "percent"); lvPoint startpt ( sel_startX.get(), sel_startY.get() ); lvPoint endpt ( sel_endX.get(), sel_endY.get() ); ldomXPointer startp = p->_docview->getNodeByPoint( startpt ); ldomXPointer endp = p->_docview->getNodeByPoint( endpt ); if ( !startp.isNull() && !endp.isNull() ) { ldomXRange r( startp, endp ); if ( r.getStart().isNull() || r.getEnd().isNull() ) return; r.sort(); if ( !r.getStart().isVisibleWordStart() ) r.getStart().prevVisibleWordStart(); //lString16 start = r.getStart().toString(); if ( !r.getEnd().isVisibleWordEnd() ) r.getEnd().nextVisibleWordEnd(); if ( r.isNull() ) return; //lString16 end = r.getEnd().toString(); //CRLog::debug("Range: %s - %s", UnicodeToUtf8(start).c_str(), UnicodeToUtf8(end).c_str()); r.setFlags(1); p->_docview->selectRange( r ); int page = p->_docview->getBookmarkPage(startp); int pages = p->_docview->getPageCount(); lString16 titleText; lString16 posText; p->_docview->getBookmarkPosText(startp, titleText, posText); int percent = 0; if ( pages>1 ) percent = 10000 * page/(pages-1); lString16 selText = r.getRangeText( '\n', 8192 ); sel_percent.set(percent); sel_startPos.set( startp.toString() ); sel_endPos.set( endp.toString() ); sel_text.set(selText); sel_chapter.set(titleText); } }
/* * Class: org_coolreader_crengine_ReaderView * Method: moveSelectionInternal * Signature: (Lorg/coolreader/crengine/Selection;II)Z */ JNIEXPORT jboolean JNICALL Java_org_coolreader_crengine_ReaderView_moveSelectionInternal (JNIEnv * _env, jobject _this, jobject _sel, jint _cmd, jint _param) { CRJNIEnv env(_env); ReaderViewNative * p = getNative(_env, _this); CRObjectAccessor sel(_env, _sel); CRStringField sel_startPos(sel, "startPos"); CRStringField sel_endPos(sel, "endPos"); CRStringField sel_text(sel, "text"); CRStringField sel_chapter(sel, "chapter"); CRIntField sel_startX(sel, "startX"); CRIntField sel_startY(sel, "startY"); CRIntField sel_endX(sel, "endX"); CRIntField sel_endY(sel, "endY"); CRIntField sel_percent(sel, "percent"); int res = p->_docview->doCommand( (LVDocCmd)_cmd, (int)_param ); if ( res ) { ldomXRangeList & sel = p->_docview->getDocument()->getSelections(); if ( sel.length()>0 ) { ldomXRange currSel; currSel = *sel[0]; if ( !currSel.isNull() ) { sel_startPos.set( currSel.getStart().toString() ); sel_endPos.set( currSel.getEnd().toString() ); lvPoint startpt ( currSel.getStart().toPoint() ); lvPoint endpt ( currSel.getEnd().toPoint() ); sel_startX.set( startpt.x ); sel_startY.set( startpt.y ); sel_endX.set( endpt.x ); sel_endY.set( endpt.y ); int page = p->_docview->getBookmarkPage(currSel.getStart()); int pages = p->_docview->getPageCount(); lString16 titleText; lString16 posText; p->_docview->getBookmarkPosText(currSel.getStart(), titleText, posText); int percent = 0; if ( pages>1 ) percent = 10000 * page/(pages-1); lString16 selText = currSel.getRangeText( '\n', 8192 ); sel_percent.set(percent); sel_text.set(selText); sel_chapter.set(titleText); return JNI_TRUE; } } } return JNI_FALSE; }