OSDN Git Service

BrowserRecord関係のメソッドを移動
authorh677 <h677>
Sun, 27 Nov 2005 16:40:05 +0000 (16:40 +0000)
committerh677 <h677>
Sun, 27 Nov 2005 16:40:05 +0000 (16:40 +0000)
BrowserRecord.pas
Giko.pas
GikoDataModule.pas

index ab6ee16..d03170e 100644 (file)
@@ -30,11 +30,17 @@ type
                property        LastSize        : Integer               read FLastSize  write FLastSize;
                property        Repaint         : Boolean               read FRepaint   write FRepaint;
                property        Movement        : string                read FMovement  write FMovement;
+               procedure       Move(const AName: string);
+               procedure       IDAnchorPopup(Abody :string);
        end;
        // BrowserRecord\82É\82Â\82¢\82Ä\82¢\82éFBrowser\82ð\8aO\82·
        procedure ReleaseBrowser( BRecord: TBrowserRecord);
 
 implementation
+
+uses
+       Forms, SysUtils;
+
 // *************************************************************************
 //! BrowserRecord\82É\82Â\82¢\82Ä\82¢\82éFBrowser\82ð\8aO\82·
 // *************************************************************************
@@ -67,11 +73,81 @@ begin
                                Self.Thread.ScrollTop := doc.Body.ScrollTop;
                        end;
                end;
-               //TOleControl(Self.FBrowser).Visible := false;
                ShowWindow(Self.FBrowser.Handle, SW_HIDE);
        end;
 
 end;
+// *************************************************************************
+//! \83u\83\89\83E\83U\82ð\83X\83N\83\8d\81[\83\8b\82³\82¹\82é
+// *************************************************************************
+procedure TBrowserRecord.Move(const AName: string);
+var
+       top: Integer;
+       item: OleVariant;
+begin
+       //\83u\83\89\83E\83U\82ª\95t\82¢\82Ä\82é\82Æ\82«\82¾\82¯\8f\88\97\9d\82·\82é
+       if (Self.Browser <> nil) then begin
+               //\83u\83\89\83E\83U\82ª\83f\81[\83^\82Ì\93Ç\82Ý\8d\9e\82Ý\92\86\82Ì\8e\9e\82Í\93Ç\82Ý\8d\9e\82Ý\82ð\91Ò\82Â
+               while (Self.Browser.ReadyState <> READYSTATE_COMPLETE) and
+                                       (Self.Browser.ReadyState <> READYSTATE_INTERACTIVE) do begin
+                       Sleep(1);
+                       Application.ProcessMessages;
+               end;
+
+               try
+                       top := 0;
+                       item := OleVariant( Self.Browser.Document as IHTMLDocument2)
+                                       .anchors.item(OleVariant(AName));
+                       item.focus();
+                       repeat
+                               top := top + item.offsetTop;
+                               item := item.offsetParent;
+                       until AnsiCompareText(item.tagName, 'body' ) = 0;
+                       OleVariant(Self.Browser.Document as IHTMLDocument2).body.scrollTop := top;
+               except
+               end;
+       end;
+end;
+//ID\83A\83\93\83J\81[\92Ç\89Á
+procedure TBrowserRecord.IDAnchorPopup(Abody :string);
+const
+       OUTER_HTML = '<p id="idSearch"></p>';
+       HIDDEN = 'hidden';
+var
+       firstElement: IHTMLElement;
+       document: IHTMLDocument2;
+       docAll: IHTMLElementCollection;
+       doc : Variant;
+       nCSS : string;
+begin
+       if Self.Browser <> nil then begin
+               try
+                       document := Self.Browser.Document as IHTMLDocument2;
+
+                       if Assigned(document) then begin
+                               docAll := document.all;
+                               firstElement := docAll.item('idSearch', 0) as IHTMLElement;
+                               if (Assigned(firstElement)) then begin
+                                       if Length(Abody) > 0 then begin
+                                               doc := Idispatch( olevariant(Self.Browser.ControlInterface).Document) as IHTMLDocument2;
+                                               nCSS := '<p id="idSearch" style="position:absolute;top:' + IntToStr(doc.Body.ScrollTop + 10) + 'px;right:5px;' //
+                                                       + 'background-color:window; border:outset 1px infobackground; z-index:10; overflow-y:auto; border-top:none">'
+                                                       + Abody + '</p>';
+                                               firstElement.outerHTML := nCSS;
+                                               firstElement.style.visibility := 'visible';
+                                       end else begin
+                                               firstElement.outerHTML := OUTER_HTML;
+                                               firstElement.style.visibility := HIDDEN;
+                                       end;
+                               end else if (Assigned(firstElement)) then begin
+                                       firstElement.outerHTML := OUTER_HTML;
+                                       firstElement.style.visibility := HIDDEN;
+                               end;
+                       end;
+               except
+               end;
+       end;
+end;
 
 
 end.
index 5bfd2a5..33956dd 100644 (file)
--- a/Giko.pas
+++ b/Giko.pas
@@ -741,8 +741,6 @@ type
                procedure IndividualAbonID(Atype : Integer);
                //\82±\82Ì\83\8c\83X\82 \82Ú\81`\82ñ
                procedure IndividualAbon(Atag, Atype : Integer);
-               //ID\83A\83\93\83J\81[\92Ç\89Á
-               procedure IDAnchorPopup(Abody :string);
                //\83u\83\89\83E\83U\82Ì\8dÄ\95`\89æ true:\91S\82Ä\82Ì\83^\83u false:\83A\83N\83e\83B\83u\82È\83^\83u\82Ì\82Ý
                procedure RepaintAllTabsBrowser();
                //\83\8a\83\93\83N\83o\81[\90Ý\92è
@@ -758,9 +756,7 @@ type
                procedure DeleteTab(ThreadItem: TThreadItem); overload;
                procedure DeleteTab(BrowserRecord: TBrowserRecord); overload;
                //\8c»\8dÝ\95\\8e¦\82µ\82Ä\82¢\82é\83X\83\8c\83b\83h\82ð\83X\83N\83\8d\81[\83\8b
-               procedure BrowserMovement(const AName: string); overload;
-               //\8ew\92è\82µ\82½\83u\83\89\83E\83U\82ð\83X\83N\83\8d\81[\83\8b
-               procedure BrowserMovement(const AName: string; BrowserRecord: TBrowserRecord); overload;
+               procedure BrowserMovement(const AName: string);
                //Application\82ÌMainForm\82ð\8eæ\93¾\82·\82é
                function GetMainForm(): TComponent;
                procedure SelectTreeNode(Item: TObject; CallEvent: Boolean);
@@ -3489,61 +3485,13 @@ begin
                end;
        end;
 end;
-procedure TGikoForm.BrowserMovement(const AName: string; BrowserRecord: TBrowserRecord);
-var
-       top: Integer;
-       item: OleVariant;
-       nm: OleVariant;
-       activeBrower :TWebBrowser;
-begin
-       //
-       while (BrowserRecord.Browser.ReadyState <> READYSTATE_COMPLETE) and
-                               (BrowserRecord.Browser.ReadyState <> READYSTATE_INTERACTIVE) do begin
-               Sleep(1);
-               Application.ProcessMessages;
-       end;
-
-       // Access Violation \82ª\8bN\82«\82é\8e\96\82ª\82 \82é\82Ì\82Å\8d¡\8cã\97v\83`\83F\83b\83N
-       if(BrowserRecord <> nil) and (BrowserRecord.Browser <> nil) then begin
-               activeBrower := BrowserRecord.Browser;
-               try
-                       top := 0;
-                       nm := AName;
-                       item := OleVariant( activeBrower.Document as IHTMLDocument2).anchors.item(nm);
-                       item.focus();
-                       repeat
-                               top := top + item.offsetTop;
-                               item := item.offsetParent;
-                       until AnsiCompareText(item.tagName, 'body' ) = 0;
-                       OleVariant(activeBrower.Document as IHTMLDocument2).body.scrollTop := top;
-               except
-               end;
-       end;
-end;
 
 procedure TGikoForm.BrowserMovement(const AName: string);
-var
-       top: Integer;
-       item: OleVariant;
-       nm: OleVariant;
-       activeBrower :TWebBrowser;
 begin
        // Access Violation \82ª\8bN\82«\82é\8e\96\82ª\82 \82é\82Ì\82Å\8d¡\8cã\97v\83`\83F\83b\83N
-       if(BrowserTab.Tabs.Count > 0) and (BrowserTab.TabIndex >= 0) then begin
-               activeBrower := FActiveContent.Browser;
-               try
-                       top := 0;
-                       nm := AName;
-                       item := OleVariant( activeBrower.Document as IHTMLDocument2).anchors.item(nm);
-                       item.focus();
-                       repeat
-                               top := top + item.offsetTop;
-                               item := item.offsetParent;
-                       until AnsiCompareText(item.tagName, 'body' ) = 0;
-
-                       OleVariant(activeBrower.Document as IHTMLDocument2).body.scrollTop := top;
-               except
-               end;
+       if(BrowserTab.Tabs.Count > 0) and (BrowserTab.TabIndex >= 0)
+               and (FActiveContent <> nil) then begin
+               FActiveContent.Move(AName);
        end;
 end;
 
@@ -3871,7 +3819,7 @@ begin
                if(AnsiPos('>>', Text) = 1) or (AnsiPos('>', Text) = 1)
                        or (AnsiPos('\81\84\81\84', Text) = 1) or (AnsiPos('\81\84', Text) = 1) then begin
                        if GikoSys.Setting.ResAnchorJamp then begin
-                               Text := ZenToHan(Text);
+                               Text := ZenToHan(Trim(Text));
 
                                if(AnsiPos('>>', Text) = 1) then begin
                                        //Text := Copy(Text, 3, Length(Text) - 2);
@@ -3880,18 +3828,19 @@ begin
                                        //Text := Copy(Text, 2, Length(Text) - 1);
                                        Delete(Text, 1, 1);
                                end;
+
                                if AnsiPos('-', Text) <> 0 then begin
                                        wkIntSt := StrToIntDef(Copy(Text, 1, AnsiPos('-', Text) - 1), 0);
                                        Text := Copy(Text, AnsiPos('-', Text) + 1, Length(Text));
                                        wkIntTo := StrToIntDef(Text, 0);
                                        if wkIntTo < wkIntSt then
                                                wkIntSt := wkIntTo;
-                               end else
+                               end else begin
                                        wkIntSt := StrToIntDef(Text, 0);
+                               end;
 
                                if wkIntSt <> 0 then begin
-                                       document := FActiveContent.Browser.Document as IHTMLDocument2;
-                    IDAnchorPopup('');
+                                       FActiveContent.IDAnchorPopup('');
                                        BrowserMovement(IntToStr(wkIntSt));
                                end;
 
@@ -4223,14 +4172,14 @@ begin
                                        TreeView.Refresh;
                                        ListView.Refresh;
                                end;
-                               BrowserMovement( BrowserRecord.Movement, BrowserRecord );
+                               BrowserRecord.Move(BrowserRecord.Movement);
                                BrowserRecord.Movement := '';
                        end else if threadItem.UnRead then begin
                                threadItem.UnRead := False;
                                threadItem.ParentBoard.UnRead := ThreadItem.ParentBoard.UnRead - 1;
                                if threadItem.ParentBoard.UnRead < 0 then threadItem.ParentBoard.UnRead := 0;
                                TreeView.Refresh;
-                               BrowserMovement( 'new', BrowserRecord );
+                               BrowserRecord.Move('new');
                                ListView.Refresh;
                        end else if threadItem.ScrollTop <> 0 then begin
                                try
@@ -4637,7 +4586,7 @@ begin
                                                                browserRec := InsertBrowserTab( ThreadItem );
                                                                if ThreadItem.IsLogFile then begin
                                                                        if (browserRec <> nil) and (stRes > 0) then
-                                                                               BrowserMovement( IntToStr( stRes ), browserRec );
+                                                                               browserRec.Move(IntToStr( stRes ));
                                                                end else begin
                                                                        if (browserRec <> nil) and (stRes > 0) then
                                                                                browserRec.Movement := IntToStr( stRes );
@@ -5032,7 +4981,7 @@ var
        ThreadItem: TThreadItem;
 begin
        Result := False;
-    IDAnchorPopup('');
+       FactiveContent.IDAnchorPopup('');
        Doc := FactiveContent.Browser.Document as IHtmlDocument2;
        if Assigned(Doc) then begin
                Range := Doc.selection.createRange as IHTMLTxtRange;
@@ -6848,11 +6797,11 @@ begin
                         rc := GikoUtil.MsgBox(Handle,
                                 '20\8cÂ\88È\8fã\82 \82è\82Ü\82·\82ª\81A\82·\82×\82Ä\95\\8e¦\82µ\82Ü\82·\82©\81H',
                                 'ID\83|\83b\83v\83A\83b\83v\8cx\8d\90',
-                                MB_YESNO or MB_ICONQUESTION);
+                                                               MB_YESNO or MB_ICONQUESTION);
                         limited := rc <> ID_YES;
                     end;
-                    body := GikoSys.GetSameIDResAnchor(AID, FActiveContent.Thread, limited);
-                    IDAnchorPopup(body);
+                                       body := GikoSys.GetSameIDResAnchor(AID, FActiveContent.Thread, limited);
+                                       FActiveContent.IDAnchorPopup(body);
                                end;
                        end;
                except
@@ -6861,8 +6810,6 @@ begin
   end;
 end;
 
-
-
 //\83X\83\8c\83b\83h\88ê\97\97\82ð\8dÅ\91å\89»\82µ\82Ä\83t\83H\81[\83J\83X\82ð\93\96\82Ä\82é
 procedure TGikoForm.SelectTimerTimer(Sender: TObject);
 begin
@@ -7341,42 +7288,6 @@ begin
        CoolBarResized( Sender, BrowserCoolBar );
 end;
 
-//ID\83A\83\93\83J\81[\92Ç\89Á
-procedure TGikoForm.IDAnchorPopup(Abody :string);
-var
-       firstElement: IHTMLElement;
-       document: IHTMLDocument2;
-       docAll: IHTMLElementCollection;
-       doc : Variant;
-       nCSS : string;
-begin
-       try
-               document := FActiveContent.Browser.Document as IHTMLDocument2;
-
-               if Assigned(document) then begin
-                       docAll := document.all;
-                       firstElement := docAll.item('idSearch', 0) as IHTMLElement;
-                       if (Assigned(firstElement)) then begin
-                               if Length(Abody) > 0 then begin
-                                       doc := Idispatch( olevariant(FActiveContent.Browser.ControlInterface).Document) as IHTMLDocument2;
-                                       nCSS := '<p id="idSearch" style="position:absolute;top:' + IntToStr(doc.Body.ScrollTop + 10) + 'px;right:5px;' //
-                                               + 'background-color:window; border:outset 1px infobackground; z-index:10; overflow-y:auto; border-top:none">'
-                                               + Abody + '</p>';
-                                       firstElement.outerHTML := nCSS;
-                                       firstElement.style.visibility := 'visible';
-                               end else begin
-                                       firstElement.outerHTML := '<p id="idSearch"></p>';
-                                       firstElement.style.visibility := 'hidden';
-                               end;
-                       end else if (Assigned(firstElement)) then begin
-                               firstElement.outerHTML := '<p id="idSearch"></p>';
-                               firstElement.style.visibility := 'hidden';
-                       end;
-               end;
-       except
-       end;
-end;
-
 //\82±\82Ì\83\8c\83X\82 \82Ú\81`\82ñ
 procedure TGikoForm.IndividualAbon(Atag, Atype : Integer);
 var
index 9f3a7d0..6c80978 100644 (file)
@@ -1525,10 +1525,10 @@ begin
                str := ZenToHan(str);
                res := StrToIntDef(str, -1);
                if (res > 0) and (res <= GikoForm.GetActiveContent.Count) then begin
-                       GikoForm.BrowserMovement(IntToStr(res), GikoForm.ActiveContent);
+                       GikoForm.ActiveContent.Move(IntToStr(res));
                        SetFocusForBrowserAction.Execute;
                end else if res > GikoForm.GetActiveContent.Count then begin
-                       GikoForm.BrowserMovement(IntToStr(GikoForm.GetActiveContent.Count), GikoForm.ActiveContent);
+                       GikoForm.ActiveContent.Move(IntToStr(GikoForm.GetActiveContent.Count));
                        SetFocusForBrowserAction.Execute;
                end;
        end;
@@ -1681,8 +1681,6 @@ procedure TGikoDM.ToolBarSettingActionExecute(Sender: TObject);
 var
        Dlg: TToolBarSettingDialog;
        i: Integer;
-       //Component: TComponent;
-       ToolButton : TToolButton;
 begin
        Dlg := TToolBarSettingDialog.Create(GikoForm, GikoFormActionList);
        try
@@ -2354,7 +2352,7 @@ begin
                limited := rc <> ID_YES;
        end;
        body := GikoSys.GetSameIDResAnchor(No, ThreadItem, limited);
-       GikoForm.IDAnchorPopup(body);
+       GikoForm.ActiveContent.IDAnchorPopup(body);
 end;
 // *************************************************************************
 //! \82±\82Ì\83\8c\83X\82 \82Ú\81`\82ñ\81@\81i\92Ê\8fí\81j