Skip to content

Commit

Permalink
cool#10630 doc sign: expose visual signing
Browse files Browse the repository at this point in the history
Visual signing means the user first inserts a signature shape, can
adjust the position & size of that shape to fill in the place where the
signature is expected, finally finish the signing by actually adding the
crypto signature.

This requires extending the kit/ code to annotate the
.uno:InsertSignatureLine command similar to what happens when using
.uno:Signature already.

Then the UNO command has to be added to the JS menu, and allow this
action even in UI is in "view mode".

The move / resize of the inserted shape is not yet possible.

Signed-off-by: Miklos Vajna <[email protected]>
Change-Id: Ic6c6f4de6a5c703f34c9bfa435c56d18bc1943db
  • Loading branch information
vmiklos committed Jan 7, 2025
1 parent 888f40f commit dfa5214
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
2 changes: 2 additions & 0 deletions browser/src/control/Control.Menubar.js
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,7 @@ L.Control.Menubar = L.Control.extend({
{name: _UNO('.uno:InsertPageTitleField', 'presentation'), uno: '.uno:InsertPageTitleField'},
{name: _UNO('.uno:InsertPagesField', 'presentation'), uno: '.uno:InsertPagesField'},
]},
{uno: '.uno:InsertSignatureLine', id: 'insert-signatureline'},
{name: _('Electronic signature...'), id: 'insert-esignature', type: 'action'},
]},
{name: _UNO('.uno:FormatMenu', 'presentation'), id: 'format', type: 'menu', menu: [
Expand Down Expand Up @@ -1370,6 +1371,7 @@ L.Control.Menubar = L.Control.extend({
// Only these UNO commands will be enabled in readonly mode
allowedViewModeCommands: [
'.uno:Signature',
'.uno:InsertSignatureLine',
],

allowedViewModeActions: [
Expand Down
3 changes: 2 additions & 1 deletion browser/src/control/Toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,8 @@ L.Map.include({

var isAllowedInReadOnly = false;
var allowedCommands = ['.uno:Save', '.uno:WordCountDialog',
'.uno:Signature', '.uno:PrepareSignature', '.uno:DownloadSignature', '.uno:ShowResolvedAnnotations',
'.uno:Signature', '.uno:PrepareSignature', '.uno:DownloadSignature', '.uno:InsertSignatureLine',
'.uno:ShowResolvedAnnotations',
'.uno:ToolbarMode?Mode:string=notebookbar_online.ui', '.uno:ToolbarMode?Mode:string=Default',
'.uno:ExportToEPUB', '.uno:ExportToPDF', '.uno:ExportDirectToPDF', '.uno:MoveKeepInsertMode', '.uno:ShowRuler'];
if (app.isCommentEditingAllowed()) {
Expand Down
1 change: 1 addition & 0 deletions browser/src/unocommands.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ var unoCommandsArray = {
'InsertRowsBefore':{presentation:{menu:_('Insert Row Above'),},spreadsheet:{context:_('Insert Rows ~Above'),menu:_('Rows ~Above'),},text:{context:_('Insert rows above'),menu:_('Rows ~Above'),},},
'InsertRowsMenu':{spreadsheet:{menu:_('Insert ~Rows'),},},
'InsertSection':{text:{menu:_('Se~ction...'),},},
'InsertSignatureLine':{global:{menu:_('Signat~ure Line...'),},},
'InsertSlide':{presentation:{menu:_('~New Slide'),},},
'InsertSlideField':{presentation:{menu:_('~Slide Number'),},},
'InsertSlideTitleField':{presentation:{menu:_('Slide Tit~le'),},},
Expand Down
12 changes: 7 additions & 5 deletions kit/ChildSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -681,12 +681,12 @@ bool ChildSession::_handleInput(const char *buffer, int length)
}
}
}
else if (tokens[1].find(".uno:Signature") != std::string::npos)
else if (tokens[1] == ".uno:Signature" || tokens[1] == ".uno:InsertSignatureLine")
{
// See if the command has parameters: if not, annotate with sign cert/key.
if (tokens.size() == 2 && unoSignatureCommand())
if (tokens.size() == 2 && unoSignatureCommand(tokens[1]))
{
// .uno:Signature has been sent with parameters from user private info, done.
// The command has been sent with parameters from user private info, done.
return true;
}
}
Expand Down Expand Up @@ -2185,7 +2185,7 @@ bool ChildSession::completeFunction(const StringVector& tokens)
return true;
}

bool ChildSession::unoSignatureCommand()
bool ChildSession::unoSignatureCommand(const std::string& commandName)
{
// See if user private info has a signing key/cert: if so, annotate the UNO command with those
// parameters before sending.
Expand Down Expand Up @@ -2230,7 +2230,9 @@ bool ChildSession::unoSignatureCommand()
argumentsObj->set("SignatureKey", JsonUtil::makePropertyValue("string", signatureKey));

std::ostringstream oss;
oss << "uno .uno:Signature ";
oss << "uno ";
oss << commandName;
oss << " ";
argumentsObj->stringify(oss);
std::string str = oss.str();
StringVector tokens = StringVector::tokenize(str.data(), str.size());
Expand Down
2 changes: 1 addition & 1 deletion kit/ChildSession.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class ChildSession final : public Session
bool dialogEvent(const StringVector& tokens);
bool completeFunction(const StringVector& tokens);
bool unoCommand(const StringVector& tokens);
bool unoSignatureCommand();
bool unoSignatureCommand(const std::string& commandName);
bool selectText(const StringVector& tokens, const LokEventTargetEnum target);
bool selectGraphic(const StringVector& tokens);
bool renderNextSlideLayer(const unsigned width, const unsigned height, double dDevicePixelRatio, bool& done);
Expand Down

0 comments on commit dfa5214

Please sign in to comment.