diff options
-rw-r--r-- | desktop/source/lib/init.cxx | 18 | ||||
-rw-r--r-- | include/LibreOfficeKit/LibreOfficeKitEnums.h | 19 | ||||
-rw-r--r-- | include/sfx2/sfxsids.hrc | 2 | ||||
-rw-r--r-- | include/svtools/ruler.hxx | 1 | ||||
-rw-r--r-- | include/svx/ruler.hxx | 9 | ||||
-rw-r--r-- | include/svx/svxids.hrc | 1 | ||||
-rw-r--r-- | include/vcl/ITiledRenderable.hxx | 9 | ||||
-rw-r--r-- | libreofficekit/source/gtk/lokdocview.cxx | 16 | ||||
-rw-r--r-- | sfx2/source/appl/appuno.cxx | 2 | ||||
-rw-r--r-- | svtools/source/control/ruler.cxx | 5 | ||||
-rw-r--r-- | svx/sdi/svx.sdi | 18 | ||||
-rw-r--r-- | svx/source/dialog/svxruler.cxx | 13 | ||||
-rw-r--r-- | sw/inc/unotxdoc.hxx | 3 | ||||
-rw-r--r-- | sw/sdi/_viewsh.sdi | 4 | ||||
-rw-r--r-- | sw/source/uibase/inc/swruler.hxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/misc/swruler.cxx | 33 | ||||
-rw-r--r-- | sw/source/uibase/uiview/viewtab.cxx | 19 | ||||
-rw-r--r-- | sw/source/uibase/uno/unotxdoc.cxx | 8 |
18 files changed, 177 insertions, 5 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 4e7f9210a83e..b0499399b97b 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -66,6 +66,7 @@ #include <sfx2/viewsh.hxx> #include <svx/dialmgr.hxx> #include <svx/dialogs.hrc> +#include <svx/ruler.hxx> #include <svx/svxids.hrc> #include <svx/ucsubset.hxx> #include <vcl/svapp.hxx> @@ -830,6 +831,7 @@ void CallbackFlushHandler::queue(const int type, const char* data) case LOK_CALLBACK_CURSOR_VISIBLE: case LOK_CALLBACK_SET_PART: case LOK_CALLBACK_STATUS_INDICATOR_SET_VALUE: + case LOK_CALLBACK_RULER_UPDATE: { removeAll([type] (const queue_type::value_type& elem) { return (elem.first == type); }); } @@ -2071,6 +2073,18 @@ static char* getPostItsPos(LibreOfficeKitDocument* pThis) return strdup(aComments.toUtf8().getStr()); } +static char* getRulerState(LibreOfficeKitDocument* pThis) +{ + ITiledRenderable* pDoc = getTiledRenderable(pThis); + if (!pDoc) + { + gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering"; + return nullptr; + } + OUString state = pDoc->getRulerState(); + return strdup(state.toUtf8().getStr()); +} + static void doc_postKeyEvent(LibreOfficeKitDocument* pThis, int nType, int nCharCode, int nKeyCode) { SolarMutexGuard aGuard; @@ -2678,6 +2692,10 @@ static char* doc_getCommandValues(LibreOfficeKitDocument* pThis, const char* pCo { return getPostItsPos(pThis); } + else if (aCommand == ".uno:RulerState") + { + return getRulerState(pThis); + } else if (aCommand.startsWith(aViewRowColumnHeaders)) { ITiledRenderable* pDoc = getTiledRenderable(pThis); diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h b/include/LibreOfficeKit/LibreOfficeKitEnums.h index 300b71bb01ff..c3b71f3f1aad 100644 --- a/include/LibreOfficeKit/LibreOfficeKitEnums.h +++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h @@ -504,7 +504,24 @@ typedef enum /** * The text content of the address field in Calc. */ - LOK_CALLBACK_CELL_ADDRESS = 34 + LOK_CALLBACK_CELL_ADDRESS = 34, + /** + * The key ruler related properties on change are reported by this. + * + * The payload format is: + * + * { + * "margin1": "...", + * "margin2": "...", + * "leftOffset": "...", + * "pageOffset": "...", + * "pageWidth": "...", + * "unit": "..." + * } + * + * Here all aproperties are same as described in svxruler. + */ + LOK_CALLBACK_RULER_UPDATE = 35 } LibreOfficeKitCallbackType; diff --git a/include/sfx2/sfxsids.hrc b/include/sfx2/sfxsids.hrc index cfc59403d198..20afe0808bc2 100644 --- a/include/sfx2/sfxsids.hrc +++ b/include/sfx2/sfxsids.hrc @@ -562,6 +562,8 @@ #define SID_COMP_BIBLIOGRAPHY (SID_SVX_START + 880) #define SID_ADDRESS_DATA_SOURCE (SID_SVX_START + 934) #define SID_OPEN_SMARTTAGOPTIONS (SID_SVX_START + 1062) +#define SID_RULER_MARGIN1 (SID_SVX_START + 1063) +#define SID_RULER_MARGIN2 (SID_SVX_START + 1064) #define FID_SVX_START (SID_LIB_START + 500) #define FID_SEARCH_NOW (FID_SVX_START + 2) diff --git a/include/svtools/ruler.hxx b/include/svtools/ruler.hxx index 1c5b0cdea845..fa9da1d8c162 100644 --- a/include/svtools/ruler.hxx +++ b/include/svtools/ruler.hxx @@ -776,6 +776,7 @@ public: void SetMargin2() { SetMargin2( 0, RulerMarginStyle::Invisible ); } void SetMargin2( long nPos, RulerMarginStyle nMarginStyle = RulerMarginStyle::Sizeable ); long GetMargin2() const; + long GetPageWidth() const; void SetLeftFrameMargin( long nPos ); void SetRightFrameMargin( long nPos ); diff --git a/include/svx/ruler.hxx b/include/svx/ruler.hxx index d8a78516b156..f8ba4cea149f 100644 --- a/include/svx/ruler.hxx +++ b/include/svx/ruler.hxx @@ -41,6 +41,12 @@ class SvxObjectItem; class SfxBoolItem; struct SvxRuler_Impl; +enum class RulerChangeType +{ + MARGIN1, + MARGIN2 +}; + enum class SvxRulerDragFlags { NONE = 0x00, @@ -255,7 +261,6 @@ protected: bool bForceDontConsiderHidden = false, sal_uInt16 nAct=USHRT_MAX ) const; long CalcPropMaxRight(sal_uInt16 nCol = USHRT_MAX) const; - long GetPageWidth() const; public: @@ -278,6 +283,8 @@ public: //#i24363# tab stops relative to indent void SetTabsRelativeToIndent( bool bRel ); + void SetValues(RulerChangeType type, long value); + long GetPageWidth() const; }; #endif diff --git a/include/svx/svxids.hrc b/include/svx/svxids.hrc index 40b63ea05018..394276fd1ac3 100644 --- a/include/svx/svxids.hrc +++ b/include/svx/svxids.hrc @@ -255,6 +255,7 @@ // CAUTION! Range <64 .. 67> used by EditEngine (!) +#define SID_RULER_CHANGE_STATE ( SID_SVX_START + 78 ) #define SID_RULER_NULL_OFFSET ( SID_SVX_START + 79 ) #define SID_RULER_BORDERS ( SID_SVX_START + 80 ) #define SID_RULER_OBJECT ( SID_SVX_START + 81 ) diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx index e330cd14f074..ae3ba9e76c3c 100644 --- a/include/vcl/ITiledRenderable.hxx +++ b/include/vcl/ITiledRenderable.hxx @@ -13,6 +13,7 @@ #include <LibreOfficeKit/LibreOfficeKitTypes.h> #include <tools/gen.hxx> +#include <svx/ruler.hxx> #include <vcl/pointr.hxx> #include <vcl/virdev.hxx> #include <com/sun/star/datatransfer/clipboard/XClipboardEx.hpp> @@ -233,8 +234,14 @@ public: { return OUString(); } -}; + /// Implementation for + /// lok::Document::getCommandValues(".uno:RulerState"); + virtual OUString getRulerState() + { + return OUString(); + } +}; } // namespace vcl #endif // INCLUDED_VCL_ITILEDRENDERABLE_HXX diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx index 9a8c00b875b2..9e41014c05c3 100644 --- a/libreofficekit/source/gtk/lokdocview.cxx +++ b/libreofficekit/source/gtk/lokdocview.cxx @@ -278,6 +278,7 @@ enum TEXT_SELECTION, PASSWORD_REQUIRED, COMMENT, + RULER, LAST_SIGNAL }; @@ -433,6 +434,8 @@ callbackTypeToString (int nType) return "LOK_CALLBACK_REDLINE_TABLE_ENTRY_MODIFIED"; case LOK_CALLBACK_COMMENT: return "LOK_CALLBACK_COMMENT"; + case LOK_CALLBACK_RULER_UPDATE: + return "LOK_CALLBACK_RULER_UPDATE"; } g_assert(false); return nullptr; @@ -1423,6 +1426,9 @@ callback (gpointer pData) case LOK_CALLBACK_COMMENT: g_signal_emit(pCallback->m_pDocView, doc_view_signals[COMMENT], 0, pCallback->m_aPayload.c_str()); break; + case LOK_CALLBACK_RULER_UPDATE: + g_signal_emit(pCallback->m_pDocView, doc_view_signals[RULER], 0, pCallback->m_aPayload.c_str()); + break; default: g_assert(false); break; @@ -3188,6 +3194,16 @@ static void lok_doc_view_class_init (LOKDocViewClass* pClass) g_cclosure_marshal_generic, G_TYPE_NONE, 1, G_TYPE_STRING); + + doc_view_signals[RULER] = + g_signal_new("ruler", + G_TYPE_FROM_CLASS(pGObjectClass), + G_SIGNAL_RUN_FIRST, + 0, + nullptr, nullptr, + g_cclosure_marshal_generic, + G_TYPE_NONE, 1, + G_TYPE_STRING); } SAL_DLLPUBLIC_EXPORT GtkWidget* diff --git a/sfx2/source/appl/appuno.cxx b/sfx2/source/appl/appuno.cxx index bbd9a1f16df6..cdda5c948177 100644 --- a/sfx2/source/appl/appuno.cxx +++ b/sfx2/source/appl/appuno.cxx @@ -88,6 +88,8 @@ SfxFormalArgument aFormalArgs[] = { { reinterpret_cast<SfxType*>(&aSfxBoolItem_Impl), "VersionMajor", SID_DOCINFO_MAJOR }, { reinterpret_cast<SfxType*>(&aSfxStringItem_Impl), "FilterOptions", SID_FILE_FILTEROPTIONS }, { reinterpret_cast<SfxType*>(&aSfxStringItem_Impl), "FilterName", SID_FILTER_NAME }, + { reinterpret_cast<SfxType*>(&aSfxStringItem_Impl), "Margin1", SID_RULER_MARGIN1 }, + { reinterpret_cast<SfxType*>(&aSfxStringItem_Impl), "Margin2", SID_RULER_MARGIN2 }, // { reinterpret_cast<SfxType*>(&aSfxStringItem_Impl), "FileName", SID_FILE_NAME }, { reinterpret_cast<SfxType*>(&aSfxStringItem_Impl), "URL", SID_FILE_NAME }, { reinterpret_cast<SfxType*>(&aSfxStringItem_Impl), "OpenFlags", SID_OPTIONS }, diff --git a/svtools/source/control/ruler.cxx b/svtools/source/control/ruler.cxx index 7306b097df87..e2a78c16c971 100644 --- a/svtools/source/control/ruler.cxx +++ b/svtools/source/control/ruler.cxx @@ -2773,6 +2773,11 @@ void Ruler::SetTextRTL(bool bRTL) } +long Ruler::GetPageWidth() const +{ + return mpData->nPageWidth; +} + long Ruler::GetPageOffset() const { return mpData->nPageOff; diff --git a/svx/sdi/svx.sdi b/svx/sdi/svx.sdi index 91265a3df430..a2ea22bcf0c9 100644 --- a/svx/sdi/svx.sdi +++ b/svx/sdi/svx.sdi @@ -7216,6 +7216,24 @@ SvxProtectItem RulerProtect SID_RULER_PROTECT GroupId = GID_VIEW; ] +SfxVoidItem RulerChangeState SID_RULER_CHANGE_STATE +(SfxStringItem Margin1 SID_RULER_MARGIN1, SfxStringItem Margin2 SID_RULER_MARGIN2) +[ + AutoUpdate = FALSE, + FastCall = TRUE, + ReadOnlyDoc = TRUE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + + + AccelConfig = FALSE, + MenuConfig = FALSE, + ToolBoxConfig = FALSE, + GroupId = ; +] + SfxVoidItem SbaExecuteSql SID_FM_EXECUTE () diff --git a/svx/source/dialog/svxruler.cxx b/svx/source/dialog/svxruler.cxx index 9cd586654e31..2b178555828a 100644 --- a/svx/source/dialog/svxruler.cxx +++ b/svx/source/dialog/svxruler.cxx @@ -34,6 +34,7 @@ #include <editeng/tstpitem.hxx> #include <editeng/lrspitem.hxx> #include <editeng/protitem.hxx> +#include <comphelper/lok.hxx> #include <svx/svdtrans.hxx> @@ -3628,4 +3629,14 @@ void SvxRuler::SetTabsRelativeToIndent( bool bRel ) mxRulerImpl->bIsTabsRelativeToIndent = bRel; } -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ +void SvxRuler::SetValues(RulerChangeType type, long diffValue) +{ + if (diffValue == 0) + return; + + if (type == RulerChangeType::MARGIN1) + AdjustMargin1(diffValue); + else if (type == RulerChangeType::MARGIN2) + SetMargin2( GetMargin2() - diffValue); + ApplyMargins(); +}
\ No newline at end of file diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx index a0af69fbc5bc..94fcd42cbd8f 100644 --- a/sw/inc/unotxdoc.hxx +++ b/sw/inc/unotxdoc.hxx @@ -63,6 +63,7 @@ #include <com/sun/star/util/XCloneable.hpp> #include <svl/itemprop.hxx> #include <svx/fmdmod.hxx> +#include <svx/ruler.hxx> #include <editeng/UnoForbiddenCharsTable.hxx> #include <cppuhelper/weak.hxx> #include <cppuhelper/implbase.hxx> @@ -444,6 +445,8 @@ public: OUString getTrackedChanges() override; /// @see vcl::ITiledRenderable::getTrackedChangeAuthors(). OUString getTrackedChangeAuthors() override; + + OUString getRulerState() override; /// @see vcl::ITiledRenderable::getPostIts(). OUString getPostIts() override; // css::tiledrendering::XTiledRenderable diff --git a/sw/sdi/_viewsh.sdi b/sw/sdi/_viewsh.sdi index 02706cc34247..8a5f6dfe97ab 100644 --- a/sw/sdi/_viewsh.sdi +++ b/sw/sdi/_viewsh.sdi @@ -219,6 +219,10 @@ interface BaseTextEditView StateMethod = StateTabWin ; DisableFlags="SW_DISABLE_ON_PROTECTED_CURSOR"; ] + SID_RULER_CHANGE_STATE + [ + ExecMethod = ExecTabWin ; + ] SID_RULER_BORDERS // status() [ ExecMethod = ExecTabWin ; diff --git a/sw/source/uibase/inc/swruler.hxx b/sw/source/uibase/inc/swruler.hxx index 824eaca10642..bc4b2a1164d1 100644 --- a/sw/source/uibase/inc/swruler.hxx +++ b/sw/source/uibase/inc/swruler.hxx @@ -41,6 +41,7 @@ public: * \param rRect ignored */ virtual void Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect ) override; + const std::string CreateJsonNotification(); protected: SwViewShell * mpViewShell; //< Shell to check if there is any comments on doc and their visibility @@ -50,6 +51,7 @@ protected: int mnFadeRate; //< From 0 to 100. 0 means not highlighted. ScopedVclPtr<VirtualDevice> maVirDev; //< VirtualDevice of this window. Just for convenience. + void NotifyKit(); /** * Callback function to handle a mouse button down event. * diff --git a/sw/source/uibase/misc/swruler.cxx b/sw/source/uibase/misc/swruler.cxx index e84b6a04c90e..588d35ed9dcb 100644 --- a/sw/source/uibase/misc/swruler.cxx +++ b/sw/source/uibase/misc/swruler.cxx @@ -24,9 +24,11 @@ #include <vcl/window.hxx> #include <vcl/settings.hxx> #include "misc.hrc" +#include <comphelper/lok.hxx> +#include <LibreOfficeKit/LibreOfficeKitEnums.h> +#include <boost/property_tree/json_parser.hpp> #define CONTROL_BORDER_WIDTH 1 - #define CONTROL_LEFT_OFFSET 6 #define CONTROL_RIGHT_OFFSET 3 #define CONTROL_TOP_OFFSET 4 @@ -245,12 +247,41 @@ void SwCommentRuler::MouseButtonDown( const MouseEvent& rMEvt ) Invalidate(); } +const std::string SwCommentRuler::CreateJsonNotification() +{ + boost::property_tree::ptree jsonNotif; + + jsonNotif.put("margin1", convertTwipToMm100(GetMargin1())); + jsonNotif.put("margin2", convertTwipToMm100(GetMargin2())); + jsonNotif.put("leftOffset", convertTwipToMm100(GetNullOffset())); + jsonNotif.put("pageOffset", convertTwipToMm100(GetPageOffset())); + jsonNotif.put("pageWidth", convertTwipToMm100(GetPageWidth())); + + RulerUnitData aUnitData = GetCurrentRulerUnit(); + jsonNotif.put("unit", aUnitData.aUnitStr); + + std::stringstream aStream; + boost::property_tree::write_json(aStream, jsonNotif); + std::string aPayload = aStream.str(); + return aPayload; +} + +void SwCommentRuler::NotifyKit() +{ + if (!comphelper::LibreOfficeKit::isActive()) + return; + + const std::string test = CreateJsonNotification(); + mpViewShell->GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_RULER_UPDATE, test.c_str()); +} + void SwCommentRuler::Update() { Rectangle aPreviousControlRect = GetCommentControlRegion(); SvxRuler::Update(); if (aPreviousControlRect != GetCommentControlRegion()) Invalidate(); + NotifyKit(); } void SwCommentRuler::UpdateCommentHelpText() diff --git a/sw/source/uibase/uiview/viewtab.cxx b/sw/source/uibase/uiview/viewtab.cxx index 84eaceb7ef29..a1fb909ba92e 100644 --- a/sw/source/uibase/uiview/viewtab.cxx +++ b/sw/source/uibase/uiview/viewtab.cxx @@ -54,6 +54,7 @@ #include "wview.hxx" #include "fmtcol.hxx" #include "section.hxx" +#include "swruler.hxx" #include "ndtxt.hxx" #include "pam.hxx" @@ -790,6 +791,24 @@ void SwView::ExecTabWin( SfxRequest& rReq ) rSh.SetAttrItem( aULSpace ); } break; + + case SID_RULER_CHANGE_STATE: + { + const SfxPoolItem *pMargin1, *pMargin2; + if ( pReqArgs && + pReqArgs->GetItemState(SID_RULER_MARGIN1,true,&pMargin1) == SfxItemState::SET ) + { + const OUString ratio = static_cast<const SfxStringItem*>(pMargin1)->GetValue(); + GetHRuler().SetValues(RulerChangeType::MARGIN1, GetHRuler().GetPageWidth() * ratio.toFloat()); + } + else if ( pReqArgs && + pReqArgs->GetItemState(SID_RULER_MARGIN2,true,&pMargin2) == SfxItemState::SET ) + { + const OUString ratio = static_cast<const SfxStringItem*>(pMargin2)->GetValue(); + GetHRuler().SetValues(RulerChangeType::MARGIN2, GetHRuler().GetPageWidth() * ratio.toFloat()); + } + } + break; case SID_RULER_BORDERS_VERTICAL: case SID_RULER_BORDERS: if ( pReqArgs ) diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index 4fae34bb4565..279bb36709b3 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -130,6 +130,8 @@ #include <comphelper/storagehelper.hxx> #include <cppuhelper/supportsservice.hxx> #include <unotools/saveopt.hxx> +#include "swruler.hxx" + #include <EnhancedPDFExportHelper.hxx> #include <numrule.hxx> @@ -3319,6 +3321,12 @@ OUString SwXTextDocument::getTrackedChangeAuthors() return SW_MOD()->GetRedlineAuthorInfo(); } +OUString SwXTextDocument::getRulerState() +{ + SwView* pView = pDocShell->GetView(); + return OUString::fromUtf8((dynamic_cast<SwCommentRuler&>(pView->GetHRuler())).CreateJsonNotification().c_str()); +} + OUString SwXTextDocument::getPostIts() { SolarMutexGuard aGuard; |