Commit Graph

388 Commits

Author SHA1 Message Date
8885343a33 Fix inefficient usage of string::find() in condition (CWE597)
string::compare() will be faster when string::find's result is
compared with 0, because it will not scan the whole string.

Change-Id: I78596a6d796fe9779f88b7c7b91da09aa27b7035
Reviewed-on: https://gerrit.libreoffice.org/32430
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2017-01-02 10:39:04 +00:00
c5ceb0134d lok: Fix state feedback for ToggleMergeCells
Now it broadcasts "disabled" to disable the command and
true/false to tell the status of the command which automatically
means "enabled"

Change-Id: I3314da77fb2b84d97f64b9832d65791b84fcd7df
Reviewed-on: https://gerrit.libreoffice.org/32086
Reviewed-by: pranavk <pranavk@collabora.co.uk>
Tested-by: pranavk <pranavk@collabora.co.uk>
2016-12-16 15:07:31 +00:00
828e77009b lokit: support password protected binary MS and OOXML documents
Change-Id: Id7fa1f428d07271e71f3df962bd6718a35372389
Reviewed-on: https://gerrit.libreoffice.org/31730
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
2016-12-08 10:04:08 +00:00
96918103a0 Revert "lok: in preinit stage, do not force locale"
Fixes unit-prefork in online for me.

Kendy suggested to also change the forced locale to en-US.UTF-8
instead of just en-US, but that caused:
warn:i18nlangtag:32416:1:i18nlangtag/source/languagetag/languagetag.cxx:1369:
LanguageTagImpl::convertLocaleToLang: with bAllowOnTheFlyID invalid
'en-US.UTF-8'.

This reverts commit c3d25b8b74867b5b8419d09f6e362aa6c8eae34f.

Change-Id: I2cd8c50a783918c380505e7a3aaf37d578e76031
Reviewed-on: https://gerrit.libreoffice.org/31489
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Tested-by: Jan Holesovsky <kendy@collabora.com>
2016-12-05 09:47:25 +02:00
2a5d8d7306 Lok: better logging and warnings
Change-Id: Ia933ae65197893592eeb04cb8a1a617a931ad623
Reviewed-on: https://gerrit.libreoffice.org/31606
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
2016-12-05 04:07:06 +00:00
9c218858f1 Lok: correct tile invalidation merging
Rectangles that are empty (i.e. IsEmpty() returns true)
were incorrectly considered to mean equivalent to "EMPTY".
The latter means full-area, while the former mean zero-area.

This fixes the issue by restrict full-area to rectangles
with 2 billion units on the each side (roughly INT_MAX) or
more, and using this new check rather than IsEmpty().

Change-Id: I12aca17267f5dd33b2932012d1d9db3545f9af6f
Reviewed-on: https://gerrit.libreoffice.org/31458
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
2016-12-02 12:54:06 +00:00
b18b1e80e9 sw: use auto when initializing with a cast to avoid duplicating the type name
Change-Id: Ide7bd0f1f444824b78aa53cfe1db0129cbca1a5d
Reviewed-on: https://gerrit.libreoffice.org/31397
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
2016-11-30 10:43:43 +00:00
098fb95772 lok: ensure positive values for width and height
also check the pointer memory block allocated

Change-Id: I0ded04e06f80400e64c5e58126a32ee503aeb394
Reviewed-on: https://gerrit.libreoffice.org/31388
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Henry Castro <hcastro@collabora.com>
2016-11-30 00:09:58 +00:00
2db42ab241 sw lok: notify repair when exist a conflict of multiple users undo/redo
Change-Id: I026f4df6239fa87ee191f92127f9fa98ac2993eb
Reviewed-on: https://gerrit.libreoffice.org/31161
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Henry Castro <hcastro@collabora.com>
2016-11-28 02:26:23 +00:00
e2d5f1ba3f lok: avoid render font with empty rectangle
Change-Id: I58e24e0de37144ae5d67857b243e6a7091f2b77a
Reviewed-on: https://gerrit.libreoffice.org/31281
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Henry Castro <hcastro@collabora.com>
2016-11-28 02:00:56 +00:00
af18b7d60f lok: in preinit stage, do not force locale
force locale load some fonts before the lokit process
is jail rooted, so it causes invalid rendering special
characters in doc_renderFont function

Change-Id: I25f00e5bb947753b820c6966a99a6c3849413315
Reviewed-on: https://gerrit.libreoffice.org/31280
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Henry Castro <hcastro@collabora.com>
2016-11-28 01:14:04 +00:00
f80140bf3a Lok: compress duplicate state-changed events
STATE_CHANGED callback events that have the form
of name=value are only removed when newer ones
are identical. This is not very helpful since
often the same name (i.e. state type) changes
its value and we need to superseed older ones
with new values.

This patch makes sure that a STATE_CHANGED with
a given name has its latest value and doesn't
change multiple times while in the queue.

Change-Id: Ibfa18359464d7137411e5846b1c6d415a0aad43d
Reviewed-on: https://gerrit.libreoffice.org/31258
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
2016-11-27 16:44:33 +00:00
3aac26671d lok: add command values .uno:FontSubset
Conflicts:
	desktop/Library_sofficeapp.mk

Change-Id: Id36a98c32f0eb5e88e4e9a714e260a71d7465c05
Reviewed-on: https://gerrit.libreoffice.org/31033
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Henry Castro <hcastro@collabora.com>
2016-11-22 00:56:46 +00:00
e1b2af1932 that should have been LibreOfficeKit*Document*Class
Change-Id: I48f9db39be18ae9a456002de8f40fbb0fb3be707
2016-11-17 16:38:30 +01:00
121a202076 tdf#92346 - Copy functionality in the viewer
Reference class added to
desktop/source/lib/lokandroid.cxx
for Java_org_libreoffice_kit_Document_getTextSelection()

Change-Id: I211d5709df39fd9fafdab9232af760613f6b86c0
Reviewed-on: https://gerrit.libreoffice.org/29804
Reviewed-by: jan iversen <jani@documentfoundation.org>
Tested-by: jan iversen <jani@documentfoundation.org>
2016-11-16 06:16:17 +00:00
32d0378284 lok: add character parameter to renderFont
When client side request special character, it is very useful to send a
preview of the rendered font character

Conflicts:
	desktop/source/lib/init.cxx

Change-Id: I1f5727163dfcc861add121e616bdb17881c28197
Reviewed-on: https://gerrit.libreoffice.org/30784
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Andras Timar <andras.timar@collabora.com>
2016-11-14 13:06:47 +00:00
a71d6a2a84 loplugin:expandablemethods in dbaccess
Change-Id: I6087a3eff46926646ac1637615a0af30b38956a4
Reviewed-on: https://gerrit.libreoffice.org/30712
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2016-11-09 11:13:34 +00:00
6320a0f210 revert string::find changes
this reverts

    commit 610f59651563205564a0f4818b5c1d347ca02132
    fix "cppcheck:stlIfStrFind"

and

    commit 5c1bb338ef0d781648d5b33ffc9d64c2be6d9926
    cppcheck:stlIfStrFind

which are deficient in one way or another, the original logic, while
inefficient, is still most accurate

Change-Id: I4907d2569c9c2976533f8ac9f4b8b45eb1807b72
2016-10-24 11:30:14 +02:00
610f596515 fix "cppcheck:stlIfStrFind"
in commit 5c1bb338ef0d781648d5b33ffc9d64c2be6d9926, compare does not do
a startswith

Change-Id: If518b3f6880848a5b5463c09fb73974d972010fd
2016-10-24 10:56:08 +02:00
5c1bb338ef cppcheck:stlIfStrFind
Change-Id: Ic3c1b37b0c2cf9995e0bd1017cdbaed427fb296c
Reviewed-on: https://gerrit.libreoffice.org/30185
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2016-10-24 06:11:08 +00:00
629bc69708 LOK: hold the solar mutex consistently for document method calls.
(cherry picked from commit eb69d8cb5eb6192de89ca8310a53ae7a434a73d1)

Change-Id: I200dff44b457a1632d99619981e237de73a2a8df
Reviewed-on: https://gerrit.libreoffice.org/30070
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Michael Meeks <michael.meeks@collabora.com>
2016-10-20 08:41:11 +00:00
8687e31b54 typo
Change-Id: I88c404d8e46ba87017af2167fd31dc9dd8758082
2016-10-16 19:55:47 +02:00
9a0e3d1de7 fix Android build (desktop)
stol is missing in the std namespace on the broken Android toolchain, work it around.

(I copycat https://cgit.freedesktop.org/libreoffice/core/commit/?id=c2673a358c78b864c1276f7956d5a348003b7a02)

Change-Id: I4d85b81abf5d72c08d9aae72638823b8a0484cc1
Reviewed-on: https://gerrit.libreoffice.org/29921
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2016-10-16 16:40:44 +00:00
21327496cb LOK: handle "EMPTY" invalid tile msg with part number in payload
What's new:
1) RectangleAndPart handles "EMPTY" payloads
2) LOK_CALLBACK_INVALIDATE_TILES msg type with "EMPTY" payload are
handled in CallbackFlushHandler::queue
3) gtktiledviewer handles "EMPTY" LOK_CALLBACK_INVALIDATE_TILES msg
even if the part number is included in the payload

Change-Id: I21f4a71ec875d24f4bbd100e4aacf8437d745ae4
2016-10-14 14:16:24 +02:00
051a9eb9ca Calc LOK: clear cell background when editing in parallel
Change-Id: Id8eccf00ec6555d62c49e06130e3aa3a0eaaddea
Reviewed-on: https://gerrit.libreoffice.org/29450
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
(cherry picked from commit b16ba7314ef93b657dea4d6dd676b2dfd265bcaa)
Reviewed-on: https://gerrit.libreoffice.org/29486
Reviewed-by: Marco Cecchetti <mrcekets@gmail.com>
Tested-by: Marco Cecchetti <mrcekets@gmail.com>
2016-10-03 12:24:57 +00:00
943919692e Fix typos
Change-Id: I8374d6d08f4eb4ae2821e213371c615b92d7e9ab
Reviewed-on: https://gerrit.libreoffice.org/29432
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2016-10-01 19:02:02 +00:00
d5263c2c56 LOK: conditionally include part number in invalidation payload
Since desktop/ code queues, compresses and only emits callbacks on idle,
it's possible that two invalidations are in the queue, and there was a
setPart() call between them. In this case it's impossible to tell what
part the invalidation was sent for.

Fix this by conditionally including the part number in the invalidation
payload. It's off by default, a new feature flag is added to request
this behavior.

gtktiledviewer enables this feature flag by default, though just to show
the part number in the debug output. Android doesn't enable it.

Change-Id: I73e6def848c0eb61d64e71026002c7a0e750aab4
2016-09-29 12:53:02 +02:00
a912ec7dad desktop: guard against nullptr frame in doc_registerCallback()
Change-Id: I96956d6631ed574c06df62e9b633d7e1e4d5a5f2
2016-09-22 11:09:51 +02:00
d778828745 lok::Document::getCommandValues: expose sw redline author colors
These colors are used in the tiles, so it's a good idea if the client
can use matching colors for cursors and selections. But to be able to do
that, we need an API to expose these colors.

Change-Id: Ia688c07e6c300fecdf8dc428d5a3f000d1857387
2016-09-21 19:32:01 +02:00
f255c3e96e [API CHANGE] Remove HAVE_GCC_VISIBILITY_FEATURE, always true
* GCC documents -fvisibility at least as far back as the GCC 4.0 online
  documentation at
  <https://gcc.gnu.org/onlinedocs/gcc-4.0.4/gcc/Code-Gen-Options.html>.

* For external code, odk/settings/settings.mk unconditionally set
  HAVE_GCC_VISIBILITY_FEATURE for all platforms other than Windows.

Make this a fatal configure error for now.  The check should be removed
completely after LO 5.3 branch-off.

Change-Id: I1de415b6ed1591e0a7b6640ece861b6f0ef74112
Reviewed-on: https://gerrit.libreoffice.org/29073
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Tested-by: Stephan Bergmann <sbergman@redhat.com>
2016-09-20 07:34:27 +00:00
288013f25d sw: emit LOK_CALLBACK_STATE_CHANGED when cursor enters/leaves a redline
For now only care about the start of the cursor, which can be only at a
single redline.

Add matching testcase + expose it in the gtktiledviewer status bar for
interactive manual testing.

Change-Id: Ib61757412d6b54bef64361d4a8563795ca0bab6c
2016-09-19 20:10:22 +02:00
dcc92a7cb5 sfx2: add SfxLokHelper::getViewIds
and also expose it in the LOK API. This way clients don't have to keep
track of what views they created / destroyed, they can also get an up to
date list with this method.

Change-Id: Ibaee42c545803e04a31e7c13ab6ec370b99465c4
2016-09-16 14:48:23 +02:00
dc00592b4e lok::Document: rename getViews() to getViewsCount()
As this only returns the number of views, not the actual views. Since
it's a rename, it's just an API (but not an ABI) change.

Change-Id: Ib4f0ea56a90e5ae9c80ee1781aa2f29aff4259e7
2016-09-16 12:36:28 +02:00
a097d680d2 Revert "LOK: we use callbacks latch for not missing messages sent very early"
This reverts commit bbae556d12e4edf7795b0b5643df77fd8cdbdacd.

Change-Id: If1370751b612ff06ef5be13e8a4017af7dc34a7c
Reviewed-on: https://gerrit.libreoffice.org/28908
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
(cherry picked from commit c0dd075d52409031876f5bc3923062ba5847fd53)
Reviewed-on: https://gerrit.libreoffice.org/28929
Reviewed-by: Marco Cecchetti <mrcekets@gmail.com>
Tested-by: Marco Cecchetti <mrcekets@gmail.com>
2016-09-15 13:25:51 +00:00
bee4ff508a desktop lok: avoid unnecessary setPart() in paintPartTile()
If possible, switch views, not parts, that way started Impress text
edits don't end as a side-effect.

Change-Id: I3f18d4dda6bc24235bf1219416f153248a867fa4
2016-09-14 19:47:48 +02:00
91dd2db17b loplugin:override: No more need for the "MSVC dtor override" workaround
The issue of 362d4f0cd4e50111edfae9d30c90602c37ed65a2 "Explicitly mark
overriding destructors as 'virtual'" appears to no longer be a problem with
MSVC 2013.

(The little change in the rewriting code of compilerplugins/clang/override.cxx
was necessary to prevent an endless loop when adding "override" to

  OOO_DLLPUBLIC_CHARTTOOLS    virtual ~CloseableLifeTimeManager();

in chart2/source/inc/LifeTime.hxx, getting stuck in the leading
OOO_DLLPUBLIC_CHARTTOOLS macro.  Can't remember what that
isAtEndOfImmediateMacroExpansion thing was originally necessary for, anyway.)

Change-Id: I534c634504d7216b9bb632c2775c04eaf27e927e
2016-09-13 13:19:22 +02:00
539f981900 LOK: we use callbacks latch for not missing messages sent very early
- lok::Document::setCallbackLatch: used on document load for
set/unset the latch

- now cell cursors of other views are correctly notified to the new
view

Change-Id: Ife6dca0e3e329b801d44070f55869afe95a2f313
Reviewed-on: https://gerrit.libreoffice.org/28812
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Marco Cecchetti <mrcekets@gmail.com>
2016-09-11 17:05:22 +00:00
7038a05224 LOK: new callback dropping implementation
Now view callbacks have their own collection of last states where the
key is made up by both the view id and the callback type.

Callback dropping based on the last state is no more handled on
queueing but on flushing, since what really matters is the last
performed callback (for each callback type).
Anyway in order to not modify the order of callbacks, that could be
changed when an already queued callback is superseeded, dropping still
occurs on queuing too, just by looking for the last queued callback of
the same type.

The result is a substantial reduction of redundant callbacks and fix
the following problem in loleaflet: when there are more views for a
speadsheet and cell cursors for two view are placed on the same cell,
a continuos swapping between the two cell cursors can occur. That was
due to a sequence of "EMPTY" and coordinates messages or cell cursor
and cell view cursor messages which were sent in an alternating way.

Change-Id: I79e14d11d4e8590aff715181e3410ad88c4e6175
Reviewed-on: https://gerrit.libreoffice.org/28783
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Marco Cecchetti <mrcekets@gmail.com>
2016-09-10 19:31:57 +00:00
785a7e58c4 LOK: tidy up CallbackFlushHandler::queue, improved cell view cursor
Rewritten the switch statement in `CallbackFlushHandler::queue`:

- Now, the new callback data is emplaced after removing all states
overridden by the new one.
- View callbacks are checked not only for the same type but even for
the same view id: that allowed to fix the following issue: starting
from the 3rd view for a spreadsheet it could occur that only the cell
cursor of the previous last view was displayed in the new view.

Change-Id: I2b63526deb4dca39e3a1f430443ebc5d0f61938d
Reviewed-on: https://gerrit.libreoffice.org/28782
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Marco Cecchetti <mrcekets@gmail.com>
2016-09-10 18:08:01 +00:00
f96fa389f9 sfx2: nullptr pViewShell was seen in SfxLokHelper::getView()
I'm not sure how to trigger this reliably, but Pranav got this:

	#0  0x00007fb2f471bbf0 in SfxLokHelper::getView(SfxViewShell*) (pViewShell=0x0) at sfx2/source/view/lokhelper.cxx:82
	#1  0x00007fb2f75edf4f in doc_paintPartTile(LibreOfficeKitDocument*, unsigned char*, int, int, int, int, int, int, int) (pThis=0x7fb290253c40, pBuffer=0x281fbd0 "", nPart=0, nCanvasWidth=1024, nCanvasHeight=256, nTilePosX=0, nTilePosY=11520, nTileWidth=15360, nTileHeight=3840) at desktop/source/lib/init.cxx:1338

Given that SfxViewShell::Current() may indeed return nullptr (e.g.
during shutdown), change SfxLokHelper::getView() to return -1 in that
case, and adapt client code to handle that.

Change-Id: Ia191c843c8a993f3d7157de432af57964c0a8f63
Reviewed-on: https://gerrit.libreoffice.org/28583
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
2016-09-01 10:01:17 +00:00
6330590e7a desktop: fix Android build
to_string() is missing in the std namespace on the broken Android
toolchain, work it around.

Change-Id: I77fd06f869291e04c265b6b6d38b2e60b0d48caf
2016-08-31 17:07:30 +02:00
ce7484ffff LOK: queue-up events while processing client calls
To prevent feedback effects and improve performance,
we now queue up events fired during the processing
of a client call on the LOK API.

This has the advantage of giving us a chance to
compress redundant events and to combine others
(where possible) into fewer ones.

Change-Id: I2f6ea12c5d85205e6495cb130f6a6262534b6bb2
Reviewed-on: https://gerrit.libreoffice.org/28311
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
2016-08-31 11:51:51 +00:00
3ab2b0625b sc lok: implement getCommandValues(.uno:AcceptTrackedChanges) API
Unlike in Writer, there doesn't seem to be an existing UNO API that can
be reused here.

Change-Id: I011a2f34d4d09ad604991637322ceadf6b2eb181
Reviewed-on: https://gerrit.libreoffice.org/28498
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
2016-08-30 15:00:40 +00:00
5d77b738cb No reason why these functions can't be static, too
Change-Id: I95b68e912c87657a6884f8c56bfcc7bc52c2f2e5
2016-08-30 10:18:07 +03:00
9e310a4705 sw redlines: expose description as part of the UNO/LOK API
A redline can have a manual comment and also an autogenerated
description, like "Insert 'abc'". Expose this later property as well, as
it provides useful additional information, especially when the comment
property is empty.

Change-Id: Id0f0ff62aef58d96b9b6071706c6f5b4a0d74800
2016-08-19 16:51:36 +02:00
ccc355bc4e coverity#1371375 Resource leak
Change-Id: I53b5ddc26e77168c29ba1bcfd199b1accbc54d3a
2016-08-19 13:00:44 +01:00
d890ec2f13 tdf#101592 sw: track changes state is doc-specific, not view-specific
So update the bindings of all views after changing it.

Change-Id: I5355f40ba27be521dcdf343b08305f3736979bbb
Reviewed-on: https://gerrit.libreoffice.org/28233
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
2016-08-19 09:02:32 +00:00
69fb6a3071 lok::Document::getCommandValues: expose redline info
Index is added as a property for each item, so that later changes can be
identified by the index when they are accepted/rejected.

Change-Id: I9362d208fdbed1f46d64558d44498d2b19150c81
2016-08-17 14:02:34 +02:00
9dd8a0dcfd desktop: add undo/redo support to lok::Document::getCommandValues()
Expose the undo/redo stack and the metadata of each item.

Change-Id: I66b81e855a945c97be3d491ed709959f310d4b73
Reviewed-on: https://gerrit.libreoffice.org/27905
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
2016-08-05 13:25:34 +00:00
af2eed716f lok: re-load UNO bootstrap pieces and set UserInstallation on second init.
Ideally should check whether the path is different. Changing the user-install
path is useful for valgrinding online outside of a chroot jail.

Change-Id: I6ad76af1245491acdcb6664896be89073406b742
Reviewed-on: https://gerrit.libreoffice.org/27782
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Michael Meeks <michael.meeks@collabora.com>
2016-08-01 17:08:33 +00:00