Sandwich schrieb:
Hallo,
das Problem - nach dem Schließen und Wiederöffnen eines LO-Calc Dokuments sind (in erratischer Weise, d.h. manche schon, manche nicht) die Kommentare verschwunden - ist anscheinend schon uralt, aber noch immer aktuell ( https://bugs.documentfoundation.org/show_bug.cgi?id=86725 ).
Ich habe es jetzt "am eigenen Leib verspürt".
(LO Version: 6.4.6.2 , Build-ID: 1:6.4.6-0ubuntu0.20.04.1)
1. Weiß jemand einen praktikablen workaround?
Wie wäre es mit einer ordentlichen Eingabemaske für eine richtige Datenbank?
Ich hätte mir folgendes überlegt:
Die Kommentare stehen nicht in der eigentlichen Tabelle ("Haupttabelle"), sondern in einer eigenen "Kommentar-Tabelle" als "normaler" Text in den entsprechenden Zellen; also z.B. der Kommentar für die Zelle "Haupttabelle.A1" steht als normaler Text in der Zelle "Kommentare.A1" u.s.w. u.s.f.
Beim Öffnen des Dokuments (oder beim Klicken auf einen bestimmten Button) wird ein Makro aktiv, das folgendes macht:
Es geht alle Zellen in einem definierten Bereich durch und falls eine Zelle in "Kommentare" nicht leer ist und die entsprechende Zelle in "Haupttabelle" keinen Kommentar hat, wird der Text von "Kommentare" in die entsprechende Zelle von "Haupttabelle" als Kommentar eingefügt.
Leider kann ich zu wenig Makro-Sprache (Basic?).
Sowas kann man sich ergoogeln... - ist für LO Basic zwar mühsam, aber möglicht
2. Wie würde so ein Makro ausschauen?
Zum Beispiel so - am besten mal mit dem angehängten Dokument ausprobieren:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72 | REM ***** BASIC *****
REM save this as test.bas and execute the set_annotations_from_sheet macro
sub set_annotations_from_sheet
rem set the area to work on
dim max_cols as integer: max_cols = 2
dim max_rows as integer: max_rows = 10
rem check if we got a spreadsheet document
dim oDoc as Object : oDoc = ThisComponent
if not oDoc.supportsService("com.sun.star.sheet.SpreadsheetDocument") then
msgbox "Das ist kein Spreadsheet, LMAA!"
exit sub
end if
rem get the work sheets in the document
dim sheets as object: sheets = oDoc.Sheets
rem get the spreadsheet for comments
dim commentSheet as object: commentSheet = sheets.getByName("Kommentare")
rem get the worksheet for the main spreadsheet
dim mainSheet as object: mainSheet = sheets.getByName("Haupttabelle")
rem get the annotations for the main spreadsheet
dim sheetAnnotations as object: sheetAnnotations = mainSheet.annotations
rem define a cell for working in the comment table
dim c_cell as object
rem define a cell for working in the main table
dim w_cell as object
rem loop over the defined range of cells
for y=0 to max_rows
for x=0 to max_cols
rem get the cell in the comment sheet at the given position
c_cell = commentSheet.getCellbyPosition(x, y)
rem check if the cell is empty
if (c_cell.Type <> com.sun.star.table.CellContentType.EMPTY) then
rem get the cell in the main sheet at the given position
w_cell = mainSheet.getCellbyPosition(x, y)
rem check if the cell in the main sheet has no annotation
if (w_cell.getAnnotation().getString( ) = "") then
rem add the annotation to the cell
sheetAnnotations.insertNew(w_cell.getCellAddress, c_cell.string)
rem set the annotation to be visible
w_cell.Annotation.isVisible = True
end if
end if
next x
next y
end sub
rem see https://gist.github.com/Zenkly/876e61975c6d0983383a28bda8efbe52#file-libreoffice-code-L69
Function getIndexAnnotationByCell(AgeCell As Object) As Long
Dim result As Long
Dim SheetAnnotations As Object
Dim annotationIndex As Long
Dim anAnnotation As Object
Dim isFound As Boolean
SheetAnnotations = AgeCell.spreadSheet.annotations
While ((annotationIndex < SheetAnnotations.count) and (not isFound))
anAnnotation = SheetAnnotations.getByIndex(annotationIndex)
isFound = ((anAnnotation.position.row = AgeCell.cellAddress.row) and (anAnnotation.position.column = AgeCell.cellAddress.column))
If (isFound) Then
result = annotationIndex
End If
annotationIndex = annotationIndex + 1
Wend
if(not isFound) Then
result = -1
End If
getIndexAnnotationByCell = result
End Function
|
Eine Sache, die mir noch nicht gefällt ist, dass Annotationen überlappen können, wenn sie zu nahe bei einander sind und es dann so aussieht, als würden zwei Zellen auf den selben Kommentar zeigen.