OOobbs2/66
質問
Writer ドキュメントで索引を作成するときに利用できるコンコーダンスファイルを Writer ドキュメント上で作成する補助をする拡張機能。 回答
使い方
選択範囲のインデックスマークを削除するマクロ。インデックスは最初に見つかったものを取得。 Sub RemoveIndexMarksFromSelection() Dim oDoc As Object oDoc = ThisComponent If NOT oDoc.supportsService("com.sun.star.text.TextDocument") Then Exit Sub oSelection = oDoc.getCurrentSelection() 'sIndexName = "Alphabetical Index1" If oSelection.supportsService("com.sun.star.text.TextRanges") Then oIndexes = oDoc.DocumentIndexes If oIndexes.getCount() = 0 Then Exit Sub oIndex = GetDocumentIndex(oIndexes) 'oIndex = oIndexes.getByName(sIndexName) If IsNull(oIndex) Then Exit Sub oSelected = oSelection.getByIndex(0) oText = oDoc.getText() oMarks = oIndex.DocumentIndexMarks For i = 0 To UBound(oMarks) On Error Goto Handler oRange = oMarks(i).Anchor nRS = oText.compareRegionStarts(oRange,oSelected) nRE = oText.compareRegionEnds(oRange,oSelected) If (nRS = -1 AND nRE = 1) Then oText.removeTextContent(oMarks(i)) Else If (nRS = 0 AND nRE = 1) OR (nRS = -1 AND nRE = 0) Then oText.removeTextContent(oMarks(i)) End If End If Handler: Resume Next Next i End If End Sub Function GetDocumentIndex(oIndexes) As Object Dim oIndex As Object For i = 0 To oIndexes.getCount() -1 oIdx = oIndexes.getByIndex(i) If oIdx.supportsService("com.sun.star.text.DocumentIndex") Then oIndex = oIdx Exit For End If Next i GetDocumentIndex = oIndex End Function ccindex と上記マクロを利用すれば、
残ったインデックスエントリーを編集するマクロが必要か・・・ 日本語を利用するときのコンコーダンスファイルのエンコード
感想,コメント,メモ
|