5

私の問題: .doc と .odt を読み取る必要がある自動化されたシステムを作成し、それに対して何らかの操作を実行して、再度 pdf にエクスポートします。

現在、必要なものすべてで問題なく動作します。これまで、すべての問題を解決できました。

ユーザーが変更を記録したドキュメント (レッドライン) を提供した場合、そのすべての変更を自動的に受け入れるか、非表示にする必要があります。

OOo が画面に表示されている限り、以下のコードで解決できます。非表示で起動すると、呼び出しはまったく何もしません。

だから、ここに私が現在していることがあります:

    // DO NOT try to cast this to Desktop as com.sun.star.frame.Desktop is NOT a valid class!
    // keep it as Object and cast it to XDesktop later (via queryInterface)
    Object desktop = xMCF.createInstanceWithContext("com.sun.star.frame.Desktop", xContext);
    XMultiServiceFactory xFactory = (XMultiServiceFactory) UnoRuntime.queryInterface(
        XMultiServiceFactory.class, xMCF);
    // what goes for desktop above is valid for DispatchHelper as well.
    Object dispatchHelper = xFactory.createInstance("com.sun.star.frame.DispatchHelper");

    // the DispatchHelper is the class that handles the interaction with dialogs.
    XDispatchHelper helper = (XDispatchHelper) UnoRuntime.queryInterface(
        XDispatchHelper.class, dispatchHelper);
    XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface(com.sun.star.frame.XDesktop.class, desktop);
    XFrame xFrame = xDesktop.getCurrentFrame();
    XDispatchProvider xDispatchProvider = (XDispatchProvider) UnoRuntime.queryInterface(XDispatchProvider.class, xFrame);

    // We issute the Track Changes Dialog (Bearbeiten - Änderungen // Edit - Changes) and tell it
    // to ACCEPT all changes.
    PropertyValue[] acceptChanges = new PropertyValue[1];
    acceptChanges[0] = new PropertyValue();
    acceptChanges[0].Name = "AcceptTrackedChanges";
    acceptChanges[0].Value = Boolean.TRUE;
    helper.executeDispatch(xDispatchProvider, ".uno:AcceptTrackedChanges", "", 0, acceptChanges);

    // We issue it again to tell it to stop showing changes.
    PropertyValue[] showChanges = new PropertyValue[1];
    showChanges[0] = new PropertyValue();
    showChanges[0].Name = "ShowTrackedChanges";
    showChanges[0].Value = Boolean.FALSE;
    helper.executeDispatch(xDispatchProvider, ".uno:ShowTrackedChanges", "", 0, showChanges);

私の現在の推測では、非表示になっているため、ディスパッチャーを呼び出すフレームがないため、これを呼び出すことはできません。しかし、コンポーネントの Dispatcher を取得する方法が見つかりませんでした。

TrackChanges私はすでに(に)ディスパッチしようとしましFALSEたが、それもできませんでした。

4

1 に答える 1

4

OOo API を理解するのに 2 日間費やした後、ドキュメントがフロントエンドに読み込まれていないことがわかりました。これが、このアプローチが失敗する理由です。ただし、ドキュメントのプロパティを直接変更できます。

XPropertySet docProperties = UnoRuntime.queryInterface(XPropertySet.class, document);
docProperties.setPropertyValue("RedlineDisplayType", RedlineDisplayType.NONE);

プロパティ名"RedlineDisplayType"RedlinePortion ドキュメントにあります

于 2014-02-21T17:26:08.480 に答える