> ## Documentation Index
> Fetch the complete documentation index at: https://docs.abbyy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Component Synchronizer の動作

> ABBYY FineReader Engine の Component Synchronizer が Visual Components（Image Viewer、Text Editor など）を接続し、Windows 上で単一の OCR アプリケーションとしてイベントに反応する仕組み。

<Warning>
  Visual Components は、Windows 版 FRE に実装されています。
</Warning>

[Component Synchronizer](/ja/fine-reader/engine/visual-components-reference/supplementary-objects/componentsynchronizer) は、Visual Components で発生するさまざまなイベントに自動的に応答する特別なコンポーネントです。複数の Visual Components を Synchronizer に接続すると、それらを 1 つのアプリケーションとして動作させることができます。

接続されているコンポーネントすべてを Component Synchronizer で使用する必要はなく、必要なものだけを接続できます。たとえば、[Image Viewer](/ja/fine-reader/engine/visual-components-reference/imageviewer) は ImageViewer プロパティを介して、[Text Editor](/ja/fine-reader/engine/visual-components-reference/texteditor) は TextEditor プロパティを介して接続できます。

Component Synchronizer にはユーザーインターフェイスがありません。また、Visual Components の内部機能は使用せず、各コンポーネントの COM API のみを使用します。Component Synchronizer は以下のように動作します。

<div id="when-a-component-is-connected-to-the-synchronizer-through-the-api">
  ## コンポーネントがAPIを通じてSynchronizerに接続されている場合
</div>

コンポーネントまたはオブジェクトがComponent Synchronizerに接続されている場合:

<Accordion title="ImageViewer property">
  この場合、<strong>IComponentSynchronizer::ImageViewer</strong> propertyに指定の <strong>ImageViewer</strong> オブジェクトが設定され、続いて以下の操作が実行されます:

  <table>
    <thead>
      <tr>
        <th>property</th>
        <th>設定値</th>
      </tr>
    </thead>

    <tbody>
      <tr>
        <td>
          <strong>IImageViewer::ZoomRectEnabled</strong>
        </td>

        <td>True</td>
      </tr>

      <tr>
        <td>
          <strong>IImageViewer::DocumentProcessingParams</strong>
        </td>

        <td>
          <strong>IComponentSynchronizer::DocumentProcessingParams</strong>
        </td>
      </tr>

      <tr>
        <td>
          <strong>IImageViewer::FRPage</strong>
        </td>

        <td>
          <strong>IComponentSynchronizer::Document</strong> 内で <strong>IComponentSynchronizer::PageIndex</strong> インデックスに対応するページ
        </td>
      </tr>
    </tbody>
  </table>
</Accordion>

<Accordion title="ZoomViewer property">
  この場合、<strong>IComponentSynchronizer::ZoomViewer</strong> propertyに指定の <strong>ZoomViewer</strong> オブジェクトが設定され、続いて以下の操作が実行されます:

  <table>
    <thead>
      <tr>
        <th>property</th>
        <th>設定値</th>
      </tr>
    </thead>

    <tbody>
      <tr>
        <td>
          <strong>IZoomViewer::SymbolRectEnabled</strong>
        </td>

        <td>True</td>
      </tr>

      <tr>
        <td>
          <strong>IZoomViewer::DocumentProcessingParams</strong>
        </td>

        <td>
          <strong>IComponentSynchronizer::DocumentProcessingParams</strong>
        </td>
      </tr>

      <tr>
        <td>
          <strong>IZoomViewer::FRPage</strong>
        </td>

        <td>
          <strong>IComponentSynchronizer::Document</strong> 内で <strong>IComponentSynchronizer::PageIndex</strong> インデックスに対応するページ
        </td>
      </tr>
    </tbody>
  </table>
</Accordion>

<Accordion title="TextEditor property">
  この場合、<strong>IComponentSynchronizer::TextEditor</strong> propertyに指定の <strong>TextEditor</strong> オブジェクトが設定され、続いて以下の操作が実行されます:

  <table>
    <thead>
      <tr>
        <th>property</th>
        <th>設定値</th>
      </tr>
    </thead>

    <tbody>
      <tr>
        <td>
          <strong>ITextEditor::SynthesisParamsForDocument</strong>
        </td>

        <td>
          <strong>SynthesisParamsForDocument</strong> propertyの値 (
          <strong>IComponentSynchronizer::DocumentProcessingParams</strong>{" "}
          オブジェクト)
        </td>
      </tr>

      <tr>
        <td>
          <strong>ITextEditor::FRPage</strong>
        </td>

        <td>
          <strong>IComponentSynchronizer::Document</strong> 内で <strong>IComponentSynchronizer::PageIndex</strong> インデックスに対応するページ
        </td>
      </tr>
    </tbody>
  </table>
</Accordion>

<Accordion title="TextValidator property">
  この場合、<strong>IComponentSynchronizer::TextValidator</strong> propertyに指定の <strong>TextValidator</strong> オブジェクトが設定され、続いて以下の操作が実行されます:

  <table>
    <thead>
      <tr>
        <th>property</th>
        <th>設定値</th>
      </tr>
    </thead>

    <tbody>
      <tr>
        <td>
          <strong>ITextValidator::SynthesisParamsForDocument</strong>
        </td>

        <td>
          <strong>SynthesisParamsForDocument</strong> propertyの値 (
          <strong>IComponentSynchronizer::DocumentProcessingParams</strong>{" "}
          オブジェクト)
        </td>
      </tr>

      <tr>
        <td>
          <strong>ITextValidator::FRDocument</strong>
        </td>

        <td>
          <strong>IComponentSynchronizer::Document</strong>
        </td>
      </tr>
    </tbody>
  </table>
</Accordion>

<Accordion title="DocumentViewer property">
  In this case, the IComponentSynchronizer::DocumentViewer property is set to the specified <strong>DocumentViewer</strong> object, and then the following operations are performed:

  <table>
    <thead>
      <tr>
        <th>The property</th>
        <th>Is set to</th>
      </tr>
    </thead>

    <tbody>
      <tr>
        <td>
          <strong>IDocumentViewer::FRDocument</strong>
        </td>

        <td>
          <strong>IComponentSynchronizer::Document</strong>
        </td>
      </tr>

      <tr>
        <td>
          <strong>IDocumentViewer::DocumentProcessingParams</strong>
        </td>

        <td>
          <strong>IComponentSynchronizer::DocumentProcessingParams</strong>
        </td>
      </tr>

      <tr>
        <td>
          <strong>IDocumentViewer::ActivePage</strong>
        </td>

        <td>
          The ページ in the <strong>IComponentSynchronizer::Document</strong> with
          the <strong>IComponentSynchronizer::PageIndex</strong> index
        </td>
      </tr>
    </tbody>
  </table>
</Accordion>

<Accordion title="Document property">
  In this case, the <strong>IComponentSynchronizer::Document</strong> property is set to the specified <strong>FRDocument</strong> object, and then the following operations are performed:

  <table>
    <thead>
      <tr>
        <th>The property</th>
        <th>Is set to</th>
      </tr>
    </thead>

    <tbody>
      <tr>
        <td>
          <strong>IImageViewer::FRPage</strong>

          <br />

          <strong>IZoomViewer::FRPage</strong>

          <br />

          <strong>ITextEditor::FRPage</strong>

          <br />

          <strong>IDocumentViewer::ActivePage</strong>
        </td>

        <td>
          The first ページ in the <strong>IComponentSynchronizer::Document</strong>
        </td>
      </tr>

      <tr>
        <td>
          <strong>IComponentSynchronizer::PageIndex</strong>
        </td>

        <td>0</td>
      </tr>

      <tr>
        <td>
          <strong>IDocumentViewer::FRDocument</strong>

          <br />

          <strong>ITextValidator::FRDocument</strong>
        </td>

        <td>
          <strong>IComponentSynchronizer::Document</strong>
        </td>
      </tr>
    </tbody>
  </table>
</Accordion>

<Accordion title="DocumentProcessingParams property">
  In this case, the <strong>IComponentSynchronizer::DocumentProcessingParams</strong> property is set to the specified <strong>DocumentProcessingParams</strong> object, and then the following operations are performed:

  <table>
    <thead>
      <tr>
        <th>The property</th>
        <th>Is set to</th>
      </tr>
    </thead>

    <tbody>
      <tr>
        <td>
          <strong>IImageViewer::DocumentProcessingParams</strong>

          <br />

          <strong>IZoomViewer::DocumentProcessingParams</strong>

          <br />

          <strong>IDocumentViewer::DocumentProcessingParams</strong>
        </td>

        <td>
          <strong>IComponentSynchronizer::DocumentProcessingParams</strong>
        </td>
      </tr>

      <tr>
        <td>
          <strong>ITextEditor::SynthesisParamsForDocument</strong> <br />
          <strong>ITextValidator::SynthesisParamsForDocument</strong>
        </td>

        <td>
          The value of the <strong>SynthesisParamsForDocument</strong> property of
          the <strong>IComponentSynchronizer::DocumentProcessingParams</strong>{" "}
          object
        </td>
      </tr>
    </tbody>
  </table>
</Accordion>

<Accordion title="PageIndex property">
  In this case, the <strong>IComponentSynchronizer::PageIndex</strong> property is set to the specified value, and then the following operations are performed:

  <table>
    <thead>
      <tr>
        <th>The property</th>
        <th>Is set to</th>
      </tr>
    </thead>

    <tbody>
      <tr>
        <td>
          <strong>IImageViewer::FRPage</strong>

          <br />

          <strong>IZoomViewer::FRPage</strong>

          <br />

          <strong>ITextEditor::FRPage</strong>

          <br />

          <strong>IDocumentViewer::ActivePage</strong>
        </td>

        <td>
          The ページ in the <strong>IComponentSynchronizer::Document</strong> with
          the <strong>IComponentSynchronizer::PageIndex</strong> index
        </td>
      </tr>
    </tbody>
  </table>
</Accordion>

<div id="when-a-connected-component-generates-an-event">
  ## 接続されたコンポーネントがイベントを発生させた場合
</div>

接続された Image Viewer のイベント:

<Accordion title="OnMouseButtonUp イベント">
  Image Viewer で [OnMouseButtonUp](/ja/fine-reader/engine/visual-components-reference/iinputevents/onmousebuttonup-method) イベントが発生すると、Component Synchronizer は次の操作を実行します。

  ```
  if( mouseButton == MBU_LeftButton && ZoomViewer != 0 ) {
   int documentX = 0;
   int documentY = 0;
   ImageViewer->ScreenToDocument( x, y, &documentX, &documentY );
   ZoomViewer->CenterOnDocumentPoint( documentX, documentY );
  }
  ```
</Accordion>

<Accordion title="OnBlockSelectionChanged イベント">
  Image Viewer で [OnBlockSelectionChanged](/ja/fine-reader/engine/visual-components-reference/iimageviewerevents/onblockselectionchanged-method) イベントが発生すると、Component Synchronizer は次の操作を実行します。

  ```
  if( selected == VARIANT_TRUE ) {
   if( textEditor != 0 ) {
    textEditor->ShowBlock( blockIndex, NotFound );
   }
  }
  ```
</Accordion>

<Accordion title="OnTableSelected イベント">
  Image Viewer で [OnTableCellsSelected](/ja/fine-reader/engine/visual-components-reference/iimageviewerevents/ontablecellsselected-method) イベントが発生すると、Component Synchronizer は選択されたブロックのインデックスと右下のセルのインデックスを指定して、[TextEditor](/ja/fine-reader/engine/visual-components-reference/texteditor) オブジェクトの [ShowBlock](/ja/fine-reader/engine/visual-components-reference/texteditor/showblock-method) メソッドを呼び出します。
</Accordion>

<Accordion title="OnAfterDblClick イベント">
  Image Viewer で [OnAfterDblClick](/ja/fine-reader/engine/visual-components-reference/iimageviewerevents/onafterdblclick-method) イベントが発生すると、Component Synchronizer は次の操作を実行します。

  ```
  if( textEditor != 0 ) {
   textEditor->ActivateOn( blockIndex, x, y );
  }
  ```
</Accordion>

<Accordion title="OnActivePageChanged イベント">
  Image Viewer で [OnActivePageChanged](/ja/fine-reader/engine/visual-components-reference/iimageviewerevents/onactivepagechanged-method) イベントが発生し、ComponentSynchronizer オブジェクトの ZoomViewer、TextEditor、DocumentViewer の各プロパティがすでに設定されている場合、対応するコンポーネントの FRPage または ActivePage プロパティが、文書の指定されたページに設定されます。
</Accordion>

<Accordion title="OnSelectTool イベント">
  Image Viewer で [OnSelectTool](/ja/fine-reader/engine/visual-components-reference/iimageviewerevents/onselecttool-method) イベントが発生すると、Component Synchronizer は次の操作を実行します。

  ```
  if( ZoomViewer == 0 ) {
   return;
  }
  IFRPagePtr curPage;
  ZoomViewer->get_FRPage( &curPage );
  if( curPage != 0 ) {
   ZoomViewer->put_ActiveTool( selectedTool );
  }
  ```
</Accordion>

<Accordion title="OnOptionsChanged イベント">
  Image Viewer で [OnOptionsChanged](/ja/fine-reader/engine/visual-components-reference/iimageviewerevents/onoptionschanged-method) イベントが発生し、ComponentSynchronizer オブジェクトの ZoomViewer、DocumentViewer、TextEditor、TextValidator の各プロパティがすでに設定されている場合、ZoomViewer、DocumentViewer、TextEditor、TextValidator の各オブジェクトの UpdateOptions メソッドが呼び出されます。
</Accordion>

接続された Zoom Viewer のイベント:

<Accordion title="OnVisibleDocumentAreaChanged イベント">
  Zoom Viewer で [OnVisibleDocumentAreaChange](/ja/fine-reader/engine/visual-components-reference/izoomviewerevents/onvisibledocumentareachange-method) イベントが発生すると、Component Synchronizer は次の操作を実行します。

  ```
  if( ImageViewer != 0 ) {
   ImageViewer->put_ZoomRect( visibleRect );
   if( isInFocus ) {
    ImageViewer->ShowDocumentArea( visibleRect );
   }
  }
  ```
</Accordion>

<Accordion title="OnBlockSelectionChanged イベント">
  Zoom Viewer で [OnBlockSelectionChanged](/ja/fine-reader/engine/visual-components-reference/izoomviewerevents/onblockselectionchanged-method) イベントが発生すると、Component Synchronizer は次の操作を実行します。

  ```
  if( selected == VARIANT_TRUE ) {
   if( textEditor != 0 ) {
    textEditor->ShowBlock( blockIndex, NotFound );
   }
  }
  ```
</Accordion>

<Accordion title="OnTableCellsSelected イベント">
  Zoom Viewer で [OnTableCellsSelected](/ja/fine-reader/engine/visual-components-reference/izoomviewerevents/ontablecellsselected-method) イベントが発生すると、Component Synchronizer は選択されたブロックのインデックスと右下のセルのインデックスを指定して、TextEditor オブジェクトの ShowBlock メソッドを呼び出します。
</Accordion>

<Accordion title="OnAfterDblClick イベント">
  Zoom Viewer が [OnAfterDblClick](/ja/fine-reader/engine/visual-components-reference/iimageviewerevents/onafterdblclick-method) イベントを発生させると、Component Synchronizer は次の処理を実行します。

  ```
  if( textEditor != 0 ) {
   textEditor->ActivateOn( blockIndex, x, y );
  }
  ```
</Accordion>

<Accordion title="OnActivePageChanged イベント">
  Zoom Viewer が [OnActivePageChanged](/ja/fine-reader/engine/visual-components-reference/izoomviewerevents/onactivepagechanged-method) イベントを発生させ、かつ ComponentSynchronizer object の ImageViewer、TextEditor、DocumentViewer プロパティがすでに設定されている場合、対応する component の FRPage または ActivePage プロパティが、Document の指定されたページに設定されます。
</Accordion>

<Accordion title="OnSelectTool イベント">
  Zoom Viewer が [OnSelectTool](/ja/fine-reader/engine/visual-components-reference/izoomviewerevents/onselecttool-method) イベントを発生させると、Component Synchronizer は次の処理を実行します。

  ```
  if( ImageViewer == 0 ) {
   return;
  }
  IFRPagePtr curPage;
  ImageViewer->get_FRPage( &curPage );
  if( curPage != 0 ) {
   ImageViewer->put_ActiveTool( selectedTool );
  }
  ```
</Accordion>

<Accordion title="OnOptionsChanged イベント">
  Zoom Viewer が [OnOptionsChanged](/ja/fine-reader/engine/visual-components-reference/izoomviewerevents/onoptionschanged-method) イベントを発生させ、かつ ComponentSynchronizer object の ImageViewer、DocumentViewer、TextEditor、TextValidator プロパティがすでに設定されている場合、ImageViewer、DocumentViewer、TextEditor、TextValidator objects の UpdateOptions メソッドが呼び出されます。
</Accordion>

接続された Document Viewer のイベント:

<Accordion title="OnActivePageChanged イベント">
  Document Viewer が [OnActivePageChanged](/ja/fine-reader/engine/visual-components-reference/idocumentviewerevents/onactivepagechanged-method) イベントを発生させ、かつ ComponentSynchronizer object の ImageViewer、ZoomViewer、TextEditor プロパティがすでに設定されている場合、対応する component の FRPage プロパティが、Document の指定されたページに設定されます。
</Accordion>

<Accordion title="OnDocumentChanged イベント">
  Document Viewer が [OnDocumentChanged](/ja/fine-reader/engine/visual-components-reference/idocumentviewerevents/ondocumentchanged-method) イベントを発生させ、かつ ComponentSynchronizer object の ImageViewer、ZoomViewer、TextEditor、TextValidator プロパティがすでに設定されている場合:

  * TextValidator object の FRDocument プロパティが新しい Document に設定されます
  * ImageViewer、ZoomViewer、TextEditor objects の FRPage プロパティと DocumentViewer object の ActivePage プロパティが、新しい Document の最初のページに設定されます
</Accordion>

<Accordion title="OnOptionsChanged イベント">
  Document Viewer が [OnOptionsChanged](/ja/fine-reader/engine/visual-components-reference/idocumentviewerevents/onoptionschanged-method) イベントを発生させ、かつ ComponentSynchronizer object の ImageViewer、ZoomViewer、TextEditor、TextValidator プロパティがすでに設定されている場合、ImageViewer、ZoomViewer、TextEditor、TextValidator objects の UpdateOptions メソッドが呼び出されます。
</Accordion>

接続された Text Editor のイベント:

<Accordion title="OnEditorBlockChanged イベント">
  Text Editor が [OnEditorBlockChanged](/ja/fine-reader/engine/visual-components-reference/itexteditorevents/oneditorblockchanged-method) イベントを発生させると、ComponentSynchronizer は次の処理を実行します。

  1. ComponentSynchronizer object の ImageViewer、ZoomViewer プロパティがすでに設定されている場合、指定された block に対して、ImageViewer object と ZoomViewer object の SetSelectedBlocksIndices メソッドが呼び出されます。
  2. それがテーブルブロックの場合、選択されたセルに対して、ImageViewer object と ZoomViewer object の SetSelectedCells メソッドが呼び出されます。
  3. 次に、ImageViewer object と ZoomViewer object の ShowDocumentArea メソッドが呼び出されます。
</Accordion>

<Accordion title="OnSymbolSelected イベント">
  Text Editor が [OnSymbolSelected](/ja/fine-reader/engine/visual-components-reference/itexteditorevents/onsymbolselected-method) イベントを発生させると、Component Synchronizer は次の処理を実行します。

  ```
  if( ZoomViewer != 0 ) {
   ZoomViewer->put_SymbolRect( symbolRect );
  }
  if( ImageViewer != 0 ) {
   ImageViewer->ShowDocumentArea( symbolRect );
  }
  if( ZoomViewer != 0 ) {
   ZoomViewer->ShowDocumentArea( symbolRect );
  }
  ```
</Accordion>

<Accordion title="OnActivePageChanged イベント">
  Text Editor で [OnActivePageChanged](/ja/fine-reader/engine/visual-components-reference/itexteditorevents/onactivepagechanged-method) イベントが発生し、Component Synchronizer オブジェクトの ImageViewer、ZoomViewer、DocumentViewer の各プロパティがすでに設定されている場合、対応するコンポーネントの FRPage または ActivePage プロパティが、文書内の指定されたページに設定されます。
</Accordion>

<Accordion title="OnOptionsChanged イベント">
  Text Editor で [OnOptionsChanged](/ja/fine-reader/engine/visual-components-reference/itexteditorevents/onoptionschanged-method) イベントが発生し、Component Synchronizer オブジェクトの ImageViewer、ZoomViewer、DocumentViewer、TextValidator の各プロパティがすでに設定されている場合、ImageViewer、ZoomViewer、DocumentViewer、TextValidator オブジェクトの UpdateOptions メソッドが呼び出されます。
</Accordion>

接続されている Text Validator のイベント:

<Accordion title="OnSymbolSelected イベント">
  Text Validator で [OnSymbolSelected](/ja/fine-reader/engine/visual-components-reference/itextvalidatorevents/onsymbolselected-method) イベントが発生すると、Component Synchronizer は次の処理を実行します:

  ```
  if( ZoomViewer != 0 ) {
   ZoomViewer->put_SymbolRect( symbolRectangle );
  }
  ```
</Accordion>

<Accordion title="OnSelectionChanged イベント">
  Text Validator で [OnSelectionChanged](/ja/fine-reader/engine/visual-components-reference/itextvalidatorevents/onselectionchanged-method) イベントが発生すると、Component Synchronizer は次の処理を実行します:

  ```
  int symbolPos;
  IEditorPosition* nextPosition;
  position->get_Symbol( &symbolPos );
  nextPosition->put_Symbol( symbolPos + length );
  if( textEditor != 0 ) {
   textEditor->SetSelection( position, nextPosition );
  }
  ```
</Accordion>

<Accordion title="OnActivePageChanged イベント">
  Text Validator で [OnActivePageChanged](/ja/fine-reader/engine/visual-components-reference/itextvalidatorevents/onactivepagechanged-method) イベントが発生し、Component Synchronizer オブジェクトの ImageViewer、ZoomViewer、TextEditor、DocumentViewer の各プロパティがすでに設定されている場合、対応するコンポーネントの FRPage または ActivePage プロパティが、文書内の指定されたページに設定されます。
</Accordion>

<Accordion title="OnDocumentChanged イベント">
  Text Validator で [OnDocumentChanged](/ja/fine-reader/engine/visual-components-reference/itextvalidatorevents/ondocumentchanged-method) イベントが発生し、Component Synchronizer オブジェクトの ImageViewer、ZoomViewer、TextEditor、DocumentViewer の各プロパティがすでに設定されている場合:

  * DocumentViewer オブジェクトの FRDocument プロパティが新しい文書に設定されます
  * ImageViewer、ZoomViewer、TextEditor オブジェクトの FRPage プロパティと、DocumentViewer オブジェクトの ActivePage プロパティが、新しい文書の最初のページに設定されます。
</Accordion>

<Accordion title="OnOptionsChanged イベント">
  Text Validator で [OnOptionsChanged](/ja/fine-reader/engine/visual-components-reference/itextvalidatorevents/onoptionschanged-method) イベントが発生し、Component Synchronizer オブジェクトの ImageViewer、ZoomViewer、TextEditor、DocumentViewer の各プロパティがすでに設定されている場合、ImageViewer、ZoomViewer、TextEditor、DocumentViewer オブジェクトの UpdateOptions メソッドが呼び出されます。
</Accordion>

<div id="see-also">
  ## 関連項目
</div>

[ComponentSynchronizer](/ja/fine-reader/engine/visual-components-reference/supplementary-objects/componentsynchronizer)
