summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--desktop/source/lib/init.cxx266
-rw-r--r--include/sfx2/lokunocmdlist.hxx52
-rw-r--r--sd/inc/app.hrc2
-rw-r--r--sd/inc/sdpage.hxx3
-rw-r--r--sd/qa/unit/uiimpress.cxx107
-rw-r--r--sd/sdi/_drvwsh.sdi4
-rw-r--r--sd/sdi/sdraw.sdi17
-rw-r--r--sd/source/core/sdpage.cxx22
-rw-r--r--sd/source/ui/inc/unomodel.hxx2
-rw-r--r--sd/source/ui/unoidl/unomodel.cxx118
-rw-r--r--sd/source/ui/view/drviews2.cxx490
-rw-r--r--sfx2/source/control/unoctitm.cxx572
12 files changed, 1145 insertions, 510 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index f828d9e2e243..bd5eb0654614 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -153,6 +153,7 @@
#include <sfx2/lokcomponenthelpers.hxx>
#include <sfx2/DocumentSigner.hxx>
#include <sfx2/sidebar/Sidebar.hxx>
+#include <sfx2/lokunocmdlist.hxx>
#include <svl/numformat.hxx>
#include <svx/dialmgr.hxx>
#include <svx/strings.hrc>
@@ -3264,7 +3265,9 @@ static char* lo_extractDocumentStructureRequest(LibreOfficeKit* /*pThis*/, const
//if it is a writer document..
uno::Reference<lang::XServiceInfo> xDocument(xComp, uno::UNO_QUERY_THROW);
- if (xDocument->supportsService(u"com.sun.star.text.TextDocument"_ustr) || xDocument->supportsService(u"com.sun.star.text.WebDocument"_ustr))
+ if (xDocument->supportsService(u"com.sun.star.text.TextDocument"_ustr)
+ || xDocument->supportsService(u"com.sun.star.text.WebDocument"_ustr)
+ || xDocument->supportsService(u"com.sun.star.presentation.PresentationDocument"_ustr))
{
tools::JsonWriter aJson;
{
@@ -3826,244 +3829,6 @@ static void doc_iniUnoCommands ()
SolarMutexGuard aGuard;
SetLastExceptionMsg();
- static constexpr OUString sUnoCommands[] =
- {
- u".uno:AlignLeft"_ustr,
- u".uno:AlignHorizontalCenter"_ustr,
- u".uno:AlignRight"_ustr,
- u".uno:BackgroundColor"_ustr,
- u".uno:TableCellBackgroundColor"_ustr,
- u".uno:Bold"_ustr,
- u".uno:CenterPara"_ustr,
- u".uno:CharBackColor"_ustr,
- u".uno:CharBackgroundExt"_ustr,
- u".uno:CharFontName"_ustr,
- u".uno:Color"_ustr,
- u".uno:ControlCodes"_ustr,
- u".uno:DecrementIndent"_ustr,
- u".uno:DefaultBullet"_ustr,
- u".uno:DefaultNumbering"_ustr,
- u".uno:FontColor"_ustr,
- u".uno:FontHeight"_ustr,
- u".uno:IncrementIndent"_ustr,
- u".uno:Italic"_ustr,
- u".uno:JustifyPara"_ustr,
- u".uno:JumpToMark"_ustr,
- u".uno:OutlineFont"_ustr,
- u".uno:LeftPara"_ustr,
- u".uno:LanguageStatus"_ustr,
- u".uno:RightPara"_ustr,
- u".uno:Shadowed"_ustr,
- u".uno:SubScript"_ustr,
- u".uno:SuperScript"_ustr,
- u".uno:Strikeout"_ustr,
- u".uno:StyleApply"_ustr,
- u".uno:Underline"_ustr,
- u".uno:ModifiedStatus"_ustr,
- u".uno:Undo"_ustr,
- u".uno:Redo"_ustr,
- u".uno:InsertPage"_ustr,
- u".uno:DeletePage"_ustr,
- u".uno:DuplicatePage"_ustr,
- u".uno:InsertSlide"_ustr,
- u".uno:DeleteSlide"_ustr,
- u".uno:DuplicateSlide"_ustr,
- u".uno:ChangeTheme"_ustr,
- u".uno:Cut"_ustr,
- u".uno:Copy"_ustr,
- u".uno:Paste"_ustr,
- u".uno:SelectAll"_ustr,
- u".uno:ReplyComment"_ustr,
- u".uno:ResolveComment"_ustr,
- u".uno:ResolveCommentThread"_ustr,
- u".uno:PromoteComment"_ustr,
- u".uno:InsertRowsBefore"_ustr,
- u".uno:InsertRowsAfter"_ustr,
- u".uno:InsertColumnsBefore"_ustr,
- u".uno:InsertColumnsAfter"_ustr,
- u".uno:DeleteRows"_ustr,
- u".uno:DeleteColumns"_ustr,
- u".uno:DeleteTable"_ustr,
- u".uno:SelectTable"_ustr,
- u".uno:EntireRow"_ustr,
- u".uno:EntireColumn"_ustr,
- u".uno:EntireCell"_ustr,
- u".uno:AssignLayout"_ustr,
- u".uno:StatusDocPos"_ustr,
- u".uno:RowColSelCount"_ustr,
- u".uno:StatusPageStyle"_ustr,
- u".uno:InsertMode"_ustr,
- u".uno:SpellOnline"_ustr,
- u".uno:StatusSelectionMode"_ustr,
- u".uno:StateTableCell"_ustr,
- u".uno:StatusBarFunc"_ustr,
- u".uno:StatePageNumber"_ustr,
- u".uno:StateWordCount"_ustr,
- u".uno:SelectionMode"_ustr,
- u".uno:PageStatus"_ustr,
- u".uno:LayoutStatus"_ustr,
- u".uno:Scale"_ustr,
- u".uno:Context"_ustr,
- u".uno:WrapText"_ustr,
- u".uno:ToggleMergeCells"_ustr,
- u".uno:NameGroup"_ustr,
- u".uno:ObjectTitleDescription"_ustr,
- u".uno:NumberFormatCurrency"_ustr,
- u".uno:NumberFormatPercent"_ustr,
- u".uno:NumberFormatDecimal"_ustr,
- u".uno:NumberFormatIncDecimals"_ustr,
- u".uno:NumberFormatDecDecimals"_ustr,
- u".uno:NumberFormatDate"_ustr,
- u".uno:EditHeaderAndFooter"_ustr,
- u".uno:FrameLineColor"_ustr,
- u".uno:SortAscending"_ustr,
- u".uno:SortDescending"_ustr,
- u".uno:TrackChanges"_ustr,
- u".uno:ShowTrackedChanges"_ustr,
- u".uno:NextTrackedChange"_ustr,
- u".uno:PreviousTrackedChange"_ustr,
- u".uno:AcceptAllTrackedChanges"_ustr,
- u".uno:RejectAllTrackedChanges"_ustr,
- u".uno:TableDialog"_ustr,
- u".uno:FormatCellDialog"_ustr,
- u".uno:FontDialog"_ustr,
- u".uno:ParagraphDialog"_ustr,
- u".uno:OutlineBullet"_ustr,
- u".uno:InsertIndexesEntry"_ustr,
- u".uno:DocumentRepair"_ustr,
- u".uno:TransformDialog"_ustr,
- u".uno:InsertPageHeader"_ustr,
- u".uno:InsertPageFooter"_ustr,
- u".uno:OnlineAutoFormat"_ustr,
- u".uno:InsertObjectChart"_ustr,
- u".uno:InsertSection"_ustr,
- u".uno:InsertAnnotation"_ustr,
- u".uno:DeleteAnnotation"_ustr,
- u".uno:InsertPagebreak"_ustr,
- u".uno:InsertColumnBreak"_ustr,
- u".uno:HyperlinkDialog"_ustr,
- u".uno:InsertSymbol"_ustr,
- u".uno:EditRegion"_ustr,
- u".uno:ThesaurusDialog"_ustr,
- u".uno:FormatArea"_ustr,
- u".uno:FormatLine"_ustr,
- u".uno:FormatColumns"_ustr,
- u".uno:Watermark"_ustr,
- u".uno:ResetAttributes"_ustr,
- u".uno:Orientation"_ustr,
- u".uno:ObjectAlignLeft"_ustr,
- u".uno:ObjectAlignRight"_ustr,
- u".uno:AlignCenter"_ustr,
- u".uno:TransformPosX"_ustr,
- u".uno:TransformPosY"_ustr,
- u".uno:TransformWidth"_ustr,
- u".uno:TransformHeight"_ustr,
- u".uno:ObjectBackOne"_ustr,
- u".uno:SendToBack"_ustr,
- u".uno:ObjectForwardOne"_ustr,
- u".uno:BringToFront"_ustr,
- u".uno:WrapRight"_ustr,
- u".uno:WrapThrough"_ustr,
- u".uno:WrapLeft"_ustr,
- u".uno:WrapIdeal"_ustr,
- u".uno:WrapOn"_ustr,
- u".uno:WrapOff"_ustr,
- u".uno:UpdateCurIndex"_ustr,
- u".uno:InsertCaptionDialog"_ustr,
- u".uno:FormatGroup"_ustr,
- u".uno:SplitTable"_ustr,
- u".uno:SplitCell"_ustr,
- u".uno:MergeCells"_ustr,
- u".uno:DeleteNote"_ustr,
- u".uno:AcceptChanges"_ustr,
- u".uno:FormatPaintbrush"_ustr,
- u".uno:SetDefault"_ustr,
- u".uno:ParaLeftToRight"_ustr,
- u".uno:ParaRightToLeft"_ustr,
- u".uno:ParaspaceIncrease"_ustr,
- u".uno:ParaspaceDecrease"_ustr,
- u".uno:AcceptTrackedChange"_ustr,
- u".uno:RejectTrackedChange"_ustr,
- u".uno:AcceptTrackedChangeToNext"_ustr,
- u".uno:RejectTrackedChangeToNext"_ustr,
- u".uno:ShowResolvedAnnotations"_ustr,
- u".uno:InsertBreak"_ustr,
- u".uno:InsertEndnote"_ustr,
- u".uno:InsertFootnote"_ustr,
- u".uno:InsertReferenceField"_ustr,
- u".uno:InsertBookmark"_ustr,
- u".uno:InsertAuthoritiesEntry"_ustr,
- u".uno:InsertMultiIndex"_ustr,
- u".uno:InsertField"_ustr,
- u".uno:PageNumberWizard"_ustr,
- u".uno:InsertPageNumberField"_ustr,
- u".uno:InsertPageCountField"_ustr,
- u".uno:InsertDateField"_ustr,
- u".uno:InsertTitleField"_ustr,
- u".uno:InsertFieldCtrl"_ustr,
- u".uno:CharmapControl"_ustr,
- u".uno:EnterGroup"_ustr,
- u".uno:LeaveGroup"_ustr,
- u".uno:AlignUp"_ustr,
- u".uno:AlignMiddle"_ustr,
- u".uno:AlignDown"_ustr,
- u".uno:TraceChangeMode"_ustr,
- u".uno:Combine"_ustr,
- u".uno:Merge"_ustr,
- u".uno:Dismantle"_ustr,
- u".uno:Substract"_ustr,
- u".uno:DistributeSelection"_ustr,
- u".uno:Intersect"_ustr,
- u".uno:BorderInner"_ustr,
- u".uno:BorderOuter"_ustr,
- u".uno:FreezePanes"_ustr,
- u".uno:FreezePanesColumn"_ustr,
- u".uno:FreezePanesRow"_ustr,
- u".uno:Sidebar"_ustr,
- u".uno:SheetRightToLeft"_ustr,
- u".uno:RunMacro"_ustr,
- u".uno:SpacePara1"_ustr,
- u".uno:SpacePara15"_ustr,
- u".uno:SpacePara2"_ustr,
- u".uno:InsertSparkline"_ustr,
- u".uno:DeleteSparkline"_ustr,
- u".uno:DeleteSparklineGroup"_ustr,
- u".uno:EditSparklineGroup"_ustr,
- u".uno:EditSparkline"_ustr,
- u".uno:GroupSparklines"_ustr,
- u".uno:UngroupSparklines"_ustr,
- u".uno:FormatSparklineMenu"_ustr,
- u".uno:DataDataPilotRun"_ustr,
- u".uno:RecalcPivotTable"_ustr,
- u".uno:DeletePivotTable"_ustr,
- u".uno:Protect"_ustr,
- u".uno:UnsetCellsReadOnly"_ustr,
- u".uno:ContentControlProperties"_ustr,
- u".uno:DeleteContentControl"_ustr,
- u".uno:InsertCheckboxContentControl"_ustr,
- u".uno:InsertContentControl"_ustr,
- u".uno:InsertDateContentControl"_ustr,
- u".uno:InsertDropdownContentControl"_ustr,
- u".uno:InsertPlainTextContentControl"_ustr,
- u".uno:InsertPictureContentControl"_ustr,
- u".uno:DataFilterAutoFilter"_ustr,
- u".uno:CellProtection"_ustr,
- u".uno:MoveKeepInsertMode"_ustr,
- u".uno:ToggleSheetGrid"_ustr,
- u".uno:ChangeBezier"_ustr,
- u".uno:DistributeHorzCenter"_ustr,
- u".uno:DistributeHorzDistance"_ustr,
- u".uno:DistributeHorzLeft"_ustr,
- u".uno:DistributeHorzRight"_ustr,
- u".uno:DistributeVertBottom"_ustr,
- u".uno:DistributeVertCenter"_ustr,
- u".uno:DistributeVertDistance"_ustr,
- u".uno:DistributeVertTop"_ustr,
- u".uno:AnimationEffects"_ustr,
- u".uno:ExecuteAnimationEffect"_ustr,
- u".uno:EditDoc"_ustr,
- };
-
util::URL aCommandURL;
SfxViewShell* pViewShell = SfxViewShell::Current();
SfxViewFrame* pViewFrame = pViewShell ? &pViewShell->GetViewFrame() : nullptr;
@@ -4102,17 +3867,22 @@ static void doc_iniUnoCommands ()
SfxSlotPool& rSlotPool = SfxSlotPool::GetSlotPool(pViewFrame);
uno::Reference<util::XURLTransformer> xParser(util::URLTransformer::create(xContext));
- for (const auto & sUnoCommand : sUnoCommands)
+ const std::map<std::u16string_view, KitUnoCommand>& rUnoCommandList = GetKitUnoCommandList();
+ for (const auto& aUnoCommand : rUnoCommandList)
{
- aCommandURL.Complete = sUnoCommand;
- xParser->parseStrict(aCommandURL);
-
- // when null, this command is not supported by the given component
- // (like eg. Calc does not have ".uno:DefaultBullet" etc.)
- if (const SfxSlot* pSlot = rSlotPool.GetUnoSlot(aCommandURL.Path))
+ if (aUnoCommand.second.initializeForStatusUpdates)
{
- // Initialize slot to dispatch .uno: Command.
- pViewFrame->GetBindings().GetDispatch(pSlot, aCommandURL, false);
+ aCommandURL.Complete = u".uno:"_ustr + aUnoCommand.first;
+ xParser->parseStrict(aCommandURL);
+
+ // when null, this command is not supported by the given component
+ // (like eg. Calc does not have ".uno:DefaultBullet" etc.)
+ if (const SfxSlot* pSlot = rSlotPool.GetUnoSlot(aCommandURL.Path))
+ {
+ // Initialize slot to dispatch .uno: Command.
+ pViewFrame->GetBindings().GetDispatch(pSlot, aCommandURL, false);
+ }
+
}
}
}
diff --git a/include/sfx2/lokunocmdlist.hxx b/include/sfx2/lokunocmdlist.hxx
new file mode 100644
index 000000000000..8472497793bd
--- /dev/null
+++ b/include/sfx2/lokunocmdlist.hxx
@@ -0,0 +1,52 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <sfx2/dllapi.h>
+#include <map>
+
+enum class PayloadType
+{
+ None,
+ IsActivePayload,
+ FontNamePayload,
+ FontHeightPayload,
+ StyleApplyPayload,
+ ColorPayload,
+ UndoRedoPayload,
+ EnabledPayload,
+ ParaDirectionPayload,
+ Int32Payload,
+ TransformPayload,
+ StringPayload,
+ RowColSelCountPayload,
+ StateTableCellPayload,
+ BooleanPayload,
+ BooleanOrDisabledPayload,
+ PointPayload,
+ SizePayload,
+ StringOrStrSeqPayload,
+ StrSeqPayload,
+ TableSizePayload,
+};
+
+struct KitUnoCommand
+{
+ // (if != None) --> function used by libreOfficeKitViewCallback in
+ // unoctitm.cxx.
+ PayloadType payloadType;
+ // (if == true) --> command is listened to for status updates. This is used
+ // by doc_iniUnoCommands in init.cxx.
+ bool initializeForStatusUpdates;
+};
+
+// Get list of uno commands that are safe enough to be allowed to use in some cases
+// Parameters:
+SFX2_DLLPUBLIC const std::map<std::u16string_view, KitUnoCommand>& GetKitUnoCommandList();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/sd/inc/app.hrc b/sd/inc/app.hrc
index 56cfc31ede21..34f0d368b8f9 100644
--- a/sd/inc/app.hrc
+++ b/sd/inc/app.hrc
@@ -453,4 +453,6 @@
#define SID_PRESENTATION_MINIMIZER (SID_SD_START+450)
#define SID_ALIGN_PAGE (SID_SD_START+451)
+#define FN_TRANSFORM_DOCUMENT_STRUCTURE (SID_SD_START+452)
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/inc/sdpage.hxx b/sd/inc/sdpage.hxx
index 208c5888a69b..a1121b68b18b 100644
--- a/sd/inc/sdpage.hxx
+++ b/sd/inc/sdpage.hxx
@@ -384,6 +384,9 @@ public:
*/
void getGraphicsForPrefetch(std::vector<Graphic*>& graphics) const;
+ static AutoLayout stringToAutoLayout(std::u16string_view rLayoutName);
+ static OUString autoLayoutToString(AutoLayout nLayoutId);
+
static sal_uInt16 mnLastPageId;
private:
diff --git a/sd/qa/unit/uiimpress.cxx b/sd/qa/unit/uiimpress.cxx
index 8d399f024b03..4d22a30b057c 100644
--- a/sd/qa/unit/uiimpress.cxx
+++ b/sd/qa/unit/uiimpress.cxx
@@ -172,6 +172,113 @@ void SdUiImpressTest::lcl_search(const OUString& rKey, bool bFindAll, bool bBack
dispatchCommand(mxComponent, u".uno:ExecuteSearch"_ustr, aPropertyValues);
}
+CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testDocumentStructureTransformExtractSlide)
+{
+ createSdImpressDoc("odp/tdf161430.odp");
+
+ OString aJson = R"json(
+{
+ "Transforms": {
+ "SlideCommands": [
+ {"JumpToSlideByName": "Slide 3"},
+ {"MoveSlide": 0},
+ {"RenameSlide": "Slide3-Renamed"},
+ {"DeleteSlide": 2},
+ {"JumpToSlide": 2},
+ {"DeleteSlide": ""},
+ {"JumpToSlide": 1},
+ {"DuplicateSlide": ""},
+ {"RenameSlide": "Slide1-Duplicated"},
+ {"InsertMasterSlide": 1},
+ {"RenameSlide": "SlideInserted-1"},
+ {"ChangeLayout": 18},
+ {"JumpToSlide": "last"},
+ {"InsertMasterSlideByName": "Topic Separator white"},
+ {"RenameSlide": "SlideInserted-Name"},
+ {"ChangeLayoutByName": "AUTOLAYOUT_TITLE_2CONTENT"},
+ {"SetText.0": "first"},
+ {"SetText.1": "second"},
+ {"SetText.2": "third"},
+ {"DuplicateSlide": 1},
+ {"MoveSlide.2": 6}
+ ]
+ }
+}
+)json"_ostr;
+
+ //transform
+ uno::Sequence<css::beans::PropertyValue> aArgs = {
+ comphelper::makePropertyValue(u"DataJson"_ustr,
+ uno::Any(OStringToOUString(aJson, RTL_TEXTENCODING_UTF8))),
+ };
+ dispatchCommand(mxComponent, u".uno:TransformDocumentStructure"_ustr, aArgs);
+
+ //extract
+ tools::JsonWriter aJsonWriter;
+ std::string_view aCommand(".uno:ExtractDocumentStructure?filter=slides");
+ auto pXPresDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get());
+ pXPresDocument->getCommandValues(aJsonWriter, aCommand);
+
+ OString aExpectedStr
+ = "{ \"DocStructure\": { \"SlideCount\": 7, \"MasterSlideCount\": 8, \"MasterSlides\": [ "
+ "\"MasterSlide 0\": { \"Name\": \"Topic_Separator_Purple\"}, \"MasterSlide 1\": { "
+ "\"Name\": \"Content_sidebar_White\"}, \"MasterSlide 2\": { \"Name\": \"Topic Separator "
+ "white\"}, \"MasterSlide 3\": { \"Name\": \"Content_sidebar_White_\"}, \"MasterSlide "
+ "4\": { \"Name\": \"Topic_Separator_Purple_\"}, \"MasterSlide 5\": { \"Name\": "
+ "\"Content_White_Purple_Sidebar\"}, \"MasterSlide 6\": { \"Name\": \"Default 1\"}, "
+ "\"MasterSlide 7\": { \"Name\": \"Default 1_\"}], \"Slides\": [ \"Slide 0\": { "
+ "\"SlideName\": \"Slide3-Renamed\", \"MasterSlideName\": "
+ "\"Content_White_Purple_Sidebar\", \"LayoutId\": 3, \"LayoutName\": "
+ "\"AUTOLAYOUT_TITLE_2CONTENT\", \"ObjectCount\": 4, \"Objects\": [ \"Objects 0\": { "
+ "\"TextCount\": 1, \"Texts\": [ \"Text 0\": { \"ParaCount\": 1, \"Paragraphs\": [ "
+ "\"Friendly Open Source Project\"]}]}, \"Objects 1\": { }, \"Objects 2\": { "
+ "\"TextCount\": 1, \"Texts\": [ \"Text 0\": { \"ParaCount\": 9, \"Paragraphs\": [ \"Real "
+ "Open Source\", \"100% open-source code\", \"Built with LibreOffice technology\", "
+ "\"Built with Free Software technology stacks: primarily C++\", \"Runs best on Linux\", "
+ "\"Open Development\", \"Anyone can contribute & participate\", \"Follow commits and "
+ "tickets\", \"Public community calls - forum has details\"]}]}, \"Objects 3\": { "
+ "\"TextCount\": 1, \"Texts\": [ \"Text 0\": { \"ParaCount\": 5, \"Paragraphs\": [ "
+ "\"Focus:\", \"a non-renewable resource.\", \"Office Productivity & Documents\", "
+ "\"Excited about migrating your\\u0001documents\", \"Grateful to our partners for "
+ "solving\\u0001other problems.\"]}]}]}, \"Slide 1\": { \"SlideName\": \"Slide 2\", "
+ "\"MasterSlideName\": \"Topic_Separator_Purple\", \"LayoutId\": 3, \"LayoutName\": "
+ "\"AUTOLAYOUT_TITLE_2CONTENT\", \"ObjectCount\": 1, \"Objects\": [ \"Objects 0\": { "
+ "\"TextCount\": 1, \"Texts\": [ \"Text 0\": { \"ParaCount\": 3, \"Paragraphs\": [ "
+ "\"Collabora Online\", \"\", \"Powerful Online Collaboration\"]}]}]}, \"Slide 2\": { "
+ "\"SlideName\": \"Slide1-Duplicated\", \"MasterSlideName\": \"Topic_Separator_Purple\", "
+ "\"LayoutId\": 3, \"LayoutName\": \"AUTOLAYOUT_TITLE_2CONTENT\", \"ObjectCount\": 1, "
+ "\"Objects\": [ \"Objects 0\": { \"TextCount\": 1, \"Texts\": [ \"Text 0\": { "
+ "\"ParaCount\": 3, \"Paragraphs\": [ \"Collabora Online\", \"\", \"Powerful Online "
+ "Collaboration\"]}]}]}, \"Slide 3\": { \"SlideName\": \"SlideInserted-1\", "
+ "\"MasterSlideName\": \"Content_sidebar_White\", \"LayoutId\": 18, \"LayoutName\": "
+ "\"AUTOLAYOUT_TITLE_4CONTENT\", \"ObjectCount\": 5, \"Objects\": [ \"Objects 0\": { "
+ "\"TextCount\": 1, \"Texts\": [ \"Text 0\": { \"ParaCount\": 1, \"Paragraphs\": [ "
+ "\"Click to add Title\"]}]}, \"Objects 1\": { \"TextCount\": 1, \"Texts\": [ \"Text 0\": "
+ "{ \"ParaCount\": 1, \"Paragraphs\": [ \"Click to add Text\"]}]}, \"Objects 2\": { "
+ "\"TextCount\": 1, \"Texts\": [ \"Text 0\": { \"ParaCount\": 1, \"Paragraphs\": [ "
+ "\"Click to add Text\"]}]}, \"Objects 3\": { \"TextCount\": 1, \"Texts\": [ \"Text 0\": "
+ "{ \"ParaCount\": 1, \"Paragraphs\": [ \"Click to add Text\"]}]}, \"Objects 4\": { "
+ "\"TextCount\": 1, \"Texts\": [ \"Text 0\": { \"ParaCount\": 1, \"Paragraphs\": [ "
+ "\"Click to add Text\"]}]}]}, \"Slide 4\": { \"SlideName\": \"Slide 6\", "
+ "\"MasterSlideName\": \"Topic_Separator_Purple\", \"LayoutId\": 3, \"LayoutName\": "
+ "\"AUTOLAYOUT_TITLE_2CONTENT\", \"ObjectCount\": 1, \"Objects\": [ \"Objects 0\": { "
+ "\"TextCount\": 1, \"Texts\": [ \"Text 0\": { \"ParaCount\": 1, \"Paragraphs\": [ \"With "
+ "thanks to our Partners, Customers & Community !\"]}]}]}, \"Slide 5\": { \"SlideName\": "
+ "\"SlideInserted-Name\", \"MasterSlideName\": \"Topic Separator white\", \"LayoutId\": "
+ "3, \"LayoutName\": \"AUTOLAYOUT_TITLE_2CONTENT\", \"ObjectCount\": 3, \"Objects\": [ "
+ "\"Objects 0\": { \"TextCount\": 1, \"Texts\": [ \"Text 0\": { \"ParaCount\": 1, "
+ "\"Paragraphs\": [ \"first\"]}]}, \"Objects 1\": { \"TextCount\": 1, \"Texts\": [ \"Text "
+ "0\": { \"ParaCount\": 1, \"Paragraphs\": [ \"second\"]}]}, \"Objects 2\": { "
+ "\"TextCount\": 1, \"Texts\": [ \"Text 0\": { \"ParaCount\": 1, \"Paragraphs\": [ "
+ "\"third\"]}]}]}, \"Slide 6\": { \"SlideName\": \"Slide 7\", \"MasterSlideName\": "
+ "\"Topic_Separator_Purple\", \"LayoutId\": 3, \"LayoutName\": "
+ "\"AUTOLAYOUT_TITLE_2CONTENT\", \"ObjectCount\": 1, \"Objects\": [ \"Objects 0\": { "
+ "\"TextCount\": 1, \"Texts\": [ \"Text 0\": { \"ParaCount\": 3, \"Paragraphs\": [ "
+ "\"Collabora Online\", \"\", \"Powerful Online Collaboration\"]}]}]}]}}"_ostr;
+
+ CPPUNIT_ASSERT_EQUAL(aExpectedStr, aJsonWriter.finishAndGetAsOString());
+}
+
CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf111522)
{
// Load the document and create two new windows.
diff --git a/sd/sdi/_drvwsh.sdi b/sd/sdi/_drvwsh.sdi
index 5a19a4155e9c..b0c655176b1b 100644
--- a/sd/sdi/_drvwsh.sdi
+++ b/sd/sdi/_drvwsh.sdi
@@ -146,6 +146,10 @@ interface DrawView
ExecMethod = FuTemporary ;
StateMethod = GetMenuState ;
]
+ FN_TRANSFORM_DOCUMENT_STRUCTURE
+ [
+ ExecMethod = FuTemporary ;
+ ]
SID_INSERTPAGE // ole : no, status : play rec
[
ExecMethod = FuTemporary ;
diff --git a/sd/sdi/sdraw.sdi b/sd/sdi/sdraw.sdi
index d98a938c1cfd..5cb4bd732c42 100644
--- a/sd/sdi/sdraw.sdi
+++ b/sd/sdi/sdraw.sdi
@@ -2195,6 +2195,23 @@ SfxVoidItem InsertLayer SID_INSERTLAYER
GroupId = SfxGroupId::Insert;
]
+SfxVoidItem TransformDocumentStructure FN_TRANSFORM_DOCUMENT_STRUCTURE
+(SfxStringItem DataJson FN_PARAM_1)
+[
+ AutoUpdate = FALSE,
+ FastCall = FALSE,
+ ReadOnlyDoc = FALSE,
+ Toggle = FALSE,
+ Container = FALSE,
+ RecordAbsolute = FALSE,
+ RecordPerSet;
+
+ AccelConfig = TRUE,
+ MenuConfig = TRUE,
+ ToolBoxConfig = TRUE,
+ GroupId = SfxGroupId::Edit;
+]
+
SfxVoidItem InsertPage SID_INSERTPAGE
(SfxStringItem PageName ID_VAL_PAGENAME,SfxUInt32Item WhatLayout ID_VAL_WHATLAYOUT,SfxBoolItem IsPageBack ID_VAL_ISPAGEBACK,SfxBoolItem IsPageObj ID_VAL_ISPAGEOBJ,SfxUInt16Item InsertPos ID_INSERT_POS)
[
diff --git a/sd/source/core/sdpage.cxx b/sd/source/core/sdpage.cxx
index dc5dfbf85aac..501c2da5b8ed 100644
--- a/sd/source/core/sdpage.cxx
+++ b/sd/source/core/sdpage.cxx
@@ -1353,6 +1353,28 @@ static OUString enumtoString(AutoLayout aut)
return retstr;
}
+AutoLayout SdPage::stringToAutoLayout(std::u16string_view rLayoutName)
+{
+ for (int i = AUTOLAYOUT_START; i < AUTOLAYOUT_END; i++)
+ {
+ AutoLayout nLId = static_cast<AutoLayout>(i);
+ if (autoLayoutToString(nLId) == rLayoutName)
+ {
+ return nLId;
+ }
+ }
+ return AUTOLAYOUT_END;
+}
+
+OUString SdPage::autoLayoutToString(AutoLayout nLayoutId)
+{
+ if (nLayoutId == AUTOLAYOUT_TITLE)
+ {
+ return "AUTOLAYOUT_TITLE";
+ }
+ return enumtoString(nLayoutId);
+}
+
static void CalcAutoLayoutRectangles( SdPage const & rPage,::tools::Rectangle* rRectangle ,const OUString& sLayoutType )
{
::tools::Rectangle aTitleRect;
diff --git a/sd/source/ui/inc/unomodel.hxx b/sd/source/ui/inc/unomodel.hxx
index 7a299c54c280..c4bb88802821 100644
--- a/sd/source/ui/inc/unomodel.hxx
+++ b/sd/source/ui/inc/unomodel.hxx
@@ -298,6 +298,8 @@ public:
/// @see vcl::ITiledRenderable::getViewRenderState().
SD_DLLPUBLIC OString getViewRenderState(SfxViewShell* pViewShell = nullptr) override;
+ SD_DLLPUBLIC virtual void getCommandValues(tools::JsonWriter& rJsonWriter, std::string_view rCommand) override;
+
/// @see vcl::ITiledRenderable::getPresentationInfo().
SD_DLLPUBLIC OString getPresentationInfo() const override;
/// @see vcl::ITiledRenderable::createSlideRenderer().
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index d778a6196611..4dded27a41b6 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -1455,6 +1455,110 @@ void AnimationsExporter::exportAnimate(const Reference<XAnimate>& xAnimate)
}
}
+void GetDocStructureSlides(::tools::JsonWriter& rJsonWriter, SdXImpressDocument* pDoc,
+ const std::map<OUString, OUString>& rArguments)
+{
+ auto it = rArguments.find(u"filter"_ustr);
+ if (it != rArguments.end())
+ {
+ // If filter is present but we are filtering not to slide informations
+ if (!it->second.equals(u"slides"_ustr))
+ return;
+ }
+
+ sal_uInt16 nPageCount = pDoc->GetDoc()->GetSdPageCount(PageKind::Standard);
+ sal_uInt16 nMasterPageCount = pDoc->GetDoc()->GetMasterSdPageCount(PageKind::Standard);
+
+ rJsonWriter.put("SlideCount", nPageCount);
+ rJsonWriter.put("MasterSlideCount", nMasterPageCount);
+
+ // write data of every master slide
+ if (nMasterPageCount > 0)
+ {
+ auto aMasterPagesNode = rJsonWriter.startArray("MasterSlides");
+ for (int nMPId = 0; nMPId < nMasterPageCount; nMPId++)
+ {
+ auto aMasterPageNode = rJsonWriter.startNode("MasterSlide " + std::to_string(nMPId));
+ const OUString& aMName
+ = pDoc->GetDoc()->GetMasterSdPage(nMPId, PageKind::Standard)->GetName();
+ rJsonWriter.put("Name", aMName);
+ }
+ }
+
+ // write data of every slide
+ if (nPageCount > 0)
+ {
+ auto aPagesNode = rJsonWriter.startArray("Slides");
+ for (int nPId = 0; nPId < nPageCount; nPId++)
+ {
+ auto aPageNode = rJsonWriter.startNode("Slide " + std::to_string(nPId));
+ SdPage* pPageStandard = pDoc->GetDoc()->GetSdPage(nPId, PageKind::Standard);
+
+ // Slide Name
+ rJsonWriter.put("SlideName", pPageStandard->GetName());
+
+ // MatserSlide Name
+ const FmFormPage* pMasterPage
+ = dynamic_cast<const FmFormPage*>(&pPageStandard->TRG_GetMasterPage());
+
+ if (pMasterPage)
+ {
+ rJsonWriter.put("MasterSlideName", pMasterPage->GetName());
+ }
+
+ // Layout id, and name.
+ AutoLayout nLayout = pPageStandard->GetAutoLayout();
+ rJsonWriter.put("LayoutId", static_cast<int>(nLayout));
+ rJsonWriter.put("LayoutName", SdPage::autoLayoutToString(nLayout));
+
+ // Every Objects in the page
+ int nObjCount = pPageStandard->GetObjCount();
+ rJsonWriter.put("ObjectCount", nObjCount);
+
+ if (nObjCount > 0)
+ {
+ auto aObjectsNode = rJsonWriter.startArray("Objects");
+ for (int nOId = 0; nOId < nObjCount; nOId++)
+ {
+ auto aObjectNode = rJsonWriter.startNode("Objects " + std::to_string(nOId));
+ SdrObject* pSdrObj = pPageStandard->GetObj(nOId);
+ SdrTextObj* pSdrTxtObj = DynCastSdrTextObj(pSdrObj);
+ if (pSdrTxtObj && pSdrTxtObj->HasText())
+ {
+ sal_Int32 nTextCount = pSdrTxtObj->getTextCount();
+ rJsonWriter.put("TextCount", nTextCount);
+ if (nTextCount > 0)
+ {
+ auto aTextsNode = rJsonWriter.startArray("Texts");
+ for (int nTId = 0; nTId < nTextCount; nTId++)
+ {
+ auto aTextNode
+ = rJsonWriter.startNode("Text " + std::to_string(nTId));
+ SdrText* pSdrTxt = pSdrTxtObj->getText(nTId);
+ OutlinerParaObject* pOutlinerParaObject
+ = pSdrTxt->GetOutlinerParaObject();
+
+ sal_Int32 nParaCount
+ = pOutlinerParaObject->GetTextObject().GetParagraphCount();
+
+ rJsonWriter.put("ParaCount", nParaCount);
+ auto aParasNode = rJsonWriter.startArray("Paragraphs");
+ for (int nParaId = 0; nParaId < nParaCount; nParaId++)
+ {
+ OUString aParaStr(
+ pOutlinerParaObject->GetTextObject().GetText(nParaId));
+
+ rJsonWriter.putSimpleValue(aParaStr);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
} // end anonymous namespace
SdUnoForbiddenCharsTable::SdUnoForbiddenCharsTable( SdrModel* pModel )
@@ -1752,6 +1856,20 @@ void SdXImpressDocument::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
SfxBaseModel::Notify( rBC, rHint );
}
+void SdXImpressDocument::getCommandValues(::tools::JsonWriter& rJsonWriter, std::string_view rCommand)
+{
+ static constexpr OStringLiteral aExtractDocStructure(".uno:ExtractDocumentStructure");
+
+ std::map<OUString, OUString> aMap
+ = SfxLokHelper::parseCommandParameters(OUString::fromUtf8(rCommand));
+
+ if (o3tl::starts_with(rCommand, aExtractDocStructure))
+ {
+ auto commentsNode = rJsonWriter.startNode("DocStructure");
+ GetDocStructureSlides(rJsonWriter, this, aMap);
+ }
+}
+
/******************************************************************************
* *
******************************************************************************/
diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx
index fc011865e7fa..f578bc29ea00 100644
--- a/sd/source/ui/view/drviews2.cxx
+++ b/sd/source/ui/view/drviews2.cxx
@@ -39,6 +39,10 @@
#include <comphelper/propertysequence.hxx>
#include <comphelper/scopeguard.hxx>
#include <comphelper/lok.hxx>
+#include <comphelper/sequence.hxx>
+#include <comphelper/sequenceashashmap.hxx>
+#include <comphelper/dispatchcommand.hxx>
+#include <comphelper/propertyvalue.hxx>
#include <editeng/contouritem.hxx>
#include <editeng/editdata.hxx>
@@ -59,6 +63,8 @@
#include <sfx2/request.hxx>
#include <sfx2/viewfrm.hxx>
#include <sfx2/zoomitem.hxx>
+#include <sfx2/lokhelper.hxx>
+#include <sfx2/lokunocmdlist.hxx>
#include <svx/compressgraphicdialog.hxx>
#include <svx/ClassificationDialog.hxx>
@@ -198,6 +204,11 @@
#include <SelectLayerDlg.hxx>
#include <unomodel.hxx>
+#include <iostream>
+#include <boost/property_tree/json_parser.hpp>
+#include <rtl/uri.hxx>
+
+
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -245,6 +256,11 @@ OUString getWeightString(SfxItemSet const & rItemSet)
return sWeightString;
}
+void lcl_LogWarning(const std::string& rWarning)
+{
+ LOK_WARN("sd.transform", rWarning);
+}
+
class ClassificationCommon
{
protected:
@@ -741,6 +757,480 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
}
break;
+ case FN_TRANSFORM_DOCUMENT_STRUCTURE:
+ {
+ // get the parameter, what to transform
+ OUString aDataJson;
+ const SfxStringItem* pDataJson = rReq.GetArg<SfxStringItem>(FN_PARAM_1);
+ if (pDataJson)
+ {
+ aDataJson = pDataJson->GetValue();
+ aDataJson = rtl::Uri::decode(aDataJson, rtl_UriDecodeStrict, RTL_TEXTENCODING_UTF8);
+ }
+
+ // parse the JSON transform parameter
+ boost::property_tree::ptree aTree;
+ std::stringstream aStream(
+ (std::string(OUStringToOString(aDataJson, RTL_TEXTENCODING_UTF8))));
+ try
+ {
+ boost::property_tree::read_json(aStream, aTree);
+ }
+ catch (...)
+ {
+ lcl_LogWarning("FillApi Transform parameter, Wrong JSON format. ");
+ throw;
+ }
+
+ // Iterate through the JSON data loaded into a tree structure
+ for (const auto& aItem : aTree)
+ {
+ if (aItem.first == "Transforms")
+ {
+ // Handle all transformations
+ for (const auto& aItem2 : aItem.second)
+ {
+ //jump to slide
+ if (aItem2.first == "SlideCommands")
+ {
+ int nActPageId = -1;
+ int nNextPageId = 0;
+ for (const auto& aItem3Obj : aItem2.second)
+ {
+ const auto& aItem3 = *aItem3Obj.second.ordered_begin();
+
+ sal_uInt16 nPageCount
+ = GetDoc()->GetSdPageCount(PageKind::Standard);
+ sal_uInt16 nMasterPageCount
+ = GetDoc()->GetMasterSdPageCount(PageKind::Standard);
+
+ if (nActPageId != nNextPageId)
+ {
+ // Make it sure it always point to a real page
+ if (nNextPageId < 0)
+ nNextPageId = 0;
+ if (nNextPageId >= nPageCount)
+ nNextPageId = nPageCount - 1;
+
+ nActPageId = nNextPageId;
+ // Make sure nActPageId is the current Page
+ maTabControl->SetCurPageId(nActPageId);
+ SdPage* pPageStandard
+ = GetDoc()->GetSdPage(nActPageId, PageKind::Standard);
+ mpDrawView->ShowSdrPage(pPageStandard);
+ }
+
+ if (aItem3.first == "JumpToSlide")
+ {
+ std::string aIndex = aItem3.second.get_value<std::string>();
+ if (aIndex == "last")
+ {
+ nNextPageId = nPageCount - 1;
+ }
+ else
+ {
+ nNextPageId = aItem3.second.get_value<int>();
+ if (nNextPageId >= nPageCount)
+ {
+ lcl_LogWarning(
+ "FillApi SlideCmd: Slide idx >= Slide count. '"
+ + aItem3.first + ": " + aIndex
+ + "' (Slide count = " + std::to_string(nPageCount));
+ nNextPageId = nPageCount - 1;
+ }
+ else if (nNextPageId < 0)
+ {
+ lcl_LogWarning("FillApi SlideCmd: Slide idx < 0. '"
+ + aItem3.first + ": " + aIndex + "'");
+ nNextPageId = 0;
+ }
+ }
+ }
+ if (aItem3.first == "JumpToSlideByName")
+ {
+ std::string aPageName = aItem3.second.get_value<std::string>();
+ int nId = 0;
+ while (
+ nId < nPageCount
+ && GetDoc()->GetSdPage(nId, PageKind::Standard)->GetName()
+ != OStringToOUString(aPageName,
+ RTL_TEXTENCODING_UTF8))
+ {
+ nId++;
+ }
+ if (nId < nPageCount)
+ {
+ nNextPageId = nId;
+ }
+ else
+ {
+ lcl_LogWarning(
+ "FillApi SlideCmd: Slide name not found at: '"
+ + aItem3.first + ": " + aPageName + "'");
+ }
+ }
+ else if (aItem3.first == "InsertMasterSlide"
+ || aItem3.first == "InsertMasterSlideByName")
+ {
+ int nMasterPageId = 0;
+ if (aItem3.first == "InsertMasterSlideByName")
+ {
+ int nMId = 0;
+ std::string aMPageName
+ = aItem3.second.get_value<std::string>();
+ while (
+ nMId < nMasterPageCount
+ && GetDoc()->GetMasterSdPage(nMId, PageKind::Standard)
+ ->GetName()
+ != OStringToOUString(aMPageName,
+ RTL_TEXTENCODING_UTF8))
+ {
+ nMId++;
+ }
+ if (nMId < nMasterPageCount)
+ {
+ nMasterPageId = nMId;
+ }
+ else
+ {
+ lcl_LogWarning(
+ "FillApi SlideCmd: MatserSlide name not found at: '"
+ + aItem3.first + ": " + aMPageName + "'");
+ }
+ }
+ else
+ {
+ nMasterPageId = aItem3.second.get_value<int>();
+ }
+
+ if (nMasterPageId >= nMasterPageCount)
+ {
+ lcl_LogWarning(
+ "FillApi SlideCmd: Slide idx >= MasterSlide count. '"
+ + aItem3.first + ": " + std::to_string(nMasterPageId)
+ + "' (Slide count = " + std::to_string(nMasterPageCount));
+ nMasterPageId = nMasterPageCount - 1;
+ }
+ else if (nMasterPageId < 0)
+ {
+ lcl_LogWarning("FillApi SlideCmd: Slide idx < 0. '"
+ + aItem3.first + ": "
+ + std::to_string(nMasterPageId) + "'");
+ nMasterPageId = 0;
+ }
+
+ SdPage* pMPage = GetDoc()->GetMasterSdPage(nMasterPageId,
+ PageKind::Standard);
+ SdPage* pPage
+ = GetDoc()->GetSdPage(nActPageId, PageKind::Standard);
+
+ // It will move to the next slide.
+ nNextPageId = GetDoc()->CreatePage(
+ pPage, PageKind::Standard, OUString(), OUString(),
+ AUTOLAYOUT_TITLE_CONTENT, AUTOLAYOUT_NOTES, true, true,
+ pPage->GetPageNum() + 2);
+
+ SdPage* pPageStandard
+ = GetDoc()->GetSdPage(nNextPageId, PageKind::Standard);
+ SdPage* pPageNote
+ = GetDoc()->GetSdPage(nNextPageId, PageKind::Notes);
+
+ // Change master value
+ pPageStandard->TRG_SetMasterPage(*pMPage);
+ pPageNote->TRG_SetMasterPage(*pMPage);
+ }
+ else if (aItem3.first == "DeleteSlide")
+ {
+ int nPageIdToDel = nActPageId;
+ if (aItem3.second.get_value<std::string>() != "")
+ {
+ nPageIdToDel = aItem3.second.get_value<int>();
+ }
+
+ if (nPageCount > 1)
+ {
+ if (nPageIdToDel >= nPageCount)
+ {
+ lcl_LogWarning(
+ "FillApi SlideCmd: Slide idx >= Slide count. '"
+ + aItem3.first + ": " + std::to_string(nPageIdToDel)
+ + "' (Slide count = " + std::to_string(nPageCount));
+ nPageIdToDel = nPageCount - 1;
+ }
+ else if (nPageIdToDel < 0)
+ {
+ lcl_LogWarning("FillApi SlideCmd: Slide idx < 0. '"
+ + aItem3.first + ": "
+ + std::to_string(nPageIdToDel) + "'");
+ nPageIdToDel = 0;
+ }
+ GetDoc()->RemovePage(nPageIdToDel * 2 + 1);
+ GetDoc()->RemovePage(nPageIdToDel * 2 + 1);
+
+ if (nPageIdToDel <= nActPageId)
+ {
+ nNextPageId--;
+ }
+ }
+ else
+ {
+ lcl_LogWarning(
+ "FillApi SlideCmd: Not enought Slide to delete 1. '"
+ + aItem3.first + ": " + std::to_string(nPageIdToDel));
+ }
+ }
+ else if (aItem3.first.starts_with("MoveSlide"))
+ {
+ int nMoveFrom = nActPageId;
+ if (aItem3.first.starts_with("MoveSlide."))
+ {
+ nMoveFrom = stoi(aItem3.first.substr(10));
+ }
+ int nMoveTo = aItem3.second.get_value<int>();
+
+ if (nMoveFrom == nMoveTo)
+ {
+ lcl_LogWarning(
+ "FillApi SlideCmd: Move slide to the same position. '"
+ + aItem3.first + ": " + std::to_string(nMoveTo));
+ }
+ else if (nMoveFrom >= nPageCount || nMoveTo > nPageCount)
+ {
+ lcl_LogWarning(
+ "FillApi SlideCmd: Slide idx >= Slide count. '"
+ + aItem3.first + ": " + std::to_string(nMoveTo));
+ }
+ else if (nMoveFrom < 0 || nMoveTo < 0)
+ {
+ lcl_LogWarning(
+ "FillApi SlideCmd: Slide idx < 0. '"
+ + aItem3.first + ": " + std::to_string(nMoveTo));
+ }
+ else
+ {
+ // Move both the standard and the Note Page.
+ // First move the page that will not change
+ // the order of the other page.
+ int nFirst = 1;
+ if (nMoveFrom < nMoveTo)
+ {
+ nFirst = 2;
+ }
+ int nSecond = 3 - nFirst;
+
+ GetDoc()->MovePage(nMoveFrom * 2 + nFirst,
+ nMoveTo * 2 + nFirst);
+ GetDoc()->MovePage(nMoveFrom * 2 + nSecond,
+ nMoveTo * 2 + nSecond);
+
+ // If the act page is moved, then follow it.
+ if (nActPageId == nMoveFrom)
+ {
+ nNextPageId = nMoveTo;
+ }
+ else if (nMoveFrom < nActPageId && nMoveTo >= nActPageId)
+ {
+ nNextPageId = nActPageId - 1;
+ }
+ else if (nMoveFrom > nActPageId && nMoveTo <= nActPageId)
+ {
+ nNextPageId = nActPageId + 1;
+ }
+ }
+ }
+ else if (aItem3.first == "DuplicateSlide")
+ {
+ int nDupSlideId = nActPageId;
+ if (aItem3.second.get_value<std::string>() != "")
+ {
+ nDupSlideId = aItem3.second.get_value<int>();
+ }
+
+ if (nDupSlideId >= nPageCount)
+ {
+ lcl_LogWarning(
+ "FillApi SlideCmd: Slide idx >= Slide count. '"
+ + aItem3.first + ": " + std::to_string(nDupSlideId)
+ + "' (Slide count = " + std::to_string(nPageCount));
+ nDupSlideId = nPageCount - 1;
+ }
+ else if (nDupSlideId < 0)
+ {
+ lcl_LogWarning("FillApi SlideCmd: Slide idx < 0. '"
+ + aItem3.first + ": "
+ + std::to_string(nDupSlideId) + "'");
+ nDupSlideId = 0;
+ }
+ GetDoc()->DuplicatePage(nDupSlideId);
+ // Jump to the created page.
+ nNextPageId = nDupSlideId + 1;
+ // Make sure the current page will be set also.
+ nActPageId = nDupSlideId;
+ }
+ else if (aItem3.first == "ChangeLayout"
+ || aItem3.first == "ChangeLayoutByName")
+ {
+ AutoLayout nLayoutId;
+ if (aItem3.first == "ChangeLayoutByName")
+ {
+ std::string aLayoutName
+ = aItem3.second.get_value<std::string>();
+
+ nLayoutId = SdPage::stringToAutoLayout(
+ OStringToOUString(aLayoutName, RTL_TEXTENCODING_UTF8));
+ if (nLayoutId == AUTOLAYOUT_END)
+ {
+ lcl_LogWarning(
+ "FillApi SlideCmd: Layout name not found at: '"
+ + aItem3.first + ": " + aLayoutName + "'");
+ nLayoutId = AUTOLAYOUT_TITLE_CONTENT;
+ }
+ }
+ else
+ {
+ nLayoutId = static_cast<AutoLayout>(
+ aItem3.second.get_value<int>());
+ if (nLayoutId < AUTOLAYOUT_START
+ || nLayoutId >= AUTOLAYOUT_END)
+ {
+ lcl_LogWarning(
+ "FillApi SlideCmd: Wrong Layout index at: '"
+ + aItem3.first + ": " + std::to_string(nLayoutId)
+ + "'");
+ nLayoutId = AUTOLAYOUT_TITLE_CONTENT;
+ }
+ }
+
+ // Todo warning: ... if (nLayoutId >= ???)
+ GetDoc()
+ ->GetSdPage(nActPageId, PageKind::Standard)
+ ->SetAutoLayout(nLayoutId, true);
+ }
+ else if (aItem3.first == "RenameSlide")
+ {
+ SdPage* pPageStandard
+ = GetDoc()->GetSdPage(nActPageId, PageKind::Standard);
+ pPageStandard->SetName(
+ OStringToOUString(aItem3.second.get_value<std::string>(),
+ RTL_TEXTENCODING_UTF8));
+ }
+ else if (aItem3.first.starts_with("SetText."))
+ {
+ int nObjId = stoi(aItem3.first.substr(8));
+
+ SdPage* pPageStandard
+ = GetDoc()->GetSdPage(nActPageId, PageKind::Standard);
+ int nObjCount = pPageStandard->GetObjCount();
+ if (nObjId < 0)
+ {
+ lcl_LogWarning("FillApi SlideCmd SetText: Object idx < 0. '"
+ + aItem3.first + "'");
+ }
+ else if (nObjId < nObjCount)
+ {
+ SdrObject* pSdrObj = pPageStandard->GetObj(nObjId);
+ if (pSdrObj->IsSdrTextObj())
+ {
+ SdrTextObj* pSdrTxt = static_cast<SdrTextObj*>(pSdrObj);
+ pSdrTxt->SetText(OStringToOUString(
+ aItem3.second.get_value<std::string>(),
+ RTL_TEXTENCODING_UTF8));
+
+ // Todo: maybe with empty string it should work elseway?
+ pSdrObj->SetEmptyPresObj(false);
+ }
+ }
+ else
+ {
+ lcl_LogWarning(
+ "FillApi SlideCmd SetText: Object idx >= Object Count. '"
+ + aItem3.first
+ + "' (Object Count = " + std::to_string(nPageCount));
+ }
+ }
+ else if (aItem3.first == "MarkObject"
+ || aItem3.first == "UnMarkObject")
+ {
+ bool bUnMark = aItem3.first == "UnMarkObject";
+ int nObjId
+ = static_cast<AutoLayout>(aItem3.second.get_value<int>());
+
+ SdPage* pPageStandard
+ = GetDoc()->GetSdPage(nActPageId, PageKind::Standard);
+ int nObjCount = pPageStandard->GetObjCount();
+
+ // Todo: check id vs count
+ if (nObjId < 0)
+ {
+ lcl_LogWarning("FillApi SlideCmd: Object idx < 0 at: '"
+ + aItem3.first + std::to_string(nObjId)
+ + "'");
+ }
+ if (nObjId < nObjCount)
+ {
+ SdrObject* pSdrObj = pPageStandard->GetObj(nObjId);
+ mpDrawView->MarkObj(pSdrObj, mpDrawView->GetSdrPageView(),
+ bUnMark);
+ }
+ else
+ {
+ lcl_LogWarning(
+ "FillApi SlideCmd: Object idx > Object Count. '"
+ + aItem3.first + std::to_string(nObjId)
+ + "' (Object Count = " + std::to_string(nObjId));
+ }
+ }
+ else if (aItem3.first == "UnoCommand")
+ {
+ std::string aText = aItem3.second.get_value<std::string>();
+ if (aText.size() > 0)
+ {
+ OUString aCmd;
+ std::vector<beans::PropertyValue> aArg;
+ std::size_t nSpace = aText.find(' ');
+ if (nSpace != std::string::npos)
+ {
+ aCmd = OStringToOUString(aText.substr(0, nSpace),
+ RTL_TEXTENCODING_UTF8);
+ std::string aArgText = aText.substr(nSpace + 1);
+
+ aArg = comphelper::JsonToPropertyValues(aArgText);
+ }
+ else
+ {
+ aCmd = OStringToOUString(aText, RTL_TEXTENCODING_UTF8);
+ }
+
+ // Check if the uno command is allowed
+ const std::map<std::u16string_view, KitUnoCommand>& rUnoCommandList = GetKitUnoCommandList();
+ const bool bSupportedCmd = rUnoCommandList.find(aCmd) != rUnoCommandList.end();
+ if (bSupportedCmd)
+ {
+ // Make the uno command synchron
+ aArg.push_back(comphelper::makePropertyValue(
+ "SynchronMode", true));
+
+ // Todo: check why it does not work on my windows system
+ comphelper::dispatchCommand(
+ aCmd, comphelper::containerToSequence(aArg));
+ }
+ else
+ {
+ lcl_LogWarning(
+ "FillApi SlideCmd: uno command not recognized'"
+ + aText + "'");
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ rReq.Done();
+ }
+ break;
+
case SID_INSERTPAGE:
case SID_INSERTPAGE_QUICK:
{
diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx
index 984bd83c96c7..976cd48ce152 100644
--- a/sfx2/source/control/unoctitm.cxx
+++ b/sfx2/source/control/unoctitm.cxx
@@ -64,6 +64,7 @@
#include <slotserv.hxx>
#include <rtl/ustring.hxx>
#include <sfx2/lokhelper.hxx>
+#include <sfx2/lokunocmdlist.hxx>
#include <memory>
#include <string_view>
@@ -1148,275 +1149,319 @@ OString TableSizePayload(sal_uInt16, SfxViewFrame*, const css::frame::FeatureSta
return aBuffer.makeStringAndClear();
}
-constexpr auto handlers = frozen::make_unordered_map<std::u16string_view, PayloadGetter_t>({
- { u"Bold", IsActivePayload },
- { u"CenterPara", IsActivePayload },
- { u"CharBackgroundExt", IsActivePayload },
- { u"ControlCodes", IsActivePayload },
- { u"DefaultBullet", IsActivePayload },
- { u"DefaultNumbering", IsActivePayload },
- { u"Italic", IsActivePayload },
- { u"JustifyPara", IsActivePayload },
- { u"LeftPara", IsActivePayload },
- { u"OutlineFont", IsActivePayload },
- { u"RightPara", IsActivePayload },
- { u"Shadowed", IsActivePayload },
- { u"SpellOnline", IsActivePayload },
- { u"OnlineAutoFormat", IsActivePayload },
- { u"SubScript", IsActivePayload },
- { u"SuperScript", IsActivePayload },
- { u"Strikeout", IsActivePayload },
- { u"Underline", IsActivePayload },
- { u"ModifiedStatus", IsActivePayload },
- { u"TrackChanges", IsActivePayload },
- { u"ShowTrackedChanges", IsActivePayload },
- { u"AlignLeft", IsActivePayload },
- { u"AlignHorizontalCenter", IsActivePayload },
- { u"AlignRight", IsActivePayload },
- { u"DocumentRepair", IsActivePayload },
- { u"ObjectAlignLeft", IsActivePayload },
- { u"ObjectAlignRight", IsActivePayload },
- { u"AlignCenter", IsActivePayload },
- { u"AlignUp", IsActivePayload },
- { u"AlignMiddle", IsActivePayload },
- { u"AlignDown", IsActivePayload },
- { u"TraceChangeMode", IsActivePayload },
- { u"FormatPaintbrush", IsActivePayload },
- { u"FreezePanes", IsActivePayload },
- { u"Sidebar", IsActivePayload },
- { u"SpacePara1", IsActivePayload },
- { u"SpacePara15", IsActivePayload },
- { u"SpacePara2", IsActivePayload },
- { u"DataFilterAutoFilter", IsActivePayload },
- { u"CellProtection", IsActivePayload },
- { u"NormalMultiPaneGUI", IsActivePayload },
- { u"NotesMode", IsActivePayload },
- { u"SlideMasterPage", IsActivePayload },
-
- { u"CharFontName", FontNamePayload },
-
- { u"FontHeight", FontHeightPayload },
-
- { u"StyleApply", StyleApplyPayload },
-
- { u"BackColor", ColorPayload },
- { u"BackgroundColor", ColorPayload },
- { u"TableCellBackgroundColor", ColorPayload },
- { u"CharBackColor", ColorPayload },
- { u"Color", ColorPayload },
- { u"FontColor", ColorPayload },
- { u"FrameLineColor", ColorPayload },
- { u"GlowColor", ColorPayload },
-
- { u"Undo", UndoRedoPayload },
- { u"Redo", UndoRedoPayload },
-
- { u"Cut", EnabledPayload },
- { u"Copy", EnabledPayload },
- { u"Paste", EnabledPayload },
- { u"SelectAll", EnabledPayload },
- { u"InsertAnnotation", EnabledPayload },
- { u"DeleteAnnotation", EnabledPayload },
- { u"ResolveAnnotation", EnabledPayload },
- { u"ResolveAnnotationThread", EnabledPayload },
- { u"PromoteComment", EnabledPayload },
- { u"InsertRowsBefore", EnabledPayload },
- { u"InsertRowsAfter", EnabledPayload },
- { u"InsertColumnsBefore", EnabledPayload },
- { u"InsertColumnsAfter", EnabledPayload },
- { u"NameGroup", EnabledPayload },
- { u"ObjectTitleDescription", EnabledPayload },
- { u"MergeCells", EnabledPayload },
- { u"InsertObjectChart", EnabledPayload },
- { u"InsertSection", EnabledPayload },
- { u"InsertPagebreak", EnabledPayload },
- { u"InsertColumnBreak", EnabledPayload },
- { u"HyperlinkDialog", EnabledPayload },
- { u"InsertSymbol", EnabledPayload },
- { u"InsertPage", EnabledPayload },
- { u"DeletePage", EnabledPayload },
- { u"DuplicatePage", EnabledPayload },
- { u"DeleteRows", EnabledPayload },
- { u"DeleteColumns", EnabledPayload },
- { u"DeleteTable", EnabledPayload },
- { u"SelectTable", EnabledPayload },
- { u"EntireRow", EnabledPayload },
- { u"EntireColumn", EnabledPayload },
- { u"EntireCell", EnabledPayload },
- { u"SortAscending", EnabledPayload },
- { u"SortDescending", EnabledPayload },
- { u"AcceptAllTrackedChanges", EnabledPayload },
- { u"RejectAllTrackedChanges", EnabledPayload },
- { u"AcceptTrackedChange", EnabledPayload },
- { u"RejectTrackedChange", EnabledPayload },
- { u"AcceptTrackedChangeToNext", EnabledPayload },
- { u"RejectTrackedChangeToNext", EnabledPayload },
- { u"NextTrackedChange", EnabledPayload },
- { u"PreviousTrackedChange", EnabledPayload },
- { u"FormatGroup", EnabledPayload },
- { u"ObjectBackOne", EnabledPayload },
- { u"SendToBack", EnabledPayload },
- { u"ObjectForwardOne", EnabledPayload },
- { u"BringToFront", EnabledPayload },
- { u"WrapRight", EnabledPayload },
- { u"WrapThrough", EnabledPayload },
- { u"WrapLeft", EnabledPayload },
- { u"WrapIdeal", EnabledPayload },
- { u"WrapOn", EnabledPayload },
- { u"WrapOff", EnabledPayload },
- { u"UpdateCurIndex", EnabledPayload },
- { u"InsertCaptionDialog", EnabledPayload },
- { u"SplitTable", EnabledPayload },
- { u"SplitCell", EnabledPayload },
- { u"DeleteNote", EnabledPayload },
- { u"AcceptChanges", EnabledPayload },
- { u"SetDefault", EnabledPayload },
- { u"ParaspaceIncrease", EnabledPayload },
- { u"ParaspaceDecrease", EnabledPayload },
- { u"TableDialog", EnabledPayload },
- { u"FormatCellDialog", EnabledPayload },
- { u"FontDialog", EnabledPayload },
- { u"ParagraphDialog", EnabledPayload },
- { u"OutlineBullet", EnabledPayload },
- { u"InsertIndexesEntry", EnabledPayload },
- { u"TransformDialog", EnabledPayload },
- { u"EditRegion", EnabledPayload },
- { u"ThesaurusDialog", EnabledPayload },
- { u"OutlineRight", EnabledPayload },
- { u"OutlineLeft", EnabledPayload },
- { u"OutlineDown", EnabledPayload },
- { u"OutlineUp", EnabledPayload },
- { u"FormatArea", EnabledPayload },
- { u"FormatLine", EnabledPayload },
- { u"FormatColumns", EnabledPayload },
- { u"Watermark", EnabledPayload },
- { u"InsertBreak", EnabledPayload },
- { u"InsertEndnote", EnabledPayload },
- { u"InsertFootnote", EnabledPayload },
- { u"InsertReferenceField", EnabledPayload },
- { u"InsertBookmark", EnabledPayload },
- { u"InsertAuthoritiesEntry", EnabledPayload },
- { u"InsertMultiIndex", EnabledPayload },
- { u"InsertField", EnabledPayload },
- { u"PageNumberWizard", EnabledPayload },
- { u"InsertPageNumberField", EnabledPayload },
- { u"InsertPageCountField", EnabledPayload },
- { u"InsertDateField", EnabledPayload },
- { u"InsertTitleField", EnabledPayload },
- { u"InsertFieldCtrl", EnabledPayload },
- { u"CharmapControl", EnabledPayload },
- { u"EnterGroup", EnabledPayload },
- { u"LeaveGroup", EnabledPayload },
- { u"Combine", EnabledPayload },
- { u"Merge", EnabledPayload },
- { u"Dismantle", EnabledPayload },
- { u"Substract", EnabledPayload },
- { u"DistributeSelection", EnabledPayload },
- { u"Intersect", EnabledPayload },
- { u"ResetAttributes", EnabledPayload },
- { u"IncrementIndent", EnabledPayload },
- { u"DecrementIndent", EnabledPayload },
- { u"EditHeaderAndFooter", EnabledPayload },
- { u"InsertSparkline", EnabledPayload },
- { u"DeleteSparkline", EnabledPayload },
- { u"DeleteSparklineGroup", EnabledPayload },
- { u"EditSparklineGroup", EnabledPayload },
- { u"EditSparkline", EnabledPayload },
- { u"GroupSparklines", EnabledPayload },
- { u"UngroupSparklines", EnabledPayload },
- { u"FormatSparklineMenu", EnabledPayload },
- { u"DataDataPilotRun", EnabledPayload },
- { u"RecalcPivotTable", EnabledPayload },
- { u"DeletePivotTable", EnabledPayload },
- { u"NumberFormatDecDecimals", EnabledPayload },
- { u"NumberFormatIncDecimals", EnabledPayload },
- { u"Protect", EnabledPayload },
- { u"UnsetCellsReadOnly", EnabledPayload },
- { u"ContentControlProperties", EnabledPayload },
- { u"DeleteContentControl", EnabledPayload },
- { u"InsertCheckboxContentControl", EnabledPayload },
- { u"InsertContentControl", EnabledPayload },
- { u"InsertDateContentControl", EnabledPayload },
- { u"InsertDropdownContentControl", EnabledPayload },
- { u"InsertPlainTextContentControl", EnabledPayload },
- { u"InsertPictureContentControl", EnabledPayload },
- { u"ChangeBezier", EnabledPayload },
- { u"DistributeHorzCenter", EnabledPayload },
- { u"DistributeHorzDistance", EnabledPayload },
- { u"DistributeHorzLeft", EnabledPayload },
- { u"DistributeHorzRight", EnabledPayload },
- { u"DistributeVertBottom", EnabledPayload },
- { u"DistributeVertCenter", EnabledPayload },
- { u"DistributeVertDistance", EnabledPayload },
- { u"DistributeVertTop", EnabledPayload },
- { u"AnimationEffects", EnabledPayload },
- { u"ExecuteAnimationEffect", EnabledPayload },
-
- { u"ParaLeftToRight", ParaDirectionPayload },
- { u"ParaRightToLeft", ParaDirectionPayload },
-
- { u"AssignLayout", Int32Payload },
- { u"StatusSelectionMode", Int32Payload },
- { u"Signature", Int32Payload },
- { u"SelectionMode", Int32Payload },
- { u"StatusBarFunc", Int32Payload },
-
- { u"TransformPosX", TransformPayload },
- { u"TransformPosY", TransformPayload },
- { u"TransformWidth", TransformPayload },
- { u"TransformHeight", TransformPayload },
-
- { u"StatusDocPos", StringPayload },
- { u"StatusPageStyle", StringPayload },
- { u"StateWordCount", StringPayload },
- { u"PageStyleName", StringPayload },
- { u"PageStatus", StringPayload },
- { u"LayoutStatus", StringPayload },
- { u"Scale", StringPayload },
- { u"Context", StringPayload },
-
- { u"RowColSelCount", RowColSelCountPayload },
-
- { u"StateTableCell", StateTableCellPayload },
-
- { u"InsertMode", BooleanPayload },
- { u"WrapText", BooleanPayload },
- { u"NumberFormatCurrency", BooleanPayload },
- { u"NumberFormatPercent", BooleanPayload },
- { u"NumberFormatDecimal", BooleanPayload },
- { u"NumberFormatDate", BooleanPayload },
- { u"ShowResolvedAnnotations", BooleanPayload },
-
- { u"ToggleMergeCells", BooleanOrDisabledPayload },
- { u"SheetRightToLeft", BooleanOrDisabledPayload },
- { u"ToggleSheetGrid", BooleanOrDisabledPayload },
- { u"EditDoc", BooleanOrDisabledPayload },
-
- { u"Position", PointPayload },
- { u"FreezePanesColumn", PointPayload },
- { u"FreezePanesRow", PointPayload },
-
- { u"Size", SizePayload },
-
- { u"LanguageStatus", StringOrStrSeqPayload },
- { u"StatePageNumber", StringOrStrSeqPayload },
-
- { u"InsertPageHeader", StrSeqPayload },
- { u"InsertPageFooter", StrSeqPayload },
-
- { u"TableColumWidth", TableSizePayload },
- { u"TableRowHeight", TableSizePayload },
+constexpr auto enumToPayload = frozen::make_unordered_map<PayloadType, PayloadGetter_t>({
+ { PayloadType::None, nullptr },
+ { PayloadType::IsActivePayload, IsActivePayload },
+ { PayloadType::FontNamePayload, FontNamePayload },
+ { PayloadType::FontHeightPayload, FontHeightPayload },
+ { PayloadType::StyleApplyPayload, StyleApplyPayload },
+ { PayloadType::ColorPayload, ColorPayload },
+ { PayloadType::UndoRedoPayload, UndoRedoPayload },
+ { PayloadType::EnabledPayload, EnabledPayload },
+ { PayloadType::ParaDirectionPayload, ParaDirectionPayload },
+ { PayloadType::Int32Payload, Int32Payload },
+ { PayloadType::TransformPayload, TransformPayload },
+ { PayloadType::StringPayload, StringPayload },
+ { PayloadType::RowColSelCountPayload, RowColSelCountPayload },
+ { PayloadType::StateTableCellPayload, StateTableCellPayload },
+ { PayloadType::BooleanPayload, BooleanPayload },
+ { PayloadType::BooleanOrDisabledPayload, BooleanOrDisabledPayload },
+ { PayloadType::PointPayload, PointPayload },
+ { PayloadType::SizePayload, SizePayload },
+ { PayloadType::StringOrStrSeqPayload, StringOrStrSeqPayload },
+ { PayloadType::StrSeqPayload, StrSeqPayload },
+ { PayloadType::TableSizePayload, TableSizePayload },
});
}
+const std::map<std::u16string_view, KitUnoCommand>& GetKitUnoCommandList()
+{
+ static std::map<std::u16string_view, KitUnoCommand> aUnoCommandList = {
+ { u"Bold", { PayloadType::IsActivePayload, true } },
+ { u"CenterPara", { PayloadType::IsActivePayload, true } },
+
+ { u"CharBackgroundExt", { PayloadType::IsActivePayload, true } },
+ { u"ControlCodes", { PayloadType::IsActivePayload, true } },
+ { u"DefaultBullet", { PayloadType::IsActivePayload, true } },
+ { u"DefaultNumbering", { PayloadType::IsActivePayload, true } },
+ { u"Italic", { PayloadType::IsActivePayload, true } },
+ { u"JustifyPara", { PayloadType::IsActivePayload, true } },
+ { u"LeftPara", { PayloadType::IsActivePayload, true } },
+ { u"OutlineFont", { PayloadType::IsActivePayload, true } },
+ { u"RightPara", { PayloadType::IsActivePayload, true } },
+ { u"Shadowed", { PayloadType::IsActivePayload, true } },
+ { u"SpellOnline", { PayloadType::IsActivePayload, true } },
+ { u"OnlineAutoFormat", { PayloadType::IsActivePayload, true } },
+ { u"SubScript", { PayloadType::IsActivePayload, true } },
+ { u"SuperScript", { PayloadType::IsActivePayload, true } },
+ { u"Strikeout", { PayloadType::IsActivePayload, true } },
+ { u"Underline", { PayloadType::IsActivePayload, true } },
+ { u"ModifiedStatus", { PayloadType::IsActivePayload, true } },
+ { u"TrackChanges", { PayloadType::IsActivePayload, true } },
+ { u"ShowTrackedChanges", { PayloadType::IsActivePayload, true } },
+ { u"AlignLeft", { PayloadType::IsActivePayload, true } },
+ { u"AlignHorizontalCenter", { PayloadType::IsActivePayload, true } },
+ { u"AlignRight", { PayloadType::IsActivePayload, true } },
+ { u"DocumentRepair", { PayloadType::IsActivePayload, true } },
+ { u"ObjectAlignLeft", { PayloadType::IsActivePayload, true } },
+ { u"ObjectAlignRight", { PayloadType::IsActivePayload, true } },
+ { u"AlignCenter", { PayloadType::IsActivePayload, true } },
+ { u"AlignUp", { PayloadType::IsActivePayload, true } },
+ { u"AlignMiddle", { PayloadType::IsActivePayload, true } },
+ { u"AlignDown", { PayloadType::IsActivePayload, true } },
+ { u"TraceChangeMode", { PayloadType::IsActivePayload, true } },
+ { u"FormatPaintbrush", { PayloadType::IsActivePayload, true } },
+ { u"FreezePanes", { PayloadType::IsActivePayload, true } },
+ { u"Sidebar", { PayloadType::IsActivePayload, true } },
+ { u"SpacePara1", { PayloadType::IsActivePayload, true } },
+ { u"SpacePara15", { PayloadType::IsActivePayload, true } },
+ { u"SpacePara2", { PayloadType::IsActivePayload, true } },
+ { u"DataFilterAutoFilter", { PayloadType::IsActivePayload, true } },
+ { u"CellProtection", { PayloadType::IsActivePayload, true } },
+ { u"NormalMultiPaneGUI", { PayloadType::IsActivePayload, false } },
+ { u"NotesMode", { PayloadType::IsActivePayload, false } },
+ { u"SlideMasterPage", { PayloadType::IsActivePayload, false } },
+
+ { u"CharFontName", { PayloadType::FontNamePayload, true } },
+
+ { u"FontHeight", { PayloadType::FontHeightPayload, true } },
+
+ { u"StyleApply", { PayloadType::StyleApplyPayload, true } },
+
+ { u"BackColor", { PayloadType::ColorPayload, false } },
+ { u"BackgroundColor", { PayloadType::ColorPayload, true } },
+ { u"TableCellBackgroundColor", { PayloadType::ColorPayload, true } },
+ { u"CharBackColor", { PayloadType::ColorPayload, true } },
+ { u"Color", { PayloadType::ColorPayload, true } },
+ { u"FontColor", { PayloadType::ColorPayload, true } },
+ { u"FrameLineColor", { PayloadType::ColorPayload, true } },
+ { u"GlowColor", { PayloadType::ColorPayload, false } },
+
+ { u"Undo", { PayloadType::UndoRedoPayload, true } },
+ { u"Redo", { PayloadType::UndoRedoPayload, true } },
+
+ { u"Cut", { PayloadType::EnabledPayload, true } },
+ { u"Copy", { PayloadType::EnabledPayload, true } },
+ { u"Paste", { PayloadType::EnabledPayload, true } },
+ { u"SelectAll", { PayloadType::EnabledPayload, true } },
+ { u"InsertAnnotation", { PayloadType::EnabledPayload, true } },
+ { u"DeleteAnnotation", { PayloadType::EnabledPayload, true } },
+ { u"ResolveAnnotation", { PayloadType::EnabledPayload, false } },
+ { u"ResolveAnnotationThread", { PayloadType::EnabledPayload, false } },
+ { u"PromoteComment", { PayloadType::EnabledPayload, true } },
+ { u"InsertRowsBefore", { PayloadType::EnabledPayload, true } },
+ { u"InsertRowsAfter", { PayloadType::EnabledPayload, true } },
+ { u"InsertColumnsBefore", { PayloadType::EnabledPayload, true } },
+ { u"InsertColumnsAfter", { PayloadType::EnabledPayload, true } },
+ { u"NameGroup", { PayloadType::EnabledPayload, true } },
+ { u"ObjectTitleDescription", { PayloadType::EnabledPayload, true } },
+ { u"MergeCells", { PayloadType::EnabledPayload, true } },
+ { u"InsertObjectChart", { PayloadType::EnabledPayload, true } },
+ { u"InsertSection", { PayloadType::EnabledPayload, true } },
+ { u"InsertPagebreak", { PayloadType::EnabledPayload, true } },
+ { u"InsertColumnBreak", { PayloadType::EnabledPayload, true } },
+ { u"HyperlinkDialog", { PayloadType::EnabledPayload, true } },
+ { u"InsertSymbol", { PayloadType::EnabledPayload, true } },
+ { u"InsertPage", { PayloadType::EnabledPayload, true } },
+ { u"DeletePage", { PayloadType::EnabledPayload, true } },
+ { u"DuplicatePage", { PayloadType::EnabledPayload, true } },
+ { u"DeleteRows", { PayloadType::EnabledPayload, true } },
+ { u"DeleteColumns", { PayloadType::EnabledPayload, true } },
+ { u"DeleteTable", { PayloadType::EnabledPayload, true } },
+ { u"SelectTable", { PayloadType::EnabledPayload, true } },
+ { u"EntireRow", { PayloadType::EnabledPayload, true } },
+ { u"EntireColumn", { PayloadType::EnabledPayload, true } },
+ { u"EntireCell", { PayloadType::EnabledPayload, true } },
+ { u"SortAscending", { PayloadType::EnabledPayload, true } },
+ { u"SortDescending", { PayloadType::EnabledPayload, true } },
+ { u"AcceptAllTrackedChanges", { PayloadType::EnabledPayload, true } },
+ { u"RejectAllTrackedChanges", { PayloadType::EnabledPayload, true } },
+ { u"AcceptTrackedChange", { PayloadType::EnabledPayload, true } },
+ { u"RejectTrackedChange", { PayloadType::EnabledPayload, true } },
+ { u"AcceptTrackedChangeToNext", { PayloadType::EnabledPayload, true } },
+ { u"RejectTrackedChangeToNext", { PayloadType::EnabledPayload, true } },
+ { u"NextTrackedChange", { PayloadType::EnabledPayload, true } },
+ { u"PreviousTrackedChange", { PayloadType::EnabledPayload, true } },
+ { u"FormatGroup", { PayloadType::EnabledPayload, true } },
+ { u"ObjectBackOne", { PayloadType::EnabledPayload, true } },
+ { u"SendToBack", { PayloadType::EnabledPayload, true } },
+ { u"ObjectForwardOne", { PayloadType::EnabledPayload, true } },
+ { u"BringToFront", { PayloadType::EnabledPayload, true } },
+ { u"WrapRight", { PayloadType::EnabledPayload, true } },
+ { u"WrapThrough", { PayloadType::EnabledPayload, true } },
+ { u"WrapLeft", { PayloadType::EnabledPayload, true } },
+ { u"WrapIdeal", { PayloadType::EnabledPayload, true } },
+ { u"WrapOn", { PayloadType::EnabledPayload, true } },
+ { u"WrapOff", { PayloadType::EnabledPayload, true } },
+ { u"UpdateCurIndex", { PayloadType::EnabledPayload, true } },
+ { u"InsertCaptionDialog", { PayloadType::EnabledPayload, true } },
+ { u"SplitTable", { PayloadType::EnabledPayload, true } },
+ { u"SplitCell", { PayloadType::EnabledPayload, true } },
+ { u"DeleteNote", { PayloadType::EnabledPayload, true } },
+ { u"AcceptChanges", { PayloadType::EnabledPayload, true } },
+ { u"SetDefault", { PayloadType::EnabledPayload, true } },
+ { u"ParaspaceIncrease", { PayloadType::EnabledPayload, true } },
+ { u"ParaspaceDecrease", { PayloadType::EnabledPayload, true } },
+ { u"TableDialog", { PayloadType::EnabledPayload, true } },
+ { u"FormatCellDialog", { PayloadType::EnabledPayload, true } },
+ { u"FontDialog", { PayloadType::EnabledPayload, true } },
+ { u"ParagraphDialog", { PayloadType::EnabledPayload, true } },
+ { u"OutlineBullet", { PayloadType::EnabledPayload, true } },
+ { u"InsertIndexesEntry", { PayloadType::EnabledPayload, true } },
+ { u"TransformDialog", { PayloadType::EnabledPayload, true } },
+ { u"EditRegion", { PayloadType::EnabledPayload, true } },
+ { u"ThesaurusDialog", { PayloadType::EnabledPayload, true } },
+ { u"OutlineRight", { PayloadType::EnabledPayload, false } },
+ { u"OutlineLeft", { PayloadType::EnabledPayload, false } },
+ { u"OutlineDown", { PayloadType::EnabledPayload, false } },
+ { u"OutlineUp", { PayloadType::EnabledPayload, false } },
+ { u"FormatArea", { PayloadType::EnabledPayload, true } },
+ { u"FormatLine", { PayloadType::EnabledPayload, true } },
+ { u"FormatColumns", { PayloadType::EnabledPayload, true } },
+ { u"Watermark", { PayloadType::EnabledPayload, true } },
+ { u"InsertBreak", { PayloadType::EnabledPayload, true } },
+ { u"InsertEndnote", { PayloadType::EnabledPayload, true } },
+ { u"InsertFootnote", { PayloadType::EnabledPayload, true } },
+ { u"InsertReferenceField", { PayloadType::EnabledPayload, true } },
+ { u"InsertBookmark", { PayloadType::EnabledPayload, true } },
+ { u"InsertAuthoritiesEntry", { PayloadType::EnabledPayload, true } },
+ { u"InsertMultiIndex", { PayloadType::EnabledPayload, true } },
+ { u"InsertField", { PayloadType::EnabledPayload, true } },
+ { u"PageNumberWizard", { PayloadType::EnabledPayload, true } },
+ { u"InsertPageNumberField", { PayloadType::EnabledPayload, true } },
+ { u"InsertPageCountField", { PayloadType::EnabledPayload, true } },
+ { u"InsertDateField", { PayloadType::EnabledPayload, true } },
+ { u"InsertTitleField", { PayloadType::EnabledPayload, true } },
+ { u"InsertFieldCtrl", { PayloadType::EnabledPayload, true } },
+ { u"CharmapControl", { PayloadType::EnabledPayload, true } },
+ { u"EnterGroup", { PayloadType::EnabledPayload, true } },
+ { u"LeaveGroup", { PayloadType::EnabledPayload, true } },
+ { u"Combine", { PayloadType::EnabledPayload, true } },
+ { u"Merge", { PayloadType::EnabledPayload, true } },
+ { u"Dismantle", { PayloadType::EnabledPayload, true } },
+ { u"Substract", { PayloadType::EnabledPayload, true } },
+ { u"DistributeSelection", { PayloadType::EnabledPayload, true } },
+ { u"Intersect", { PayloadType::EnabledPayload, true } },
+ { u"ResetAttributes", { PayloadType::EnabledPayload, true } },
+ { u"IncrementIndent", { PayloadType::EnabledPayload, true } },
+ { u"DecrementIndent", { PayloadType::EnabledPayload, true } },
+ { u"EditHeaderAndFooter", { PayloadType::EnabledPayload, true } },
+ { u"InsertSparkline", { PayloadType::EnabledPayload, true } },
+ { u"DeleteSparkline", { PayloadType::EnabledPayload, true } },
+ { u"DeleteSparklineGroup", { PayloadType::EnabledPayload, true } },
+ { u"EditSparklineGroup", { PayloadType::EnabledPayload, true } },
+ { u"EditSparkline", { PayloadType::EnabledPayload, true } },
+ { u"GroupSparklines", { PayloadType::EnabledPayload, true } },
+ { u"UngroupSparklines", { PayloadType::EnabledPayload, true } },
+ { u"FormatSparklineMenu", { PayloadType::EnabledPayload, true } },
+ { u"DataDataPilotRun", { PayloadType::EnabledPayload, true } },
+ { u"RecalcPivotTable", { PayloadType::EnabledPayload, true } },
+ { u"DeletePivotTable", { PayloadType::EnabledPayload, true } },
+ { u"NumberFormatDecDecimals", { PayloadType::EnabledPayload, true } },
+ { u"NumberFormatIncDecimals", { PayloadType::EnabledPayload, true } },
+ { u"Protect", { PayloadType::EnabledPayload, true } },
+ { u"UnsetCellsReadOnly", { PayloadType::EnabledPayload, true } },
+ { u"ContentControlProperties", { PayloadType::EnabledPayload, true } },
+ { u"DeleteContentControl", { PayloadType::EnabledPayload, true } },
+ { u"InsertCheckboxContentControl", { PayloadType::EnabledPayload, true } },
+ { u"InsertContentControl", { PayloadType::EnabledPayload, true } },
+ { u"InsertDateContentControl", { PayloadType::EnabledPayload, true } },
+ { u"InsertDropdownContentControl", { PayloadType::EnabledPayload, true } },
+ { u"InsertPlainTextContentControl", { PayloadType::EnabledPayload, true } },
+ { u"InsertPictureContentControl", { PayloadType::EnabledPayload, true } },
+ { u"ChangeBezier", { PayloadType::EnabledPayload, true } },
+ { u"DistributeHorzCenter", { PayloadType::EnabledPayload, true } },
+ { u"DistributeHorzDistance", { PayloadType::EnabledPayload, true } },
+ { u"DistributeHorzLeft", { PayloadType::EnabledPayload, true } },
+ { u"DistributeHorzRight", { PayloadType::EnabledPayload, true } },
+ { u"DistributeVertBottom", { PayloadType::EnabledPayload, true } },
+ { u"DistributeVertCenter", { PayloadType::EnabledPayload, true } },
+ { u"DistributeVertDistance", { PayloadType::EnabledPayload, true } },
+ { u"DistributeVertTop", { PayloadType::EnabledPayload, true } },
+ { u"AnimationEffects", { PayloadType::EnabledPayload, true } },
+ { u"ExecuteAnimationEffect", { PayloadType::EnabledPayload, true } },
+
+ { u"ParaLeftToRight", { PayloadType::ParaDirectionPayload, true } },
+ { u"ParaRightToLeft", { PayloadType::ParaDirectionPayload, true } },
+
+ { u"AssignLayout", { PayloadType::Int32Payload, true } },
+ { u"StatusSelectionMode", { PayloadType::Int32Payload, true } },
+ { u"Signature", { PayloadType::Int32Payload, false } },
+ { u"SelectionMode", { PayloadType::Int32Payload, true } },
+ { u"StatusBarFunc", { PayloadType::Int32Payload, true } },
+
+ { u"TransformPosX", { PayloadType::TransformPayload, true } },
+ { u"TransformPosY", { PayloadType::TransformPayload, true } },
+ { u"TransformWidth", { PayloadType::TransformPayload, true } },
+ { u"TransformHeight", { PayloadType::TransformPayload, true } },
+
+ { u"StatusDocPos", { PayloadType::StringPayload, true } },
+ { u"StatusPageStyle", { PayloadType::StringPayload, true } },
+ { u"StateWordCount", { PayloadType::StringPayload, true } },
+ { u"PageStyleName", { PayloadType::StringPayload, false } },
+ { u"PageStatus", { PayloadType::StringPayload, true } },
+ { u"LayoutStatus", { PayloadType::StringPayload, true } },
+ { u"Scale", { PayloadType::StringPayload, true } },
+ { u"Context", { PayloadType::StringPayload, true } },
+
+ { u"RowColSelCount", { PayloadType::RowColSelCountPayload, true } },
+
+ { u"StateTableCell", { PayloadType::StateTableCellPayload, true } },
+
+ { u"InsertMode", { PayloadType::BooleanPayload, true } },
+ { u"WrapText", { PayloadType::BooleanPayload, true } },
+ { u"NumberFormatCurrency", { PayloadType::BooleanPayload, true } },
+ { u"NumberFormatPercent", { PayloadType::BooleanPayload, true } },
+ { u"NumberFormatDecimal", { PayloadType::BooleanPayload, true } },
+ { u"NumberFormatDate", { PayloadType::BooleanPayload, true } },
+ { u"ShowResolvedAnnotations", { PayloadType::BooleanPayload, true } },
+
+ { u"ToggleMergeCells", { PayloadType::BooleanOrDisabledPayload, true } },
+ { u"SheetRightToLeft", { PayloadType::BooleanOrDisabledPayload, true } },
+ { u"ToggleSheetGrid", { PayloadType::BooleanOrDisabledPayload, true } },
+ { u"EditDoc", { PayloadType::BooleanOrDisabledPayload, true } },
+
+ { u"Position", { PayloadType::PointPayload, false } },
+ { u"FreezePanesColumn", { PayloadType::PointPayload, true } },
+ { u"FreezePanesRow", { PayloadType::PointPayload, true } },
+
+ { u"Size", { PayloadType::SizePayload, false } },
+
+ { u"LanguageStatus", { PayloadType::StringOrStrSeqPayload, true } },
+ { u"StatePageNumber", { PayloadType::StringOrStrSeqPayload, true } },
+
+ { u"InsertPageHeader", { PayloadType::StrSeqPayload, true } },
+ { u"InsertPageFooter", { PayloadType::StrSeqPayload, true } },
+
+ { u"TableColumWidth", { PayloadType::TableSizePayload, false } },
+ { u"TableRowHeight", { PayloadType::TableSizePayload, false } },
+
+ { u"BorderInner", { PayloadType::None, true } },
+ { u"BorderOuter", { PayloadType::None, true } },
+ { u"ChangeTheme", { PayloadType::None, true } },
+ { u"DeleteSlide", { PayloadType::None, true } },
+ { u"DuplicateSlide", { PayloadType::None, true } },
+ { u"InsertSlide", { PayloadType::None, true } },
+ { u"JumpToMark", { PayloadType::None, true } },
+ { u"MoveKeepInsertMode", { PayloadType::None, true } },
+ { u"Orientation", { PayloadType::None, true } },
+ { u"ReplyComment", { PayloadType::None, true } },
+ { u"ResolveComment", { PayloadType::None, true } },
+ { u"ResolveCommentThread", { PayloadType::None, true } },
+ { u"RunMacro", { PayloadType::None, true } },
+ };
+ return aUnoCommandList;
+}
+
static void InterceptLOKStateChangeEvent(sal_uInt16 nSID, SfxViewFrame* pViewFrame, const css::frame::FeatureStateEvent& aEvent, const SfxPoolItem* pState)
{
const SfxViewShell* pViewShell = pViewFrame->GetViewShell();
if (!comphelper::LibreOfficeKit::isActive() || !pViewShell)
return;
- auto handler = handlers.find(aEvent.FeatureURL.Path);
- if (handler == handlers.end())
+ const std::map<std::u16string_view, KitUnoCommand>& rUnoCommandList = GetKitUnoCommandList();
+ auto handler = rUnoCommandList.find(aEvent.FeatureURL.Path);
+ if (handler == rUnoCommandList.end())
{
// Try to send JSON state version
SfxLokHelper::sendUnoStatus(pViewShell, pState);
@@ -1424,8 +1469,11 @@ static void InterceptLOKStateChangeEvent(sal_uInt16 nSID, SfxViewFrame* pViewFra
return;
}
- pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED,
- handler->second(nSID, pViewFrame, aEvent, pState));
+ auto payloadIter = enumToPayload.find(handler->second.payloadType);
+ PayloadGetter_t pFunct = payloadIter != enumToPayload.end() ? payloadIter->second : nullptr;
+ if (pFunct != nullptr)
+ pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED,
+ pFunct(nSID, pViewFrame, aEvent, pState));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */