Ely Office: six offline-first desktop apps in Rust and GPUI
ElyDoc, ElyTable, ElyShow (LibreOfficeKit), ElyPDF (MuPDF), ElyTree (Git), ElyMark (Milkdown and CodeMirror in CEF). ElyMail and ElyAgent follow.
This commit is contained in:
817 files changed
+143101
No files matched your search
@@ -0,0 +1,62 @@
|
||||
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
|
||||
index a1bebedb4..27584ba49 100644
|
||||
--- a/desktop/source/lib/init.cxx
|
||||
+++ b/desktop/source/lib/init.cxx
|
||||
@@ -181,7 +181,7 @@
|
||||
#include <vcl/ImageTree.hxx>
|
||||
#include <vcl/ITiledRenderable.hxx>
|
||||
#include <vcl/dialoghelper.hxx>
|
||||
-#ifdef _WIN32
|
||||
+#if defined(_WIN32) || defined(MACOSX)
|
||||
#include <vcl/BitmapTools.hxx>
|
||||
#endif
|
||||
#include <unicode/uchar.h>
|
||||
@@ -2603,10 +2603,15 @@ void CallbackFlushHandler::stop()
|
||||
stop();
|
||||
}
|
||||
|
||||
void CallbackFlushHandler::scheduleFlush()
|
||||
{
|
||||
+#if defined(MACOSX)
|
||||
+ // Aqua never runs posted user events: flush inline.
|
||||
+ invoke();
|
||||
+#else
|
||||
if (!m_pFlushEvent)
|
||||
m_pFlushEvent = Application::PostUserEvent(LINK(this, CallbackFlushHandler, FlushQueue));
|
||||
+#endif
|
||||
}
|
||||
|
||||
IMPL_LINK_NOARG(CallbackFlushHandler, FlushQueue, void*, void)
|
||||
@@ -4274,7 +4274,7 @@ static void doc_paintTile(LibreOfficeKitDocument* pThis,
|
||||
return;
|
||||
}
|
||||
|
||||
-#if defined(UNX) && !defined(MACOSX) || defined(_WIN32)
|
||||
+#if defined(UNX) || defined(_WIN32)
|
||||
|
||||
// Painting of zoomed or HiDPI spreadsheets is special, we actually draw everything at 100%,
|
||||
// and only set cairo's (or CoreGraphic's, in the iOS case) scale factor accordingly, so that
|
||||
@@ -4317,9 +4317,14 @@ static void doc_paintTile(LibreOfficeKitDocument* pThis,
|
||||
// Set background to transparent by default.
|
||||
pDevice->SetBackground(Wallpaper(COL_TRANSPARENT));
|
||||
|
||||
+#if defined(MACOSX)
|
||||
+ // Aqua devices cannot paint client buffers: paint, then copy.
|
||||
+ pDevice->SetOutputSizePixel(Size(nCanvasWidth, nCanvasHeight));
|
||||
+#else
|
||||
pDevice->SetOutputSizePixelScaleOffsetAndLOKBuffer(
|
||||
Size(nCanvasWidth, nCanvasHeight), Fraction(1.0), Point(),
|
||||
pBuffer);
|
||||
+#endif
|
||||
|
||||
pDoc->paintTile(*pDevice, nCanvasWidth, nCanvasHeight,
|
||||
nTilePosX, nTilePosY, nTileWidth, nTileHeight);
|
||||
@@ -4336,7 +4341,7 @@ static void doc_paintTile(LibreOfficeKitDocument* pThis,
|
||||
pDevice->DrawRect(aRect);
|
||||
}
|
||||
|
||||
-#ifdef _WIN32
|
||||
+#if defined(_WIN32) || defined(MACOSX)
|
||||
// pBuffer was not used there
|
||||
pDevice->EnableMapMode(false);
|
||||
Bitmap aBmp(pDevice->GetBitmap({ 0, 0 }, { nCanvasWidth, nCanvasHeight }));
|
||||
@@ -0,0 +1,21 @@
|
||||
--- a/desktop/source/lib/init.cxx
|
||||
+++ b/desktop/source/lib/init.cxx
|
||||
@@ -5627,14 +5627,16 @@
|
||||
}
|
||||
}
|
||||
bool bResult = false;
|
||||
+ // Dispatch to this document's frame, not the desktop's active one.
|
||||
+ uno::Reference<frame::XFrame> xFrame = pViewShell->GetViewFrame().GetFrame().GetFrameInterface();
|
||||
if (bNotifyWhenFinished && pDocument->mpCallbackFlushHandlers.count(nView))
|
||||
{
|
||||
- bResult = comphelper::dispatchCommand(aCommand, comphelper::containerToSequence(aPropertyValuesVector),
|
||||
+ bResult = comphelper::dispatchCommand(aCommand, xFrame, comphelper::containerToSequence(aPropertyValuesVector),
|
||||
new DispatchResultListener(pCommand, pDocument->mpCallbackFlushHandlers[nView],
|
||||
pDocSh && pDocSh->IsModified()));
|
||||
}
|
||||
else
|
||||
- bResult = comphelper::dispatchCommand(aCommand, comphelper::containerToSequence(aPropertyValuesVector));
|
||||
+ bResult = comphelper::dispatchCommand(aCommand, xFrame, comphelper::containerToSequence(aPropertyValuesVector));
|
||||
|
||||
if (!bResult)
|
||||
{
|
||||
@@ -0,0 +1,228 @@
|
||||
diff --git a/include/sfx2/lokunocmdlist.hxx b/include/sfx2/lokunocmdlist.hxx
|
||||
index 34fd3f529..07d653df6 100644
|
||||
--- a/include/sfx2/lokunocmdlist.hxx
|
||||
+++ b/include/sfx2/lokunocmdlist.hxx
|
||||
@@ -34,6 +34,7 @@ enum class PayloadType
|
||||
StringOrStrSeqPayload,
|
||||
StrSeqPayload,
|
||||
TableSizePayload,
|
||||
+ ULSpacingPayload,
|
||||
};
|
||||
|
||||
struct KitUnoCommand
|
||||
diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx
|
||||
index ec456a103..cb14e6e6f 100644
|
||||
--- a/sfx2/source/control/unoctitm.cxx
|
||||
+++ b/sfx2/source/control/unoctitm.cxx
|
||||
@@ -35,6 +35,7 @@
|
||||
#include <com/sun/star/util/URLTransformer.hpp>
|
||||
#include <com/sun/star/util/XURLTransformer.hpp>
|
||||
#include <com/sun/star/frame/XFrame.hpp>
|
||||
+#include <com/sun/star/frame/status/UpperLowerMarginScale.hpp>
|
||||
#include <com/sun/star/frame/status/FontHeight.hpp>
|
||||
#include <com/sun/star/frame/status/ItemStatus.hpp>
|
||||
#include <com/sun/star/frame/status/ItemState.hpp>
|
||||
@@ -973,6 +974,17 @@ OString StyleApplyPayload(sal_uInt16, SfxViewFrame*, const css::frame::FeatureSt
|
||||
return aEvent.FeatureURL.Complete.toUtf8() + "=" + aTemplate.StyleName.toUtf8();
|
||||
}
|
||||
|
||||
+// Spacing above and below in 1/100 mm: "upper,lower".
|
||||
+OString ULSpacingPayload(sal_uInt16, SfxViewFrame*, const css::frame::FeatureStateEvent& aEvent,
|
||||
+ const SfxPoolItem*)
|
||||
+{
|
||||
+ css::frame::status::UpperLowerMarginScale aMargin;
|
||||
+ if (!(aEvent.State >>= aMargin))
|
||||
+ return aEvent.FeatureURL.Complete.toUtf8() + "=";
|
||||
+ return aEvent.FeatureURL.Complete.toUtf8() + "=" + OString::number(aMargin.Upper) + ","
|
||||
+ + OString::number(aMargin.Lower);
|
||||
+}
|
||||
+
|
||||
OString ColorPayload(sal_uInt16, SfxViewFrame*, const css::frame::FeatureStateEvent& aEvent,
|
||||
const SfxPoolItem*)
|
||||
{
|
||||
@@ -1155,6 +1167,7 @@ constexpr auto enumToPayload = frozen::make_unordered_map<PayloadType, PayloadGe
|
||||
{ PayloadType::FontNamePayload, FontNamePayload },
|
||||
{ PayloadType::FontHeightPayload, FontHeightPayload },
|
||||
{ PayloadType::StyleApplyPayload, StyleApplyPayload },
|
||||
+ { PayloadType::ULSpacingPayload, ULSpacingPayload },
|
||||
{ PayloadType::ColorPayload, ColorPayload },
|
||||
{ PayloadType::UndoRedoPayload, UndoRedoPayload },
|
||||
{ PayloadType::EnabledPayload, EnabledPayload },
|
||||
@@ -1230,6 +1243,8 @@ const std::map<std::u16string_view, KitUnoCommand>& GetKitUnoCommandList()
|
||||
{ u"FontHeight", { PayloadType::FontHeightPayload, true } },
|
||||
|
||||
{ u"StyleApply", { PayloadType::StyleApplyPayload, true } },
|
||||
+ { u"CharStyle", { PayloadType::StyleApplyPayload, true } },
|
||||
+ { u"ULSpacing", { PayloadType::ULSpacingPayload, true } },
|
||||
|
||||
{ u"BackColor", { PayloadType::ColorPayload, false } },
|
||||
{ u"BackgroundColor", { PayloadType::ColorPayload, true } },
|
||||
@@ -1482,6 +1497,16 @@ static void InterceptLOKStateChangeEvent(sal_uInt16 nSID, SfxViewFrame* pViewFra
|
||||
return;
|
||||
}
|
||||
|
||||
+ // Mixed selections report don't-care, not a made-up value.
|
||||
+ css::frame::status::ItemStatus aStatus;
|
||||
+ if ((aEvent.State >>= aStatus) && aStatus.State == css::frame::status::ItemState::DONT_CARE)
|
||||
+ {
|
||||
+ pViewShell->libreOfficeKitViewCallback(
|
||||
+ LOK_CALLBACK_STATE_CHANGED,
|
||||
+ "{\"commandName\":\"" + aEvent.FeatureURL.Complete.toUtf8() + "\",\"dontcare\":true}");
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
auto payloadIter = enumToPayload.find(handler->second.payloadType);
|
||||
PayloadGetter_t pFunct = payloadIter != enumToPayload.end() ? payloadIter->second : nullptr;
|
||||
if (pFunct != nullptr)
|
||||
diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx
|
||||
index b4e02d48b..9beb188b3 100644
|
||||
--- a/sw/source/core/txtnode/thints.cxx
|
||||
+++ b/sw/source/core/txtnode/thints.cxx
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <editeng/nhypitem.hxx>
|
||||
#include <osl/diagnose.h>
|
||||
#include <svl/whiter.hxx>
|
||||
+#include <comphelper/lok.hxx>
|
||||
#include <svl/itemiter.hxx>
|
||||
#include <editeng/charhiddenitem.hxx>
|
||||
#include <editeng/langitem.hxx>
|
||||
@@ -2288,9 +2289,9 @@ bool SwTextNode::GetParaAttr(SfxItemSet& rSet, sal_Int32 nStt, sal_Int32 nEnd,
|
||||
|
||||
const sal_Int32 nHintEnd = *pAttrEnd;
|
||||
|
||||
- for (; pItem; pItem = oItemIter ? oItemIter->NextItem() : nullptr)
|
||||
+ auto lcl_Check = [&](const SfxPoolItem* pCheck)
|
||||
{
|
||||
- const sal_uInt16 nHintWhich = pItem->Which();
|
||||
+ const sal_uInt16 nHintWhich = pCheck->Which();
|
||||
OSL_ENSURE(!isUNKNOWNATR(nHintWhich),
|
||||
"SwTextNode::GetAttr(): unknown attribute?");
|
||||
|
||||
@@ -2314,7 +2315,7 @@ bool SwTextNode::GetParaAttr(SfxItemSet& rSet, sal_Int32 nStt, sal_Int32 nEnd,
|
||||
{
|
||||
if( !pPrev->mpItem )
|
||||
{
|
||||
- if ( bOnlyTextAttr || *pItem != aFormatSet.Get( nHintWhich ) )
|
||||
+ if ( bOnlyTextAttr || *pCheck != aFormatSet.Get( nHintWhich ) )
|
||||
{
|
||||
if( nAttrStart > nStt )
|
||||
{
|
||||
@@ -2323,18 +2324,18 @@ bool SwTextNode::GetParaAttr(SfxItemSet& rSet, sal_Int32 nStt, sal_Int32 nEnd,
|
||||
}
|
||||
else
|
||||
{
|
||||
- pPrev->mpItem = pItem;
|
||||
+ pPrev->mpItem = pCheck;
|
||||
pPrev->mnEndPos = nHintEnd;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( !IsInvalidItem(pPrev->mpItem) )
|
||||
{
|
||||
- if( pPrev->mnEndPos == nAttrStart &&
|
||||
- *pPrev->mpItem == *pItem )
|
||||
+ if( nAttrStart <= pPrev->mnEndPos &&
|
||||
+ *pPrev->mpItem == *pCheck )
|
||||
{
|
||||
- pPrev->mpItem = pItem;
|
||||
- pPrev->mnEndPos = nHintEnd;
|
||||
+ pPrev->mpItem = pCheck;
|
||||
+ pPrev->mnEndPos = std::max(pPrev->mnEndPos, nHintEnd);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2343,7 +2344,27 @@ bool SwTextNode::GetParaAttr(SfxItemSet& rSet, sal_Int32 nStt, sal_Int32 nEnd,
|
||||
}
|
||||
}
|
||||
}
|
||||
- } // end while
|
||||
+ };
|
||||
+ for (; pItem; pItem = oItemIter ? oItemIter->NextItem() : nullptr)
|
||||
+ lcl_Check(pItem);
|
||||
+ // LOK: char style attributes can be ambiguous too.
|
||||
+ if (bGetFromChrFormat && comphelper::LibreOfficeKit::isActive()
|
||||
+ && RES_TXTATR_CHARFMT == pHt->Which())
|
||||
+ {
|
||||
+ if (const SfxItemSet* pChrSet = CharFormat::GetItemSet(pHt->GetAttr()))
|
||||
+ {
|
||||
+ SfxWhichIter aIter(*pChrSet);
|
||||
+ for (sal_uInt16 nWhich = aIter.FirstWhich(); nWhich;
|
||||
+ nWhich = aIter.NextWhich())
|
||||
+ {
|
||||
+ const SfxPoolItem* pChrItem = nullptr;
|
||||
+ if (isCHRATR(nWhich)
|
||||
+ && SfxItemState::SET
|
||||
+ == pChrSet->GetItemState(nWhich, true, &pChrItem))
|
||||
+ lcl_Check(pChrItem);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/sw/source/uibase/app/docst.cxx b/sw/source/uibase/app/docst.cxx
|
||||
index 4678df9fc..1b5d9e004 100644
|
||||
--- a/sw/source/uibase/app/docst.cxx
|
||||
+++ b/sw/source/uibase/app/docst.cxx
|
||||
@@ -90,9 +90,29 @@
|
||||
#include <svl/ptitem.hxx>
|
||||
#include <editeng/sizeitem.hxx>
|
||||
#include <editeng/ulspitem.hxx>
|
||||
+#include <comphelper/lok.hxx>
|
||||
+#include <ndtxt.hxx>
|
||||
+#include <pam.hxx>
|
||||
+#include <txtfrm.hxx>
|
||||
|
||||
using namespace ::com::sun::star;
|
||||
|
||||
+// LOK: whether the selection spans paragraph styles.
|
||||
+static bool lcl_MixedColl(SwWrtShell& rShell, const SwTextFormatColl& rColl)
|
||||
+{
|
||||
+ for (SwPaM& rPaM : rShell.GetCursor()->GetRingContainer())
|
||||
+ {
|
||||
+ for (SwNodeOffset n = rPaM.Start()->GetNodeIndex(); n <= rPaM.End()->GetNodeIndex(); ++n)
|
||||
+ {
|
||||
+ SwNode* pNode = rShell.GetDoc()->GetNodes()[n];
|
||||
+ if (pNode->IsTextNode()
|
||||
+ && sw::GetParaPropsNode(*rShell.GetLayout(), *pNode)->GetTextColl() != &rColl)
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+ return false;
|
||||
+}
|
||||
+
|
||||
static OutlinerView* lcl_GetPostItOutlinerView(SwWrtShell& rShell)
|
||||
{
|
||||
SwPostItMgr* pPostItMgr = rShell.GetPostItMgr();
|
||||
@@ -156,6 +176,12 @@ void SwDocShell::StateStyleSheet(SfxItemSet& rSet, SwWrtShell* pSh)
|
||||
else
|
||||
{
|
||||
SwTextFormatColl* pColl = pShell->GetCurTextFormatColl();
|
||||
+ if (pColl && comphelper::LibreOfficeKit::isActive()
|
||||
+ && lcl_MixedColl(*pShell, *pColl))
|
||||
+ {
|
||||
+ rSet.InvalidateItem(nWhich);
|
||||
+ break;
|
||||
+ }
|
||||
if(pColl)
|
||||
aName = pColl->GetName();
|
||||
}
|
||||
@@ -168,6 +194,18 @@ void SwDocShell::StateStyleSheet(SfxItemSet& rSet, SwWrtShell* pSh)
|
||||
SwCharFormat* pFormat = pShell->GetCurCharFormat();
|
||||
if(pFormat)
|
||||
aName = pFormat->GetName();
|
||||
+ else if (comphelper::LibreOfficeKit::isActive())
|
||||
+ {
|
||||
+ // LOK: mixed is don't-care, none is empty.
|
||||
+ SfxItemSetFixed<RES_TXTATR_CHARFMT, RES_TXTATR_CHARFMT> aSet(
|
||||
+ pShell->GetAttrPool());
|
||||
+ pShell->GetCurAttr(aSet);
|
||||
+ if (aSet.GetItemState(RES_TXTATR_CHARFMT, false) == SfxItemState::INVALID)
|
||||
+ {
|
||||
+ rSet.InvalidateItem(nWhich);
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
else
|
||||
aName = UIName(SwResId(STR_POOLCHR_STANDARD));
|
||||
rSet.Put(SfxTemplateItem(nWhich, aName.toString()));
|
||||
@@ -0,0 +1,112 @@
|
||||
--- a/include/sfx2/lokunocmdlist.hxx
|
||||
+++ b/include/sfx2/lokunocmdlist.hxx
|
||||
@@ -35,6 +35,8 @@
|
||||
StrSeqPayload,
|
||||
TableSizePayload,
|
||||
ULSpacingPayload,
|
||||
+ MarginsPayload,
|
||||
+ PageItemPayload,
|
||||
};
|
||||
|
||||
struct KitUnoCommand
|
||||
--- a/sfx2/source/control/unoctitm.cxx
|
||||
+++ b/sfx2/source/control/unoctitm.cxx
|
||||
@@ -36,6 +36,9 @@
|
||||
#include <com/sun/star/util/XURLTransformer.hpp>
|
||||
#include <com/sun/star/frame/XFrame.hpp>
|
||||
#include <com/sun/star/frame/status/UpperLowerMarginScale.hpp>
|
||||
+#include <com/sun/star/frame/status/LeftRightMargin.hpp>
|
||||
+#include <com/sun/star/frame/status/UpperLowerMargin.hpp>
|
||||
+#include <com/sun/star/style/PageStyleLayout.hpp>
|
||||
#include <com/sun/star/frame/status/FontHeight.hpp>
|
||||
#include <com/sun/star/frame/status/ItemStatus.hpp>
|
||||
#include <com/sun/star/frame/status/ItemState.hpp>
|
||||
@@ -983,6 +986,39 @@
|
||||
return aEvent.FeatureURL.Complete.toUtf8() + "=";
|
||||
return aEvent.FeatureURL.Complete.toUtf8() + "=" + OString::number(aMargin.Upper) + ","
|
||||
+ OString::number(aMargin.Lower);
|
||||
+}
|
||||
+
|
||||
+// Page margins in 1/100 mm: "left,right" or "upper,lower".
|
||||
+OString MarginsPayload(sal_uInt16, SfxViewFrame*, const css::frame::FeatureStateEvent& aEvent,
|
||||
+ const SfxPoolItem*)
|
||||
+{
|
||||
+ OString aCommand = aEvent.FeatureURL.Complete.toUtf8() + "=";
|
||||
+ if (css::frame::status::LeftRightMargin aLR; aEvent.State >>= aLR)
|
||||
+ return aCommand + OString::number(aLR.Left) + "," + OString::number(aLR.Right);
|
||||
+ if (css::frame::status::UpperLowerMargin aUL; aEvent.State >>= aUL)
|
||||
+ return aCommand + OString::number(aUL.Upper) + "," + OString::number(aUL.Lower);
|
||||
+ return aCommand;
|
||||
+}
|
||||
+
|
||||
+// The page item: "landscape,layout,numtype".
|
||||
+OString PageItemPayload(sal_uInt16, SfxViewFrame*, const css::frame::FeatureStateEvent& aEvent,
|
||||
+ const SfxPoolItem* pState)
|
||||
+{
|
||||
+ OString aCommand = aEvent.FeatureURL.Complete.toUtf8() + "=";
|
||||
+ if (!pState || IsInvalidItem(pState) || IsDisabledItem(pState))
|
||||
+ return aCommand;
|
||||
+ // Member ids of SvxPageItem, as svx/unomid.hxx defines them.
|
||||
+ constexpr sal_uInt8 MID_PAGE_NUMTYPE = 0, MID_PAGE_ORIENTATION = 1, MID_PAGE_LAYOUT = 2;
|
||||
+ css::uno::Any aLandscape, aLayout, aNumType;
|
||||
+ bool bLandscape = false;
|
||||
+ css::style::PageStyleLayout eLayout = css::style::PageStyleLayout_ALL;
|
||||
+ sal_Int16 nNumType = 0;
|
||||
+ if (!pState->QueryValue(aLandscape, MID_PAGE_ORIENTATION) || !(aLandscape >>= bLandscape)
|
||||
+ || !pState->QueryValue(aLayout, MID_PAGE_LAYOUT) || !(aLayout >>= eLayout)
|
||||
+ || !pState->QueryValue(aNumType, MID_PAGE_NUMTYPE) || !(aNumType >>= nNumType))
|
||||
+ return aCommand;
|
||||
+ return aCommand + OString::boolean(bLandscape) + "," + OString::number(sal_Int32(eLayout))
|
||||
+ + "," + OString::number(nNumType);
|
||||
}
|
||||
|
||||
OString ColorPayload(sal_uInt16, SfxViewFrame*, const css::frame::FeatureStateEvent& aEvent,
|
||||
@@ -1168,6 +1204,8 @@
|
||||
{ PayloadType::FontHeightPayload, FontHeightPayload },
|
||||
{ PayloadType::StyleApplyPayload, StyleApplyPayload },
|
||||
{ PayloadType::ULSpacingPayload, ULSpacingPayload },
|
||||
+ { PayloadType::MarginsPayload, MarginsPayload },
|
||||
+ { PayloadType::PageItemPayload, PageItemPayload },
|
||||
{ PayloadType::ColorPayload, ColorPayload },
|
||||
{ PayloadType::UndoRedoPayload, UndoRedoPayload },
|
||||
{ PayloadType::EnabledPayload, EnabledPayload },
|
||||
@@ -1245,6 +1283,20 @@
|
||||
{ u"StyleApply", { PayloadType::StyleApplyPayload, true } },
|
||||
{ u"CharStyle", { PayloadType::StyleApplyPayload, true } },
|
||||
{ u"ULSpacing", { PayloadType::ULSpacingPayload, true } },
|
||||
+ { u"AttributePageSize", { PayloadType::SizePayload, true } },
|
||||
+ { u"AttributePage", { PayloadType::PageItemPayload, true } },
|
||||
+ { u"PageLRMargin", { PayloadType::MarginsPayload, true } },
|
||||
+ { u"PageULMargin", { PayloadType::MarginsPayload, true } },
|
||||
+ { u"PageColumnType", { PayloadType::Int32Payload, true } },
|
||||
+ { u"SwPageHeaderItem", { PayloadType::BooleanPayload, true } },
|
||||
+ { u"SwPageFooterItem", { PayloadType::BooleanPayload, true } },
|
||||
+ { u"SwPageHeaderLayout", { PayloadType::Int32Payload, true } },
|
||||
+ { u"SwPageFooterLayout", { PayloadType::Int32Payload, true } },
|
||||
+ { u"SetAnchorToPage", { PayloadType::BooleanOrDisabledPayload, true } },
|
||||
+ { u"SetAnchorToPara", { PayloadType::BooleanOrDisabledPayload, true } },
|
||||
+ { u"SetAnchorAtChar", { PayloadType::BooleanOrDisabledPayload, true } },
|
||||
+ { u"SetAnchorToChar", { PayloadType::BooleanOrDisabledPayload, true } },
|
||||
+ { u"HeadingRowsRepeat", { PayloadType::BooleanOrDisabledPayload, true } },
|
||||
|
||||
{ u"BackColor", { PayloadType::ColorPayload, false } },
|
||||
{ u"BackgroundColor", { PayloadType::ColorPayload, true } },
|
||||
@@ -1307,12 +1359,12 @@
|
||||
{ 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"WrapRight", { PayloadType::BooleanOrDisabledPayload, true } },
|
||||
+ { u"WrapThrough", { PayloadType::BooleanOrDisabledPayload, true } },
|
||||
+ { u"WrapLeft", { PayloadType::BooleanOrDisabledPayload, true } },
|
||||
+ { u"WrapIdeal", { PayloadType::BooleanOrDisabledPayload, true } },
|
||||
+ { u"WrapOn", { PayloadType::BooleanOrDisabledPayload, true } },
|
||||
+ { u"WrapOff", { PayloadType::BooleanOrDisabledPayload, true } },
|
||||
{ u"UpdateCurIndex", { PayloadType::EnabledPayload, true } },
|
||||
{ u"InsertCaptionDialog", { PayloadType::EnabledPayload, true } },
|
||||
{ u"SplitTable", { PayloadType::EnabledPayload, true } },
|
||||
@@ -0,0 +1,63 @@
|
||||
diff --git a/vcl/inc/jsdialog/jsdialogmessages.hxx b/vcl/inc/jsdialog/jsdialogmessages.hxx
|
||||
index 3958a702c..74448fd4f 100644
|
||||
--- a/vcl/inc/jsdialog/jsdialogmessages.hxx
|
||||
+++ b/vcl/inc/jsdialog/jsdialogmessages.hxx
|
||||
@@ -10,6 +10,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <deque>
|
||||
+#include <memory>
|
||||
#include <mutex>
|
||||
|
||||
#include <rtl/ustring.hxx>
|
||||
@@ -96,10 +97,13 @@ class JSDialogNotifyIdle final : public Idle
|
||||
|
||||
std::deque<JSDialogMessageInfo> m_aMessageQueue;
|
||||
std::mutex m_aQueueMutex;
|
||||
+ // False once destroyed: a send may close the dialog.
|
||||
+ std::shared_ptr<bool> m_pAlive;
|
||||
|
||||
public:
|
||||
JSDialogNotifyIdle(VclPtr<vcl::Window> aNotifierWindow, VclPtr<vcl::Window> aContentWindow,
|
||||
const rtl::OUString& sTypeOfJSON);
|
||||
+ ~JSDialogNotifyIdle() override;
|
||||
|
||||
void Invoke() override;
|
||||
|
||||
diff --git a/vcl/jsdialog/jsdialogsender.cxx b/vcl/jsdialog/jsdialogsender.cxx
|
||||
index 1ca544647..155fd554c 100644
|
||||
--- a/vcl/jsdialog/jsdialogsender.cxx
|
||||
+++ b/vcl/jsdialog/jsdialogsender.cxx
|
||||
@@ -20,10 +20,13 @@ JSDialogNotifyIdle::JSDialogNotifyIdle(VclPtr<vcl::Window> aNotifierWindow,
|
||||
, m_aContentWindow(std::move(aContentWindow))
|
||||
, m_sTypeOfJSON(sTypeOfJSON)
|
||||
, m_bForce(false)
|
||||
+ , m_pAlive(std::make_shared<bool>(true))
|
||||
{
|
||||
SetPriority(TaskPriority::POST_PAINT);
|
||||
}
|
||||
|
||||
+JSDialogNotifyIdle::~JSDialogNotifyIdle() { *m_pAlive = false; }
|
||||
+
|
||||
void JSDialogNotifyIdle::forceUpdate() { m_bForce = true; }
|
||||
|
||||
void JSDialogNotifyIdle::send(const OString& sMsg)
|
||||
@@ -248,8 +251,18 @@ void JSDialogNotifyIdle::Invoke()
|
||||
std::swap(aMessageQueue, m_aMessageQueue);
|
||||
}
|
||||
|
||||
+ // A disposed dialog has nothing left to describe.
|
||||
+ if ((m_aNotifierWindow && m_aNotifierWindow->isDisposed())
|
||||
+ || (m_aContentWindow && m_aContentWindow->isDisposed()))
|
||||
+ return;
|
||||
+
|
||||
+ const std::shared_ptr<bool> pAlive = m_pAlive;
|
||||
for (auto& rMessage : aMessageQueue)
|
||||
{
|
||||
+ // The last send's client closed the dialog.
|
||||
+ if (!*pAlive)
|
||||
+ return;
|
||||
+
|
||||
jsdialog::MessageType eType = rMessage.m_eType;
|
||||
|
||||
if (m_sTypeOfJSON == "formulabar" && eType != jsdialog::MessageType::Action)
|
||||
@@ -0,0 +1,14 @@
|
||||
diff --git a/svx/sdi/svx.sdi b/svx/sdi/svx.sdi
|
||||
index 5ccbd6018..9c81bb0a2 100644
|
||||
--- a/svx/sdi/svx.sdi
|
||||
+++ b/svx/sdi/svx.sdi
|
||||
@@ -6464,7 +6464,8 @@ SvxPaperBinItem PagePaperBin SID_ATTR_PAGE_PAPERBIN
|
||||
SvxSizeItem AttributePageSize SID_ATTR_PAGE_SIZE
|
||||
(
|
||||
SvxSizeItem AttributePageSize SID_ATTR_PAGE_SIZE,
|
||||
- SfxUInt16Item PaperFormat FN_PARAM_1
|
||||
+ SfxUInt16Item PaperFormat FN_PARAM_1,
|
||||
+ SvxPageItem AttributePage SID_ATTR_PAGE
|
||||
)
|
||||
[
|
||||
AutoUpdate = FALSE,
|
||||
@@ -0,0 +1,15 @@
|
||||
diff --git a/vcl/osx/salinst.cxx b/vcl/osx/salinst.cxx
|
||||
index 6cd78291c..368ed718c 100644
|
||||
--- a/vcl/osx/salinst.cxx
|
||||
+++ b/vcl/osx/salinst.cxx
|
||||
@@ -754,6 +754,10 @@ bool AquaSalInstance::AnyInput( VclInputFlags nType )
|
||||
return true;
|
||||
}
|
||||
|
||||
+ // LOK: peeking runs client requests inside idle jobs.
|
||||
+ if (comphelper::LibreOfficeKit::isActive())
|
||||
+ return comphelper::LibreOfficeKit::anyInput();
|
||||
+
|
||||
unsigned/*NSUInteger*/ nEventMask = 0;
|
||||
if( nType & VclInputFlags::MOUSE)
|
||||
{
|
||||
@@ -0,0 +1,299 @@
|
||||
diff --git a/sw/sdi/olesh.sdi b/sw/sdi/olesh.sdi
|
||||
index 0d24c4686..13922a820 100644
|
||||
--- a/sw/sdi/olesh.sdi
|
||||
+++ b/sw/sdi/olesh.sdi
|
||||
@@ -19,6 +19,12 @@
|
||||
interface TextOLEObject : BaseTextOLEObject
|
||||
{
|
||||
import TextFrame;
|
||||
+
|
||||
+ FN_INSERT_SMA
|
||||
+ [
|
||||
+ ExecMethod = Execute ;
|
||||
+ StateMethod = GetState ;
|
||||
+ ]
|
||||
}
|
||||
|
||||
shell SwOleShell : SwFrameShell
|
||||
diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi
|
||||
index 2bf53f9ed..2cf26e846 100644
|
||||
--- a/sw/sdi/swriter.sdi
|
||||
+++ b/sw/sdi/swriter.sdi
|
||||
@@ -2799,7 +2799,7 @@ SfxVoidItem InsertBreak FN_INSERT_BREAK_DLG
|
||||
]
|
||||
|
||||
SfxVoidItem InsertCaptionDialog FN_INSERT_CAPTION
|
||||
-()
|
||||
+(SfxStringItem Category FN_PARAM_1, SfxStringItem Text FN_PARAM_2)
|
||||
[
|
||||
AutoUpdate = FALSE,
|
||||
FastCall = FALSE,
|
||||
@@ -3410,7 +3410,7 @@ SfxVoidItem TransformDocumentStructure FN_TRANSFORM_DOCUMENT_STRUCTURE
|
||||
]
|
||||
|
||||
SfxVoidItem InsertMultiIndex FN_INSERT_MULTI_TOX
|
||||
-()
|
||||
+(SfxStringItem Title FN_PARAM_1)
|
||||
[
|
||||
AutoUpdate = FALSE,
|
||||
FastCall = FALSE,
|
||||
@@ -3481,7 +3481,7 @@ SfxVoidItem InsertObjectDialog FN_INSERT_OBJECT_DLG
|
||||
]
|
||||
|
||||
SfxVoidItem InsertObjectStarMath FN_INSERT_SMA
|
||||
-()
|
||||
+(SfxStringItem Formula FN_PARAM_1)
|
||||
[
|
||||
AutoUpdate = FALSE,
|
||||
FastCall = FALSE,
|
||||
diff --git a/sw/source/uibase/inc/wrtsh.hxx b/sw/source/uibase/inc/wrtsh.hxx
|
||||
index 956a962f7..edfdecc75 100644
|
||||
--- a/sw/source/uibase/inc/wrtsh.hxx
|
||||
+++ b/sw/source/uibase/inc/wrtsh.hxx
|
||||
@@ -361,6 +361,8 @@ typedef bool (SwWrtShell::*FNSimpleMove)();
|
||||
bool InsertOleObject( const svt::EmbeddedObjectRef& xObj, SwFlyFrameFormat **pFlyFrameFormat = nullptr );
|
||||
SW_DLLPUBLIC void LaunchOLEObj(sal_Int32 nVerb = css::embed::EmbedVerbs::MS_OLEVERB_PRIMARY); // start server
|
||||
bool IsOLEMath();
|
||||
+ // Turns the text into a formula object, replacing the selection.
|
||||
+ void InsertFormula(const OUString& rFormula);
|
||||
virtual void MoveObjectIfActive( svt::EmbeddedObjectRef& xObj, const Point& rOffset ) override;
|
||||
virtual void CalcAndSetScale( svt::EmbeddedObjectRef& xObj,
|
||||
const SwRect *pFlyPrtRect = nullptr,
|
||||
diff --git a/sw/source/uibase/shells/frmsh.cxx b/sw/source/uibase/shells/frmsh.cxx
|
||||
index b7c016ed3..483dede9f 100644
|
||||
--- a/sw/source/uibase/shells/frmsh.cxx
|
||||
+++ b/sw/source/uibase/shells/frmsh.cxx
|
||||
@@ -140,6 +140,13 @@ void SwFrameShell::Execute(SfxRequest &rReq)
|
||||
rSh.SelectionToTop();
|
||||
break;
|
||||
|
||||
+ case FN_INSERT_SMA:
|
||||
+ if (const SfxStringItem* pFormula
|
||||
+ = pArgs ? pArgs->GetItem<SfxStringItem>(FN_PARAM_1, false) : nullptr;
|
||||
+ pFormula && rSh.IsOLEMath())
|
||||
+ rSh.InsertFormula(pFormula->GetValue());
|
||||
+ break;
|
||||
+
|
||||
case SID_FRAME_TO_BOTTOM:
|
||||
rSh.SelectionToBottom();
|
||||
break;
|
||||
diff --git a/sw/source/uibase/shells/olesh.cxx b/sw/source/uibase/shells/olesh.cxx
|
||||
index 60bf35538..fb9ab78bf 100644
|
||||
--- a/sw/source/uibase/shells/olesh.cxx
|
||||
+++ b/sw/source/uibase/shells/olesh.cxx
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <view.hxx>
|
||||
#include <frmsh.hxx>
|
||||
#include <olesh.hxx>
|
||||
+#include <cmdid.h>
|
||||
|
||||
#include <sfx2/sidebar/SidebarController.hxx>
|
||||
|
||||
diff --git a/sw/source/uibase/shells/textidx.cxx b/sw/source/uibase/shells/textidx.cxx
|
||||
index da59097f9..cb12c373f 100644
|
||||
--- a/sw/source/uibase/shells/textidx.cxx
|
||||
+++ b/sw/source/uibase/shells/textidx.cxx
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <sfx2/request.hxx>
|
||||
#include <sfx2/viewfrm.hxx>
|
||||
#include <svl/eitem.hxx>
|
||||
+#include <svl/stritem.hxx>
|
||||
#include <editeng/sizeitem.hxx>
|
||||
#include <osl/diagnose.h>
|
||||
#include <fmtfsize.hxx>
|
||||
@@ -180,6 +181,14 @@ void SwTextShell::ExecIdx(SfxRequest const &rReq)
|
||||
}
|
||||
case FN_INSERT_MULTI_TOX:
|
||||
{
|
||||
+ if (const SfxStringItem* pTitle
|
||||
+ = pArgs ? pArgs->GetItem<SfxStringItem>(FN_PARAM_1, false) : nullptr)
|
||||
+ {
|
||||
+ SwTOXDescription aDesc(TOX_CONTENT);
|
||||
+ aDesc.SetTitle(pTitle->GetValue());
|
||||
+ SwTOXMgr(&GetShell()).UpdateOrInsertTOX(aDesc, nullptr, nullptr);
|
||||
+ break;
|
||||
+ }
|
||||
SfxItemSet aSet(SfxItemSet::makeFixedSfxItemSet<RES_FRM_SIZE, RES_FRM_SIZE,
|
||||
RES_LR_SPACE, RES_LR_SPACE,
|
||||
RES_BACKGROUND, RES_BACKGROUND,
|
||||
diff --git a/sw/source/uibase/shells/textsh.cxx b/sw/source/uibase/shells/textsh.cxx
|
||||
index 329460332..8c100bf1c 100644
|
||||
--- a/sw/source/uibase/shells/textsh.cxx
|
||||
+++ b/sw/source/uibase/shells/textsh.cxx
|
||||
@@ -421,6 +421,12 @@ void SwTextShell::ExecInsert(SfxRequest &rReq)
|
||||
|
||||
case FN_INSERT_SMA:
|
||||
{
|
||||
+ if (const SfxStringItem* pFormula
|
||||
+ = pArgs ? pArgs->GetItem<SfxStringItem>(FN_PARAM_1, false) : nullptr)
|
||||
+ {
|
||||
+ rSh.InsertFormula(pFormula->GetValue());
|
||||
+ break;
|
||||
+ }
|
||||
// if sidebar is closed - open to show elements deck
|
||||
if (comphelper::LibreOfficeKit::isActive())
|
||||
sfx2::sidebar::Sidebar::Setup(u"");
|
||||
diff --git a/sw/source/uibase/uiview/viewdlg2.cxx b/sw/source/uibase/uiview/viewdlg2.cxx
|
||||
index ff57083b1..88b1ef75b 100644
|
||||
--- a/sw/source/uibase/uiview/viewdlg2.cxx
|
||||
+++ b/sw/source/uibase/uiview/viewdlg2.cxx
|
||||
@@ -52,6 +52,21 @@ void SwView::ExecDlgExt(SfxRequest& rReq)
|
||||
{
|
||||
case FN_INSERT_CAPTION:
|
||||
{
|
||||
+ const SfxItemSet* pArgs = rReq.GetArgs();
|
||||
+ if (const SfxStringItem* pCategory
|
||||
+ = pArgs ? pArgs->GetItem<SfxStringItem>(FN_PARAM_1, false) : nullptr)
|
||||
+ {
|
||||
+ const SfxStringItem* pText = pArgs->GetItem<SfxStringItem>(FN_PARAM_2, false);
|
||||
+ InsCaptionOpt aOpt;
|
||||
+ aOpt.SetCategory(SwStyleNameMapper::GetUIName(ProgName(pCategory->GetValue()),
|
||||
+ SwGetPoolIdFromName::TxtColl)
|
||||
+ .toString());
|
||||
+ aOpt.SetCaption(pText ? pText->GetValue() : OUString());
|
||||
+ aOpt.UseCaption() = true;
|
||||
+ aOpt.IgnoreSeqOpts() = true;
|
||||
+ InsertCaption(&aOpt);
|
||||
+ break;
|
||||
+ }
|
||||
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
|
||||
VclPtr<VclAbstractDialog> pDialog(
|
||||
pFact->CreateSwCaptionDialog(GetFrameWeld(), *this));
|
||||
diff --git a/sw/source/uibase/uno/loktxdoc.cxx b/sw/source/uibase/uno/loktxdoc.cxx
|
||||
index 27f0ebca1..56d1c258a 100644
|
||||
--- a/sw/source/uibase/uno/loktxdoc.cxx
|
||||
+++ b/sw/source/uibase/uno/loktxdoc.cxx
|
||||
@@ -65,6 +65,9 @@
|
||||
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
|
||||
|
||||
#include <sax/tools/converter.hxx>
|
||||
+#include <svtools/embedhlp.hxx>
|
||||
+#include <com/sun/star/beans/XPropertySet.hpp>
|
||||
+#include <com/sun/star/embed/XEmbeddedObject.hpp>
|
||||
|
||||
using namespace ::com::sun::star;
|
||||
|
||||
@@ -1093,6 +1096,20 @@ void GetDocStructure(tools::JsonWriter& rJsonWriter, SwDocShell* pDocShell,
|
||||
GetDocStructureTrackChanges(rJsonWriter, pDocShell, o3tl::trim(rest));
|
||||
}
|
||||
|
||||
+/// Implements getCommandValues(".uno:Formula").
|
||||
+void GetFormula(tools::JsonWriter& rJsonWriter, SwDocShell* pDocShell)
|
||||
+{
|
||||
+ SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
|
||||
+ if (!pWrtShell || !(pWrtShell->GetSelectionType() & SelectionType::Ole)
|
||||
+ || !pWrtShell->IsOLEMath())
|
||||
+ return;
|
||||
+ svt::EmbeddedObjectRef& xObj = pWrtShell->GetOLEObject();
|
||||
+ if (!svt::EmbeddedObjectRef::TryRunningState(xObj.GetObject()))
|
||||
+ return;
|
||||
+ uno::Reference<beans::XPropertySet> xSet(xObj->getComponent(), uno::UNO_QUERY_THROW);
|
||||
+ rJsonWriter.put("formula", xSet->getPropertyValue(u"Formula"_ustr).get<OUString>());
|
||||
+}
|
||||
+
|
||||
/// Implements getCommandValues(".uno:Sections").
|
||||
///
|
||||
/// Parameters:
|
||||
@@ -1130,7 +1147,8 @@ bool SwXTextDocument::supportsCommand(std::u16string_view rCommand)
|
||||
static const std::initializer_list<std::u16string_view> vForward
|
||||
= { u"TextFormFields", u"TextFormField", u"SetDocumentProperties",
|
||||
u"Bookmarks", u"Fields", u"Sections",
|
||||
- u"Bookmark", u"Field", u"Layout" };
|
||||
+ u"Bookmark", u"Field", u"Layout",
|
||||
+ u"Formula" };
|
||||
|
||||
return std::find(vForward.begin(), vForward.end(), rCommand) != vForward.end();
|
||||
}
|
||||
@@ -1217,6 +1235,10 @@ void SwXTextDocument::getCommandValues(tools::JsonWriter& rJsonWriter, std::stri
|
||||
{
|
||||
GetDocStructure(rJsonWriter, m_pDocShell, aMap);
|
||||
}
|
||||
+ else if (o3tl::starts_with(rCommand, ".uno:Formula"sv))
|
||||
+ {
|
||||
+ GetFormula(rJsonWriter, m_pDocShell);
|
||||
+ }
|
||||
else if (o3tl::starts_with(rCommand, ".uno:Layout"sv))
|
||||
{
|
||||
GetLayout(rJsonWriter, m_pDocShell);
|
||||
diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx b/sw/source/uibase/wrtsh/wrtsh1.cxx
|
||||
index 4fb53b840..3f4de184d 100644
|
||||
--- a/sw/source/uibase/wrtsh/wrtsh1.cxx
|
||||
+++ b/sw/source/uibase/wrtsh/wrtsh1.cxx
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <com/sun/star/beans/XPropertySet.hpp>
|
||||
#include <com/sun/star/container/XChild.hpp>
|
||||
#include <com/sun/star/embed/EmbedMisc.hpp>
|
||||
+#include <com/sun/star/text/VertOrientation.hpp>
|
||||
#include <com/sun/star/embed/EmbedStates.hpp>
|
||||
#include <com/sun/star/embed/EmbedVerbs.hpp>
|
||||
#include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
|
||||
@@ -28,7 +29,9 @@
|
||||
#include <com/sun/star/lang/XInitialization.hpp>
|
||||
|
||||
#include <hintids.hxx>
|
||||
+#include <optional>
|
||||
#include <sot/exchange.hxx>
|
||||
+#include <comphelper/classids.hxx>
|
||||
#include <svx/xfillit0.hxx>
|
||||
#include <svx/hdft.hxx>
|
||||
#include <svx/svdview.hxx>
|
||||
@@ -50,6 +53,8 @@
|
||||
#include <svx/fontworkbar.hxx>
|
||||
#include <dialoghelp.hxx>
|
||||
#include <frmfmt.hxx>
|
||||
+#include <fmtanchr.hxx>
|
||||
+#include <fmtornt.hxx>
|
||||
#include <fmtftn.hxx>
|
||||
#include <fmthdft.hxx>
|
||||
#include <fmtpdsc.hxx>
|
||||
@@ -676,6 +681,50 @@ bool SwWrtShell::IsOLEMath() {
|
||||
return false;
|
||||
}
|
||||
|
||||
+void SwWrtShell::InsertFormula(const OUString& rFormula)
|
||||
+{
|
||||
+ StartUndo(SwUndoId::INSERT);
|
||||
+ // A replaced formula's place: anchor, spacing, alignment.
|
||||
+ std::optional<SfxItemSetFixed<RES_LR_SPACE, RES_UL_SPACE, RES_OPAQUE, RES_ANCHOR>> oPlace;
|
||||
+ if (IsFrameSelected())
|
||||
+ {
|
||||
+ oPlace.emplace(GetAttrPool());
|
||||
+ GetFlyFrameAttr(*oPlace);
|
||||
+ // Baseline alignment places a new inline formula itself.
|
||||
+ if (oPlace->Get(RES_ANCHOR).GetAnchorId() == RndStdIds::FLY_AS_CHAR
|
||||
+ && oPlace->Get(RES_VERT_ORIENT).GetVertOrient() == css::text::VertOrientation::NONE)
|
||||
+ oPlace->ClearItem(RES_VERT_ORIENT);
|
||||
+ }
|
||||
+ if (IsFrameSelected() || HasSelection())
|
||||
+ DelRight();
|
||||
+ // Write where the replaced formula was anchored.
|
||||
+ if (oPlace && oPlace->Get(RES_ANCHOR).GetContentAnchor())
|
||||
+ {
|
||||
+ GetCursor()->DeleteMark();
|
||||
+ *GetCursor()->GetPoint() = *oPlace->Get(RES_ANCHOR).GetContentAnchor();
|
||||
+ }
|
||||
+ const sal_Int32 nStart = GetCursor()->GetPoint()->GetContentIndex();
|
||||
+ Insert(rFormula);
|
||||
+ SwPaM* pCursor = GetCursor();
|
||||
+ pCursor->SetMark();
|
||||
+ pCursor->GetMark()->SetContent(nStart);
|
||||
+ SvGlobalName aName(SO3_SM_CLASSID);
|
||||
+ InsertObject(svt::EmbeddedObjectRef(), &aName);
|
||||
+ if (oPlace)
|
||||
+ {
|
||||
+ const SwFormatAnchor& rOld = oPlace->Get(RES_ANCHOR);
|
||||
+ if (rOld.GetAnchorId() != RndStdIds::FLY_AS_CHAR)
|
||||
+ {
|
||||
+ SwFormatAnchor aAnchor(rOld.GetAnchorId(), rOld.GetPageNum());
|
||||
+ SfxItemSet aSet(SwFEShell::makeItemSetFromFormatAnchor(GetAttrPool(), aAnchor));
|
||||
+ SetFlyFrameAttr(aSet);
|
||||
+ }
|
||||
+ oPlace->ClearItem(RES_ANCHOR);
|
||||
+ SetFlyFrameAttr(*oPlace);
|
||||
+ }
|
||||
+ EndUndo();
|
||||
+}
|
||||
+
|
||||
// The current selected OLE object will be loaded with the
|
||||
// verb into the server.
|
||||
void SwWrtShell::LaunchOLEObj(sal_Int32 nVerb)
|
||||
@@ -0,0 +1,57 @@
|
||||
--- a/sw/source/uibase/uno/loktxdoc.cxx 2026-10-04 10:51:12
|
||||
+++ b/sw/source/uibase/uno/loktxdoc.cxx 2026-10-04 10:51:12
|
||||
@@ -37,6 +37,7 @@
|
||||
#include <IDocumentRedlineAccess.hxx>
|
||||
#include <doc.hxx>
|
||||
#include <docsh.hxx>
|
||||
+#include <docstat.hxx>
|
||||
#include <fmtrfmrk.hxx>
|
||||
#include <wrtsh.hxx>
|
||||
#include <txtrfmrk.hxx>
|
||||
@@ -1110,6 +1111,26 @@
|
||||
rJsonWriter.put("formula", xSet->getPropertyValue(u"Formula"_ustr).get<OUString>());
|
||||
}
|
||||
|
||||
+/// Implements getCommandValues(".uno:WordCount").
|
||||
+void GetWordCount(tools::JsonWriter& rJsonWriter, SwDocShell* pDocShell)
|
||||
+{
|
||||
+ SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
|
||||
+ if (!pWrtShell)
|
||||
+ return;
|
||||
+ SwDocStat aSelection;
|
||||
+ pWrtShell->CountWords(aSelection);
|
||||
+ const SwDocStat aDocument = pWrtShell->GetUpdatedDocStat();
|
||||
+ for (const auto& [pName, rStat] :
|
||||
+ { std::pair<const char*, const SwDocStat&>("document", aDocument),
|
||||
+ std::pair<const char*, const SwDocStat&>("selection", aSelection) })
|
||||
+ {
|
||||
+ auto aNode = rJsonWriter.startNode(pName);
|
||||
+ rJsonWriter.put("words", static_cast<sal_Int64>(rStat.nWord));
|
||||
+ rJsonWriter.put("characters", static_cast<sal_Int64>(rStat.nChar));
|
||||
+ rJsonWriter.put("charactersNoSpaces", static_cast<sal_Int64>(rStat.nCharExcludingSpaces));
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
/// Implements getCommandValues(".uno:Sections").
|
||||
///
|
||||
/// Parameters:
|
||||
@@ -1148,7 +1169,7 @@
|
||||
= { u"TextFormFields", u"TextFormField", u"SetDocumentProperties",
|
||||
u"Bookmarks", u"Fields", u"Sections",
|
||||
u"Bookmark", u"Field", u"Layout",
|
||||
- u"Formula" };
|
||||
+ u"Formula", u"WordCount" };
|
||||
|
||||
return std::find(vForward.begin(), vForward.end(), rCommand) != vForward.end();
|
||||
}
|
||||
@@ -1235,6 +1256,10 @@
|
||||
{
|
||||
GetDocStructure(rJsonWriter, m_pDocShell, aMap);
|
||||
}
|
||||
+ else if (o3tl::starts_with(rCommand, ".uno:WordCount"sv))
|
||||
+ {
|
||||
+ GetWordCount(rJsonWriter, m_pDocShell);
|
||||
+ }
|
||||
else if (o3tl::starts_with(rCommand, ".uno:Formula"sv))
|
||||
{
|
||||
GetFormula(rJsonWriter, m_pDocShell);
|
||||
@@ -0,0 +1,87 @@
|
||||
--- a/sw/source/uibase/uno/loktxdoc.cxx 2026-10-04 12:47:34
|
||||
+++ b/sw/source/uibase/uno/loktxdoc.cxx 2026-10-04 12:47:34
|
||||
@@ -51,6 +51,8 @@
|
||||
#include <unocontentcontrol.hxx>
|
||||
#include <rootfrm.hxx>
|
||||
#include <pagefrm.hxx>
|
||||
+#include <cntfrm.hxx>
|
||||
+#include <IDocumentOutlineNodes.hxx>
|
||||
#include <com/sun/star/text/XTextContent.hpp>
|
||||
|
||||
#include <com/sun/star/text/XPageCursor.hpp>
|
||||
@@ -278,6 +280,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
|
||||
IDocumentMarkAccess& rIDMA = *pDocShell->GetDoc()->getIDocumentMarkAccess();
|
||||
auto aBookmarks = rJsonWriter.startArray("bookmarks");
|
||||
for (auto it = rIDMA.getBookmarksBegin(); it != rIDMA.getBookmarksEnd(); ++it)
|
||||
@@ -290,6 +293,15 @@
|
||||
|
||||
auto aProperty = rJsonWriter.startStruct();
|
||||
rJsonWriter.put("name", pMark->GetName().toString());
|
||||
+ if (!pWrtShell)
|
||||
+ continue;
|
||||
+ const SwPosition& rPos = pMark->GetMarkStart();
|
||||
+ const SwContentNode* pNode = rPos.GetNode().GetContentNode();
|
||||
+ const SwContentFrame* pFrame
|
||||
+ = pNode ? pNode->getLayoutFrame(pWrtShell->GetLayout(), &rPos) : nullptr;
|
||||
+ SwRect aRect;
|
||||
+ if (pFrame && pFrame->GetCharRect(aRect, rPos))
|
||||
+ rJsonWriter.put("rect", aRect.SVRect().toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1131,6 +1143,31 @@
|
||||
}
|
||||
}
|
||||
|
||||
+/// Implements getCommandValues(".uno:Outline").
|
||||
+void GetOutline(tools::JsonWriter& rJsonWriter, SwDocShell* pDocShell)
|
||||
+{
|
||||
+ SwWrtShell* pWrtShell = pDocShell->GetWrtShell();
|
||||
+ if (!pWrtShell)
|
||||
+ return;
|
||||
+ const SwDoc& rDoc = *pDocShell->GetDoc();
|
||||
+ const IDocumentOutlineNodes& rOutline = rDoc.getIDocumentOutlineNodes();
|
||||
+ const SwOutlineNodes& rNodes = rDoc.GetNodes().GetOutLineNds();
|
||||
+ const SwOutlineNodes::size_type nCurrent = pWrtShell->GetOutlinePos();
|
||||
+ auto aHeadings = rJsonWriter.startArray("outline");
|
||||
+ for (SwOutlineNodes::size_type i = 0; i < rNodes.size(); ++i)
|
||||
+ {
|
||||
+ const SwContentFrame* pFrame
|
||||
+ = rNodes[i]->GetTextNode()->getLayoutFrame(pWrtShell->GetLayout());
|
||||
+ if (!pFrame)
|
||||
+ continue;
|
||||
+ auto aHeading = rJsonWriter.startStruct();
|
||||
+ rJsonWriter.put("text", rOutline.getOutlineText(i, pWrtShell->GetLayout(), true, false, false));
|
||||
+ rJsonWriter.put("level", static_cast<sal_Int64>(rOutline.getOutlineLevel(i)));
|
||||
+ rJsonWriter.put("rect", pFrame->getFrameArea().SVRect().toString());
|
||||
+ rJsonWriter.put("current", i == nCurrent);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
/// Implements getCommandValues(".uno:Sections").
|
||||
///
|
||||
/// Parameters:
|
||||
@@ -1169,7 +1206,7 @@
|
||||
= { u"TextFormFields", u"TextFormField", u"SetDocumentProperties",
|
||||
u"Bookmarks", u"Fields", u"Sections",
|
||||
u"Bookmark", u"Field", u"Layout",
|
||||
- u"Formula", u"WordCount" };
|
||||
+ u"Formula", u"WordCount", u"Outline" };
|
||||
|
||||
return std::find(vForward.begin(), vForward.end(), rCommand) != vForward.end();
|
||||
}
|
||||
@@ -1256,6 +1293,10 @@
|
||||
{
|
||||
GetDocStructure(rJsonWriter, m_pDocShell, aMap);
|
||||
}
|
||||
+ else if (o3tl::starts_with(rCommand, ".uno:Outline"sv))
|
||||
+ {
|
||||
+ GetOutline(rJsonWriter, m_pDocShell);
|
||||
+ }
|
||||
else if (o3tl::starts_with(rCommand, ".uno:WordCount"sv))
|
||||
{
|
||||
GetWordCount(rJsonWriter, m_pDocShell);
|
||||
@@ -0,0 +1,27 @@
|
||||
--- a/desktop/source/lib/init.cxx 2026-10-04 13:38:07
|
||||
+++ b/desktop/source/lib/init.cxx 2026-10-04 13:38:07
|
||||
@@ -3055,11 +3055,20 @@
|
||||
// vcl::Font::GetItalic() returns and boldness by what
|
||||
// vcl::Font::GetWeight() returns.)
|
||||
|
||||
+ // A ';' list is present if any member is used.
|
||||
if (x.mOriginalFont.indexOf('/') == -1)
|
||||
- for (const auto &j : x.mUsedFonts)
|
||||
- if (j == x.mOriginalFont ||
|
||||
- j.startsWith(Concat2View(x.mOriginalFont + "/")))
|
||||
- return true;
|
||||
+ {
|
||||
+ sal_Int32 nIndex = 0;
|
||||
+ do
|
||||
+ {
|
||||
+ const OUString aFamily
|
||||
+ = x.mOriginalFont.getToken(0, ';', nIndex);
|
||||
+ for (const auto &j : x.mUsedFonts)
|
||||
+ if (j == aFamily
|
||||
+ || j.startsWith(Concat2View(aFamily + "/")))
|
||||
+ return true;
|
||||
+ } while (nIndex >= 0);
|
||||
+ }
|
||||
|
||||
return false;
|
||||
});
|
||||
@@ -0,0 +1,165 @@
|
||||
--- a/sc/inc/docuno.hxx
|
||||
+++ b/sc/inc/docuno.hxx
|
||||
@@ -325,6 +325,12 @@
|
||||
/// @see vcl::ITiledRenderable::getPartInfo().
|
||||
virtual OUString getPartInfo( int nPart ) override;
|
||||
|
||||
+ /// @see vcl::ITiledRenderable::supportsCommand().
|
||||
+ bool supportsCommand(std::u16string_view rCommand) override;
|
||||
+
|
||||
+ /// @see vcl::ITiledRenderable::getCommandValues().
|
||||
+ void getCommandValues(tools::JsonWriter& rJsonWriter, std::string_view rCommand) override;
|
||||
+
|
||||
/// @see vcl::ITiledRenderable::getPartName().
|
||||
virtual OUString getPartName(int nPart) override;
|
||||
|
||||
--- a/sc/source/ui/unoobj/docuno.cxx
|
||||
+++ b/sc/source/ui/unoobj/docuno.cxx
|
||||
@@ -93,6 +93,11 @@
|
||||
|
||||
#include <cellsuno.hxx>
|
||||
#include <columnspanset.hxx>
|
||||
+#include <dociter.hxx>
|
||||
+#include <o3tl/string_view.hxx>
|
||||
+#include <formulacell.hxx>
|
||||
+#include <rangenam.hxx>
|
||||
+#include <tokenarray.hxx>
|
||||
#include <convuno.hxx>
|
||||
#include <datauno.hxx>
|
||||
#include <docfunc.hxx>
|
||||
@@ -644,6 +649,100 @@
|
||||
{
|
||||
ScViewData* pViewData = ScDocShell::GetViewData();
|
||||
return pViewData ? pViewData->GetViewShell()->getPart() : 0;
|
||||
+}
|
||||
+
|
||||
+namespace
|
||||
+{
|
||||
+/// Whether rCode at rPos refers to sheet nTab.
|
||||
+bool lcl_RefersToTab(const ScDocument& rDoc, const ScTokenArray& rCode, const ScAddress& rPos,
|
||||
+ SCTAB nTab)
|
||||
+{
|
||||
+ for (const formula::FormulaToken* pToken : rCode.References())
|
||||
+ {
|
||||
+ if (pToken->GetType() == formula::svSingleRef
|
||||
+ && pToken->GetSingleRef()->toAbs(rDoc, rPos).Tab() == nTab)
|
||||
+ return true;
|
||||
+ if (pToken->GetType() == formula::svDoubleRef)
|
||||
+ {
|
||||
+ const ScRange aRange = pToken->GetDoubleRef()->toAbs(rDoc, rPos);
|
||||
+ if (aRange.aStart.Tab() <= nTab && nTab <= aRange.aEnd.Tab())
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+ return false;
|
||||
+}
|
||||
+
|
||||
+/// Whether rCode finds its target only when it runs.
|
||||
+bool lcl_IsDynamic(const ScTokenArray& rCode)
|
||||
+{
|
||||
+ formula::FormulaTokenArrayPlainIterator aIter(rCode);
|
||||
+ for (const formula::FormulaToken* pToken = aIter.First(); pToken; pToken = aIter.Next())
|
||||
+ if (pToken->GetOpCode() == ocIndirect)
|
||||
+ return true;
|
||||
+ return false;
|
||||
+}
|
||||
+}
|
||||
+
|
||||
+bool ScModelObj::supportsCommand(std::u16string_view rCommand)
|
||||
+{
|
||||
+ return rCommand == u"SheetReferences";
|
||||
+}
|
||||
+
|
||||
+void ScModelObj::getCommandValues(tools::JsonWriter& rJsonWriter, std::string_view rCommand)
|
||||
+{
|
||||
+ if (!pDocShell || !o3tl::starts_with(rCommand, ".uno:SheetReferences"))
|
||||
+ return;
|
||||
+ std::map<OUString, OUString> aMap
|
||||
+ = SfxLokHelper::parseCommandParameters(OUString::fromUtf8(rCommand));
|
||||
+ const auto aSheet = aMap.find(u"sheet"_ustr);
|
||||
+ if (aSheet == aMap.end())
|
||||
+ return;
|
||||
+ ScDocument& rDoc = pDocShell->GetDocument();
|
||||
+ const SCTAB nTab = aSheet->second.toInt32();
|
||||
+ sal_Int64 nFormulas = 0;
|
||||
+ sal_Int64 nDynamic = 0;
|
||||
+ OUString aFirst;
|
||||
+ for (SCTAB nOther = 0; nOther < rDoc.GetTableCount(); ++nOther)
|
||||
+ {
|
||||
+ if (nOther == nTab)
|
||||
+ continue;
|
||||
+ ScCellIterator aIter(rDoc, ScRange(0, 0, nOther, rDoc.MaxCol(), rDoc.MaxRow(), nOther));
|
||||
+ for (bool bHas = aIter.first(); bHas; bHas = aIter.next())
|
||||
+ {
|
||||
+ if (aIter.getType() != CELLTYPE_FORMULA)
|
||||
+ continue;
|
||||
+ const ScTokenArray& rCode = *aIter.getFormulaCell()->GetCode();
|
||||
+ if (lcl_IsDynamic(rCode))
|
||||
+ ++nDynamic;
|
||||
+ if (!lcl_RefersToTab(rDoc, rCode, aIter.GetPos(), nTab))
|
||||
+ continue;
|
||||
+ if (!nFormulas++)
|
||||
+ aFirst = aIter.GetPos().Format(ScRefFlags::VALID | ScRefFlags::TAB_3D, &rDoc);
|
||||
+ }
|
||||
+ }
|
||||
+ sal_Int64 nNames = 0;
|
||||
+ auto aCount = [&rDoc, &nNames, &nDynamic, nTab](const ScRangeName* pNames) {
|
||||
+ if (!pNames)
|
||||
+ return;
|
||||
+ for (const auto& [rName, pData] : *pNames)
|
||||
+ {
|
||||
+ if (!pData->GetCode())
|
||||
+ continue;
|
||||
+ if (lcl_IsDynamic(*pData->GetCode()))
|
||||
+ ++nDynamic;
|
||||
+ if (lcl_RefersToTab(rDoc, *pData->GetCode(), pData->GetPos(), nTab))
|
||||
+ ++nNames;
|
||||
+ }
|
||||
+ };
|
||||
+ aCount(rDoc.GetRangeName());
|
||||
+ for (SCTAB nOther = 0; nOther < rDoc.GetTableCount(); ++nOther)
|
||||
+ if (nOther != nTab)
|
||||
+ aCount(rDoc.GetRangeName(nOther));
|
||||
+ rJsonWriter.put("commandName", ".uno:SheetReferences");
|
||||
+ rJsonWriter.put("formulas", nFormulas);
|
||||
+ rJsonWriter.put("names", nNames);
|
||||
+ rJsonWriter.put("dynamic", nDynamic);
|
||||
+ rJsonWriter.put("first", aFirst);
|
||||
}
|
||||
|
||||
OUString ScModelObj::getPartInfo( int nPart )
|
||||
--- a/sc/source/ui/view/cellsh3.cxx
|
||||
+++ b/sc/source/ui/view/cellsh3.cxx
|
||||
@@ -985,6 +985,8 @@
|
||||
{
|
||||
assert(dynamic_cast<const SfxBoolItem*>( pItem) && "wrong item");
|
||||
bMoveContents = static_cast<const SfxBoolItem*>(pItem)->GetValue();
|
||||
+ // The caller chose; no dialog.
|
||||
+ bApi = true;
|
||||
}
|
||||
|
||||
pTabViewShell->MergeCells( bApi, bMoveContents, bCenter, nSlot );
|
||||
--- a/sc/source/ui/view/tabvwshc.cxx 2026-10-04 15:03:50
|
||||
+++ b/sc/source/ui/view/tabvwshc.cxx 2026-10-04 15:04:20
|
||||
@@ -461,6 +461,10 @@
|
||||
|
||||
UpdateInputHandler(true, false);
|
||||
|
||||
+ // The cell cursor predates the callback.
|
||||
+ if (ScGridWindow* pWin = GetViewData().GetActiveWin())
|
||||
+ pWin->notifyKitCellCursor();
|
||||
+
|
||||
ScInputHandler* pHdl = mpInputHandler ? mpInputHandler.get() : ScModule::get()->GetInputHdl();
|
||||
if (pHdl)
|
||||
{
|
||||
--- a/sc/source/ui/view/viewfun2.cxx
|
||||
+++ b/sc/source/ui/view/viewfun2.cxx
|
||||
@@ -1313,6 +1313,8 @@
|
||||
// else cancelled
|
||||
});
|
||||
}
|
||||
+ else
|
||||
+ doMerge(bDoContents, bEmptyMergedCells);
|
||||
} else
|
||||
doMerge(bDoContents, bEmptyMergedCells);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
--- a/desktop/source/lib/init.cxx 2026-10-04 16:16:09
|
||||
+++ b/desktop/source/lib/init.cxx 2026-10-04 16:16:09
|
||||
@@ -5351,6 +5351,13 @@
|
||||
{
|
||||
updateConfig(OUString(pValue, strlen(pValue), RTL_TEXTENCODING_UTF8));
|
||||
}
|
||||
+ else if (strcmp(pOption, "author") == 0)
|
||||
+ {
|
||||
+ // The name new comments and tracked changes carry.
|
||||
+ SvtUserOptions aOptions;
|
||||
+ aOptions.SetToken(UserOptToken::FirstName, OUString::fromUtf8(pValue));
|
||||
+ aOptions.SetToken(UserOptToken::LastName, OUString());
|
||||
+ }
|
||||
#ifdef LINUX
|
||||
else if (strcmp(pOption, "addfont") == 0)
|
||||
{
|
||||
@@ -0,0 +1,336 @@
|
||||
--- a/sc/sdi/scalc.sdi
|
||||
+++ b/sc/sdi/scalc.sdi
|
||||
@@ -1286,7 +1286,7 @@
|
||||
|
||||
|
||||
SfxVoidItem DefineName FID_DEFINE_NAME
|
||||
-(SfxStringItem Name FID_DEFINE_NAME,SfxStringItem Symbol FN_PARAM_1,SfxStringItem Options FN_PARAM_2)
|
||||
+(SfxStringItem Name FID_DEFINE_NAME,SfxStringItem Symbol FN_PARAM_1,SfxStringItem Options FN_PARAM_2,SfxStringItem Scope FN_PARAM_3)
|
||||
[
|
||||
AutoUpdate = FALSE,
|
||||
FastCall = FALSE,
|
||||
--- a/sc/source/filter/excel/excdoc.cxx
|
||||
+++ b/sc/source/filter/excel/excdoc.cxx
|
||||
@@ -82,11 +82,12 @@
|
||||
ScDocument& rDoc = self.GetDoc();
|
||||
|
||||
aRecList.AppendNewRecord( new XclExpXmlStartSingleElementRecord( XML_calcPr ) );
|
||||
- // OOXTODO: calcCompleted, calcId, calcMode, calcOnSave,
|
||||
+ // OOXTODO: calcCompleted, calcId, calcOnSave,
|
||||
// concurrentCalc, concurrentManualCount,
|
||||
// forceFullCalc, fullCalcOnLoad, fullPrecision
|
||||
aRecList.AppendNewRecord( new XclCalccount( rDoc ) );
|
||||
aRecList.AppendNewRecord( new XclRefmode( rDoc ) );
|
||||
+ aRecList.AppendNewRecord( new XclCalcMode( rDoc ) );
|
||||
aRecList.AppendNewRecord( new XclIteration( rDoc ) );
|
||||
aRecList.AppendNewRecord( new XclDelta( rDoc ) );
|
||||
aRecList.AppendNewRecord( new XclExpBoolRecord(oox::xls::BIFF_ID_SAVERECALC, true) );
|
||||
--- a/sc/source/filter/excel/excimp8.cxx
|
||||
+++ b/sc/source/filter/excel/excimp8.cxx
|
||||
@@ -163,6 +163,12 @@
|
||||
ScDocOptions aOpt = rD.GetDocOptions();
|
||||
aOpt.SetIterCount( aIn.ReaduInt16() );
|
||||
rD.SetDocOptions( aOpt );
|
||||
+}
|
||||
+
|
||||
+void ImportExcel8::Calcmode()
|
||||
+{
|
||||
+ // 0 manual; 1, or -1 (all but tables), automatic.
|
||||
+ rD.SetAutoCalc( aIn.ReaduInt16() != 0 );
|
||||
}
|
||||
|
||||
void ImportExcel8::Precision()
|
||||
--- a/sc/source/filter/excel/read.cxx
|
||||
+++ b/sc/source/filter/excel/read.cxx
|
||||
@@ -1184,6 +1184,7 @@
|
||||
case EXC_ID4_FORMULA: Formula25(); break;
|
||||
case EXC_ID_SHRFMLA: Shrfmla(); break;
|
||||
case 0x000C: Calccount(); break; // CALCCOUNT
|
||||
+ case 0x000D: Calcmode(); break; // CALCMODE
|
||||
case 0x0010: Delta(); break; // DELTA
|
||||
case 0x0011: Iteration(); break; // ITERATION
|
||||
case 0x007E:
|
||||
--- a/sc/source/filter/inc/excimp8.hxx
|
||||
+++ b/sc/source/filter/inc/excimp8.hxx
|
||||
@@ -36,6 +36,7 @@
|
||||
virtual ErrCode Read() override;
|
||||
|
||||
void Calccount(); // 0x0C
|
||||
+ void Calcmode(); // 0x0D
|
||||
void Precision(); // 0x0E
|
||||
void Delta(); // 0x10
|
||||
void Iteration(); // 0x11
|
||||
--- a/sc/source/filter/inc/xcl97rec.hxx
|
||||
+++ b/sc/source/filter/inc/xcl97rec.hxx
|
||||
@@ -506,6 +506,15 @@
|
||||
virtual void SaveXml( XclExpXmlStream& rStrm ) override;
|
||||
};
|
||||
|
||||
+/// Automatic or manual calculation.
|
||||
+class XclCalcMode : public XclExpBoolRecord
|
||||
+{
|
||||
+public:
|
||||
+ XclCalcMode( const ScDocument& );
|
||||
+
|
||||
+ virtual void SaveXml( XclExpXmlStream& rStrm ) override;
|
||||
+};
|
||||
+
|
||||
class XclExpFileEncryption : public XclExpRecord
|
||||
{
|
||||
public:
|
||||
--- a/sc/source/filter/xcl97/xcl97rec.cxx
|
||||
+++ b/sc/source/filter/xcl97/xcl97rec.cxx
|
||||
@@ -2045,6 +2045,16 @@
|
||||
void XclRefmode::SaveXml( XclExpXmlStream& rStrm )
|
||||
{
|
||||
rStrm.WriteAttributes(XML_refMode, GetBool() ? "A1" : "R1C1");
|
||||
+}
|
||||
+
|
||||
+XclCalcMode::XclCalcMode( const ScDocument& rDoc ) :
|
||||
+ XclExpBoolRecord( 0x000D, rDoc.GetAutoCalc() )
|
||||
+{
|
||||
+}
|
||||
+
|
||||
+void XclCalcMode::SaveXml( XclExpXmlStream& rStrm )
|
||||
+{
|
||||
+ rStrm.WriteAttributes(XML_calcMode, GetBool() ? "auto" : "manual");
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
--- a/sc/source/ui/app/inputhdl.cxx
|
||||
+++ b/sc/source/ui/app/inputhdl.cxx
|
||||
@@ -1767,7 +1767,7 @@
|
||||
HideTip();
|
||||
|
||||
EditView* pActiveView = pTopView ? pTopView : pTableView;
|
||||
- if (comphelper::LibreOfficeKit::isActive() && pTopView && pInputWin)
|
||||
+ if (comphelper::LibreOfficeKit::isActive() && pTopView && pInputWin && eMode == SC_INPUT_TOP)
|
||||
pInputWin->TextGrabFocus();
|
||||
if (pActiveView)
|
||||
pActiveView->ShowCursor();
|
||||
@@ -1776,7 +1776,7 @@
|
||||
void ScInputHandler::LOKPasteFunctionData(const OUString& rFunctionName)
|
||||
{
|
||||
// in case we have no top view try to create it
|
||||
- if (!pTopView && pInputWin)
|
||||
+ if (!pTopView && pInputWin && eMode == SC_INPUT_NONE)
|
||||
{
|
||||
ScInputMode eCurMode = eMode;
|
||||
SetMode(SC_INPUT_TOP);
|
||||
@@ -3527,6 +3527,10 @@
|
||||
|
||||
HideTip();
|
||||
HideTipBelow();
|
||||
+
|
||||
+ // As CancelHandler: the entered formula's marks go.
|
||||
+ if (comphelper::LibreOfficeKit::isActive() && pActiveViewSh)
|
||||
+ ScInputHandler::SendReferenceMarks(pActiveViewSh, std::vector<ReferenceMark>());
|
||||
|
||||
nFormSelStart = nFormSelEnd = 0;
|
||||
aFormText.clear();
|
||||
--- a/sc/source/ui/unoobj/docuno.cxx
|
||||
+++ b/sc/source/ui/unoobj/docuno.cxx
|
||||
@@ -678,18 +678,104 @@
|
||||
formula::FormulaTokenArrayPlainIterator aIter(rCode);
|
||||
for (const formula::FormulaToken* pToken = aIter.First(); pToken; pToken = aIter.Next())
|
||||
if (pToken->GetOpCode() == ocIndirect)
|
||||
+ return true;
|
||||
+ return false;
|
||||
+}
|
||||
+
|
||||
+/// Whether rCode lost a reference or holds an error.
|
||||
+bool lcl_IsBroken(const ScTokenArray& rCode)
|
||||
+{
|
||||
+ formula::FormulaTokenArrayPlainIterator aIter(rCode);
|
||||
+ for (const formula::FormulaToken* pToken = aIter.First(); pToken; pToken = aIter.Next())
|
||||
+ {
|
||||
+ if (pToken->GetType() == formula::svError || pToken->GetOpCode() == ocBad)
|
||||
+ return true;
|
||||
+ if (pToken->GetType() == formula::svSingleRef && pToken->GetSingleRef()->IsDeleted())
|
||||
return true;
|
||||
+ if (pToken->GetType() == formula::svDoubleRef
|
||||
+ && (pToken->GetDoubleRef()->Ref1.IsDeleted() || pToken->GetDoubleRef()->Ref2.IsDeleted()))
|
||||
+ return true;
|
||||
+ }
|
||||
return false;
|
||||
+}
|
||||
+
|
||||
+/// Every named range: name, scope, formula, and whether it broke.
|
||||
+void lcl_DefinedNames(tools::JsonWriter& rJsonWriter, ScDocument& rDoc)
|
||||
+{
|
||||
+ rJsonWriter.put("commandName", ".uno:DefinedNames");
|
||||
+ auto aNames = rJsonWriter.startArray("names");
|
||||
+ auto aPut = [&rJsonWriter, &rDoc](const ScRangeName* pNames, const OUString& rScope) {
|
||||
+ if (!pNames)
|
||||
+ return;
|
||||
+ for (const auto& [rKey, pData] : *pNames)
|
||||
+ {
|
||||
+ auto aName = rJsonWriter.startStruct();
|
||||
+ rJsonWriter.put("name", pData->GetName());
|
||||
+ rJsonWriter.put("scope", rScope);
|
||||
+ rJsonWriter.put("formula", pData->GetSymbol(rDoc.GetGrammar()));
|
||||
+ // The absolute range it names, if it is one.
|
||||
+ ScRange aRange;
|
||||
+ OUString aTarget;
|
||||
+ const ScAddress::Details aDetails(rDoc.GetAddressConvention(), 0, 0);
|
||||
+ if (pData->IsValidReference(aRange))
|
||||
+ aTarget = aRange.aStart == aRange.aEnd
|
||||
+ ? aRange.aStart.Format(ScRefFlags::ADDR_ABS_3D, &rDoc, aDetails)
|
||||
+ : aRange.Format(rDoc, ScRefFlags::RANGE_ABS_3D, aDetails);
|
||||
+ rJsonWriter.put("range", aTarget);
|
||||
+ rJsonWriter.put("broken", pData->GetErrCode() != FormulaError::NONE
|
||||
+ || (pData->GetCode() && lcl_IsBroken(*pData->GetCode())));
|
||||
+ }
|
||||
+ };
|
||||
+ aPut(rDoc.GetRangeName(), OUString());
|
||||
+ for (SCTAB nTab = 0; nTab < rDoc.GetTableCount(); ++nTab)
|
||||
+ {
|
||||
+ OUString aSheet;
|
||||
+ rDoc.GetName(nTab, aSheet);
|
||||
+ aPut(rDoc.GetRangeName(nTab), aSheet);
|
||||
+ }
|
||||
}
|
||||
}
|
||||
|
||||
bool ScModelObj::supportsCommand(std::u16string_view rCommand)
|
||||
{
|
||||
- return rCommand == u"SheetReferences";
|
||||
+ return rCommand == u"SheetReferences" || rCommand == u"DefinedNames"
|
||||
+ || rCommand == u"SelectedRange";
|
||||
}
|
||||
|
||||
void ScModelObj::getCommandValues(tools::JsonWriter& rJsonWriter, std::string_view rCommand)
|
||||
{
|
||||
+ if (pDocShell && rCommand == ".uno:DefinedNames")
|
||||
+ return lcl_DefinedNames(rJsonWriter, pDocShell->GetDocument());
|
||||
+ if (pDocShell && rCommand == ".uno:SelectedRange")
|
||||
+ {
|
||||
+ // The one selected range, absolute; empty for several.
|
||||
+ ScViewData* pViewData = ScDocShell::GetViewData();
|
||||
+ ScRange aRange;
|
||||
+ OUString aTarget;
|
||||
+ ScDocument& rDoc = pDocShell->GetDocument();
|
||||
+ const ScAddress::Details aDetails(rDoc.GetAddressConvention(), 0, 0);
|
||||
+ if (pViewData && pViewData->GetSimpleArea(aRange) == SC_MARK_SIMPLE)
|
||||
+ aTarget = aRange.aStart == aRange.aEnd
|
||||
+ ? aRange.aStart.Format(ScRefFlags::ADDR_ABS_3D, &rDoc, aDetails)
|
||||
+ : aRange.Format(rDoc, ScRefFlags::RANGE_ABS_3D, aDetails);
|
||||
+ rJsonWriter.put("commandName", ".uno:SelectedRange");
|
||||
+ rJsonWriter.put("range", aTarget);
|
||||
+ return;
|
||||
+ }
|
||||
+ if (pDocShell && o3tl::starts_with(rCommand, ".uno:DefinedNames?"))
|
||||
+ {
|
||||
+ // Whether a name would take, else why not.
|
||||
+ std::map<OUString, OUString> aMap
|
||||
+ = SfxLokHelper::parseCommandParameters(OUString::fromUtf8(rCommand));
|
||||
+ const ScRangeData::IsNameValidType eName
|
||||
+ = ScRangeData::IsNameValid(aMap[u"name"_ustr], pDocShell->GetDocument());
|
||||
+ rJsonWriter.put("commandName", ".uno:DefinedNames");
|
||||
+ rJsonWriter.put("name", eName == ScRangeData::IsNameValidType::NAME_VALID ? "valid"
|
||||
+ : eName == ScRangeData::IsNameValidType::NAME_INVALID_CELL_REF
|
||||
+ ? "address"
|
||||
+ : "characters");
|
||||
+ return;
|
||||
+ }
|
||||
if (!pDocShell || !o3tl::starts_with(rCommand, ".uno:SheetReferences"))
|
||||
return;
|
||||
std::map<OUString, OUString> aMap
|
||||
--- a/sc/source/ui/view/cellsh1.cxx
|
||||
+++ b/sc/source/ui/view/cellsh1.cxx
|
||||
@@ -67,6 +67,8 @@
|
||||
#include <transobj.hxx>
|
||||
#include <drwtrans.hxx>
|
||||
#include <docfunc.hxx>
|
||||
+#include <globalnames.hxx>
|
||||
+#include <rangenam.hxx>
|
||||
#include <editable.hxx>
|
||||
#include <dpobject.hxx>
|
||||
#include <dpsave.hxx>
|
||||
@@ -109,6 +111,42 @@
|
||||
using namespace ::com::sun::star::uno;
|
||||
|
||||
namespace{
|
||||
+/// Sets a name; an empty rSymbol removes it.
|
||||
+bool lcl_DefineName(ScDocShell& rDocSh, const ScAddress& rPos, const OUString& rName,
|
||||
+ const OUString& rSymbol, const OUString& rScope)
|
||||
+{
|
||||
+ ScDocument& rDoc = rDocSh.GetDocument();
|
||||
+ SCTAB nScope = -1;
|
||||
+ if (!rScope.isEmpty() && !rDoc.GetTable(rScope, nScope))
|
||||
+ return false;
|
||||
+ std::map<OUString, ScRangeName*> aOld;
|
||||
+ rDoc.GetRangeNameMap(aOld);
|
||||
+ std::map<OUString, ScRangeName> aNew;
|
||||
+ for (const auto& [rKey, pNames] : aOld)
|
||||
+ aNew.emplace(rKey, *pNames);
|
||||
+ ScRangeName& rList = aNew[rScope.isEmpty() ? STR_GLOBAL_RANGE_NAME : rScope];
|
||||
+ const ScRangeData* pOld = rList.findByUpperName(ScGlobal::getCharClass().uppercase(rName));
|
||||
+ const sal_uInt16 nIndex = pOld ? pOld->GetIndex() : 0;
|
||||
+ if (pOld)
|
||||
+ rList.erase(*pOld);
|
||||
+ else if (rSymbol.isEmpty())
|
||||
+ return false;
|
||||
+ if (!rSymbol.isEmpty())
|
||||
+ {
|
||||
+ if (ScRangeData::IsNameValid(rName, rDoc) != ScRangeData::IsNameValidType::NAME_VALID)
|
||||
+ return false;
|
||||
+ std::unique_ptr<ScRangeData> pNew(new ScRangeData(
|
||||
+ rDoc, rName, rSymbol, rPos, ScRangeData::Type::Name, rDoc.GetGrammar()));
|
||||
+ if (pNew->GetErrCode() != FormulaError::NONE)
|
||||
+ return false;
|
||||
+ pNew->SetIndex(nIndex);
|
||||
+ if (!rList.insert(pNew.release(), false))
|
||||
+ return false;
|
||||
+ }
|
||||
+ rDocSh.GetDocFunc().ModifyAllRangeNames(aNew);
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
InsertDeleteFlags FlagsFromString(const OUString& rFlagsStr,
|
||||
InsertDeleteFlags nFlagsMask = InsertDeleteFlags::CONTENTS | InsertDeleteFlags::ATTRIB)
|
||||
{
|
||||
@@ -2249,7 +2287,17 @@
|
||||
if( pReqArgs->HasItem( FN_PARAM_2, &pItem ) )
|
||||
aAttrib = static_cast<const SfxStringItem*>(pItem)->GetValue();
|
||||
|
||||
- if ( !aName.isEmpty() && !aSymbol.isEmpty() )
|
||||
+ if (comphelper::LibreOfficeKit::isActive() && !aName.isEmpty())
|
||||
+ {
|
||||
+ OUString aScope;
|
||||
+ if (pReqArgs->HasItem(FN_PARAM_3, &pItem))
|
||||
+ aScope = static_cast<const SfxStringItem*>(pItem)->GetValue();
|
||||
+ const ScAddress aPos(GetViewData().GetCurX(), GetViewData().GetCurY(),
|
||||
+ GetViewData().CurrentTabForData());
|
||||
+ if (lcl_DefineName(*GetViewData().GetDocShell(), aPos, aName, aSymbol, aScope))
|
||||
+ rReq.Done();
|
||||
+ }
|
||||
+ else if ( !aName.isEmpty() && !aSymbol.isEmpty() )
|
||||
{
|
||||
if (pTabViewShell->InsertName( aName, aSymbol, aAttrib ))
|
||||
rReq.Done();
|
||||
--- a/sc/source/ui/view/viewfunc.cxx
|
||||
+++ b/sc/source/ui/view/viewfunc.cxx
|
||||
@@ -630,6 +630,12 @@
|
||||
: context->aComp->GetCorrectedFormula();
|
||||
if (context->aCorrectedFormula.getLength() == 1) {
|
||||
// empty formula, just '='
|
||||
+ if (context->pArrFirst)
|
||||
+ context->pArr = context->pArrFirst;
|
||||
+ }
|
||||
+ else if (comphelper::LibreOfficeKit::isActive())
|
||||
+ {
|
||||
+ // No query: the formula enters as typed.
|
||||
if (context->pArrFirst)
|
||||
context->pArr = context->pArrFirst;
|
||||
}
|
||||
--- a/sfx2/source/control/unoctitm.cxx
|
||||
+++ b/sfx2/source/control/unoctitm.cxx
|
||||
@@ -1499,6 +1499,7 @@
|
||||
{ u"ToggleMergeCells", { PayloadType::BooleanOrDisabledPayload, true } },
|
||||
{ u"SheetRightToLeft", { PayloadType::BooleanOrDisabledPayload, true } },
|
||||
{ u"ToggleSheetGrid", { PayloadType::BooleanOrDisabledPayload, true } },
|
||||
+ { u"AutomaticCalculation", { PayloadType::BooleanPayload, true } },
|
||||
{ u"EditDoc", { PayloadType::BooleanOrDisabledPayload, true } },
|
||||
|
||||
{ u"Position", { PayloadType::PointPayload, false } },
|
||||
@@ -0,0 +1,13 @@
|
||||
--- a/vcl/osx/salinst.cxx
|
||||
+++ b/vcl/osx/salinst.cxx
|
||||
@@ -657,7 +657,9 @@
|
||||
// window is in live resize
|
||||
bool bOldIsWaitingForNativeEvent = ImplGetSVData()->mpWinData->mbIsWaitingForNativeEvent;
|
||||
ImplGetSVData()->mpWinData->mbIsWaitingForNativeEvent = !o3tl::IsRunningUnitTest();
|
||||
- if( bWait && ! bHadEvent && !ImplGetSVData()->mpWinData->mbIsLiveResize )
|
||||
+ // A due timer would never wake the native wait.
|
||||
+ const bool bTimerDue = pTimer && pTimer->IsDirectTimeout();
|
||||
+ if( bWait && ! bHadEvent && !bTimerDue && !ImplGetSVData()->mpWinData->mbIsLiveResize )
|
||||
{
|
||||
SolarMutexReleaser aReleaser;
|
||||
|
||||
@@ -0,0 +1,234 @@
|
||||
diff --git a/sc/sdi/scalc.sdi b/sc/sdi/scalc.sdi
|
||||
index 7be957b89..e49325020 100644
|
||||
--- a/sc/sdi/scalc.sdi
|
||||
+++ b/sc/sdi/scalc.sdi
|
||||
@@ -735,7 +735,7 @@ SfxVoidItem ConditionalFormatConditionMenu SID_POPUP_EASY_CONDITIONAL_FORMAT
|
||||
]
|
||||
|
||||
SfxVoidItem ConditionalFormatEasy SID_EASY_CONDITIONAL_FORMAT_DIALOG
|
||||
-(SfxInt16Item FormatRule FN_PARAM_1)
|
||||
+(SfxInt16Item FormatRule FN_PARAM_1,SfxStringItem Rule FN_PARAM_2)
|
||||
[
|
||||
AutoUpdate = FALSE,
|
||||
FastCall = FALSE,
|
||||
@@ -1106,7 +1106,7 @@ SfxVoidItem DataFilterSpecialFilter SID_SPECIAL_FILTER
|
||||
|
||||
|
||||
SfxVoidItem DataFilterStandardFilter SID_FILTER
|
||||
-()
|
||||
+(SfxStringItem Query FN_PARAM_1)
|
||||
[
|
||||
AutoUpdate = FALSE,
|
||||
FastCall = FALSE,
|
||||
@@ -3852,6 +3852,7 @@ SfxVoidItem DeleteNote SID_DELETE_NOTE
|
||||
|
||||
|
||||
SfxStringItem NumberFormat SID_NUMBER_FORMAT
|
||||
+(SfxStringItem NumberFormat SID_NUMBER_FORMAT,SfxStringItem FormatCode FN_PARAM_1)
|
||||
|
||||
[
|
||||
AutoUpdate = FALSE,
|
||||
@@ -5736,7 +5737,7 @@ SfxVoidItem AssignMacro SID_ASSIGNMACRO
|
||||
|
||||
|
||||
SfxVoidItem TextToColumns SID_TEXT_TO_COLUMNS
|
||||
-()
|
||||
+(SfxStringItem Options FN_PARAM_1)
|
||||
[
|
||||
AutoUpdate = FALSE,
|
||||
FastCall = FALSE,
|
||||
@@ -5958,7 +5959,7 @@ SfxVoidItem UpdateTableLinks SID_UPDATETABLINKS
|
||||
|
||||
|
||||
SfxVoidItem Validation FID_VALIDATION
|
||||
-()
|
||||
+(SfxStringItem Rule FN_PARAM_1)
|
||||
[
|
||||
AutoUpdate = FALSE,
|
||||
FastCall = FALSE,
|
||||
diff --git a/sc/sdi/cellsh.sdi b/sc/sdi/cellsh.sdi
|
||||
index 0f16536d1..005e4a2f6 100644
|
||||
--- a/sc/sdi/cellsh.sdi
|
||||
+++ b/sc/sdi/cellsh.sdi
|
||||
@@ -220,7 +220,8 @@ interface CellSelection
|
||||
SID_POPUP_EASY_CONDITIONAL_FORMAT []
|
||||
SfxVoidItem ConditionalFormatEasy SID_EASY_CONDITIONAL_FORMAT_DIALOG
|
||||
(
|
||||
- SfxInt16Item FormatRule FN_PARAM_1
|
||||
+ SfxInt16Item FormatRule FN_PARAM_1,
|
||||
+ SfxStringItem Rule FN_PARAM_2
|
||||
)
|
||||
[
|
||||
ExecMethod = Execute;
|
||||
diff --git a/sc/source/ui/view/formatsh.cxx b/sc/source/ui/view/formatsh.cxx
|
||||
index e395b01d2..e2a6202d8 100644
|
||||
--- a/sc/source/ui/view/formatsh.cxx
|
||||
+++ b/sc/source/ui/view/formatsh.cxx
|
||||
@@ -410,6 +410,14 @@ void ScFormatShell::ExecuteNumFormat( SfxRequest& rReq )
|
||||
// symphony version with format interpretation
|
||||
if(pReqArgs)
|
||||
{
|
||||
+ // A format code as is, from the kit client.
|
||||
+ const SfxPoolItem* pCode = nullptr;
|
||||
+ if (pReqArgs->GetItemState(FN_PARAM_1, true, &pCode) == SfxItemState::SET)
|
||||
+ {
|
||||
+ pTabViewShell->SetNumFmtByStr(static_cast<const SfxStringItem*>(pCode)->GetValue());
|
||||
+ rReq.Done();
|
||||
+ break;
|
||||
+ }
|
||||
const SfxPoolItem* pItem;
|
||||
ScDocument& rDoc = rViewData.GetDocument();
|
||||
SvNumberFormatter* pFormatter = rDoc.GetFormatTable();
|
||||
diff --git a/sc/source/ui/view/cellsh3.cxx b/sc/source/ui/view/cellsh3.cxx
|
||||
index a758333f7..32c4f3fef 100644
|
||||
--- a/sc/source/ui/view/cellsh3.cxx
|
||||
+++ b/sc/source/ui/view/cellsh3.cxx
|
||||
@@ -50,6 +50,13 @@
|
||||
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
|
||||
#include <inputwin.hxx>
|
||||
#include <officecfg/Office/Calc.hxx>
|
||||
+#include <colorscale.hxx>
|
||||
+#include <stlpool.hxx>
|
||||
+#include <conditio.hxx>
|
||||
+#include <docfunc.hxx>
|
||||
+#include <docsh.hxx>
|
||||
+#include <rangelst.hxx>
|
||||
+#include <boost/property_tree/json_parser.hpp>
|
||||
|
||||
#include <memory>
|
||||
|
||||
@@ -152,6 +159,118 @@ void lcl_lokGetWholeFunctionList()
|
||||
|
||||
} // end namespace
|
||||
|
||||
+
|
||||
+namespace
|
||||
+{
|
||||
+/// A "#RRGGBB" text as a color.
|
||||
+Color lcl_Color(const std::string& rText)
|
||||
+{
|
||||
+ return Color(ColorTransparency, OUString::fromUtf8(rText).copy(1).toUInt32(16));
|
||||
+}
|
||||
+
|
||||
+/// Adds or removes the conditional format a kit client describes.
|
||||
+bool lcl_ConditionalFormat(ScViewData& rData, const OUString& rRule)
|
||||
+{
|
||||
+ boost::property_tree::ptree aRule;
|
||||
+ std::stringstream aStream{ std::string(rRule.toUtf8()) };
|
||||
+ try
|
||||
+ {
|
||||
+ boost::property_tree::read_json(aStream, aRule);
|
||||
+ }
|
||||
+ catch (const boost::property_tree::json_parser_error&)
|
||||
+ {
|
||||
+ return false;
|
||||
+ }
|
||||
+ ScDocument& rDoc = rData.GetDocument();
|
||||
+ ScDocFunc& rFunc = rData.GetDocShell()->GetDocFunc();
|
||||
+ const SCTAB nTab = rData.CurrentTabForData();
|
||||
+ if (const auto oKey = aRule.get_optional<sal_uInt32>("remove"))
|
||||
+ {
|
||||
+ ScConditionalFormatList* pList = rDoc.GetCondFormList(nTab);
|
||||
+ ScConditionalFormat* pOld = pList ? pList->GetFormat(*oKey) : nullptr;
|
||||
+ if (!pOld)
|
||||
+ return false;
|
||||
+ const ScRangeList aOldRange = pOld->GetRange();
|
||||
+ rFunc.ReplaceConditionalFormat(*oKey, nullptr, nTab, aOldRange);
|
||||
+ return true;
|
||||
+ }
|
||||
+ ScRangeList aRanges;
|
||||
+ ScMarkData aMark(rData.GetMarkData());
|
||||
+ aMark.MarkToMulti();
|
||||
+ aMark.FillRangeListWithMarks(&aRanges, false, nTab);
|
||||
+ if (aRanges.empty())
|
||||
+ aRanges.push_back(ScRange(rData.GetCurX(), rData.GetCurY(), nTab));
|
||||
+ const ScAddress aPos = aRanges.GetTopLeftCorner();
|
||||
+ auto pFormat = std::make_unique<ScConditionalFormat>(0, rDoc);
|
||||
+ const std::string aKind = aRule.get<std::string>("kind", "");
|
||||
+ if (aKind == "cell")
|
||||
+ {
|
||||
+ static const std::pair<std::string_view, ScConditionMode> aModes[]
|
||||
+ = { { "equal", ScConditionMode::Equal },
|
||||
+ { "notequal", ScConditionMode::NotEqual },
|
||||
+ { "less", ScConditionMode::Less },
|
||||
+ { "lessequal", ScConditionMode::EqLess },
|
||||
+ { "greater", ScConditionMode::Greater },
|
||||
+ { "greaterequal", ScConditionMode::EqGreater },
|
||||
+ { "between", ScConditionMode::Between },
|
||||
+ { "notbetween", ScConditionMode::NotBetween },
|
||||
+ { "duplicate", ScConditionMode::Duplicate },
|
||||
+ { "unique", ScConditionMode::NotDuplicate },
|
||||
+ { "top10", ScConditionMode::Top10 },
|
||||
+ { "bottom10", ScConditionMode::Bottom10 },
|
||||
+ { "aboveaverage", ScConditionMode::AboveAverage },
|
||||
+ { "belowaverage", ScConditionMode::BelowAverage },
|
||||
+ { "error", ScConditionMode::Error },
|
||||
+ { "contains", ScConditionMode::ContainsText },
|
||||
+ { "beginswith", ScConditionMode::BeginsWith },
|
||||
+ { "endswith", ScConditionMode::EndsWith } };
|
||||
+ const std::string aOp = aRule.get<std::string>("operator", "");
|
||||
+ const auto pMode = std::find_if(std::begin(aModes), std::end(aModes),
|
||||
+ [&aOp](const auto& rPair) { return rPair.first == aOp; });
|
||||
+ const OUString aStyle = OUString::fromUtf8(aRule.get<std::string>("style", ""));
|
||||
+ if (pMode == std::end(aModes) || !rDoc.GetStyleSheetPool()->Find(aStyle, SfxStyleFamily::Para))
|
||||
+ return false;
|
||||
+ OUString aExpr1 = OUString::fromUtf8(aRule.get<std::string>("value1", ""));
|
||||
+ OUString aExpr2 = OUString::fromUtf8(aRule.get<std::string>("value2", ""));
|
||||
+ // Text conditions compare strings, as the dialog does.
|
||||
+ if (pMode->second == ScConditionMode::ContainsText || pMode->second == ScConditionMode::BeginsWith
|
||||
+ || pMode->second == ScConditionMode::EndsWith)
|
||||
+ aExpr1 = "\"" + aExpr1.replaceAll("\"", "\"\"") + "\"";
|
||||
+ pFormat->AddEntry(new ScCondFormatEntry(pMode->second, aExpr1, aExpr2, rDoc, aPos, aStyle));
|
||||
+ }
|
||||
+ else if (aKind == "scale")
|
||||
+ {
|
||||
+ std::vector<Color> aColors;
|
||||
+ if (const auto oColors = aRule.get_child_optional("colors"))
|
||||
+ for (const auto& rColor : *oColors)
|
||||
+ aColors.push_back(lcl_Color(rColor.second.data()));
|
||||
+ if (aColors.size() != 2 && aColors.size() != 3)
|
||||
+ return false;
|
||||
+ auto* pScale = new ScColorScaleFormat(rDoc);
|
||||
+ pScale->AddEntry(new ScColorScaleEntry(0, aColors.front(), COLORSCALE_MIN));
|
||||
+ if (aColors.size() == 3)
|
||||
+ pScale->AddEntry(new ScColorScaleEntry(50, aColors[1], COLORSCALE_PERCENTILE));
|
||||
+ pScale->AddEntry(new ScColorScaleEntry(0, aColors.back(), COLORSCALE_MAX));
|
||||
+ pFormat->AddEntry(pScale);
|
||||
+ }
|
||||
+ else if (aKind == "databar")
|
||||
+ {
|
||||
+ auto* pBar = new ScDataBarFormat(rDoc);
|
||||
+ auto* pData = new ScDataBarFormatData();
|
||||
+ pData->maPositiveColor = lcl_Color(aRule.get<std::string>("color", "#638EC6"));
|
||||
+ pData->mpLowerLimit.reset(new ScColorScaleEntry(0, COL_BLACK, COLORSCALE_AUTO));
|
||||
+ pData->mpUpperLimit.reset(new ScColorScaleEntry(0, COL_BLACK, COLORSCALE_AUTO));
|
||||
+ pBar->SetDataBarData(pData);
|
||||
+ pFormat->AddEntry(pBar);
|
||||
+ }
|
||||
+ else
|
||||
+ return false;
|
||||
+ pFormat->SetRange(aRanges);
|
||||
+ rFunc.ReplaceConditionalFormat(0, std::move(pFormat), nTab, aRanges);
|
||||
+ return true;
|
||||
+}
|
||||
+}
|
||||
+
|
||||
void ScCellShell::Execute( SfxRequest& rReq )
|
||||
{
|
||||
ScTabViewShell* pTabViewShell = GetViewData().GetViewShell();
|
||||
@@ -447,7 +566,14 @@ void ScCellShell::Execute( SfxRequest& rReq )
|
||||
|
||||
case SID_EASY_CONDITIONAL_FORMAT_DIALOG:
|
||||
{
|
||||
- if (pReqArgs != nullptr)
|
||||
+ const SfxPoolItem* pRule = nullptr;
|
||||
+ if (pReqArgs && pReqArgs->GetItemState(FN_PARAM_2, true, &pRule) == SfxItemState::SET)
|
||||
+ {
|
||||
+ // The kit client's rule; no dialog.
|
||||
+ if (lcl_ConditionalFormat(GetViewData(), static_cast<const SfxStringItem*>(pRule)->GetValue()))
|
||||
+ rReq.Done();
|
||||
+ }
|
||||
+ else if (pReqArgs != nullptr)
|
||||
{
|
||||
const SfxPoolItem* pFormat;
|
||||
if (pReqArgs->HasItem( FN_PARAM_1, &pFormat))
|
||||
@@ -0,0 +1,298 @@
|
||||
diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx
|
||||
index 57a40c6d0..5dd6e0793 100644
|
||||
--- a/sc/source/ui/view/cellsh2.cxx
|
||||
+++ b/sc/source/ui/view/cellsh2.cxx
|
||||
@@ -63,6 +63,12 @@
|
||||
#include <datastreamdlg.hxx>
|
||||
#include <dataproviderdlg.hxx>
|
||||
#include <queryentry.hxx>
|
||||
+#include <filterentries.hxx>
|
||||
+#include <svl/sharedstringpool.hxx>
|
||||
+#include <compiler.hxx>
|
||||
+#include <rtl/math.hxx>
|
||||
+#include <boost/property_tree/json_parser.hpp>
|
||||
+#include <com/sun/star/sheet/TableValidationVisibility.hpp>
|
||||
#include <markdata.hxx>
|
||||
#include <documentlinkmgr.hxx>
|
||||
#include <officecfg/Office/Common.hxx>
|
||||
@@ -225,6 +231,226 @@ namespace
|
||||
};
|
||||
}
|
||||
|
||||
+
|
||||
+namespace
|
||||
+{
|
||||
+/// The JSON argument `nWhich` of `rReq`, read into `rTree`.
|
||||
+bool lcl_JsonArg(const SfxRequest& rReq, sal_uInt16 nWhich, boost::property_tree::ptree& rTree)
|
||||
+{
|
||||
+ const SfxItemSet* pArgs = rReq.GetArgs();
|
||||
+ const SfxPoolItem* pItem = nullptr;
|
||||
+ if (!pArgs || pArgs->GetItemState(nWhich, true, &pItem) != SfxItemState::SET)
|
||||
+ return false;
|
||||
+ std::stringstream aStream(
|
||||
+ std::string(static_cast<const SfxStringItem*>(pItem)->GetValue().toUtf8()));
|
||||
+ try
|
||||
+ {
|
||||
+ boost::property_tree::read_json(aStream, rTree);
|
||||
+ }
|
||||
+ catch (const boost::property_tree::json_parser_error&)
|
||||
+ {
|
||||
+ return false;
|
||||
+ }
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
+OUString lcl_Text(const boost::property_tree::ptree& rTree, const char* pKey)
|
||||
+{
|
||||
+ return OUString::fromUtf8(rTree.get<std::string>(pKey, ""));
|
||||
+}
|
||||
+
|
||||
+/// A typed date or time, as the dialog stores it.
|
||||
+OUString lcl_Moment(ScDocument& rDoc, const OUString& rText)
|
||||
+{
|
||||
+ sal_uInt32 nIndex = 0;
|
||||
+ double fValue;
|
||||
+ if (!rDoc.GetFormatTable()->IsNumberFormat(rText, nIndex, fValue))
|
||||
+ return rText;
|
||||
+ return rtl::math::doubleToUString(fValue, rtl_math_StringFormat_Automatic,
|
||||
+ rtl_math_DecimalPlaces_Max,
|
||||
+ ScGlobal::getLocaleData().getNumDecimalSep()[0], true);
|
||||
+}
|
||||
+
|
||||
+/// Sets the validation a kit client describes on the selection.
|
||||
+bool lcl_SetValidation(ScTabViewShell& rView, ScViewData& rData,
|
||||
+ const boost::property_tree::ptree& rRule)
|
||||
+{
|
||||
+ static const std::pair<std::string_view, ScValidationMode> aModes[]
|
||||
+ = { { "any", SC_VALID_ANY }, { "whole", SC_VALID_WHOLE },
|
||||
+ { "decimal", SC_VALID_DECIMAL }, { "date", SC_VALID_DATE },
|
||||
+ { "time", SC_VALID_TIME }, { "textlength", SC_VALID_TEXTLEN },
|
||||
+ { "list", SC_VALID_LIST }, { "custom", SC_VALID_CUSTOM } };
|
||||
+ static const std::pair<std::string_view, ScConditionMode> aOperators[]
|
||||
+ = { { "equal", ScConditionMode::Equal },
|
||||
+ { "notequal", ScConditionMode::NotEqual },
|
||||
+ { "less", ScConditionMode::Less },
|
||||
+ { "lessequal", ScConditionMode::EqLess },
|
||||
+ { "greater", ScConditionMode::Greater },
|
||||
+ { "greaterequal", ScConditionMode::EqGreater },
|
||||
+ { "between", ScConditionMode::Between },
|
||||
+ { "notbetween", ScConditionMode::NotBetween } };
|
||||
+ static const std::pair<std::string_view, ScValidErrorStyle> aStyles[]
|
||||
+ = { { "stop", SC_VALERR_STOP },
|
||||
+ { "warning", SC_VALERR_WARNING },
|
||||
+ { "info", SC_VALERR_INFO } };
|
||||
+ auto find = [](const auto& rTable, const std::string& rKey) {
|
||||
+ return std::find_if(std::begin(rTable), std::end(rTable),
|
||||
+ [&rKey](const auto& rPair) { return rPair.first == rKey; });
|
||||
+ };
|
||||
+ const auto pMode = find(aModes, rRule.get<std::string>("type", "any"));
|
||||
+ const auto pOperator = find(aOperators, rRule.get<std::string>("operator", "equal"));
|
||||
+ const auto pStyle = find(aStyles, rRule.get<std::string>("errorStyle", "stop"));
|
||||
+ if (pMode == std::end(aModes) || pOperator == std::end(aOperators)
|
||||
+ || pStyle == std::end(aStyles))
|
||||
+ return false;
|
||||
+ ScDocument& rDoc = rData.GetDocument();
|
||||
+ OUString aExpr1 = lcl_Text(rRule, "value1");
|
||||
+ OUString aExpr2 = lcl_Text(rRule, "value2");
|
||||
+ if (pMode->second == SC_VALID_DATE || pMode->second == SC_VALID_TIME)
|
||||
+ {
|
||||
+ aExpr1 = lcl_Moment(rDoc, aExpr1);
|
||||
+ aExpr2 = lcl_Moment(rDoc, aExpr2);
|
||||
+ }
|
||||
+ if (const auto oList = rRule.get_child_optional("list"); oList && !oList->empty())
|
||||
+ {
|
||||
+ // Entries as the dialog writes them: quoted, separated.
|
||||
+ OUStringBuffer aList;
|
||||
+ for (const auto& rEntry : *oList)
|
||||
+ {
|
||||
+ if (!aList.isEmpty())
|
||||
+ aList.append(ScCompiler::GetNativeSymbol(ocSep));
|
||||
+ aList.append("\"" + OUString::fromUtf8(rEntry.second.data()).replaceAll("\"", "\"\"")
|
||||
+ + "\"");
|
||||
+ }
|
||||
+ aExpr1 = aList.makeStringAndClear();
|
||||
+ }
|
||||
+ const ScAddress aPos(rData.GetCurX(), rData.GetCurY(), rData.CurrentTabForData());
|
||||
+ ScValidationData aData(pMode->second, pOperator->second, aExpr1, aExpr2, rDoc, aPos);
|
||||
+ aData.SetIgnoreBlank(rRule.get<bool>("ignoreBlank", true));
|
||||
+ aData.SetListType(rRule.get<bool>("dropdown", true)
|
||||
+ ? css::sheet::TableValidationVisibility::UNSORTED
|
||||
+ : css::sheet::TableValidationVisibility::INVISIBLE);
|
||||
+ aData.SetInput(lcl_Text(rRule, "inputTitle"), lcl_Text(rRule, "inputMessage"));
|
||||
+ if (!rRule.get<bool>("showInput", false))
|
||||
+ aData.ResetInput();
|
||||
+ aData.SetError(lcl_Text(rRule, "errorTitle"), lcl_Text(rRule, "errorMessage"),
|
||||
+ pStyle->second);
|
||||
+ if (!rRule.get<bool>("showError", false))
|
||||
+ aData.ResetError();
|
||||
+ rView.SetValidation(aData);
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
+/// One query item from a value typed as text.
|
||||
+void lcl_SetItem(ScDocument& rDoc, ScQueryEntry::Item& rItem, const OUString& rText)
|
||||
+{
|
||||
+ sal_uInt32 nIndex = 0;
|
||||
+ double fValue;
|
||||
+ rItem.maString = rDoc.GetSharedStringPool().intern(rText);
|
||||
+ rItem.meType = rDoc.GetFormatTable()->IsNumberFormat(rText, nIndex, fValue)
|
||||
+ ? ScQueryEntry::ByValue
|
||||
+ : ScQueryEntry::ByString;
|
||||
+ rItem.mfVal = rItem.meType == ScQueryEntry::ByValue ? fValue : 0.0;
|
||||
+}
|
||||
+
|
||||
+/// Filters the cursor's data by a kit client's conditions.
|
||||
+bool lcl_Query(ScTabViewShell& rView, ScViewData& rData, const boost::property_tree::ptree& rQuery)
|
||||
+{
|
||||
+ ScDBData* pDBData = rView.GetDBData();
|
||||
+ if (!pDBData)
|
||||
+ return false;
|
||||
+ ScDocument& rDoc = rData.GetDocument();
|
||||
+ ScQueryParam aParam;
|
||||
+ pDBData->GetQueryParam(aParam);
|
||||
+ // With a column, only that column's conditions change.
|
||||
+ const auto oColumn = rQuery.get_optional<SCCOLROW>("column");
|
||||
+ if (oColumn)
|
||||
+ aParam.RemoveAllEntriesByField(*oColumn);
|
||||
+ else
|
||||
+ for (SCSIZE i = 0; i < aParam.GetEntryCount(); ++i)
|
||||
+ aParam.GetEntry(i).Clear();
|
||||
+ aParam.bHasHeader = pDBData->HasHeader();
|
||||
+ aParam.bInplace = true;
|
||||
+ aParam.bDuplicate = true;
|
||||
+ aParam.bCaseSens = false;
|
||||
+ aParam.eSearchType = utl::SearchParam::SearchType::Normal;
|
||||
+ const auto oConditions = rQuery.get_child_optional("conditions");
|
||||
+ if (oConditions)
|
||||
+ {
|
||||
+ for (const auto& rPair : *oConditions)
|
||||
+ {
|
||||
+ const boost::property_tree::ptree& rCondition = rPair.second;
|
||||
+ const SCCOLROW nField = oColumn ? *oColumn : rCondition.get<SCCOLROW>("field", -1);
|
||||
+ if (nField < aParam.nCol1 || nField > aParam.nCol2)
|
||||
+ return false;
|
||||
+ ScQueryEntry* pEntry = nullptr;
|
||||
+ for (SCSIZE i = 0; i < aParam.GetEntryCount() && !pEntry; ++i)
|
||||
+ if (!aParam.GetEntry(i).bDoQuery)
|
||||
+ pEntry = &aParam.GetEntry(i);
|
||||
+ if (!pEntry)
|
||||
+ pEntry = &aParam.AppendEntry();
|
||||
+ pEntry->bDoQuery = true;
|
||||
+ pEntry->nField = nField;
|
||||
+ pEntry->eConnect = rCondition.get<bool>("or", false) ? SC_OR : SC_AND;
|
||||
+ const std::string aOp = rCondition.get<std::string>("op", "");
|
||||
+ const OUString aValue = lcl_Text(rCondition, "value");
|
||||
+ if (aOp == "empty")
|
||||
+ pEntry->SetQueryByEmpty();
|
||||
+ else if (aOp == "notempty")
|
||||
+ pEntry->SetQueryByNonEmpty();
|
||||
+ else if (aOp == "values")
|
||||
+ {
|
||||
+ // The column's own entries, so types match.
|
||||
+ std::set<OUString> aWanted;
|
||||
+ if (const auto oValues = rCondition.get_child_optional("values"))
|
||||
+ for (const auto& rValue : *oValues)
|
||||
+ aWanted.insert(OUString::fromUtf8(rValue.second.data()));
|
||||
+ ScFilterEntries aEntries;
|
||||
+ rDoc.GetFilterEntries(nField, aParam.nRow1, rData.CurrentTabForData(), aEntries);
|
||||
+ pEntry->eOp = SC_EQUAL;
|
||||
+ ScQueryEntry::QueryItemsType& rItems = pEntry->GetQueryItems();
|
||||
+ rItems.clear();
|
||||
+ for (const ScTypedStrData& rStr : aEntries)
|
||||
+ {
|
||||
+ if (!aWanted.count(rStr.GetString()))
|
||||
+ continue;
|
||||
+ ScQueryEntry::Item aItem;
|
||||
+ aItem.maString = rDoc.GetSharedStringPool().intern(rStr.GetString());
|
||||
+ aItem.meType = rStr.IsDate() ? ScQueryEntry::ByDate
|
||||
+ : rStr.GetStringType() == ScTypedStrData::Value
|
||||
+ ? ScQueryEntry::ByValue
|
||||
+ : ScQueryEntry::ByString;
|
||||
+ aItem.mfVal = rStr.GetValue();
|
||||
+ rItems.push_back(aItem);
|
||||
+ }
|
||||
+ if (aWanted.count(OUString()))
|
||||
+ {
|
||||
+ ScQueryEntry::Item aEmpty;
|
||||
+ aEmpty.maString = rDoc.GetSharedStringPool().intern(OUString());
|
||||
+ rItems.push_back(aEmpty);
|
||||
+ }
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ static const std::pair<std::string_view, ScQueryOp> aOps[]
|
||||
+ = { { "contains", SC_CONTAINS }, { "equals", SC_EQUAL },
|
||||
+ { "notequals", SC_NOT_EQUAL }, { "greater", SC_GREATER },
|
||||
+ { "less", SC_LESS }, { "greaterequal", SC_GREATER_EQUAL },
|
||||
+ { "lessequal", SC_LESS_EQUAL } };
|
||||
+ const auto pOp = std::find_if(std::begin(aOps), std::end(aOps),
|
||||
+ [&aOp](const auto& rPair) { return rPair.first == aOp; });
|
||||
+ if (pOp == std::end(aOps))
|
||||
+ return false;
|
||||
+ pEntry->eOp = pOp->second;
|
||||
+ lcl_SetItem(rDoc, pEntry->GetQueryItem(), aValue);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ rView.Query(aParam, nullptr, true);
|
||||
+ return true;
|
||||
+}
|
||||
+}
|
||||
+
|
||||
void ScCellShell::ExecuteDB( SfxRequest& rReq )
|
||||
{
|
||||
ScTabViewShell* pTabViewShell = GetViewData().GetViewShell();
|
||||
@@ -614,7 +840,13 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq )
|
||||
case SID_FILTER:
|
||||
{
|
||||
const SfxItemSet* pArgs = rReq.GetArgs();
|
||||
- if ( pArgs )
|
||||
+ boost::property_tree::ptree aQuery;
|
||||
+ if (lcl_JsonArg(rReq, FN_PARAM_1, aQuery))
|
||||
+ {
|
||||
+ if (lcl_Query(*pTabViewShell, GetViewData(), aQuery))
|
||||
+ rReq.Done();
|
||||
+ }
|
||||
+ else if ( pArgs )
|
||||
{
|
||||
OSL_FAIL("SID_FILTER with arguments?");
|
||||
pTabViewShell->Query(
|
||||
@@ -868,7 +1100,10 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq )
|
||||
const SfxItemSet* pArgs = rReq.GetArgs();
|
||||
if ( pArgs )
|
||||
{
|
||||
- OSL_FAIL("later...");
|
||||
+ boost::property_tree::ptree aRule;
|
||||
+ if (lcl_JsonArg(rReq, FN_PARAM_1, aRule)
|
||||
+ && lcl_SetValidation(*pTabViewShell, GetViewData(), aRule))
|
||||
+ rReq.Done();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1098,6 +1333,26 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq )
|
||||
aExport.ExportStream( aStream, OUString(), SotClipboardFormatId::STRING );
|
||||
|
||||
aStream.Seek(0);
|
||||
+ const SfxPoolItem* pOptions = nullptr;
|
||||
+ if (pReqArgs
|
||||
+ && pReqArgs->GetItemState(FN_PARAM_1, true, &pOptions) == SfxItemState::SET)
|
||||
+ {
|
||||
+ // The kit client's options; no dialog.
|
||||
+ ScAsciiOptions aOptions;
|
||||
+ aOptions.ReadFromString(static_cast<const SfxStringItem*>(pOptions)->GetValue());
|
||||
+ ScDocShell* pDocSh = rData.GetDocShell();
|
||||
+ OUString aUndo = ScResId( STR_UNDO_TEXTTOCOLUMNS );
|
||||
+ pDocSh->GetUndoManager()->EnterListAction( aUndo, aUndo, 0, rData.GetViewShell()->GetViewShellId() );
|
||||
+ ScImportExport aImport( rDoc, aRange.aStart );
|
||||
+ aImport.SetExtOptions( aOptions );
|
||||
+ aImport.SetApi( false );
|
||||
+ aImport.SetImportBroadcast( true );
|
||||
+ aImport.SetOverwriting( true );
|
||||
+ aImport.ImportStream( aStream, OUString(), SotClipboardFormatId::STRING );
|
||||
+ pDocSh->GetUndoManager()->LeaveListAction();
|
||||
+ rReq.Done();
|
||||
+ break;
|
||||
+ }
|
||||
ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
|
||||
ScopedVclPtr<AbstractScImportAsciiDlg> pDlg(pFact->CreateScImportAsciiDlg(
|
||||
pTabViewShell->GetFrameWeld(), OUString(), &aStream, SC_TEXTTOCOLUMNS));
|
||||
@@ -0,0 +1,387 @@
|
||||
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
|
||||
index 0bd1bb34e..50582b5e4 100644
|
||||
--- a/sc/source/ui/unoobj/docuno.cxx
|
||||
+++ b/sc/source/ui/unoobj/docuno.cxx
|
||||
@@ -97,6 +97,17 @@
|
||||
#include <o3tl/string_view.hxx>
|
||||
#include <formulacell.hxx>
|
||||
#include <rangenam.hxx>
|
||||
+#include <com/sun/star/sheet/TableValidationVisibility.hpp>
|
||||
+#include <svl/zformat.hxx>
|
||||
+#include <svl/numformat.hxx>
|
||||
+#include <typedstrdata.hxx>
|
||||
+#include <filterentries.hxx>
|
||||
+#include <queryentry.hxx>
|
||||
+#include <queryparam.hxx>
|
||||
+#include <dbdata.hxx>
|
||||
+#include <unordered_set>
|
||||
+#include <conditio.hxx>
|
||||
+#include <validat.hxx>
|
||||
#include <tokenarray.hxx>
|
||||
#include <convuno.hxx>
|
||||
#include <datauno.hxx>
|
||||
@@ -736,16 +747,209 @@ void lcl_DefinedNames(tools::JsonWriter& rJsonWriter, ScDocument& rDoc)
|
||||
}
|
||||
}
|
||||
|
||||
+
|
||||
+namespace
|
||||
+{
|
||||
+/// The cell a `?col=&row=` query names, on the shown sheet.
|
||||
+bool lcl_QueryCell(std::string_view rCommand, SCCOL& rCol, SCROW& rRow)
|
||||
+{
|
||||
+ std::map<OUString, OUString> aMap
|
||||
+ = SfxLokHelper::parseCommandParameters(OUString::fromUtf8(rCommand));
|
||||
+ if (!aMap.count(u"col"_ustr) || !aMap.count(u"row"_ustr))
|
||||
+ return false;
|
||||
+ rCol = aMap[u"col"_ustr].toInt32();
|
||||
+ rRow = aMap[u"row"_ustr].toInt32();
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
+/// A filter column's entries, as the kernel menu lists them.
|
||||
+void lcl_FilterValues(tools::JsonWriter& rJson, ScDocument& rDoc, SCCOL nCol, SCROW nRow, SCTAB nTab)
|
||||
+{
|
||||
+ ScFilterEntries aEntries;
|
||||
+ rDoc.GetFilterEntries(nCol, nRow, nTab, aEntries);
|
||||
+ std::unordered_set<OUString> aStrings;
|
||||
+ std::unordered_set<double> aNumbers;
|
||||
+ bool bNonEmpty = false;
|
||||
+ bool bFiltered = false;
|
||||
+ if (const ScDBData* pDBData = rDoc.GetDBAtCursor(nCol, nRow, nTab, ScDBDataPortion::AREA))
|
||||
+ {
|
||||
+ ScQueryParam aParam;
|
||||
+ pDBData->GetQueryParam(aParam);
|
||||
+ const std::vector<ScQueryEntry*> aFound = aParam.FindAllEntriesByField(nCol);
|
||||
+ bFiltered = !aFound.empty();
|
||||
+ bNonEmpty = aFound.size() == 1 && aFound[0]->IsQueryByNonEmpty();
|
||||
+ for (const ScQueryEntry* pEntry : aFound)
|
||||
+ {
|
||||
+ if (bNonEmpty || pEntry->eOp != SC_EQUAL)
|
||||
+ continue;
|
||||
+ for (const ScQueryEntry::Item& rItem : pEntry->GetQueryItems())
|
||||
+ {
|
||||
+ if (rItem.meType == ScQueryEntry::ByValue)
|
||||
+ aNumbers.insert(rItem.mfVal);
|
||||
+ else
|
||||
+ aStrings.insert(rItem.maString.getString());
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ rJson.put("filtered", bFiltered);
|
||||
+ auto aValues = rJson.startArray("values");
|
||||
+ for (const ScTypedStrData& rStr : aEntries)
|
||||
+ {
|
||||
+ // The rules of ScGridWindow::LaunchAutoFilterMenu.
|
||||
+ bool bSelected = !rStr.IsHiddenByFilter();
|
||||
+ if (!aStrings.empty() || !aNumbers.empty())
|
||||
+ bSelected = aStrings.count(rStr.GetString())
|
||||
+ || (rStr.GetStringType() == ScTypedStrData::Value
|
||||
+ && (aNumbers.count(rStr.GetValue())
|
||||
+ || aNumbers.count(rStr.GetRoundedValue())));
|
||||
+ else if (bNonEmpty && rStr.GetString().isEmpty())
|
||||
+ bSelected = false;
|
||||
+ auto aValue = rJson.startStruct();
|
||||
+ rJson.put("text", rStr.GetString());
|
||||
+ rJson.put("hidden", rStr.IsHiddenByFilter());
|
||||
+ rJson.put("selected", bSelected);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+/// The current cell's validation, as the kit client sets it.
|
||||
+void lcl_Validation(tools::JsonWriter& rJson, ScDocument& rDoc, const ScAddress& rPos)
|
||||
+{
|
||||
+ static const char* const aModes[] = { "any", "whole", "decimal", "date",
|
||||
+ "time", "textlength", "list", "custom" };
|
||||
+ static const std::pair<ScConditionMode, const char*> aOperators[]
|
||||
+ = { { ScConditionMode::Equal, "equal" }, { ScConditionMode::NotEqual, "notequal" },
|
||||
+ { ScConditionMode::Less, "less" }, { ScConditionMode::EqLess, "lessequal" },
|
||||
+ { ScConditionMode::Greater, "greater" }, { ScConditionMode::EqGreater, "greaterequal" },
|
||||
+ { ScConditionMode::Between, "between" }, { ScConditionMode::NotBetween, "notbetween" } };
|
||||
+ const sal_uInt32 nIndex = rDoc.GetAttr(rPos, ATTR_VALIDDATA).GetValue();
|
||||
+ const ScValidationData* pData = nIndex ? rDoc.GetValidationEntry(nIndex) : nullptr;
|
||||
+ rJson.put("type", pData ? aModes[pData->GetDataMode()] : "any");
|
||||
+ if (!pData)
|
||||
+ return;
|
||||
+ const auto pOperator = std::find_if(std::begin(aOperators), std::end(aOperators),
|
||||
+ [pData](const auto& rPair) { return rPair.first == pData->GetOperation(); });
|
||||
+ rJson.put("operator", pOperator != std::end(aOperators) ? pOperator->second : "equal");
|
||||
+ rJson.put("value1", pData->GetExpression(rPos, 0));
|
||||
+ rJson.put("value2", pData->GetExpression(rPos, 1));
|
||||
+ rJson.put("dropdown", pData->GetListType() != css::sheet::TableValidationVisibility::INVISIBLE);
|
||||
+ rJson.put("ignoreBlank", pData->IsIgnoreBlank());
|
||||
+ OUString aTitle, aMessage;
|
||||
+ rJson.put("showInput", pData->GetInput(aTitle, aMessage));
|
||||
+ rJson.put("inputTitle", aTitle);
|
||||
+ rJson.put("inputMessage", aMessage);
|
||||
+ ScValidErrorStyle eStyle = SC_VALERR_STOP;
|
||||
+ rJson.put("showError", pData->GetErrMsg(aTitle, aMessage, eStyle));
|
||||
+ rJson.put("errorTitle", aTitle);
|
||||
+ rJson.put("errorMessage", aMessage);
|
||||
+ rJson.put("errorStyle", eStyle == SC_VALERR_INFO ? "info"
|
||||
+ : eStyle == SC_VALERR_WARNING ? "warning"
|
||||
+ : "stop");
|
||||
+}
|
||||
+
|
||||
+/// The current cell's number format code and kind.
|
||||
+void lcl_NumberFormat(tools::JsonWriter& rJson, ScDocument& rDoc, const ScAddress& rPos,
|
||||
+ std::string_view rCommand)
|
||||
+{
|
||||
+ SvNumberFormatter* pFormatter = rDoc.GetFormatTable();
|
||||
+ std::map<OUString, OUString> aMap
|
||||
+ = SfxLokHelper::parseCommandParameters(OUString::fromUtf8(rCommand));
|
||||
+ if (aMap.count(u"code"_ustr))
|
||||
+ {
|
||||
+ bool bThousand, bRed;
|
||||
+ sal_uInt16 nPrecision, nLeading;
|
||||
+ rJson.put("valid", pFormatter->GetFormatSpecialInfo(aMap[u"code"_ustr], bThousand, bRed,
|
||||
+ nPrecision, nLeading) == 0);
|
||||
+ return;
|
||||
+ }
|
||||
+ const sal_uInt32 nIndex = rDoc.GetNumberFormat(rPos.Col(), rPos.Row(), rPos.Tab());
|
||||
+ const SvNumberformat* pEntry = pFormatter->GetEntry(nIndex);
|
||||
+ rJson.put("code", pEntry ? pEntry->GetFormatstring() : OUString());
|
||||
+ static const std::pair<SvNumFormatType, const char*> aTypes[]
|
||||
+ = { { SvNumFormatType::NUMBER, "number" }, { SvNumFormatType::CURRENCY, "currency" },
|
||||
+ { SvNumFormatType::PERCENT, "percent" }, { SvNumFormatType::DATE, "date" },
|
||||
+ { SvNumFormatType::TIME, "time" }, { SvNumFormatType::DATETIME, "datetime" },
|
||||
+ { SvNumFormatType::SCIENTIFIC, "scientific" }, { SvNumFormatType::FRACTION, "fraction" },
|
||||
+ { SvNumFormatType::LOGICAL, "boolean" }, { SvNumFormatType::TEXT, "text" } };
|
||||
+ const SvNumFormatType eType = pEntry ? pEntry->GetMaskedType() : SvNumFormatType::ALL;
|
||||
+ const auto pType = std::find_if(std::begin(aTypes), std::end(aTypes),
|
||||
+ [eType](const auto& rPair) { return rPair.first == eType; });
|
||||
+ // General opens each locale's block and reads as a number.
|
||||
+ const bool bGeneral = !pEntry || nIndex % SV_COUNTRY_LANGUAGE_OFFSET == 0;
|
||||
+ rJson.put("type", bGeneral ? "general" : pType != std::end(aTypes) ? pType->second : "general");
|
||||
+}
|
||||
+
|
||||
+/// The shown sheet's conditional formats.
|
||||
+void lcl_ConditionalFormats(tools::JsonWriter& rJson, ScDocument& rDoc, SCTAB nTab)
|
||||
+{
|
||||
+ auto aFormats = rJson.startArray("formats");
|
||||
+ const ScConditionalFormatList* pList = rDoc.GetCondFormList(nTab);
|
||||
+ if (!pList)
|
||||
+ return;
|
||||
+ const ScAddress::Details aDetails(rDoc.GetAddressConvention(), 0, 0);
|
||||
+ for (const auto& pFormat : *pList)
|
||||
+ {
|
||||
+ auto aFormat = rJson.startStruct();
|
||||
+ rJson.put("key", static_cast<sal_Int64>(pFormat->GetKey()));
|
||||
+ OUString aRange;
|
||||
+ pFormat->GetRange().Format(aRange, ScRefFlags::VALID, rDoc, aDetails.eConv);
|
||||
+ rJson.put("range", aRange);
|
||||
+ const ScFormatEntry* pEntry = pFormat->size() ? pFormat->GetEntry(0) : nullptr;
|
||||
+ const ScFormatEntry::Type eType = pEntry ? pEntry->GetType() : ScFormatEntry::Type::Date;
|
||||
+ rJson.put("kind", eType == ScFormatEntry::Type::Colorscale ? "scale"
|
||||
+ : eType == ScFormatEntry::Type::Databar ? "databar"
|
||||
+ : eType == ScFormatEntry::Type::Iconset ? "iconset"
|
||||
+ : eType == ScFormatEntry::Type::Condition || eType == ScFormatEntry::Type::ExtCondition
|
||||
+ ? "cell"
|
||||
+ : "other");
|
||||
+ if (eType == ScFormatEntry::Type::Condition || eType == ScFormatEntry::Type::ExtCondition)
|
||||
+ {
|
||||
+ const auto* pCondition = static_cast<const ScCondFormatEntry*>(pEntry);
|
||||
+ rJson.put("style", pCondition->GetStyle());
|
||||
+ rJson.put("value1", pCondition->GetExpression(pFormat->GetRange().GetTopLeftCorner(), 0));
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+}
|
||||
+
|
||||
bool ScModelObj::supportsCommand(std::u16string_view rCommand)
|
||||
{
|
||||
- return rCommand == u"SheetReferences" || rCommand == u"DefinedNames"
|
||||
- || rCommand == u"SelectedRange";
|
||||
+ static constexpr std::u16string_view aCommands[]
|
||||
+ = { u"SheetReferences", u"DefinedNames", u"SelectedRange",
|
||||
+ u"AutoFilterValues", u"DataSelectValues", u"Validation",
|
||||
+ u"NumberFormatCode", u"ConditionalFormats" };
|
||||
+ return std::find(std::begin(aCommands), std::end(aCommands), rCommand) != std::end(aCommands);
|
||||
}
|
||||
|
||||
void ScModelObj::getCommandValues(tools::JsonWriter& rJsonWriter, std::string_view rCommand)
|
||||
{
|
||||
if (pDocShell && rCommand == ".uno:DefinedNames")
|
||||
return lcl_DefinedNames(rJsonWriter, pDocShell->GetDocument());
|
||||
+ ScViewData* pCurrent = ScDocShell::GetViewData();
|
||||
+ if (pDocShell && pCurrent)
|
||||
+ {
|
||||
+ ScDocument& rDoc = pDocShell->GetDocument();
|
||||
+ const SCTAB nTab = pCurrent->CurrentTabForData();
|
||||
+ const ScAddress aCursor(pCurrent->GetCurX(), pCurrent->GetCurY(), nTab);
|
||||
+ SCCOL nCol = 0;
|
||||
+ SCROW nRow = 0;
|
||||
+ if (o3tl::starts_with(rCommand, ".uno:AutoFilterValues?") && lcl_QueryCell(rCommand, nCol, nRow))
|
||||
+ return lcl_FilterValues(rJsonWriter, rDoc, nCol, nRow, nTab);
|
||||
+ if (o3tl::starts_with(rCommand, ".uno:DataSelectValues?") && lcl_QueryCell(rCommand, nCol, nRow))
|
||||
+ {
|
||||
+ std::vector<ScTypedStrData> aStrings;
|
||||
+ rDoc.GetDataEntries(nCol, nRow, nTab, aStrings, true);
|
||||
+ auto aValues = rJsonWriter.startArray("values");
|
||||
+ for (const ScTypedStrData& rStr : aStrings)
|
||||
+ rJsonWriter.putSimpleValue(rStr.GetString());
|
||||
+ return;
|
||||
+ }
|
||||
+ if (rCommand == ".uno:Validation")
|
||||
+ return lcl_Validation(rJsonWriter, rDoc, aCursor);
|
||||
+ if (o3tl::starts_with(rCommand, ".uno:NumberFormatCode"))
|
||||
+ return lcl_NumberFormat(rJsonWriter, rDoc, aCursor, rCommand);
|
||||
+ if (rCommand == ".uno:ConditionalFormats")
|
||||
+ return lcl_ConditionalFormats(rJsonWriter, rDoc, nTab);
|
||||
+ }
|
||||
if (pDocShell && rCommand == ".uno:SelectedRange")
|
||||
{
|
||||
// The one selected range, absolute; empty for several.
|
||||
@@ -760,6 +964,27 @@ void ScModelObj::getCommandValues(tools::JsonWriter& rJsonWriter, std::string_vi
|
||||
: aRange.Format(rDoc, ScRefFlags::RANGE_ABS_3D, aDetails);
|
||||
rJsonWriter.put("commandName", ".uno:SelectedRange");
|
||||
rJsonWriter.put("range", aTarget);
|
||||
+ if (aTarget.isEmpty())
|
||||
+ return;
|
||||
+ // The data inside it: its corners, first row, header guess.
|
||||
+ SCCOL nCol1 = aRange.aStart.Col(), nCol2 = aRange.aEnd.Col();
|
||||
+ SCROW nRow1 = aRange.aStart.Row(), nRow2 = aRange.aEnd.Row();
|
||||
+ const SCTAB nTab = aRange.aStart.Tab();
|
||||
+ if (!rDoc.ShrinkToDataArea(nTab, nCol1, nRow1, nCol2, nRow2))
|
||||
+ return;
|
||||
+ {
|
||||
+ auto aArea = rJsonWriter.startArray("area");
|
||||
+ rJsonWriter.putSimpleValue(OUString::number(nCol1));
|
||||
+ rJsonWriter.putSimpleValue(OUString::number(nRow1));
|
||||
+ rJsonWriter.putSimpleValue(OUString::number(nCol2));
|
||||
+ rJsonWriter.putSimpleValue(OUString::number(nRow2));
|
||||
+ }
|
||||
+ {
|
||||
+ auto aTop = rJsonWriter.startArray("top");
|
||||
+ for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol)
|
||||
+ rJsonWriter.putSimpleValue(rDoc.GetString(nCol, nRow1, nTab));
|
||||
+ }
|
||||
+ rJsonWriter.put("header", rDoc.HasColHeader(nCol1, nRow1, nCol2, nRow2, nTab));
|
||||
return;
|
||||
}
|
||||
if (pDocShell && o3tl::starts_with(rCommand, ".uno:DefinedNames?"))
|
||||
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
|
||||
index 401a26b18..7aa4b4ec7 100644
|
||||
--- a/sc/source/ui/view/gridwin.cxx
|
||||
+++ b/sc/source/ui/view/gridwin.cxx
|
||||
@@ -956,8 +956,25 @@ void ScGridWindow::SendAutofilterPopupPosition(SCCOL nCol, SCROW nRow) {
|
||||
}
|
||||
}
|
||||
|
||||
+namespace
|
||||
+{
|
||||
+/// Asks the kit client for its menu at a cell.
|
||||
+void lcl_AskClientMenu(const ScViewData& rViewData, const char* pType, SCCOL nCol, SCROW nRow)
|
||||
+{
|
||||
+ tools::JsonWriter aJson;
|
||||
+ aJson.put("type", pType);
|
||||
+ aJson.put("col", static_cast<sal_Int64>(nCol));
|
||||
+ aJson.put("row", static_cast<sal_Int64>(nRow));
|
||||
+ rViewData.GetViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_TOOLTIP,
|
||||
+ aJson.finishAndGetAsOString());
|
||||
+}
|
||||
+}
|
||||
+
|
||||
void ScGridWindow::LaunchAutoFilterMenu(SCCOL nCol, SCROW nRow)
|
||||
{
|
||||
+ // The kit client draws its own filter menu.
|
||||
+ if (comphelper::LibreOfficeKit::isActive())
|
||||
+ return lcl_AskClientMenu(mrViewData, "autofilter", nCol, nRow);
|
||||
SCTAB nTab = mrViewData.CurrentTabForData();
|
||||
ScDocument& rDoc = mrViewData.GetDocument();
|
||||
bool bLOKActive = comphelper::LibreOfficeKit::isActive();
|
||||
@@ -1512,6 +1529,9 @@ void ScGridWindow::DoScenarioMenu( const ScRange& rScenRange )
|
||||
|
||||
void ScGridWindow::LaunchDataSelectMenu(const SCCOL nCol, const SCROW nRow)
|
||||
{
|
||||
+ // The kit client draws its own list.
|
||||
+ if (comphelper::LibreOfficeKit::isActive())
|
||||
+ return lcl_AskClientMenu(mrViewData, "datalist", nCol, nRow);
|
||||
mpFilterBox.reset();
|
||||
|
||||
ScDocument& rDoc = mrViewData.GetDocument();
|
||||
diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx
|
||||
index 7850c0e52..8c7dde103 100644
|
||||
--- a/sc/source/core/data/validat.cxx
|
||||
+++ b/sc/source/core/data/validat.cxx
|
||||
@@ -24,6 +24,9 @@
|
||||
|
||||
#include <sfx2/app.hxx>
|
||||
#include <sfx2/viewsh.hxx>
|
||||
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
|
||||
+#include <tools/json_writer.hxx>
|
||||
+#include <comphelper/lok.hxx>
|
||||
#include <basic/sbmeth.hxx>
|
||||
#include <basic/sbmod.hxx>
|
||||
#include <basic/sbstar.hxx>
|
||||
@@ -396,6 +399,25 @@ void ScValidationData::DoError(weld::Window* pParent, const OUString& rInput, co
|
||||
if (aMessage.isEmpty())
|
||||
aMessage = ScResId( STR_VALID_DEFERROR );
|
||||
|
||||
+ if (comphelper::LibreOfficeKit::isActive())
|
||||
+ {
|
||||
+ // No dialog: the default answer, and the client tells.
|
||||
+ const bool bForget = eErrorStyle != SC_VALERR_INFO;
|
||||
+ tools::JsonWriter aJson;
|
||||
+ aJson.put("type", "validityerror");
|
||||
+ aJson.put("title", aTitle);
|
||||
+ aJson.put("message", aMessage);
|
||||
+ aJson.put("style", eErrorStyle == SC_VALERR_INFO ? "info"
|
||||
+ : eErrorStyle == SC_VALERR_WARNING ? "warning"
|
||||
+ : "stop");
|
||||
+ aJson.put("accepted", !bForget);
|
||||
+ if (SfxViewShell* pViewShell = SfxViewShell::Current())
|
||||
+ pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TOOLTIP,
|
||||
+ aJson.finishAndGetAsOString());
|
||||
+ callback(bForget);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
VclButtonsType eStyle = VclButtonsType::Ok;
|
||||
VclMessageType eType = VclMessageType::Error;
|
||||
switch (eErrorStyle)
|
||||
diff --git a/sc/source/ui/view/viewfun2.cxx b/sc/source/ui/view/viewfun2.cxx
|
||||
index 83bb29d05..e98b7c6f9 100644
|
||||
--- a/sc/source/ui/view/viewfun2.cxx
|
||||
+++ b/sc/source/ui/view/viewfun2.cxx
|
||||
@@ -2049,6 +2049,8 @@ bool ScViewFunc::SearchAndReplace( const SvxSearchItem* pSearchItem,
|
||||
bFirst = false;
|
||||
|
||||
bool bFound = false;
|
||||
+ // Find-all's cells, one rectangle each for the kit client.
|
||||
+ ScRangeList aFoundAll;
|
||||
while (true)
|
||||
{
|
||||
GetFrameWin()->EnterWait();
|
||||
@@ -2065,6 +2067,8 @@ bool ScViewFunc::SearchAndReplace( const SvxSearchItem* pSearchItem,
|
||||
aUndoStr, std::move(pUndoDoc), pSearchItem ) );
|
||||
}
|
||||
|
||||
+ if (nCommand == SvxSearchCmd::FIND_ALL)
|
||||
+ aFoundAll = aMatchedRanges;
|
||||
if (nCommand == SvxSearchCmd::FIND_ALL || nCommand == SvxSearchCmd::REPLACE_ALL)
|
||||
{
|
||||
SfxViewFrame* pViewFrm = SfxViewFrame::Current();
|
||||
@@ -2199,7 +2203,21 @@ bool ScViewFunc::SearchAndReplace( const SvxSearchItem* pSearchItem,
|
||||
if (pGridWindow)
|
||||
{
|
||||
std::vector<tools::Rectangle> aLogicRects;
|
||||
- pGridWindow->GetCellSelection(aLogicRects);
|
||||
+ if (nCommand == SvxSearchCmd::FIND_ALL)
|
||||
+ {
|
||||
+ // The marks join neighbors; the client counts cells.
|
||||
+ for (size_t i = 0; i < aFoundAll.size(); ++i)
|
||||
+ {
|
||||
+ const ScRange& rRange = aFoundAll[i];
|
||||
+ for (SCROW nY = rRange.aStart.Row(); nY <= rRange.aEnd.Row(); ++nY)
|
||||
+ for (SCCOL nX = rRange.aStart.Col(); nX <= rRange.aEnd.Col(); ++nX)
|
||||
+ aLogicRects.emplace_back(
|
||||
+ GetViewData().GetPrintTwipsPos(nX, nY),
|
||||
+ Size(rDoc.GetColWidth(nX, nTab), rDoc.GetRowHeight(nY, nTab)));
|
||||
+ }
|
||||
+ }
|
||||
+ else
|
||||
+ pGridWindow->GetCellSelection(aLogicRects);
|
||||
|
||||
boost::property_tree::ptree aTree;
|
||||
aTree.put("searchString", pSearchItem->GetSearchString().toUtf8().getStr());
|
||||
@@ -0,0 +1,324 @@
|
||||
diff --git a/sc/sdi/scalc.sdi b/sc/sdi/scalc.sdi
|
||||
index e49325020..636c1c1a4 100644
|
||||
--- a/sc/sdi/scalc.sdi
|
||||
+++ b/sc/sdi/scalc.sdi
|
||||
@@ -1124,7 +1124,7 @@ SfxVoidItem DataFilterStandardFilter SID_FILTER
|
||||
|
||||
|
||||
SfxVoidItem DataPilotExec SID_PIVOT_TABLE
|
||||
-()
|
||||
+(SfxStringItem Pivot FN_PARAM_1)
|
||||
[
|
||||
AutoUpdate = FALSE,
|
||||
FastCall = FALSE,
|
||||
diff --git a/sc/source/ui/view/cellsh2.cxx b/sc/source/ui/view/cellsh2.cxx
|
||||
index 5dd6e0793..11d4d1bf1 100644
|
||||
--- a/sc/source/ui/view/cellsh2.cxx
|
||||
+++ b/sc/source/ui/view/cellsh2.cxx
|
||||
@@ -70,6 +70,13 @@
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
#include <com/sun/star/sheet/TableValidationVisibility.hpp>
|
||||
#include <markdata.hxx>
|
||||
+#include <kitpivot.hxx>
|
||||
+#include <com/sun/star/sheet/DataPilotFieldSortMode.hpp>
|
||||
+#include <dpobject.hxx>
|
||||
+#include <dpsave.hxx>
|
||||
+#include <dpshttab.hxx>
|
||||
+#include <dputil.hxx>
|
||||
+#include <pivot.hxx>
|
||||
#include <documentlinkmgr.hxx>
|
||||
#include <officecfg/Office/Common.hxx>
|
||||
|
||||
@@ -451,6 +458,147 @@ bool lcl_Query(ScTabViewShell& rView, ScViewData& rData, const boost::property_t
|
||||
}
|
||||
}
|
||||
|
||||
+namespace
|
||||
+{
|
||||
+/// Makes or changes the pivot table a kit client describes.
|
||||
+bool lcl_KitPivot(ScTabViewShell& rShell, ScViewData& rData, const OUString& rJson)
|
||||
+{
|
||||
+ boost::property_tree::ptree aTree;
|
||||
+ std::stringstream aStream{ std::string(rJson.toUtf8()) };
|
||||
+ try
|
||||
+ {
|
||||
+ boost::property_tree::read_json(aStream, aTree);
|
||||
+ }
|
||||
+ catch (const boost::property_tree::json_parser_error&)
|
||||
+ {
|
||||
+ return false;
|
||||
+ }
|
||||
+ ScDocument& rDoc = rData.GetDocument();
|
||||
+ const ScAddress aCursor(rData.GetCurX(), rData.GetCurY(), rData.CurrentTabForData());
|
||||
+ // On a pivot table: change it; else make one.
|
||||
+ std::unique_ptr<ScDPObject> pObj;
|
||||
+ if (const ScDPObject* pOld = rDoc.GetDPAtCursor(aCursor))
|
||||
+ pObj = std::make_unique<ScDPObject>(*pOld);
|
||||
+ else
|
||||
+ {
|
||||
+ ScRange aSource;
|
||||
+ const ScAddress::Details aDetails(rDoc.GetAddressConvention(), 0, 0);
|
||||
+ const OUString aText = OUString::fromUtf8(aTree.get<std::string>("source", ""));
|
||||
+ if (!(aSource.ParseAny(aText, rDoc, aDetails) & ScRefFlags::VALID))
|
||||
+ return false;
|
||||
+ ScSheetSourceDesc aDesc(&rDoc);
|
||||
+ aDesc.SetSourceRange(aSource);
|
||||
+ if (aDesc.CheckSourceRange())
|
||||
+ return false;
|
||||
+ pObj = std::make_unique<ScDPObject>(&rDoc);
|
||||
+ pObj->SetSheetDesc(aDesc);
|
||||
+ pObj->SetOutRange(ScRange(aCursor));
|
||||
+ }
|
||||
+ ScPivotParam aParam;
|
||||
+ pObj->FillOldParam(aParam);
|
||||
+ pObj->FillLabelData(aParam);
|
||||
+ // The named fields, as the layout dialog lists them.
|
||||
+ auto aFields = [&aTree, &aParam](const char* pKey, bool bData, ScPivotFieldVector& rOut)
|
||||
+ {
|
||||
+ static const boost::property_tree::ptree aNone;
|
||||
+ for (const auto& [rKey, rEntry] : aTree.get_child(pKey, aNone))
|
||||
+ {
|
||||
+ const OUString aName = OUString::fromUtf8(
|
||||
+ bData ? rEntry.get<std::string>("field", "") : rEntry.get_value<std::string>());
|
||||
+ // An empty name places the data layout field.
|
||||
+ if (!bData && aName.isEmpty())
|
||||
+ {
|
||||
+ rOut.push_back(ScPivotField(PIVOT_DATA_FIELD));
|
||||
+ continue;
|
||||
+ }
|
||||
+ const auto pLabel = std::find_if(
|
||||
+ aParam.maLabelArray.begin(), aParam.maLabelArray.end(),
|
||||
+ [&aName](const auto& rLabel) { return !rLabel->mbDataLayout && rLabel->maName == aName; });
|
||||
+ if (pLabel == aParam.maLabelArray.end())
|
||||
+ return false;
|
||||
+ ScPivotField aField((*pLabel)->mnCol);
|
||||
+ if (bData)
|
||||
+ {
|
||||
+ const std::string aFunc = rEntry.get<std::string>("function", "");
|
||||
+ const auto pFunc = std::find_if(std::begin(aKitPivotFuncs), std::end(aKitPivotFuncs),
|
||||
+ [&aFunc](const auto& rPair) { return rPair.first == aFunc; });
|
||||
+ if (pFunc == std::end(aKitPivotFuncs))
|
||||
+ return false;
|
||||
+ aField.nFuncMask = pFunc->second;
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ // A field already placed keeps its subtotals.
|
||||
+ for (const ScPivotFieldVector* pPlaced : { &aParam.maRowFields, &aParam.maColFields, &aParam.maPageFields })
|
||||
+ for (const ScPivotField& rPlaced : *pPlaced)
|
||||
+ if (rPlaced.nCol == aField.nCol)
|
||||
+ aField.nFuncMask = rPlaced.nFuncMask;
|
||||
+ }
|
||||
+ rOut.push_back(aField);
|
||||
+ }
|
||||
+ return true;
|
||||
+ };
|
||||
+ ScPivotFieldVector aPages, aColumns, aRows, aData;
|
||||
+ if (!aFields("pages", false, aPages) || !aFields("columns", false, aColumns)
|
||||
+ || !aFields("rows", false, aRows) || !aFields("data", true, aData) || aData.empty())
|
||||
+ return false;
|
||||
+ // Options as the dialog starts them.
|
||||
+ ScDPSaveData aSave;
|
||||
+ const ScDPSaveData* pOldSave = pObj->GetSaveData();
|
||||
+ aSave.SetFilterButton(pOldSave && pOldSave->GetFilterButton());
|
||||
+ aSave.SetDrillDown(pOldSave && pOldSave->GetDrillDown());
|
||||
+ aSave.SetExpandCollapse(pOldSave && pOldSave->GetExpandCollapse());
|
||||
+ aSave.SetIgnoreEmptyRows(aParam.bIgnoreEmptyRows);
|
||||
+ aSave.SetRepeatIfEmpty(aParam.bDetectCategories);
|
||||
+ aSave.SetColumnGrand(aParam.bMakeTotalCol);
|
||||
+ aSave.SetRowGrand(aParam.bMakeTotalRow);
|
||||
+ const auto xSource = pObj->GetSource();
|
||||
+ using css::sheet::DataPilotFieldOrientation_PAGE, css::sheet::DataPilotFieldOrientation_COLUMN,
|
||||
+ css::sheet::DataPilotFieldOrientation_ROW, css::sheet::DataPilotFieldOrientation_DATA;
|
||||
+ ScDPObject::ConvertOrientation(aSave, aPages, DataPilotFieldOrientation_PAGE, xSource, aParam.maLabelArray);
|
||||
+ ScDPObject::ConvertOrientation(aSave, aColumns, DataPilotFieldOrientation_COLUMN, xSource, aParam.maLabelArray);
|
||||
+ ScDPObject::ConvertOrientation(aSave, aRows, DataPilotFieldOrientation_ROW, xSource, aParam.maLabelArray);
|
||||
+ ScDPObject::ConvertOrientation(aSave, aData, DataPilotFieldOrientation_DATA, xSource, aParam.maLabelArray,
|
||||
+ &aColumns, &aRows, &aPages);
|
||||
+ // Keep members, sort and layout, as the dialog does.
|
||||
+ for (const auto& pLabel : aParam.maLabelArray)
|
||||
+ {
|
||||
+ ScDPSaveDimension* pDim = aSave.GetExistingDimensionByName(
|
||||
+ ScDPUtil::createDuplicateDimensionName(pLabel->maName, pLabel->mnDupCount));
|
||||
+ if (!pDim)
|
||||
+ continue;
|
||||
+ pDim->SetUsedHierarchy(pLabel->mnUsedHier);
|
||||
+ pDim->SetShowEmpty(pLabel->mbShowAll);
|
||||
+ pDim->SetRepeatItemLabels(pLabel->mbRepeatItemLabels);
|
||||
+ pDim->SetSortInfo(&pLabel->maSortInfo);
|
||||
+ pDim->SetLayoutInfo(&pLabel->maLayoutInfo);
|
||||
+ pDim->SetAutoShowInfo(&pLabel->maShowInfo);
|
||||
+ const bool bManualSort = pLabel->maSortInfo.Mode == css::sheet::DataPilotFieldSortMode::MANUAL;
|
||||
+ for (const ScDPLabelData::Member& rMember : pLabel->maMembers)
|
||||
+ {
|
||||
+ if (!bManualSort && rMember.mbVisible && rMember.mbShowDetails)
|
||||
+ continue;
|
||||
+ ScDPSaveMember* pMember = pDim->GetMemberByName(rMember.maName);
|
||||
+ pMember->SetIsVisible(rMember.mbVisible);
|
||||
+ pMember->SetShowDetails(rMember.mbShowDetails);
|
||||
+ }
|
||||
+ }
|
||||
+ // "dest": a cell; empty for a new sheet.
|
||||
+ const OUString aDest = OUString::fromUtf8(aTree.get<std::string>("dest", ""));
|
||||
+ ScRange aDestRange(pObj->GetOutRange().aStart);
|
||||
+ const bool bEdit = rDoc.GetDPAtCursor(aCursor) != nullptr;
|
||||
+ if (!bEdit && !aDest.isEmpty())
|
||||
+ {
|
||||
+ ScAddress aAt;
|
||||
+ const ScAddress::Details aDetails(rDoc.GetAddressConvention(), 0, 0);
|
||||
+ if (!(aAt.Parse(aDest, rDoc, aDetails) & ScRefFlags::VALID))
|
||||
+ return false;
|
||||
+ aDestRange = ScRange(aAt);
|
||||
+ }
|
||||
+ return rShell.MakePivotTable(aSave, aDestRange, !bEdit && aDest.isEmpty(), *pObj);
|
||||
+}
|
||||
+}
|
||||
+
|
||||
void ScCellShell::ExecuteDB( SfxRequest& rReq )
|
||||
{
|
||||
ScTabViewShell* pTabViewShell = GetViewData().GetViewShell();
|
||||
@@ -948,7 +1096,15 @@ void ScCellShell::ExecuteDB( SfxRequest& rReq )
|
||||
case SID_PIVOT_TABLE:
|
||||
{
|
||||
const ScPivotItem* pPItem;
|
||||
- if ( pReqArgs && (pPItem =
|
||||
+ const SfxStringItem* pPivot = rReq.GetArg<SfxStringItem>(FN_PARAM_1);
|
||||
+ if (pPivot)
|
||||
+ {
|
||||
+ const bool bMade = lcl_KitPivot(*pTabViewShell, GetViewData(), pPivot->GetValue());
|
||||
+ SAL_WARN_IF(!bMade, "sc.lok", "pivot not made: " << pPivot->GetValue());
|
||||
+ rReq.SetReturnValue(SfxBoolItem(0, bMade));
|
||||
+ rReq.Done();
|
||||
+ }
|
||||
+ else if ( pReqArgs && (pPItem =
|
||||
pReqArgs->GetItemIfSet( SCITEM_PIVOTDATA )) )
|
||||
{
|
||||
SCTAB nCurTab = GetViewData().CurrentTabForData();
|
||||
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
|
||||
index 50582b5e4..7a0a1e54c 100644
|
||||
--- a/sc/source/ui/unoobj/docuno.cxx
|
||||
+++ b/sc/source/ui/unoobj/docuno.cxx
|
||||
@@ -154,6 +154,10 @@
|
||||
#include <output.hxx>
|
||||
#include <stlpool.hxx>
|
||||
#include <SheetViewManager.hxx>
|
||||
+#include <dpobject.hxx>
|
||||
+#include <dpshttab.hxx>
|
||||
+#include <kitpivot.hxx>
|
||||
+#include <pivot.hxx>
|
||||
|
||||
#include <strings.hrc>
|
||||
|
||||
@@ -909,6 +913,56 @@ void lcl_ConditionalFormats(tools::JsonWriter& rJson, ScDocument& rDoc, SCTAB nT
|
||||
}
|
||||
}
|
||||
}
|
||||
+
|
||||
+/// The pivot table at the cursor: ranges and fields.
|
||||
+void lcl_PivotTable(tools::JsonWriter& rJson, ScDocument& rDoc, const ScAddress& rCursor)
|
||||
+{
|
||||
+ rJson.put("commandName", ".uno:PivotTable");
|
||||
+ const ScDPObject* pFound = rDoc.GetDPAtCursor(rCursor);
|
||||
+ if (!pFound)
|
||||
+ return;
|
||||
+ ScDPObject aObj(*pFound);
|
||||
+ ScPivotParam aParam;
|
||||
+ aObj.FillOldParam(aParam);
|
||||
+ aObj.FillLabelData(aParam);
|
||||
+ const ScAddress::Details aDetails(rDoc.GetAddressConvention(), 0, 0);
|
||||
+ rJson.put("name", aObj.GetName());
|
||||
+ rJson.put("range", aObj.GetOutRange().Format(rDoc, ScRefFlags::RANGE_ABS_3D, aDetails));
|
||||
+ const ScSheetSourceDesc* pDesc = aObj.GetSheetDesc();
|
||||
+ rJson.put("source", pDesc ? pDesc->GetSourceRange().Format(rDoc, ScRefFlags::RANGE_ABS_3D, aDetails)
|
||||
+ : OUString());
|
||||
+ auto aNameOf = [&aParam](const ScPivotField& rField)
|
||||
+ {
|
||||
+ for (const auto& pLabel : aParam.maLabelArray)
|
||||
+ if (pLabel->mnCol == rField.getOriginalDim())
|
||||
+ return pLabel->maName;
|
||||
+ return OUString();
|
||||
+ };
|
||||
+ {
|
||||
+ auto aFields = rJson.startArray("fields");
|
||||
+ for (const auto& pLabel : aParam.maLabelArray)
|
||||
+ if (!pLabel->mbDataLayout && pLabel->mnOriginalDim < 0)
|
||||
+ rJson.putSimpleValue(pLabel->maName);
|
||||
+ }
|
||||
+ for (const auto& [pKey, pFields] : { std::pair("rows", &aParam.maRowFields),
|
||||
+ std::pair("columns", &aParam.maColFields),
|
||||
+ std::pair("pages", &aParam.maPageFields) })
|
||||
+ {
|
||||
+ auto aNames = rJson.startArray(pKey);
|
||||
+ // The data layout field reads as an empty name.
|
||||
+ for (const ScPivotField& rField : *pFields)
|
||||
+ rJson.putSimpleValue(rField.nCol == PIVOT_DATA_FIELD ? OUString() : aNameOf(rField));
|
||||
+ }
|
||||
+ auto aData = rJson.startArray("data");
|
||||
+ for (const ScPivotField& rField : aParam.maDataFields)
|
||||
+ {
|
||||
+ auto aField = rJson.startStruct();
|
||||
+ rJson.put("field", aNameOf(rField));
|
||||
+ const auto pFunc = std::find_if(std::begin(aKitPivotFuncs), std::end(aKitPivotFuncs),
|
||||
+ [&rField](const auto& rPair) { return rPair.second == rField.nFuncMask; });
|
||||
+ rJson.put("function", pFunc != std::end(aKitPivotFuncs) ? pFunc->first : std::string_view("other"));
|
||||
+ }
|
||||
+}
|
||||
}
|
||||
|
||||
bool ScModelObj::supportsCommand(std::u16string_view rCommand)
|
||||
@@ -916,7 +970,7 @@ bool ScModelObj::supportsCommand(std::u16string_view rCommand)
|
||||
static constexpr std::u16string_view aCommands[]
|
||||
= { u"SheetReferences", u"DefinedNames", u"SelectedRange",
|
||||
u"AutoFilterValues", u"DataSelectValues", u"Validation",
|
||||
- u"NumberFormatCode", u"ConditionalFormats" };
|
||||
+ u"NumberFormatCode", u"ConditionalFormats", u"PivotTable" };
|
||||
return std::find(std::begin(aCommands), std::end(aCommands), rCommand) != std::end(aCommands);
|
||||
}
|
||||
|
||||
@@ -949,6 +1003,8 @@ void ScModelObj::getCommandValues(tools::JsonWriter& rJsonWriter, std::string_vi
|
||||
return lcl_NumberFormat(rJsonWriter, rDoc, aCursor, rCommand);
|
||||
if (rCommand == ".uno:ConditionalFormats")
|
||||
return lcl_ConditionalFormats(rJsonWriter, rDoc, nTab);
|
||||
+ if (rCommand == ".uno:PivotTable")
|
||||
+ return lcl_PivotTable(rJsonWriter, rDoc, aCursor);
|
||||
}
|
||||
if (pDocShell && rCommand == ".uno:SelectedRange")
|
||||
{
|
||||
@@ -985,6 +1041,8 @@ void ScModelObj::getCommandValues(tools::JsonWriter& rJsonWriter, std::string_vi
|
||||
rJsonWriter.putSimpleValue(rDoc.GetString(nCol, nRow1, nTab));
|
||||
}
|
||||
rJsonWriter.put("header", rDoc.HasColHeader(nCol1, nRow1, nCol2, nRow2, nTab));
|
||||
+ rJsonWriter.put("data", ScRange(nCol1, nRow1, nTab, nCol2, nRow2, nTab)
|
||||
+ .Format(rDoc, ScRefFlags::RANGE_ABS_3D, aDetails));
|
||||
return;
|
||||
}
|
||||
if (pDocShell && o3tl::starts_with(rCommand, ".uno:DefinedNames?"))
|
||||
diff --git a/sc/source/ui/inc/kitpivot.hxx b/sc/source/ui/inc/kitpivot.hxx
|
||||
new file mode 100644
|
||||
index 000000000..79a6e5c05
|
||||
--- /dev/null
|
||||
+++ b/sc/source/ui/inc/kitpivot.hxx
|
||||
@@ -0,0 +1,23 @@
|
||||
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
+/*
|
||||
+ * 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/.
|
||||
+ */
|
||||
+
|
||||
+#pragma once
|
||||
+
|
||||
+#include <dpglobal.hxx>
|
||||
+
|
||||
+#include <string_view>
|
||||
+#include <utility>
|
||||
+
|
||||
+/// Pivot data functions by their kit client names.
|
||||
+constexpr std::pair<std::string_view, PivotFunc> aKitPivotFuncs[]
|
||||
+ = { { "sum", PivotFunc::Sum }, { "count", PivotFunc::Count },
|
||||
+ { "average", PivotFunc::Average }, { "max", PivotFunc::Max },
|
||||
+ { "min", PivotFunc::Min } };
|
||||
+
|
||||
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
@@ -0,0 +1,498 @@
|
||||
diff --git a/sc/sdi/scalc.sdi b/sc/sdi/scalc.sdi
|
||||
index 636c1c1a4..63cc999a7 100644
|
||||
--- a/sc/sdi/scalc.sdi
|
||||
+++ b/sc/sdi/scalc.sdi
|
||||
@@ -521,7 +521,7 @@ SfxVoidItem StartFormula SID_START_FORMULA
|
||||
|
||||
|
||||
SfxVoidItem ChangeChartData SID_CHART_SOURCE
|
||||
-(SfxStringItem Name SID_CHART_NAME,SfxStringItem Range SID_CHART_SOURCE,SfxBoolItem ColHeaders FN_PARAM_1,SfxBoolItem RowHeaders FN_PARAM_2)
|
||||
+(SfxStringItem Name SID_CHART_NAME,SfxStringItem Range SID_CHART_SOURCE,SfxBoolItem ColHeaders FN_PARAM_1,SfxBoolItem RowHeaders FN_PARAM_2,SfxStringItem Chart FN_PARAM_3)
|
||||
[
|
||||
AutoUpdate = FALSE,
|
||||
FastCall = FALSE,
|
||||
diff --git a/sc/sdi/tabvwsh.sdi b/sc/sdi/tabvwsh.sdi
|
||||
index 42c6018ed..9d7aebd2e 100644
|
||||
--- a/sc/sdi/tabvwsh.sdi
|
||||
+++ b/sc/sdi/tabvwsh.sdi
|
||||
@@ -68,6 +68,7 @@ interface BaseSelection
|
||||
|
||||
SfxVoidItem InsertObjectChart SID_INSERT_DIAGRAM
|
||||
(
|
||||
+ SfxStringItem Chart FN_PARAM_3,
|
||||
SfxBoolItem InNewTable FN_PARAM_4,
|
||||
SfxStringItem RangeList FN_PARAM_5
|
||||
)
|
||||
diff --git a/sc/inc/ChartTools.hxx b/sc/inc/ChartTools.hxx
|
||||
index bcb91b31f..2e49612ad 100644
|
||||
--- a/sc/inc/ChartTools.hxx
|
||||
+++ b/sc/inc/ChartTools.hxx
|
||||
@@ -13,13 +13,18 @@
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
+#include <com/sun/star/uno/Reference.hxx>
|
||||
+#include <com/sun/star/uno/XInterface.hpp>
|
||||
#include <svx/svditer.hxx>
|
||||
#include <tools/long.hxx>
|
||||
#include "types.hxx"
|
||||
+#include "rangelst.hxx"
|
||||
#include <optional>
|
||||
|
||||
class ScDocShell;
|
||||
+class ScDocument;
|
||||
class SdrOle2Obj;
|
||||
+namespace tools { class JsonWriter; }
|
||||
|
||||
namespace sctools {
|
||||
|
||||
@@ -48,6 +53,17 @@ SdrOle2Obj* getChartByIndex(ScDocShell* pDocShell, SCTAB nTab,
|
||||
|
||||
std::vector<SdrOle2Obj*> getAllPivotChartsConnectedTo(std::u16string_view sPivotTableName, ScDocShell& rDocShell);
|
||||
|
||||
+/// `rText`'s ranges, when every part names existing cells.
|
||||
+std::optional<ScRangeList> chartRanges(const ScDocument& rDoc, std::u16string_view rText);
|
||||
+/// Whether a kit client's chart look parses.
|
||||
+bool isChartLook(std::u16string_view rJson);
|
||||
+/// Sets type, title, legend and axis titles from JSON.
|
||||
+bool setChartLook(const css::uno::Reference<css::uno::XInterface>& xChart,
|
||||
+ std::u16string_view rJson);
|
||||
+/// Writes the same look as JSON members.
|
||||
+void writeChartLook(::tools::JsonWriter& rJson,
|
||||
+ const css::uno::Reference<css::uno::XInterface>& xChart);
|
||||
+
|
||||
} // end sctools
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
diff --git a/sc/source/ui/unoobj/ChartTools.cxx b/sc/source/ui/unoobj/ChartTools.cxx
|
||||
index 82419ec2c..caba334bd 100644
|
||||
--- a/sc/source/ui/unoobj/ChartTools.cxx
|
||||
+++ b/sc/source/ui/unoobj/ChartTools.cxx
|
||||
@@ -10,9 +10,21 @@
|
||||
|
||||
#include <ChartTools.hxx>
|
||||
#include <docsh.hxx>
|
||||
+#include <document.hxx>
|
||||
#include <drwlayer.hxx>
|
||||
|
||||
+#include <com/sun/star/beans/XPropertySet.hpp>
|
||||
+#include <com/sun/star/chart/XAxisXSupplier.hpp>
|
||||
+#include <com/sun/star/chart/XAxisYSupplier.hpp>
|
||||
+#include <com/sun/star/chart/XChartDocument.hpp>
|
||||
#include <com/sun/star/chart2/XChartDocument.hpp>
|
||||
+#include <com/sun/star/drawing/XShape.hpp>
|
||||
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
|
||||
+#include <functional>
|
||||
+#include <optional>
|
||||
+#include <sstream>
|
||||
+#include <tools/json_writer.hxx>
|
||||
+#include <boost/property_tree/json_parser.hpp>
|
||||
#include <com/sun/star/embed/XEmbeddedObject.hpp>
|
||||
#include <chart2/AbstractPivotTableDataProvider.hxx>
|
||||
#include <svx/svditer.hxx>
|
||||
@@ -169,6 +181,154 @@ std::vector<SdrOle2Obj*> getAllPivotChartsConnectedTo(std::u16string_view sPivot
|
||||
return aObjects;
|
||||
}
|
||||
|
||||
+namespace
|
||||
+{
|
||||
+/// Kit names and the diagram services they map to.
|
||||
+constexpr std::pair<std::string_view, std::u16string_view> aChartTypes[]
|
||||
+ = { { "column", u"com.sun.star.chart.BarDiagram" },
|
||||
+ { "bar", u"com.sun.star.chart.BarDiagram" },
|
||||
+ { "line", u"com.sun.star.chart.LineDiagram" },
|
||||
+ { "scatter", u"com.sun.star.chart.XYDiagram" },
|
||||
+ { "pie", u"com.sun.star.chart.PieDiagram" } };
|
||||
+
|
||||
+/// A parsed look; "other" keeps the diagram.
|
||||
+struct ChartLook
|
||||
+{
|
||||
+ std::string_view aType;
|
||||
+ OUString aTitle, aXTitle, aYTitle;
|
||||
+ bool bLegend = true;
|
||||
+};
|
||||
+
|
||||
+std::optional<ChartLook> lcl_ParseLook(std::u16string_view rJson)
|
||||
+{
|
||||
+ boost::property_tree::ptree aTree;
|
||||
+ std::stringstream aStream{ std::string(OUString(rJson).toUtf8()) };
|
||||
+ try
|
||||
+ {
|
||||
+ boost::property_tree::read_json(aStream, aTree);
|
||||
+ }
|
||||
+ catch (const boost::property_tree::json_parser_error&)
|
||||
+ {
|
||||
+ return std::nullopt;
|
||||
+ }
|
||||
+ const std::string aType = aTree.get<std::string>("type", "");
|
||||
+ ChartLook aLook;
|
||||
+ if (aType == "other")
|
||||
+ aLook.aType = "other";
|
||||
+ for (const auto& [rName, rService] : aChartTypes)
|
||||
+ if (rName == aType)
|
||||
+ aLook.aType = rName;
|
||||
+ if (aLook.aType.empty())
|
||||
+ return std::nullopt;
|
||||
+ aLook.aTitle = OUString::fromUtf8(aTree.get<std::string>("title", ""));
|
||||
+ aLook.aXTitle = OUString::fromUtf8(aTree.get<std::string>("xtitle", ""));
|
||||
+ aLook.aYTitle = OUString::fromUtf8(aTree.get<std::string>("ytitle", ""));
|
||||
+ aLook.bLegend = aTree.get<bool>("legend", true);
|
||||
+ return aLook;
|
||||
+}
|
||||
+
|
||||
+/// Shows a title with this text; empty hides it.
|
||||
+void lcl_SetTitle(const uno::Reference<beans::XPropertySet>& xOwner, const OUString& rHas,
|
||||
+ const std::function<uno::Reference<drawing::XShape>()>& rTitle,
|
||||
+ const OUString& rText)
|
||||
+{
|
||||
+ xOwner->setPropertyValue(rHas, uno::Any(!rText.isEmpty()));
|
||||
+ if (rText.isEmpty())
|
||||
+ return;
|
||||
+ uno::Reference<beans::XPropertySet> xTitle(rTitle(), uno::UNO_QUERY_THROW);
|
||||
+ xTitle->setPropertyValue(u"String"_ustr, uno::Any(rText));
|
||||
+}
|
||||
+
|
||||
+OUString lcl_Title(const uno::Reference<beans::XPropertySet>& xOwner, const OUString& rHas,
|
||||
+ const std::function<uno::Reference<drawing::XShape>()>& rTitle)
|
||||
+{
|
||||
+ OUString aText;
|
||||
+ if (!xOwner->getPropertyValue(rHas).get<bool>())
|
||||
+ return aText;
|
||||
+ uno::Reference<beans::XPropertySet> xTitle(rTitle(), uno::UNO_QUERY_THROW);
|
||||
+ xTitle->getPropertyValue(u"String"_ustr) >>= aText;
|
||||
+ return aText;
|
||||
+}
|
||||
+}
|
||||
+
|
||||
+std::optional<ScRangeList> chartRanges(const ScDocument& rDoc, std::u16string_view rText)
|
||||
+{
|
||||
+ ScRangeList aRanges;
|
||||
+ const ScRefFlags nFlags = aRanges.Parse(rText, rDoc, rDoc.GetAddressConvention());
|
||||
+ const bool bExist = std::all_of(aRanges.begin(), aRanges.end(), [&rDoc](const ScRange& rRange) {
|
||||
+ return rRange.IsValid() && rDoc.HasTable(rRange.aStart.Tab())
|
||||
+ && rDoc.HasTable(rRange.aEnd.Tab());
|
||||
+ });
|
||||
+ if (!(nFlags & ScRefFlags::VALID) || aRanges.empty() || !bExist)
|
||||
+ return std::nullopt;
|
||||
+ return aRanges;
|
||||
+}
|
||||
+
|
||||
+bool isChartLook(std::u16string_view rJson) { return lcl_ParseLook(rJson).has_value(); }
|
||||
+
|
||||
+bool setChartLook(const uno::Reference<uno::XInterface>& xChart, std::u16string_view rJson)
|
||||
+{
|
||||
+ const std::optional<ChartLook> oLook = lcl_ParseLook(rJson);
|
||||
+ uno::Reference<chart::XChartDocument> xDoc(xChart, uno::UNO_QUERY);
|
||||
+ if (!oLook || !xDoc.is())
|
||||
+ return false;
|
||||
+ uno::Reference<chart::XDiagram> xDiagram = xDoc->getDiagram();
|
||||
+ const auto pType = std::find_if(std::begin(aChartTypes), std::end(aChartTypes),
|
||||
+ [&oLook](const auto& rPair) { return rPair.first == oLook->aType; });
|
||||
+ if (pType != std::end(aChartTypes))
|
||||
+ {
|
||||
+ if (xDiagram->getDiagramType() != pType->second)
|
||||
+ {
|
||||
+ uno::Reference<lang::XMultiServiceFactory> xFactory(xDoc, uno::UNO_QUERY_THROW);
|
||||
+ xDiagram.set(xFactory->createInstance(OUString(pType->second)), uno::UNO_QUERY_THROW);
|
||||
+ xDoc->setDiagram(xDiagram);
|
||||
+ }
|
||||
+ uno::Reference<beans::XPropertySet> xProps(xDiagram, uno::UNO_QUERY_THROW);
|
||||
+ if (pType->second == u"com.sun.star.chart.BarDiagram")
|
||||
+ xProps->setPropertyValue(u"Vertical"_ustr, uno::Any(oLook->aType == "bar"));
|
||||
+ if (oLook->aType == "scatter")
|
||||
+ xProps->setPropertyValue(u"Lines"_ustr, uno::Any(false));
|
||||
+ }
|
||||
+ uno::Reference<beans::XPropertySet> xDocProps(xDoc, uno::UNO_QUERY_THROW);
|
||||
+ lcl_SetTitle(xDocProps, u"HasMainTitle"_ustr, [&xDoc] { return xDoc->getTitle(); },
|
||||
+ oLook->aTitle);
|
||||
+ xDocProps->setPropertyValue(u"HasLegend"_ustr, uno::Any(oLook->bLegend));
|
||||
+ // A pie has no axes.
|
||||
+ if (xDiagram->getDiagramType() == u"com.sun.star.chart.PieDiagram")
|
||||
+ return true;
|
||||
+ uno::Reference<chart::XAxisXSupplier> xX(xDiagram, uno::UNO_QUERY_THROW);
|
||||
+ uno::Reference<chart::XAxisYSupplier> xY(xDiagram, uno::UNO_QUERY_THROW);
|
||||
+ uno::Reference<beans::XPropertySet> xProps(xDiagram, uno::UNO_QUERY_THROW);
|
||||
+ lcl_SetTitle(xProps, u"HasXAxisTitle"_ustr, [&xX] { return xX->getXAxisTitle(); },
|
||||
+ oLook->aXTitle);
|
||||
+ lcl_SetTitle(xProps, u"HasYAxisTitle"_ustr, [&xY] { return xY->getYAxisTitle(); },
|
||||
+ oLook->aYTitle);
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
+void writeChartLook(::tools::JsonWriter& rJson, const uno::Reference<uno::XInterface>& xChart)
|
||||
+{
|
||||
+ uno::Reference<chart::XChartDocument> xDoc(xChart, uno::UNO_QUERY_THROW);
|
||||
+ uno::Reference<chart::XDiagram> xDiagram = xDoc->getDiagram();
|
||||
+ uno::Reference<beans::XPropertySet> xProps(xDiagram, uno::UNO_QUERY_THROW);
|
||||
+ const OUString aService = xDiagram->getDiagramType();
|
||||
+ std::string_view aType = "other";
|
||||
+ for (const auto& [rName, rService] : aChartTypes)
|
||||
+ if (rService == aService && aType == "other")
|
||||
+ aType = rName;
|
||||
+ if (aType == "column" && xProps->getPropertyValue(u"Vertical"_ustr).get<bool>())
|
||||
+ aType = "bar";
|
||||
+ rJson.put("type", aType);
|
||||
+ uno::Reference<beans::XPropertySet> xDocProps(xDoc, uno::UNO_QUERY_THROW);
|
||||
+ rJson.put("title", lcl_Title(xDocProps, u"HasMainTitle"_ustr, [&xDoc] { return xDoc->getTitle(); }));
|
||||
+ rJson.put("legend", xDocProps->getPropertyValue(u"HasLegend"_ustr).get<bool>());
|
||||
+ uno::Reference<chart::XAxisXSupplier> xX(xDiagram, uno::UNO_QUERY_THROW);
|
||||
+ uno::Reference<chart::XAxisYSupplier> xY(xDiagram, uno::UNO_QUERY_THROW);
|
||||
+ const bool bAxes = aType != "pie";
|
||||
+ rJson.put("xtitle", bAxes ? lcl_Title(xProps, u"HasXAxisTitle"_ustr, [&xX] { return xX->getXAxisTitle(); }) : OUString());
|
||||
+ rJson.put("ytitle", bAxes ? lcl_Title(xProps, u"HasYAxisTitle"_ustr, [&xY] { return xY->getYAxisTitle(); }) : OUString());
|
||||
+}
|
||||
+
|
||||
} // end sctools
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
diff --git a/sc/source/ui/drawfunc/fuins2.cxx b/sc/source/ui/drawfunc/fuins2.cxx
|
||||
index 23885c062..78e4a9c52 100644
|
||||
--- a/sc/source/ui/drawfunc/fuins2.cxx
|
||||
+++ b/sc/source/ui/drawfunc/fuins2.cxx
|
||||
@@ -63,6 +63,7 @@
|
||||
#include <PivotTableDataProvider.hxx>
|
||||
#include <chart2uno.hxx>
|
||||
#include <fuinsert.hxx>
|
||||
+#include <ChartTools.hxx>
|
||||
#include <tabvwsh.hxx>
|
||||
#include <sc.hrc>
|
||||
#include <chartpos.hxx>
|
||||
@@ -421,6 +422,21 @@ FuInsertChart::FuInsertChart(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawV
|
||||
if (!SvtModuleOptions().IsChartInstalled())
|
||||
return;
|
||||
|
||||
+ // A kit client's look must parse before anything lands.
|
||||
+ const SfxStringItem* pLook = rReq.GetArg<SfxStringItem>(FN_PARAM_3);
|
||||
+ if (pLook && !sctools::isChartLook(pLook->GetValue()))
|
||||
+ {
|
||||
+ SAL_WARN("sc.lok", "chart look does not parse: " << pLook->GetValue());
|
||||
+ return;
|
||||
+ }
|
||||
+ // A bad range would chart sample data.
|
||||
+ const SfxStringItem* pRange = rReq.GetArg<SfxStringItem>(FN_PARAM_5);
|
||||
+ if (pRange && !sctools::chartRanges(rViewSh.GetViewData().GetDocument(), pRange->GetValue()))
|
||||
+ {
|
||||
+ SAL_WARN("sc.lok", "chart range does not parse: " << pRange->GetValue());
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
// BM/IHA --
|
||||
|
||||
// get range
|
||||
@@ -622,6 +638,15 @@ FuInsertChart::FuInsertChart(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawV
|
||||
if( xChartModel.is() )
|
||||
xChartModel->unlockControllers();
|
||||
}
|
||||
+ else if (comphelper::LibreOfficeKit::isActive())
|
||||
+ {
|
||||
+ // No wizard: one undo step, the look from the request.
|
||||
+ pView->AddUndo(std::make_unique<SdrUndoNewObj>(*pObj));
|
||||
+ if (pLook)
|
||||
+ sctools::setChartLook(xChartModel, pLook->GetValue());
|
||||
+ if (xChartModel.is())
|
||||
+ xChartModel->unlockControllers();
|
||||
+ }
|
||||
else if (!rViewSh.isLOKMobilePhone())
|
||||
{
|
||||
//the controller will be unlocked by the dialog when the dialog is told to do so
|
||||
diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
|
||||
index 33563857e..226b37d05 100644
|
||||
--- a/sc/source/ui/docshell/docsh4.cxx
|
||||
+++ b/sc/source/ui/docshell/docsh4.cxx
|
||||
@@ -56,7 +56,6 @@
|
||||
#include <svl/PasswordHelper.hxx>
|
||||
#include <svl/documentlockfile.hxx>
|
||||
#include <svl/sharecontrolfile.hxx>
|
||||
-#include <tools/json_writer.hxx>
|
||||
#include <unotools/securityoptions.hxx>
|
||||
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
|
||||
#include <sal/log.hxx>
|
||||
@@ -95,6 +94,11 @@
|
||||
#include <reffact.hxx>
|
||||
#include <chartlis.hxx>
|
||||
#include <chartpos.hxx>
|
||||
+#include <ChartTools.hxx>
|
||||
+#include <com/sun/star/chart2/XChartDocument.hpp>
|
||||
+#include <com/sun/star/util/XCloneable.hpp>
|
||||
+#include <com/sun/star/chart2/XTitled.hpp>
|
||||
+#include <tools/json_writer.hxx>
|
||||
#include <tablink.hxx>
|
||||
#include <drwlayer.hxx>
|
||||
#include <docoptio.hxx>
|
||||
@@ -1600,6 +1604,68 @@ void UpdateAcceptChangesDialog()
|
||||
}
|
||||
}
|
||||
|
||||
+namespace
|
||||
+{
|
||||
+/// A chart's whole diagram and main title, cloned.
|
||||
+struct ChartState
|
||||
+{
|
||||
+ uno::Reference<chart2::XDiagram> xDiagram;
|
||||
+ uno::Reference<chart2::XTitle> xTitle;
|
||||
+};
|
||||
+
|
||||
+template <class T> uno::Reference<T> lcl_Clone(const uno::Reference<T>& xFrom)
|
||||
+{
|
||||
+ uno::Reference<util::XCloneable> xCloneable(xFrom, uno::UNO_QUERY);
|
||||
+ return xCloneable.is() ? uno::Reference<T>(xCloneable->createClone(), uno::UNO_QUERY_THROW)
|
||||
+ : uno::Reference<T>();
|
||||
+}
|
||||
+
|
||||
+ChartState lcl_ChartState(const uno::Reference<chart2::XChartDocument>& xChart)
|
||||
+{
|
||||
+ uno::Reference<chart2::XTitled> xTitled(xChart, uno::UNO_QUERY_THROW);
|
||||
+ return { lcl_Clone(xChart->getFirstDiagram()), lcl_Clone(xTitled->getTitleObject()) };
|
||||
+}
|
||||
+
|
||||
+/// Undoes a chart's look by putting its whole diagram back.
|
||||
+class ScUndoChartLook : public ScSimpleUndo
|
||||
+{
|
||||
+ OUString maName;
|
||||
+ ChartState maOld, maNew;
|
||||
+
|
||||
+ void Apply(const ChartState& rState)
|
||||
+ {
|
||||
+ auto xChart = rDocShell.GetDocument().GetChartByName(maName);
|
||||
+ uno::Reference<chart2::XTitled> xTitled(xChart, uno::UNO_QUERY_THROW);
|
||||
+ xChart->setFirstDiagram(lcl_Clone(rState.xDiagram));
|
||||
+ xTitled->setTitleObject(lcl_Clone(rState.xTitle));
|
||||
+ }
|
||||
+
|
||||
+public:
|
||||
+ ScUndoChartLook(ScDocShell& rShell, OUString aName, ChartState aOld, ChartState aNew)
|
||||
+ : ScSimpleUndo(rShell)
|
||||
+ , maName(std::move(aName))
|
||||
+ , maOld(std::move(aOld))
|
||||
+ , maNew(std::move(aNew))
|
||||
+ {
|
||||
+ }
|
||||
+ void Undo() override
|
||||
+ {
|
||||
+ BeginUndo();
|
||||
+ Apply(maOld);
|
||||
+ EndUndo();
|
||||
+ }
|
||||
+ void Redo() override
|
||||
+ {
|
||||
+ BeginRedo();
|
||||
+ Apply(maNew);
|
||||
+ EndRedo();
|
||||
+ }
|
||||
+ void Repeat(SfxRepeatTarget&) override {}
|
||||
+ bool CanRepeat(SfxRepeatTarget&) const override { return false; }
|
||||
+ OUString GetComment() const override { return ScResId(STR_UNDO_CHARTDATA); }
|
||||
+};
|
||||
+}
|
||||
+
|
||||
void ScDocShell::ExecuteChartSource(SfxRequest& rReq)
|
||||
{
|
||||
const SfxItemSet* pReqArgs = rReq.GetArgs();
|
||||
@@ -1658,6 +1724,17 @@ void ScDocShell::ExecuteChartSource(SfxRequest& rReq)
|
||||
aRangeListRef.clear();
|
||||
}
|
||||
|
||||
+ // A kit client's look; it must parse before anything changes.
|
||||
+ const SfxStringItem* pLook = rReq.GetArg<SfxStringItem>(FN_PARAM_3);
|
||||
+ if (pLook
|
||||
+ && (!bColInit || !bRowInit || !sctools::isChartLook(pLook->GetValue())
|
||||
+ || !sctools::chartRanges(rDoc, aRangeName)))
|
||||
+ {
|
||||
+ SAL_WARN("sc.lok", "chart look needs headers and must parse: " << pLook->GetValue());
|
||||
+ rReq.Ignore();
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
|
||||
if (!pViewSh || !bValid || aChartName.isEmpty() )
|
||||
{
|
||||
@@ -1714,9 +1791,23 @@ void ScDocShell::ExecuteChartSource(SfxRequest& rReq)
|
||||
}
|
||||
else
|
||||
{
|
||||
+ SfxUndoManager* pUndoManager = GetUndoManager();
|
||||
+ // One undo step; it restores range, then diagram.
|
||||
+ if (pLook)
|
||||
+ {
|
||||
+ pUndoManager->EnterListAction(ScResId(STR_UNDO_CHARTDATA), u""_ustr, 0, pViewSh->GetViewShellId());
|
||||
+ auto xChart = m_pDocument->GetChartByName(aChartName);
|
||||
+ ChartState aOld = lcl_ChartState(xChart);
|
||||
+ sctools::setChartLook(xChart, pLook->GetValue());
|
||||
+ if (bUndo)
|
||||
+ pUndoManager->AddUndoAction(std::make_unique<ScUndoChartLook>(
|
||||
+ *this, aChartName, std::move(aOld), lcl_ChartState(xChart)));
|
||||
+ }
|
||||
ExecuteChartSourcePost(bUndo, bMultiRange,
|
||||
aChartName, aRangeListRef, bColHeaders, bRowHeaders, bAddRange,
|
||||
nCol1, nRow1,nCol2, nRow2, nTab);
|
||||
+ if (pLook)
|
||||
+ pUndoManager->LeaveListAction();
|
||||
rReq.Done();
|
||||
}
|
||||
}
|
||||
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
|
||||
index 7a0a1e54c..31a7d6fc3 100644
|
||||
--- a/sc/source/ui/unoobj/docuno.cxx
|
||||
+++ b/sc/source/ui/unoobj/docuno.cxx
|
||||
@@ -154,10 +154,12 @@
|
||||
#include <output.hxx>
|
||||
#include <stlpool.hxx>
|
||||
#include <SheetViewManager.hxx>
|
||||
+#include <ChartTools.hxx>
|
||||
#include <dpobject.hxx>
|
||||
#include <dpshttab.hxx>
|
||||
#include <kitpivot.hxx>
|
||||
#include <pivot.hxx>
|
||||
+#include <svx/svdoole2.hxx>
|
||||
|
||||
#include <strings.hrc>
|
||||
|
||||
@@ -914,6 +916,29 @@ void lcl_ConditionalFormats(tools::JsonWriter& rJson, ScDocument& rDoc, SCTAB nT
|
||||
}
|
||||
}
|
||||
|
||||
+/// The one selected chart: name, data range, headers, look.
|
||||
+void lcl_Chart(tools::JsonWriter& rJson, ScDocument& rDoc, ScViewData& rData)
|
||||
+{
|
||||
+ rJson.put("commandName", ".uno:Chart");
|
||||
+ const ScDrawView* pView = rData.GetViewShell()->GetScDrawView();
|
||||
+ if (!pView || pView->GetMarkedObjectList().GetMarkCount() != 1)
|
||||
+ return;
|
||||
+ const auto* pObj = dynamic_cast<const SdrOle2Obj*>(pView->GetMarkedObjectList().GetMark(0)->GetMarkedSdrObj());
|
||||
+ if (!pObj || !pObj->IsChart())
|
||||
+ return;
|
||||
+ const OUString aName = pObj->GetPersistName();
|
||||
+ ScRangeList aRanges;
|
||||
+ bool bColHeaders = false, bRowHeaders = false;
|
||||
+ rDoc.GetOldChartParameters(aName, aRanges, bColHeaders, bRowHeaders);
|
||||
+ OUString aRange;
|
||||
+ aRanges.Format(aRange, ScRefFlags::RANGE_ABS_3D, rDoc, rDoc.GetAddressConvention());
|
||||
+ rJson.put("name", aName);
|
||||
+ rJson.put("range", aRange);
|
||||
+ rJson.put("colHeaders", bColHeaders);
|
||||
+ rJson.put("rowHeaders", bRowHeaders);
|
||||
+ sctools::writeChartLook(rJson, rDoc.GetChartByName(aName));
|
||||
+}
|
||||
+
|
||||
/// The pivot table at the cursor: ranges and fields.
|
||||
void lcl_PivotTable(tools::JsonWriter& rJson, ScDocument& rDoc, const ScAddress& rCursor)
|
||||
{
|
||||
@@ -970,7 +995,8 @@ bool ScModelObj::supportsCommand(std::u16string_view rCommand)
|
||||
static constexpr std::u16string_view aCommands[]
|
||||
= { u"SheetReferences", u"DefinedNames", u"SelectedRange",
|
||||
u"AutoFilterValues", u"DataSelectValues", u"Validation",
|
||||
- u"NumberFormatCode", u"ConditionalFormats", u"PivotTable" };
|
||||
+ u"NumberFormatCode", u"ConditionalFormats", u"Chart",
|
||||
+ u"PivotTable" };
|
||||
return std::find(std::begin(aCommands), std::end(aCommands), rCommand) != std::end(aCommands);
|
||||
}
|
||||
|
||||
@@ -1003,6 +1029,8 @@ void ScModelObj::getCommandValues(tools::JsonWriter& rJsonWriter, std::string_vi
|
||||
return lcl_NumberFormat(rJsonWriter, rDoc, aCursor, rCommand);
|
||||
if (rCommand == ".uno:ConditionalFormats")
|
||||
return lcl_ConditionalFormats(rJsonWriter, rDoc, nTab);
|
||||
+ if (rCommand == ".uno:Chart")
|
||||
+ return lcl_Chart(rJsonWriter, rDoc, *pCurrent);
|
||||
if (rCommand == ".uno:PivotTable")
|
||||
return lcl_PivotTable(rJsonWriter, rDoc, aCursor);
|
||||
}
|
||||
@@ -0,0 +1,395 @@
|
||||
diff --git a/sc/sdi/scalc.sdi b/sc/sdi/scalc.sdi
|
||||
index 63cc999..001366f 100644
|
||||
--- a/sc/sdi/scalc.sdi
|
||||
+++ b/sc/sdi/scalc.sdi
|
||||
@@ -4238,7 +4238,7 @@ SfxBoolItem PagebreakMode FID_PAGEBREAKMODE
|
||||
|
||||
|
||||
SfxVoidItem PageFormatDialog SID_FORMATPAGE
|
||||
-()
|
||||
+(SfxStringItem Page FN_PARAM_1)
|
||||
[
|
||||
AutoUpdate = FALSE,
|
||||
FastCall = FALSE,
|
||||
@@ -4274,7 +4274,7 @@ SfxVoidItem PreviousPage SID_PREVIEW_PREVIOUS
|
||||
|
||||
|
||||
SfxVoidItem Protect FID_PROTECT_TABLE
|
||||
-(SfxBoolItem Protect FID_PROTECT_TABLE)
|
||||
+(SfxBoolItem Protect FID_PROTECT_TABLE,SfxStringItem Protection FN_PARAM_1)
|
||||
[
|
||||
AutoUpdate = FALSE,
|
||||
FastCall = FALSE,
|
||||
diff --git a/sc/source/core/data/table5.cxx b/sc/source/core/data/table5.cxx
|
||||
index 5cc62bf..8e976d0 100644
|
||||
--- a/sc/source/core/data/table5.cxx
|
||||
+++ b/sc/source/core/data/table5.cxx
|
||||
@@ -979,7 +979,8 @@ void ScTable::InvalidateTextWidth(const ScAddress* pAdrFrom, const ScAddress* pA
|
||||
|
||||
const SCCOL nCol1 = pAdrFrom ? pAdrFrom->Col() : 0;
|
||||
const SCROW nRow1 = pAdrFrom ? pAdrFrom->Row() : 0;
|
||||
- const SCCOL nCol2 = pAdrTo ? pAdrTo->Col() : aCol.size() - 1;
|
||||
+ // Only allocated columns exist; a sheet-wide end is past them.
|
||||
+ const SCCOL nCol2 = std::min<SCCOL>(pAdrTo ? pAdrTo->Col() : aCol.size() - 1, aCol.size() - 1);
|
||||
const SCROW nRow2 = pAdrTo ? pAdrTo->Row() : rDocument.MaxRow();
|
||||
|
||||
for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol)
|
||||
diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
|
||||
index 226b37d..46f3547 100644
|
||||
--- a/sc/source/ui/docshell/docsh4.cxx
|
||||
+++ b/sc/source/ui/docshell/docsh4.cxx
|
||||
@@ -48,6 +48,8 @@
|
||||
#include <svx/fmshell.hxx>
|
||||
#include <svx/pageitem.hxx>
|
||||
#include <editeng/sizeitem.hxx>
|
||||
+#include <attrib.hxx>
|
||||
+#include <boost/property_tree/json_parser.hpp>
|
||||
#include <editeng/paperinf.hxx>
|
||||
#include <sfx2/passwd.hxx>
|
||||
#include <sfx2/filedlghelper.hxx>
|
||||
@@ -2244,6 +2246,82 @@ void ScDocShell::PageStyleModified( std::u16string_view rStyleName, bool bApi )
|
||||
}
|
||||
}
|
||||
|
||||
+namespace
|
||||
+{
|
||||
+/// Applies a kit client's page JSON to the page style.
|
||||
+bool lcl_KitPage(ScDocShell& rDocSh, SCTAB nTab, const OUString& rJson)
|
||||
+{
|
||||
+ constexpr int nMinScale = 10;
|
||||
+ constexpr int nMaxScale = 400;
|
||||
+ constexpr int nMaxPages = 1000;
|
||||
+ boost::property_tree::ptree aTree;
|
||||
+ std::stringstream aStream{ std::string(rJson.toUtf8()) };
|
||||
+ bool bLandscape = false;
|
||||
+ try
|
||||
+ {
|
||||
+ boost::property_tree::read_json(aStream, aTree);
|
||||
+ bLandscape = aTree.get<bool>("landscape");
|
||||
+ }
|
||||
+ catch (const boost::property_tree::ptree_error&)
|
||||
+ {
|
||||
+ return false;
|
||||
+ }
|
||||
+ sal_uInt16 nScale = 0;
|
||||
+ sal_uInt16 nPages = 0;
|
||||
+ ScPageScaleToItem aScaleTo;
|
||||
+ if (const auto oScale = aTree.get_optional<int>("scale"))
|
||||
+ {
|
||||
+ if (*oScale < nMinScale || *oScale > nMaxScale)
|
||||
+ return false;
|
||||
+ nScale = *oScale;
|
||||
+ }
|
||||
+ else if (const auto oFit = aTree.get_child_optional("fit"))
|
||||
+ {
|
||||
+ std::vector<int> aFit;
|
||||
+ for (const auto& rItem : *oFit)
|
||||
+ aFit.push_back(rItem.second.get_value<int>(-1));
|
||||
+ if (aFit.size() != 2 || aFit[0] < 0 || aFit[1] < 0 || aFit[0] > nMaxPages
|
||||
+ || aFit[1] > nMaxPages || (aFit[0] == 0 && aFit[1] == 0))
|
||||
+ return false;
|
||||
+ aScaleTo.Set(aFit[0], aFit[1]);
|
||||
+ }
|
||||
+ else if (const auto oPages = aTree.get_optional<int>("pages"))
|
||||
+ {
|
||||
+ if (*oPages < 1 || *oPages > nMaxPages)
|
||||
+ return false;
|
||||
+ nPages = *oPages;
|
||||
+ }
|
||||
+ else
|
||||
+ return false;
|
||||
+
|
||||
+ ScDocument& rDoc = rDocSh.GetDocument();
|
||||
+ const OUString aName = rDoc.GetPageStyle(nTab);
|
||||
+ SfxStyleSheetBase* pStyle = rDoc.GetStyleSheetPool()->Find(aName, SfxStyleFamily::Page);
|
||||
+ if (!pStyle)
|
||||
+ return false;
|
||||
+ ScStyleSaveData aOld;
|
||||
+ aOld.InitFromStyle(pStyle);
|
||||
+ SfxItemSet aSet(pStyle->GetItemSet());
|
||||
+ SvxPageItem aPage(aSet.Get(ATTR_PAGE));
|
||||
+ aPage.SetLandscape(bLandscape);
|
||||
+ aSet.Put(aPage);
|
||||
+ const Size aSize = aSet.Get(ATTR_PAGE_SIZE).GetSize();
|
||||
+ if ((aSize.Width() > aSize.Height()) != bLandscape)
|
||||
+ aSet.Put(SvxSizeItem(ATTR_PAGE_SIZE, Size(aSize.Height(), aSize.Width())));
|
||||
+ aSet.Put(SfxUInt16Item(ATTR_PAGE_SCALE, nScale));
|
||||
+ aSet.Put(SfxUInt16Item(ATTR_PAGE_SCALETOPAGES, nPages));
|
||||
+ aSet.Put(aScaleTo);
|
||||
+ rDoc.ModifyStyleSheet(*pStyle, aSet);
|
||||
+ ScStyleSaveData aNew;
|
||||
+ aNew.InitFromStyle(pStyle);
|
||||
+ if (rDoc.IsUndoEnabled())
|
||||
+ rDocSh.GetUndoManager()->AddUndoAction(
|
||||
+ std::make_unique<ScUndoModifyStyle>(rDocSh, SfxStyleFamily::Page, aOld, aNew));
|
||||
+ rDocSh.PageStyleModified(aName, true);
|
||||
+ return true;
|
||||
+}
|
||||
+}
|
||||
+
|
||||
void ScDocShell::ExecutePageStyle( const SfxViewShell& rCaller,
|
||||
SfxRequest& rReq,
|
||||
SCTAB nCurTab )
|
||||
@@ -2255,7 +2333,14 @@ void ScDocShell::ExecutePageStyle( const SfxViewShell& rCaller,
|
||||
case SID_STATUS_PAGESTYLE: // click on StatusBar control
|
||||
case SID_FORMATPAGE:
|
||||
{
|
||||
- if ( pReqArgs == nullptr )
|
||||
+ if (const SfxStringItem* pKit = rReq.GetArg<SfxStringItem>(FN_PARAM_1))
|
||||
+ {
|
||||
+ if (lcl_KitPage(*this, nCurTab, pKit->GetValue()))
|
||||
+ rReq.Done();
|
||||
+ else
|
||||
+ rReq.Ignore();
|
||||
+ }
|
||||
+ else if ( pReqArgs == nullptr )
|
||||
{
|
||||
OUString aOldName = m_pDocument->GetPageStyle( nCurTab );
|
||||
ScStyleSheetPool* pStylePool = m_pDocument->GetStyleSheetPool();
|
||||
diff --git a/sc/source/ui/inc/kitsheet.hxx b/sc/source/ui/inc/kitsheet.hxx
|
||||
new file mode 100644
|
||||
index 0000000..481f20d
|
||||
--- /dev/null
|
||||
+++ b/sc/source/ui/inc/kitsheet.hxx
|
||||
@@ -0,0 +1,28 @@
|
||||
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
+/*
|
||||
+ * 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/.
|
||||
+ */
|
||||
+
|
||||
+#pragma once
|
||||
+
|
||||
+#include <tabprotection.hxx>
|
||||
+
|
||||
+#include <string_view>
|
||||
+#include <utility>
|
||||
+
|
||||
+/// Sheet protection options by their kit client names.
|
||||
+constexpr std::pair<std::string_view, ScTableProtection::Option> aKitProtectOptions[]
|
||||
+ = { { "selectLocked", ScTableProtection::SELECT_LOCKED_CELLS },
|
||||
+ { "selectUnlocked", ScTableProtection::SELECT_UNLOCKED_CELLS },
|
||||
+ { "insertColumns", ScTableProtection::INSERT_COLUMNS },
|
||||
+ { "insertRows", ScTableProtection::INSERT_ROWS },
|
||||
+ { "deleteColumns", ScTableProtection::DELETE_COLUMNS },
|
||||
+ { "deleteRows", ScTableProtection::DELETE_ROWS },
|
||||
+ { "autofilter", ScTableProtection::AUTOFILTER },
|
||||
+ { "pivot", ScTableProtection::PIVOT_TABLES } };
|
||||
+
|
||||
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
|
||||
index 31a7d6f..0715e00 100644
|
||||
--- a/sc/source/ui/unoobj/docuno.cxx
|
||||
+++ b/sc/source/ui/unoobj/docuno.cxx
|
||||
@@ -158,6 +158,9 @@
|
||||
#include <dpobject.hxx>
|
||||
#include <dpshttab.hxx>
|
||||
#include <kitpivot.hxx>
|
||||
+#include <kitsheet.hxx>
|
||||
+#include <attrib.hxx>
|
||||
+#include <svx/pageitem.hxx>
|
||||
#include <pivot.hxx>
|
||||
#include <svx/svdoole2.hxx>
|
||||
|
||||
@@ -939,6 +942,65 @@ void lcl_Chart(tools::JsonWriter& rJson, ScDocument& rDoc, ScViewData& rData)
|
||||
sctools::writeChartLook(rJson, rDoc.GetChartByName(aName));
|
||||
}
|
||||
|
||||
+/// A repeated row or column span, 1-based.
|
||||
+void lcl_PutSpan(tools::JsonWriter& rJson, std::string_view rName, const std::optional<ScRange>& oRange,
|
||||
+ bool bRows)
|
||||
+{
|
||||
+ if (!oRange)
|
||||
+ return;
|
||||
+ auto aNode = rJson.startNode(rName);
|
||||
+ rJson.put("first", (bRows ? oRange->aStart.Row() : oRange->aStart.Col()) + 1);
|
||||
+ rJson.put("last", (bRows ? oRange->aEnd.Row() : oRange->aEnd.Col()) + 1);
|
||||
+}
|
||||
+
|
||||
+/// Print ranges, titles, page setup and breaks at the cursor.
|
||||
+void lcl_PrintLayout(tools::JsonWriter& rJson, ScDocument& rDoc, const ScAddress& rCursor)
|
||||
+{
|
||||
+ const SCTAB nTab = rCursor.Tab();
|
||||
+ const ScAddress::Details aDetails(rDoc.GetAddressConvention(), 0, 0);
|
||||
+ {
|
||||
+ auto aAreas = rJson.startArray("areas");
|
||||
+ for (sal_uInt16 i = 0, n = rDoc.GetPrintRangeCount(nTab); i < n; ++i)
|
||||
+ rJson.putSimpleValue(rDoc.GetPrintRange(nTab, i)->Format(rDoc, ScRefFlags::RANGE_ABS, aDetails));
|
||||
+ }
|
||||
+ lcl_PutSpan(rJson, "rows", rDoc.GetRepeatRowRange(nTab), true);
|
||||
+ lcl_PutSpan(rJson, "columns", rDoc.GetRepeatColRange(nTab), false);
|
||||
+ rJson.put("rowBreak", bool(rDoc.HasRowBreak(rCursor.Row(), nTab) & ScBreakType::Manual));
|
||||
+ rJson.put("columnBreak", bool(rDoc.HasColBreak(rCursor.Col(), nTab) & ScBreakType::Manual));
|
||||
+ const OUString aStyle = rDoc.GetPageStyle(nTab);
|
||||
+ SfxStyleSheetBase* pStyle = rDoc.GetStyleSheetPool()->Find(aStyle, SfxStyleFamily::Page);
|
||||
+ if (!pStyle)
|
||||
+ return;
|
||||
+ const SfxItemSet& rSet = pStyle->GetItemSet();
|
||||
+ rJson.put("landscape", rSet.Get(ATTR_PAGE).IsLandscape());
|
||||
+ rJson.put("scale", rSet.Get(ATTR_PAGE_SCALE).GetValue());
|
||||
+ rJson.put("pages", rSet.Get(ATTR_PAGE_SCALETOPAGES).GetValue());
|
||||
+ rJson.put("fitWidth", rSet.Get(ATTR_PAGE_SCALETO).GetWidth());
|
||||
+ rJson.put("fitHeight", rSet.Get(ATTR_PAGE_SCALETO).GetHeight());
|
||||
+ // Every sheet the page style governs.
|
||||
+ auto aSheets = rJson.startArray("sheets");
|
||||
+ for (SCTAB i = 0; i < rDoc.GetTableCount(); ++i)
|
||||
+ {
|
||||
+ OUString aName;
|
||||
+ if (rDoc.GetPageStyle(i) == aStyle && rDoc.GetName(i, aName))
|
||||
+ rJson.putSimpleValue(aName);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+/// The sheet's protection and its allowed actions.
|
||||
+void lcl_SheetProtection(tools::JsonWriter& rJson, ScDocument& rDoc, SCTAB nTab)
|
||||
+{
|
||||
+ const ScTableProtection aNone;
|
||||
+ const ScTableProtection* pProtect = rDoc.GetTabProtection(nTab);
|
||||
+ const ScTableProtection& rProtect = pProtect ? *pProtect : aNone;
|
||||
+ rJson.put("protected", rProtect.isProtected());
|
||||
+ rJson.put("password", rProtect.isProtected() && rProtect.isProtectedWithPass());
|
||||
+ auto aAllow = rJson.startArray("allow");
|
||||
+ for (const auto& [rName, eOption] : aKitProtectOptions)
|
||||
+ if (rProtect.isOptionEnabled(eOption))
|
||||
+ rJson.putSimpleValue(OUString::fromUtf8(rName));
|
||||
+}
|
||||
+
|
||||
/// The pivot table at the cursor: ranges and fields.
|
||||
void lcl_PivotTable(tools::JsonWriter& rJson, ScDocument& rDoc, const ScAddress& rCursor)
|
||||
{
|
||||
@@ -996,7 +1058,7 @@ bool ScModelObj::supportsCommand(std::u16string_view rCommand)
|
||||
= { u"SheetReferences", u"DefinedNames", u"SelectedRange",
|
||||
u"AutoFilterValues", u"DataSelectValues", u"Validation",
|
||||
u"NumberFormatCode", u"ConditionalFormats", u"Chart",
|
||||
- u"PivotTable" };
|
||||
+ u"PivotTable", u"PrintLayout", u"SheetProtection" };
|
||||
return std::find(std::begin(aCommands), std::end(aCommands), rCommand) != std::end(aCommands);
|
||||
}
|
||||
|
||||
@@ -1033,6 +1095,10 @@ void ScModelObj::getCommandValues(tools::JsonWriter& rJsonWriter, std::string_vi
|
||||
return lcl_Chart(rJsonWriter, rDoc, *pCurrent);
|
||||
if (rCommand == ".uno:PivotTable")
|
||||
return lcl_PivotTable(rJsonWriter, rDoc, aCursor);
|
||||
+ if (rCommand == ".uno:PrintLayout")
|
||||
+ return lcl_PrintLayout(rJsonWriter, rDoc, aCursor);
|
||||
+ if (rCommand == ".uno:SheetProtection")
|
||||
+ return lcl_SheetProtection(rJsonWriter, rDoc, nTab);
|
||||
}
|
||||
if (pDocShell && rCommand == ".uno:SelectedRange")
|
||||
{
|
||||
diff --git a/sc/source/ui/view/formatsh.cxx b/sc/source/ui/view/formatsh.cxx
|
||||
index e2a6202..caa636d 100644
|
||||
--- a/sc/source/ui/view/formatsh.cxx
|
||||
+++ b/sc/source/ui/view/formatsh.cxx
|
||||
@@ -1065,6 +1065,18 @@ void ScFormatShell::ExecuteAttr( SfxRequest& rReq )
|
||||
rBindings.Invalidate( nSlot );
|
||||
rBindings.Update( nSlot );
|
||||
break;
|
||||
+ case SID_SCATTR_CELLPROTECTION:
|
||||
+ {
|
||||
+ // Sets the lock, keeps the hide flags.
|
||||
+ const SfxBoolItem* pLock = rReq.GetArg<SfxBoolItem>(SID_SCATTR_CELLPROTECTION);
|
||||
+ if (!pLock)
|
||||
+ break;
|
||||
+ const ScProtectionAttr& rOld = pTabViewShell->GetSelectionPattern()->GetItem(ATTR_PROTECTION);
|
||||
+ pTabViewShell->ApplyAttr(ScProtectionAttr(pLock->GetValue(), rOld.GetHideFormula(), rOld.GetHideCell(), rOld.GetHidePrint()));
|
||||
+ rBindings.Invalidate( nSlot );
|
||||
+ rBindings.Update( nSlot );
|
||||
+ break;
|
||||
+ }
|
||||
case SID_ATTR_CHAR_COLOR:
|
||||
case SID_SCATTR_PROTECTION :
|
||||
{
|
||||
diff --git a/sc/source/ui/view/tabvwsh3.cxx b/sc/source/ui/view/tabvwsh3.cxx
|
||||
index c15d7c5..49295ba 100644
|
||||
--- a/sc/source/ui/view/tabvwsh3.cxx
|
||||
+++ b/sc/source/ui/view/tabvwsh3.cxx
|
||||
@@ -45,6 +45,9 @@
|
||||
#include <reffact.hxx>
|
||||
#include <tabprotection.hxx>
|
||||
#include <protectiondlg.hxx>
|
||||
+#include <kitsheet.hxx>
|
||||
+#include <docfunc.hxx>
|
||||
+#include <boost/property_tree/json_parser.hpp>
|
||||
#include <duplicaterecordsdlg.hxx>
|
||||
#include <markdata.hxx>
|
||||
|
||||
@@ -250,6 +253,56 @@ void ScTabViewShell::FinishProtectTable()
|
||||
SelectionChanged();
|
||||
}
|
||||
|
||||
+namespace
|
||||
+{
|
||||
+/// Protects or unprotects as a kit client's JSON asks.
|
||||
+bool lcl_KitProtect(ScTabViewShell& rShell, SCTAB nTab, bool bOld, const OUString& rJson)
|
||||
+{
|
||||
+ boost::property_tree::ptree aTree;
|
||||
+ std::stringstream aStream{ std::string(rJson.toUtf8()) };
|
||||
+ try
|
||||
+ {
|
||||
+ boost::property_tree::read_json(aStream, aTree);
|
||||
+ }
|
||||
+ catch (const boost::property_tree::json_parser_error&)
|
||||
+ {
|
||||
+ return false;
|
||||
+ }
|
||||
+ const bool bProtect = aTree.get<bool>("protect", false);
|
||||
+ const OUString aPassword = OUString::fromUtf8(aTree.get<std::string>("password", ""));
|
||||
+ if (bProtect == bOld)
|
||||
+ return false;
|
||||
+ if (!bProtect)
|
||||
+ {
|
||||
+ // A wrong password changes nothing.
|
||||
+ if (!rShell.GetViewData().GetDocShell()->GetDocFunc().Unprotect(nTab, aPassword, true))
|
||||
+ return false;
|
||||
+ rShell.SetTabProtectionSymbol(nTab, false);
|
||||
+ return true;
|
||||
+ }
|
||||
+ ScTableProtection aNew;
|
||||
+ aNew.setProtected(true);
|
||||
+ aNew.setPassword(aPassword);
|
||||
+ for (const auto& [rName, eOption] : aKitProtectOptions)
|
||||
+ aNew.setOption(eOption, false);
|
||||
+ if (const auto oAllow = aTree.get_child_optional("allow"))
|
||||
+ {
|
||||
+ for (const auto& rItem : *oAllow)
|
||||
+ {
|
||||
+ const std::string aName = rItem.second.get_value<std::string>();
|
||||
+ const auto pFound = std::find_if(std::begin(aKitProtectOptions), std::end(aKitProtectOptions),
|
||||
+ [&aName](const auto& rOption) { return rOption.first == aName; });
|
||||
+ if (pFound == std::end(aKitProtectOptions))
|
||||
+ return false;
|
||||
+ aNew.setOption(pFound->second, true);
|
||||
+ }
|
||||
+ }
|
||||
+ ScModule::get()->InputEnterHandler();
|
||||
+ rShell.ProtectSheet(nTab, aNew);
|
||||
+ return true;
|
||||
+}
|
||||
+}
|
||||
+
|
||||
void ScTabViewShell::ExecProtectTable( SfxRequest& rReq )
|
||||
{
|
||||
ScModule* pScMod = ScModule::get();
|
||||
@@ -258,6 +311,18 @@ void ScTabViewShell::ExecProtectTable( SfxRequest& rReq )
|
||||
SCTAB nTab = GetViewData().CurrentTabForData();
|
||||
bool bOldProtection = rDoc.IsTabProtected(nTab);
|
||||
|
||||
+ if (const SfxStringItem* pKit = rReq.GetArg<SfxStringItem>(FN_PARAM_1))
|
||||
+ {
|
||||
+ if (!lcl_KitProtect(*this, nTab, bOldProtection, pKit->GetValue()))
|
||||
+ {
|
||||
+ rReq.Ignore();
|
||||
+ return;
|
||||
+ }
|
||||
+ rReq.Done();
|
||||
+ FinishProtectTable();
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
if( pReqArgs )
|
||||
{
|
||||
const SfxPoolItem* pItem;
|
||||
@@ -0,0 +1,169 @@
|
||||
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
|
||||
index f735297..12f51b1 100644
|
||||
--- a/desktop/source/lib/init.cxx
|
||||
+++ b/desktop/source/lib/init.cxx
|
||||
@@ -2980,6 +2980,8 @@ static LibreOfficeKitDocument* lo_documentLoadWithOptions(LibreOfficeKit* pThis,
|
||||
// set AsTemplate explicitly false to be able to load template files
|
||||
// as regular files, otherwise we cannot save them; it will try
|
||||
// to bring saveas dialog which cannot work with LOK case
|
||||
+ // A kit client may name the filter; detection guesses otherwise.
|
||||
+ const OUString aFilterName = extractParameter(aOptions, u"FilterName");
|
||||
uno::Sequence<css::beans::PropertyValue> aFilterOptions{
|
||||
comphelper::makePropertyValue(u"FilterOptions"_ustr, aOptions),
|
||||
comphelper::makePropertyValue(u"InteractionHandler"_ustr, uno::Reference<task::XInteractionHandler2>(pInteraction)),
|
||||
@@ -2987,6 +2989,12 @@ static LibreOfficeKitDocument* lo_documentLoadWithOptions(LibreOfficeKit* pThis,
|
||||
comphelper::makePropertyValue(u"AsTemplate"_ustr, false),
|
||||
comphelper::makePropertyValue(u"Silent"_ustr, !aBatch.isEmpty())
|
||||
};
|
||||
+ if (!aFilterName.isEmpty())
|
||||
+ {
|
||||
+ aFilterOptions.realloc(aFilterOptions.getLength() + 1);
|
||||
+ aFilterOptions.getArray()[aFilterOptions.getLength() - 1]
|
||||
+ = comphelper::makePropertyValue(u"FilterName"_ustr, aFilterName);
|
||||
+ }
|
||||
|
||||
/* TODO
|
||||
sal_Int16 nUpdateDoc = document::UpdateDocMode::ACCORDING_TO_CONFIG;
|
||||
@@ -3857,21 +3865,24 @@ static int doc_saveAs(LibreOfficeKitDocument* pThis, const char* sUrl, const cha
|
||||
// saveAs() is more like save-a-copy, which allows saving to any
|
||||
// random format like PDF or PNG.
|
||||
// It is not a real filter option, so we have to filter it out.
|
||||
- const uno::Sequence<OUString> aOptionSeq = comphelper::string::convertCommaSeparated(aFilterOptions);
|
||||
+ // Other tokens pass verbatim: CSV options are positional.
|
||||
std::vector<OUString> aFilteredOptionVec;
|
||||
bool bTakeOwnership = false;
|
||||
bool bCreateFromTemplate = false;
|
||||
MediaDescriptor aSaveMediaDescriptor;
|
||||
- for (const auto& rOption : aOptionSeq)
|
||||
+ sal_Int32 nOption = aFilterOptions.isEmpty() ? -1 : 0;
|
||||
+ while (nOption >= 0)
|
||||
{
|
||||
- if (rOption == "TakeOwnership")
|
||||
+ const OUString aOption = aFilterOptions.getToken(0, ',', nOption);
|
||||
+ const OUString aKey = aOption.trim();
|
||||
+ if (aKey == "TakeOwnership")
|
||||
bTakeOwnership = true;
|
||||
- else if (rOption == "NoFileSync")
|
||||
+ else if (aKey == "NoFileSync")
|
||||
aSaveMediaDescriptor[u"NoFileSync"_ustr] <<= true;
|
||||
- else if (rOption == "FromTemplate")
|
||||
+ else if (aKey == "FromTemplate")
|
||||
bCreateFromTemplate = true;
|
||||
else
|
||||
- aFilteredOptionVec.push_back(rOption);
|
||||
+ aFilteredOptionVec.push_back(aOption);
|
||||
}
|
||||
|
||||
if (bCreateFromTemplate && bTakeOwnership)
|
||||
@@ -3886,8 +3897,14 @@ static int doc_saveAs(LibreOfficeKitDocument* pThis, const char* sUrl, const cha
|
||||
aSaveMediaDescriptor[u"Overwrite"_ustr] <<= true;
|
||||
aSaveMediaDescriptor[u"FilterName"_ustr] <<= aFilterName;
|
||||
|
||||
- auto aFilteredOptionSeq = comphelper::containerToSequence<OUString>(aFilteredOptionVec);
|
||||
- aFilterOptions = comphelper::string::convertCommaSeparated(aFilteredOptionSeq);
|
||||
+ OUStringBuffer aKept;
|
||||
+ for (size_t i = 0; i < aFilteredOptionVec.size(); ++i)
|
||||
+ {
|
||||
+ if (i)
|
||||
+ aKept.append(',');
|
||||
+ aKept.append(aFilteredOptionVec[i]);
|
||||
+ }
|
||||
+ aFilterOptions = aKept.makeStringAndClear();
|
||||
aSaveMediaDescriptor[MediaDescriptor::PROP_FILTEROPTIONS] <<= aFilterOptions;
|
||||
|
||||
comphelper::SequenceAsHashMap aFilterDataMap;
|
||||
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
|
||||
index 0715e00..b850504 100644
|
||||
--- a/sc/source/ui/unoobj/docuno.cxx
|
||||
+++ b/sc/source/ui/unoobj/docuno.cxx
|
||||
@@ -159,6 +159,14 @@
|
||||
#include <dpshttab.hxx>
|
||||
#include <kitpivot.hxx>
|
||||
#include <kitsheet.hxx>
|
||||
+#include <arealink.hxx>
|
||||
+#include <ddelink.hxx>
|
||||
+#include <documentlinkmgr.hxx>
|
||||
+#include <externalrefmgr.hxx>
|
||||
+#include <tablink.hxx>
|
||||
+#include <webservicelink.hxx>
|
||||
+#include <sfx2/linkmgr.hxx>
|
||||
+#include <set>
|
||||
#include <attrib.hxx>
|
||||
#include <svx/pageitem.hxx>
|
||||
#include <pivot.hxx>
|
||||
@@ -987,6 +995,33 @@ void lcl_PrintLayout(tools::JsonWriter& rJson, ScDocument& rDoc, const ScAddress
|
||||
}
|
||||
}
|
||||
|
||||
+/// Files and sources whose data the workbook shows as saved.
|
||||
+void lcl_ExternalLinks(tools::JsonWriter& rJson, ScDocument& rDoc)
|
||||
+{
|
||||
+ std::set<OUString> aSources;
|
||||
+ ScExternalRefManager* pRefs = rDoc.GetExternalRefManager();
|
||||
+ for (sal_uInt16 i = 0, n = pRefs->getExternalFileCount(); i < n; ++i)
|
||||
+ if (const OUString* pName = pRefs->getExternalFileName(i, true))
|
||||
+ aSources.insert(*pName);
|
||||
+ if (sfx2::LinkManager* pLinks = rDoc.GetDocLinkManager().getLinkManager(false))
|
||||
+ {
|
||||
+ for (const auto& rLink : pLinks->GetLinks())
|
||||
+ {
|
||||
+ if (auto pArea = dynamic_cast<const ScAreaLink*>(rLink.get()))
|
||||
+ aSources.insert(pArea->GetFile());
|
||||
+ else if (auto pTable = dynamic_cast<const ScTableLink*>(rLink.get()))
|
||||
+ aSources.insert(pTable->GetFileName());
|
||||
+ else if (auto pDde = dynamic_cast<const ScDdeLink*>(rLink.get()))
|
||||
+ aSources.insert(pDde->GetAppl() + "|" + pDde->GetTopic());
|
||||
+ else if (auto pWeb = dynamic_cast<const ScWebServiceLink*>(rLink.get()))
|
||||
+ aSources.insert(pWeb->GetURL());
|
||||
+ }
|
||||
+ }
|
||||
+ auto aArray = rJson.startArray("links");
|
||||
+ for (const OUString& rSource : aSources)
|
||||
+ rJson.putSimpleValue(rSource);
|
||||
+}
|
||||
+
|
||||
/// The sheet's protection and its allowed actions.
|
||||
void lcl_SheetProtection(tools::JsonWriter& rJson, ScDocument& rDoc, SCTAB nTab)
|
||||
{
|
||||
@@ -1058,7 +1093,8 @@ bool ScModelObj::supportsCommand(std::u16string_view rCommand)
|
||||
= { u"SheetReferences", u"DefinedNames", u"SelectedRange",
|
||||
u"AutoFilterValues", u"DataSelectValues", u"Validation",
|
||||
u"NumberFormatCode", u"ConditionalFormats", u"Chart",
|
||||
- u"PivotTable", u"PrintLayout", u"SheetProtection" };
|
||||
+ u"PivotTable", u"PrintLayout", u"SheetProtection",
|
||||
+ u"ExternalLinks" };
|
||||
return std::find(std::begin(aCommands), std::end(aCommands), rCommand) != std::end(aCommands);
|
||||
}
|
||||
|
||||
@@ -1066,6 +1102,8 @@ void ScModelObj::getCommandValues(tools::JsonWriter& rJsonWriter, std::string_vi
|
||||
{
|
||||
if (pDocShell && rCommand == ".uno:DefinedNames")
|
||||
return lcl_DefinedNames(rJsonWriter, pDocShell->GetDocument());
|
||||
+ if (pDocShell && rCommand == ".uno:ExternalLinks")
|
||||
+ return lcl_ExternalLinks(rJsonWriter, pDocShell->GetDocument());
|
||||
ScViewData* pCurrent = ScDocShell::GetViewData();
|
||||
if (pDocShell && pCurrent)
|
||||
{
|
||||
diff --git a/sc/source/ui/unoobj/filtuno.cxx b/sc/source/ui/unoobj/filtuno.cxx
|
||||
index ef9a326..e7c57cf 100644
|
||||
--- a/sc/source/ui/unoobj/filtuno.cxx
|
||||
+++ b/sc/source/ui/unoobj/filtuno.cxx
|
||||
@@ -41,6 +41,7 @@
|
||||
#include <optutil.hxx>
|
||||
#include <com/sun/star/uno/Any.hxx>
|
||||
#include <com/sun/star/uno/Sequence.hxx>
|
||||
+#include <comphelper/lok.hxx>
|
||||
#include <comphelper/namedvaluecollection.hxx>
|
||||
#include <comphelper/propertysequence.hxx>
|
||||
#include <memory>
|
||||
@@ -179,6 +180,10 @@ sal_Int16 SAL_CALL ScFilterOptionsObj::execute()
|
||||
|
||||
if ( !bExport && aFilterString == ScDocShell::GetAsciiFilterName() )
|
||||
{
|
||||
+ // A kit client's options stand.
|
||||
+ if (comphelper::LibreOfficeKit::isActive() && !aFilterOptions.isEmpty())
|
||||
+ return ui::dialogs::ExecutableDialogResults::OK;
|
||||
+
|
||||
// ascii import is special...
|
||||
|
||||
INetURLObject aURL( aFileName );
|
||||
@@ -0,0 +1,247 @@
|
||||
diff --git a/sd/inc/unomodel.hxx b/sd/inc/unomodel.hxx
|
||||
index 95cfafc..10b0013 100644
|
||||
--- a/sd/inc/unomodel.hxx
|
||||
+++ b/sd/inc/unomodel.hxx
|
||||
@@ -297,6 +297,8 @@ public:
|
||||
SD_DLLPUBLIC OString getViewRenderState(SfxViewShell* pViewShell = nullptr) override;
|
||||
|
||||
SD_DLLPUBLIC virtual void getCommandValues(tools::JsonWriter& rJsonWriter, std::string_view rCommand) override;
|
||||
+ /// @see vcl::ITiledRenderable::supportsCommand().
|
||||
+ SD_DLLPUBLIC virtual bool supportsCommand(std::u16string_view rCommand) override;
|
||||
|
||||
/// @see vcl::ITiledRenderable::getPresentationInfo().
|
||||
SD_DLLPUBLIC OString getPresentationInfo(bool bAllyState = false) const override;
|
||||
diff --git a/sd/sdi/sdraw.sdi b/sd/sdi/sdraw.sdi
|
||||
index 165a56f..38859c6 100644
|
||||
--- a/sd/sdi/sdraw.sdi
|
||||
+++ b/sd/sdi/sdraw.sdi
|
||||
@@ -2757,7 +2757,7 @@ SfxVoidItem ClearUndoStack SID_CLEAR_UNDO_STACK
|
||||
]
|
||||
|
||||
SfxVoidItem PresentationLayout SID_PRESENTATION_LAYOUT
|
||||
-()
|
||||
+(SfxStringItem Master FN_PARAM_1)
|
||||
[
|
||||
AutoUpdate = FALSE,
|
||||
FastCall = FALSE,
|
||||
diff --git a/sd/source/ui/func/undopage.cxx b/sd/source/ui/func/undopage.cxx
|
||||
index 174747b..2a808a8 100644
|
||||
--- a/sd/source/ui/func/undopage.cxx
|
||||
+++ b/sd/source/ui/func/undopage.cxx
|
||||
@@ -19,12 +19,28 @@
|
||||
|
||||
#include <undopage.hxx>
|
||||
#include <sdpage.hxx>
|
||||
+#include <drawdoc.hxx>
|
||||
+#include <unomodel.hxx>
|
||||
+#include <comphelper/lok.hxx>
|
||||
+#include <sfx2/lokhelper.hxx>
|
||||
|
||||
|
||||
SdPageFormatUndoAction::~SdPageFormatUndoAction()
|
||||
{
|
||||
}
|
||||
|
||||
+namespace
|
||||
+{
|
||||
+/// LOK clients read a slide's size only when told.
|
||||
+void lcl_NotifySize(SdPage& rPage)
|
||||
+{
|
||||
+ if (comphelper::LibreOfficeKit::isActive() && !rPage.IsMasterPage()
|
||||
+ && rPage.GetPageKind() == PageKind::Standard)
|
||||
+ SfxLokHelper::notifyDocumentSizeChangedAllViews(
|
||||
+ static_cast<SdDrawDocument&>(rPage.getSdrModelFromSdrPage()).getUnoModel());
|
||||
+}
|
||||
+}
|
||||
+
|
||||
void SdPageFormatUndoAction::Undo()
|
||||
{
|
||||
::tools::Rectangle aOldBorderRect(mnOldLeft, mnOldUpper, mnOldRight, mnOldLower);
|
||||
@@ -40,7 +56,7 @@ void SdPageFormatUndoAction::Undo()
|
||||
mpPage->SetBackgroundFullSize( mbOldFullSize );
|
||||
if( !mpPage->IsMasterPage() )
|
||||
static_cast<SdPage&>( mpPage->TRG_GetMasterPage() ).SetBackgroundFullSize( mbOldFullSize );
|
||||
-
|
||||
+ lcl_NotifySize(*mpPage);
|
||||
}
|
||||
|
||||
void SdPageFormatUndoAction::Redo()
|
||||
@@ -58,7 +74,7 @@ void SdPageFormatUndoAction::Redo()
|
||||
mpPage->SetBackgroundFullSize( mbNewFullSize );
|
||||
if( !mpPage->IsMasterPage() )
|
||||
static_cast<SdPage&>( mpPage->TRG_GetMasterPage() ).SetBackgroundFullSize( mbNewFullSize );
|
||||
-
|
||||
+ lcl_NotifySize(*mpPage);
|
||||
}
|
||||
|
||||
SdPageLRUndoAction::~SdPageLRUndoAction()
|
||||
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
|
||||
index ea6ce5b..f47b443 100644
|
||||
--- a/sd/source/ui/unoidl/unomodel.cxx
|
||||
+++ b/sd/source/ui/unoidl/unomodel.cxx
|
||||
@@ -189,6 +189,8 @@
|
||||
#include <controller/SlsPageSelector.hxx>
|
||||
|
||||
#include <app.hrc>
|
||||
+#include <svx/ColorSets.hxx>
|
||||
+#include <docmodel/theme/Theme.hxx>
|
||||
|
||||
using namespace ::cppu;
|
||||
using namespace ::com::sun::star;
|
||||
@@ -2042,9 +2044,44 @@ void SdXImpressDocument::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
|
||||
SfxBaseModel::Notify( rBC, rHint );
|
||||
}
|
||||
|
||||
+bool SdXImpressDocument::supportsCommand(std::u16string_view rCommand)
|
||||
+{
|
||||
+ return rCommand == u"SlideDesign";
|
||||
+}
|
||||
+
|
||||
+namespace
|
||||
+{
|
||||
+/// Masters, color sets, and the shown slide's design.
|
||||
+void lcl_SlideDesign(::tools::JsonWriter& rJson, SdDrawDocument& rDoc, sd::DrawViewShell& rShell)
|
||||
+{
|
||||
+ SdPage* pPage = rShell.GetActualPage();
|
||||
+ const SdPage& rMaster = pPage->IsMasterPage() ? *pPage : static_cast<const SdPage&>(pPage->TRG_GetMasterPage());
|
||||
+ {
|
||||
+ auto aMasters = rJson.startArray("masters");
|
||||
+ for (sal_uInt16 i = 0; i < rDoc.GetMasterSdPageCount(PageKind::Standard); ++i)
|
||||
+ rJson.putSimpleValue(rDoc.GetMasterSdPage(i, PageKind::Standard)->GetName());
|
||||
+ }
|
||||
+ rJson.put("master", rMaster.GetName());
|
||||
+ rJson.put("masterView", rShell.GetEditMode() == EditMode::MasterPage);
|
||||
+ rJson.put("layout", static_cast<sal_Int32>(pPage->GetAutoLayout()));
|
||||
+ const auto& pTheme = rMaster.getSdrPageProperties().getTheme();
|
||||
+ const auto pSet = pTheme ? pTheme->getColorSet() : nullptr;
|
||||
+ rJson.put("theme", pSet ? pSet->getName() : OUString());
|
||||
+ auto aThemes = rJson.startArray("themes");
|
||||
+ for (const model::ColorSet& rSet : svx::ColorSets::get().getColorSetVector())
|
||||
+ rJson.putSimpleValue(rSet.getName());
|
||||
+}
|
||||
+}
|
||||
+
|
||||
void SdXImpressDocument::getCommandValues(::tools::JsonWriter& rJsonWriter, std::string_view rCommand)
|
||||
{
|
||||
static constexpr OStringLiteral aExtractDocStructure(".uno:ExtractDocumentStructure");
|
||||
+ if (rCommand == ".uno:SlideDesign")
|
||||
+ {
|
||||
+ if (auto pShell = dynamic_cast<sd::DrawViewShell*>(mpDocShell->GetViewShell()))
|
||||
+ lcl_SlideDesign(rJsonWriter, *mpDoc, *pShell);
|
||||
+ return;
|
||||
+ }
|
||||
|
||||
std::map<OUString, OUString> aMap
|
||||
= SfxLokHelper::parseCommandParameters(OUString::fromUtf8(rCommand));
|
||||
diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx
|
||||
index d0b3ead..b1f1461 100644
|
||||
--- a/sd/source/ui/view/drviews2.cxx
|
||||
+++ b/sd/source/ui/view/drviews2.cxx
|
||||
@@ -210,6 +210,8 @@
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
#include <rtl/uri.hxx>
|
||||
#include <editeng/editeng.hxx>
|
||||
+#include <svx/ColorSets.hxx>
|
||||
+#include "../sidebar/DocumentHelper.hxx"
|
||||
|
||||
|
||||
using namespace ::com::sun::star;
|
||||
@@ -1561,8 +1563,13 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
|
||||
|
||||
Size aSize (pWidth->GetValue (), pHeight->GetValue ());
|
||||
|
||||
- SetupPage (aSize, 0, 0, 0, 0, true, false, pScaleAll->GetValue ());
|
||||
- rReq.Ignore ();
|
||||
+ // The dialog's path: one undo step, orientation follows.
|
||||
+ SdPage* pPage = GetActualPage();
|
||||
+ SdPage* pMaster = pPage->IsMasterPage() ? pPage : &static_cast<SdPage&>(pPage->TRG_GetMasterPage());
|
||||
+ SetPageSizeAndBorder(GetPageKind(), aSize, -1, -1, -1, -1, pScaleAll->GetValue(),
|
||||
+ aSize.Width() >= aSize.Height() ? Orientation::Landscape : Orientation::Portrait,
|
||||
+ pPage->GetPaperBin(), pMaster->IsBackgroundFullSize());
|
||||
+ rReq.Done ();
|
||||
break;
|
||||
}
|
||||
#if HAVE_FEATURE_SCRIPTING
|
||||
@@ -2188,6 +2195,24 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
|
||||
|
||||
case SID_PRESENTATION_LAYOUT:
|
||||
{
|
||||
+ // A kit client names the master for this slide.
|
||||
+ if (const SfxStringItem* pName = rReq.GetArg<SfxStringItem>(FN_PARAM_1))
|
||||
+ {
|
||||
+ SdPage* pMaster = nullptr;
|
||||
+ for (sal_uInt16 i = 0; i < GetDoc()->GetMasterSdPageCount(PageKind::Standard); ++i)
|
||||
+ if (GetDoc()->GetMasterSdPage(i, PageKind::Standard)->GetName() == pName->GetValue())
|
||||
+ pMaster = GetDoc()->GetMasterSdPage(i, PageKind::Standard);
|
||||
+ SdPage* pPage = GetActualPage();
|
||||
+ if (!pMaster || pPage->IsMasterPage())
|
||||
+ {
|
||||
+ rReq.Ignore();
|
||||
+ break;
|
||||
+ }
|
||||
+ auto pPages = std::make_shared<std::vector<SdPage*>>(1, pPage);
|
||||
+ sidebar::DocumentHelper::AssignMasterPageToPageList(*GetDoc(), pMaster, pPages);
|
||||
+ rReq.Done();
|
||||
+ break;
|
||||
+ }
|
||||
SetCurrentFunction( FuPresentationLayout::Create(*this, GetActiveWindow(), mpDrawView.get(), *GetDoc(), rReq) );
|
||||
Cancel();
|
||||
}
|
||||
@@ -4237,6 +4262,20 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
|
||||
case SID_THEME_DIALOG:
|
||||
{
|
||||
SdrPage* pMasterPage = &GetActualPage()->TRG_GetMasterPage();
|
||||
+ // A kit client names the color set.
|
||||
+ if (const SfxStringItem* pName = rReq.GetArg<SfxStringItem>(FN_PARAM_1))
|
||||
+ {
|
||||
+ const model::ColorSet* pSet = svx::ColorSets::get().getColorSet(pName->GetValue());
|
||||
+ if (!pSet)
|
||||
+ {
|
||||
+ rReq.Ignore();
|
||||
+ break;
|
||||
+ }
|
||||
+ sd::ThemeColorChanger aChanger(pMasterPage, GetDocSh());
|
||||
+ aChanger.apply(std::make_shared<model::ColorSet>(*pSet));
|
||||
+ rReq.Done();
|
||||
+ break;
|
||||
+ }
|
||||
auto pTheme = pMasterPage->getSdrPageProperties().getTheme();
|
||||
auto pDialog = std::make_shared<svx::ThemeDialog>(GetFrameWeld(), pTheme.get());
|
||||
auto* pDocShell = GetDocSh();
|
||||
diff --git a/sd/source/ui/view/viewshe2.cxx b/sd/source/ui/view/viewshe2.cxx
|
||||
index a883dfa..4c16936 100644
|
||||
--- a/sd/source/ui/view/viewshe2.cxx
|
||||
+++ b/sd/source/ui/view/viewshe2.cxx
|
||||
@@ -61,6 +61,8 @@
|
||||
#include <svtools/soerr.hxx>
|
||||
#include <svx/charthelper.hxx>
|
||||
#include <comphelper/lok.hxx>
|
||||
+#include <sfx2/lokhelper.hxx>
|
||||
+#include <unomodel.hxx>
|
||||
|
||||
using namespace com::sun::star;
|
||||
|
||||
@@ -562,6 +564,10 @@ void ViewShell::SetPageSizeAndBorder(PageKind ePageKind, const Size& rNewSize,
|
||||
pViewShell->GetViewFrame().GetObjectShell()->GetUndoManager()->AddUndoAction(std::move(pUndoGroup));
|
||||
}
|
||||
|
||||
+ // LOK clients read the size only when told.
|
||||
+ if (comphelper::LibreOfficeKit::isActive())
|
||||
+ SfxLokHelper::notifyDocumentSizeChangedAllViews(GetDoc()->getUnoModel());
|
||||
+
|
||||
// calculate View-Sizes
|
||||
SdPage* pPage(0 != nPageCnt
|
||||
? GetDoc()->GetSdPage(0, ePageKind)
|
||||
diff --git a/svx/sdi/svx.sdi b/svx/sdi/svx.sdi
|
||||
index 9c81bb0..2cc2a87 100644
|
||||
--- a/svx/sdi/svx.sdi
|
||||
+++ b/svx/sdi/svx.sdi
|
||||
@@ -13278,7 +13278,7 @@ SfxVoidItem GraphicSizeCheck SID_GRAPHIC_SIZE_CHECK
|
||||
]
|
||||
|
||||
SfxVoidItem ThemeDialog SID_THEME_DIALOG
|
||||
-()
|
||||
+(SfxStringItem ColorSet FN_PARAM_1)
|
||||
[
|
||||
AutoUpdate = FALSE,
|
||||
FastCall = FALSE,
|
||||
@@ -0,0 +1,19 @@
|
||||
LOK: the Math in-place helper erased the painted tile
|
||||
|
||||
PaintAllInPlaceOnTile resized the tile device with the default erase,
|
||||
so every Impress tile painted during text edit came back blank (black on
|
||||
macOS). Keep the content, as the chart helper does.
|
||||
|
||||
diff --git a/sfx2/source/view/lokstarmathhelper.cxx b/sfx2/source/view/lokstarmathhelper.cxx
|
||||
index 78f27b9..ff2becb 100644
|
||||
--- a/sfx2/source/view/lokstarmathhelper.cxx
|
||||
+++ b/sfx2/source/view/lokstarmathhelper.cxx
|
||||
@@ -220,7 +220,7 @@ void LokStarMathHelper::PaintAllInPlaceOnTile(VirtualDevice& rDevice, int nOutpu
|
||||
const int nPartForCurView = pCurView->getPart();
|
||||
|
||||
// Resizes the virtual device to contain the entries context
|
||||
- rDevice.SetOutputSizePixel({ nOutputWidth, nOutputHeight });
|
||||
+ rDevice.SetOutputSizePixel({ nOutputWidth, nOutputHeight }, /*bErase*/false);
|
||||
|
||||
auto popIt = rDevice.ScopedPush(vcl::PushFlags::MAPMODE);
|
||||
MapMode aMapMode(rDevice.GetMapMode());
|
||||
@@ -0,0 +1,26 @@
|
||||
LOK: Impress paints and types into the current view
|
||||
|
||||
SdXImpressDocument::GetViewShell asked the doc shell for its connected
|
||||
view. Impress disconnects it whenever the shell stack reshuffles
|
||||
(ViewShellManager::MoveToTop), so a LOK request landing in that gap found
|
||||
no view: the tile came back blank (black on macOS) and keys were dropped.
|
||||
Under LOK take the main shell of the current view instead.
|
||||
|
||||
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
|
||||
index f47b443..aa4d8de 100644
|
||||
--- a/sd/source/ui/unoidl/unomodel.cxx
|
||||
+++ b/sd/source/ui/unoidl/unomodel.cxx
|
||||
@@ -3869,7 +3869,12 @@ DrawViewShell* SdXImpressDocument::GetViewShell()
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
- DrawViewShell* pViewSh = dynamic_cast<DrawViewShell*>(mpDocShell->GetViewShell());
|
||||
+ // The doc shell drops its view while shells reshuffle.
|
||||
+ ViewShellBase* pBase = comphelper::LibreOfficeKit::isActive()
|
||||
+ ? dynamic_cast<ViewShellBase*>(SfxViewShell::Current()) : nullptr;
|
||||
+ DrawViewShell* pViewSh = pBase && pBase->GetDocShell() == mpDocShell
|
||||
+ ? dynamic_cast<DrawViewShell*>(pBase->GetMainViewShell().get())
|
||||
+ : dynamic_cast<DrawViewShell*>(mpDocShell->GetViewShell());
|
||||
if (!pViewSh)
|
||||
{
|
||||
SAL_WARN("sd", "DrawViewShell not available!");
|
||||
@@ -0,0 +1,74 @@
|
||||
LOK: Impress applies queued pane changes before a command
|
||||
|
||||
Impress queues pane reconfiguration in user events. A LOK command that
|
||||
arrives first finds the slide sorter shell off the dispatcher stack, and
|
||||
slots it serves (hide, show) are dropped without a trace. A new
|
||||
ITiledRenderable::settleViews runs before dispatch; Impress drains its
|
||||
configuration queue there.
|
||||
|
||||
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
|
||||
index 12f51b1..76a0212 100644
|
||||
--- a/desktop/source/lib/init.cxx
|
||||
+++ b/desktop/source/lib/init.cxx
|
||||
@@ -5659,6 +5659,8 @@ static void doc_postUnoCommand(LibreOfficeKitDocument* pThis, const char* pComma
|
||||
return;
|
||||
}
|
||||
}
|
||||
+ if (ITiledRenderable* pDoc = getTiledRenderable(pThis))
|
||||
+ pDoc->settleViews();
|
||||
bool bResult = false;
|
||||
// Dispatch to this document's frame, not the desktop's active one.
|
||||
uno::Reference<frame::XFrame> xFrame = pViewShell->GetViewFrame().GetFrame().GetFrameInterface();
|
||||
diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
|
||||
index 1adcc3b..67eb24f 100644
|
||||
--- a/include/vcl/ITiledRenderable.hxx
|
||||
+++ b/include/vcl/ITiledRenderable.hxx
|
||||
@@ -379,6 +379,9 @@ public:
|
||||
*/
|
||||
virtual void setPaintTextEdit(bool) {}
|
||||
|
||||
+ /// Applies view changes still queued, before a LOK command.
|
||||
+ virtual void settleViews() {}
|
||||
+
|
||||
/// Decides if it's OK to call getCommandValues(rCommand).
|
||||
virtual bool supportsCommand(std::u16string_view /*rCommand*/) { return false; }
|
||||
|
||||
diff --git a/sd/inc/unomodel.hxx b/sd/inc/unomodel.hxx
|
||||
index 10b0013..91b55d0 100644
|
||||
--- a/sd/inc/unomodel.hxx
|
||||
+++ b/sd/inc/unomodel.hxx
|
||||
@@ -293,6 +293,8 @@ public:
|
||||
}
|
||||
/// @see vcl::ITiledRenderable::setPaintTextEdit().
|
||||
virtual void setPaintTextEdit(bool bPaint) override { mbPaintTextEdit = bPaint; }
|
||||
+ /// @see vcl::ITiledRenderable::settleViews().
|
||||
+ virtual void settleViews() override;
|
||||
/// @see vcl::ITiledRenderable::getViewRenderState().
|
||||
SD_DLLPUBLIC OString getViewRenderState(SfxViewShell* pViewShell = nullptr) override;
|
||||
|
||||
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
|
||||
index aa4d8de..d86deef 100644
|
||||
--- a/sd/source/ui/unoidl/unomodel.cxx
|
||||
+++ b/sd/source/ui/unoidl/unomodel.cxx
|
||||
@@ -127,6 +127,7 @@
|
||||
#include <xmloff/xmlgrhlp.hxx>
|
||||
#include <DrawDocShell.hxx>
|
||||
#include <ViewShellBase.hxx>
|
||||
+#include <framework/FrameworkHelper.hxx>
|
||||
#include "UnoDocumentSettings.hxx"
|
||||
|
||||
#include <Annotation.hxx>
|
||||
@@ -3883,6 +3884,13 @@ DrawViewShell* SdXImpressDocument::GetViewShell()
|
||||
return pViewSh;
|
||||
}
|
||||
|
||||
+void SdXImpressDocument::settleViews()
|
||||
+{
|
||||
+ // Pane changes are queued; their shells serve the slots.
|
||||
+ if (DrawViewShell* pViewSh = GetViewShell())
|
||||
+ sd::framework::FrameworkHelper::Instance(pViewSh->GetViewShellBase())->RequestSynchronousUpdate();
|
||||
+}
|
||||
+
|
||||
void SdXImpressDocument::paintTile( VirtualDevice& rDevice,
|
||||
int nOutputWidth, int nOutputHeight,
|
||||
int nTilePosX, int nTilePosY,
|
||||
@@ -0,0 +1,469 @@
|
||||
LOK: Impress slide objects, guides and pictures without dialogs
|
||||
|
||||
- .uno:SlideObjects reads the shown slide: objects in z order (kind, frame,
|
||||
placeholder role, lock, selected; comments, which 26.2 keeps as
|
||||
objects, are left out), the selection (kind, fill, outline,
|
||||
transparency, shadow, autofit, frame, rotation and its centre, locks,
|
||||
group and ungroup), snapping, and guides. .uno:SlideDesign reads the
|
||||
current view too.
|
||||
- .uno:SelectObject takes Index (and Add) to mark an object by z order,
|
||||
comments not counted, as in .uno:SlideObjects; Add without Index
|
||||
unmarks all.
|
||||
- .uno:CapturePoint takes Kind, X, Y to add a guide, or Index with X, Y
|
||||
or Delete to move or remove one; LOK has no snap line dialog.
|
||||
- .uno:TransformDialog takes ProtectPos and ProtectSize.
|
||||
- .uno:TextAutoFitToSize takes Fit (off, shrink, grow) for every marked
|
||||
object in one step, both growths set and the text kept for undo;
|
||||
the toggle acted on one object only.
|
||||
- .uno:ChangePicture takes FileName and replaces the selected picture.
|
||||
- Under LOK an inserted picture lands at the slide centre; the window
|
||||
area it used means nothing there.
|
||||
|
||||
diff --git a/sd/sdi/sdraw.sdi b/sd/sdi/sdraw.sdi
|
||||
index 38859c6..ccc665d 100644
|
||||
--- a/sd/sdi/sdraw.sdi
|
||||
+++ b/sd/sdi/sdraw.sdi
|
||||
@@ -244,7 +244,7 @@ SfxVoidItem Break SID_BREAK
|
||||
]
|
||||
|
||||
SfxVoidItem CapturePoint SID_CAPTUREPOINT
|
||||
-()
|
||||
+(SfxUInt32Item Index ID_VAL_INDEX, SfxUInt16Item Kind FN_PARAM_1, SfxInt32Item X FN_PARAM_2, SfxInt32Item Y FN_PARAM_3, SfxBoolItem Delete FN_PARAM_4)
|
||||
[
|
||||
AutoUpdate = FALSE,
|
||||
FastCall = FALSE,
|
||||
@@ -3314,7 +3314,7 @@ SfxBoolItem TextFitToSizeTool SID_TEXT_FITTOSIZE
|
||||
]
|
||||
|
||||
SfxBoolItem TextAutoFitToSize SID_OUTLINE_TEXT_AUTOFIT
|
||||
-
|
||||
+(SfxStringItem Fit FN_PARAM_1)
|
||||
[
|
||||
AutoUpdate = TRUE,
|
||||
FastCall = FALSE,
|
||||
diff --git a/sd/source/ui/func/fuinsert.cxx b/sd/source/ui/func/fuinsert.cxx
|
||||
index 7bab8d8..bbe3705 100644
|
||||
--- a/sd/source/ui/func/fuinsert.cxx
|
||||
+++ b/sd/source/ui/func/fuinsert.cxx
|
||||
@@ -181,7 +181,10 @@ void FuInsertGraphic::DoExecute( SfxRequest& rReq )
|
||||
nAction = DND_ACTION_LINK;
|
||||
}
|
||||
|
||||
- Point aPos = mpWindow->GetVisibleCenter();
|
||||
+ // LOK's window area means nothing; use the slide.
|
||||
+ Point aPos = comphelper::LibreOfficeKit::isActive()
|
||||
+ ? ::tools::Rectangle(Point(), mpView->GetSdrPageView()->GetPage()->GetSize()).Center()
|
||||
+ : mpWindow->GetVisibleCenter();
|
||||
SdrGrafObj* pGrafObj = mpView->InsertGraphic(aGraphic, nAction, aPos, pPickObj, nullptr);
|
||||
|
||||
if(pGrafObj && bAsLink )
|
||||
diff --git a/sd/source/ui/func/fusnapln.cxx b/sd/source/ui/func/fusnapln.cxx
|
||||
index 33a2690..7c0cfe9 100644
|
||||
--- a/sd/source/ui/func/fusnapln.cxx
|
||||
+++ b/sd/source/ui/func/fusnapln.cxx
|
||||
@@ -18,6 +18,8 @@
|
||||
*/
|
||||
|
||||
#include <fusnapln.hxx>
|
||||
+#include <comphelper/lok.hxx>
|
||||
+#include <svl/eitem.hxx>
|
||||
#include <svl/intitem.hxx>
|
||||
#include <sfx2/request.hxx>
|
||||
#include <svx/svxids.hrc>
|
||||
@@ -58,6 +60,12 @@ void FuSnapLine::DoExecute( SfxRequest& rReq )
|
||||
|
||||
// Get index of snap line or snap point from the request.
|
||||
const SfxUInt32Item* pHelpLineIndex = rReq.GetArg(ID_VAL_INDEX);
|
||||
+ SdrPageView* pPV = mpView->GetSdrPageView();
|
||||
+ if (comphelper::LibreOfficeKit::isActive() && pArgs)
|
||||
+ {
|
||||
+ DoLokExecute(rReq, pHelpLineIndex, *pPV);
|
||||
+ return;
|
||||
+ }
|
||||
if (pHelpLineIndex != nullptr)
|
||||
{
|
||||
nHelpLine = static_cast<sal_uInt16>(pHelpLineIndex->GetValue());
|
||||
@@ -65,8 +73,6 @@ void FuSnapLine::DoExecute( SfxRequest& rReq )
|
||||
pArgs = nullptr;
|
||||
}
|
||||
|
||||
- SdrPageView* pPV = mpView->GetSdrPageView();
|
||||
-
|
||||
if (!pArgs)
|
||||
{
|
||||
SfxItemSetFixed<ATTR_SNAPLINE_START, ATTR_SNAPLINE_END> aNewAttr(mrViewShell.GetPool());
|
||||
@@ -182,6 +188,43 @@ void FuSnapLine::DoExecute( SfxRequest& rReq )
|
||||
}
|
||||
}
|
||||
|
||||
+// LOK adds, moves or deletes a guide without the dialog.
|
||||
+void FuSnapLine::DoLokExecute(SfxRequest& rReq, const SfxUInt32Item* pIndex, SdrPageView& rPV)
|
||||
+{
|
||||
+ const SfxUInt16Item* pKind = rReq.GetArg<SfxUInt16Item>(FN_PARAM_1);
|
||||
+ const SfxInt32Item* pX = rReq.GetArg<SfxInt32Item>(FN_PARAM_2);
|
||||
+ const SfxInt32Item* pY = rReq.GetArg<SfxInt32Item>(FN_PARAM_3);
|
||||
+ const SfxBoolItem* pDelete = rReq.GetArg<SfxBoolItem>(FN_PARAM_4);
|
||||
+ const SdrHelpLineList& rLines = rPV.GetHelpLines();
|
||||
+ if (pIndex && pIndex->GetValue() >= rLines.GetCount())
|
||||
+ return;
|
||||
+ if (pIndex && pDelete && pDelete->GetValue())
|
||||
+ {
|
||||
+ rPV.DeleteHelpLine(pIndex->GetValue());
|
||||
+ rReq.Done();
|
||||
+ return;
|
||||
+ }
|
||||
+ if (!pX || !pY || (!pIndex && !pKind))
|
||||
+ return;
|
||||
+ Point aPos(pX->GetValue(), pY->GetValue());
|
||||
+ rPV.PagePosToLogic(aPos);
|
||||
+ if (pIndex)
|
||||
+ {
|
||||
+ const sal_uInt16 nLine = pIndex->GetValue();
|
||||
+ rPV.SetHelpLine(nLine, SdrHelpLine(rLines[nLine].GetKind(), aPos));
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ SdrHelpLineKind eKind = SdrHelpLineKind::Point;
|
||||
+ if (static_cast<SnapKind>(pKind->GetValue()) == SnapKind::Horizontal)
|
||||
+ eKind = SdrHelpLineKind::Horizontal;
|
||||
+ else if (static_cast<SnapKind>(pKind->GetValue()) == SnapKind::Vertical)
|
||||
+ eKind = SdrHelpLineKind::Vertical;
|
||||
+ rPV.InsertHelpLine(SdrHelpLine(eKind, aPos));
|
||||
+ }
|
||||
+ rReq.Done();
|
||||
+}
|
||||
+
|
||||
void FuSnapLine::Activate()
|
||||
{
|
||||
}
|
||||
diff --git a/sd/source/ui/inc/fusnapln.hxx b/sd/source/ui/inc/fusnapln.hxx
|
||||
index 20ebf94..a9dc82a 100644
|
||||
--- a/sd/source/ui/inc/fusnapln.hxx
|
||||
+++ b/sd/source/ui/inc/fusnapln.hxx
|
||||
@@ -21,6 +21,9 @@
|
||||
|
||||
#include "fupoor.hxx"
|
||||
|
||||
+class SfxUInt32Item;
|
||||
+class SdrPageView;
|
||||
+
|
||||
namespace sd {
|
||||
|
||||
class FuSnapLine final
|
||||
@@ -35,6 +38,8 @@ public:
|
||||
virtual void DoExecute( SfxRequest& rReq ) override;
|
||||
|
||||
private:
|
||||
+ void DoLokExecute(SfxRequest& rReq, const SfxUInt32Item* pIndex, SdrPageView& rPV);
|
||||
+
|
||||
FuSnapLine (
|
||||
ViewShell& rViewSh,
|
||||
::sd::Window* pWin,
|
||||
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
|
||||
index d86deef..488eb85 100644
|
||||
--- a/sd/source/ui/unoidl/unomodel.cxx
|
||||
+++ b/sd/source/ui/unoidl/unomodel.cxx
|
||||
@@ -109,6 +109,19 @@
|
||||
#include <toolkit/awt/vclxdevice.hxx>
|
||||
#include <svx/svdpool.hxx>
|
||||
#include <svx/svdpagv.hxx>
|
||||
+#include <svx/svdoole2.hxx>
|
||||
+#include <svx/xflclit.hxx>
|
||||
+#include <svx/xfillit0.hxx>
|
||||
+#include <svx/xlineit0.hxx>
|
||||
+#include <svx/xlnclit.hxx>
|
||||
+#include <svx/xlnwtit.hxx>
|
||||
+#include <svx/xfltrit.hxx>
|
||||
+#include <svx/sdtfsitm.hxx>
|
||||
+#include <svx/sdtagitm.hxx>
|
||||
+#include <svx/sdshitm.hxx>
|
||||
+#include <svx/svdhlpln.hxx>
|
||||
+#include <svx/sdangitm.hxx>
|
||||
+#include <svx/svxids.hrc>
|
||||
#include <svtools/unoimap.hxx>
|
||||
#include <svx/unoshape.hxx>
|
||||
#include <editeng/unonrule.hxx>
|
||||
@@ -2047,7 +2060,7 @@ void SdXImpressDocument::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
|
||||
|
||||
bool SdXImpressDocument::supportsCommand(std::u16string_view rCommand)
|
||||
{
|
||||
- return rCommand == u"SlideDesign";
|
||||
+ return rCommand == u"SlideDesign" || rCommand == u"SlideObjects";
|
||||
}
|
||||
|
||||
namespace
|
||||
@@ -2072,6 +2085,157 @@ void lcl_SlideDesign(::tools::JsonWriter& rJson, SdDrawDocument& rDoc, sd::DrawV
|
||||
for (const model::ColorSet& rSet : svx::ColorSets::get().getColorSetVector())
|
||||
rJson.putSimpleValue(rSet.getName());
|
||||
}
|
||||
+
|
||||
+/// What an object is, as Ely names it.
|
||||
+std::string_view lcl_ObjectKind(const SdrObject& rObj)
|
||||
+{
|
||||
+ if (rObj.GetObjInventor() != SdrInventor::Default)
|
||||
+ return "other";
|
||||
+ switch (rObj.GetObjIdentifier())
|
||||
+ {
|
||||
+ case SdrObjKind::Group: return "group";
|
||||
+ case SdrObjKind::Line:
|
||||
+ case SdrObjKind::PolyLine:
|
||||
+ case SdrObjKind::PathLine:
|
||||
+ case SdrObjKind::FreehandLine:
|
||||
+ case SdrObjKind::Measure: return "line";
|
||||
+ case SdrObjKind::Edge: return "connector";
|
||||
+ case SdrObjKind::Graphic: return "image";
|
||||
+ case SdrObjKind::Table: return "table";
|
||||
+ case SdrObjKind::OLE2:
|
||||
+ return static_cast<const SdrOle2Obj&>(rObj).IsChart() ? "chart" : "object";
|
||||
+ case SdrObjKind::Media: return "media";
|
||||
+ case SdrObjKind::Text:
|
||||
+ case SdrObjKind::TitleText:
|
||||
+ case SdrObjKind::OutlineText: return "text";
|
||||
+ default: return "shape";
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+/// A placeholder's role; empty for none.
|
||||
+std::string_view lcl_Placeholder(PresObjKind eKind)
|
||||
+{
|
||||
+ switch (eKind)
|
||||
+ {
|
||||
+ case PresObjKind::NONE: return "";
|
||||
+ case PresObjKind::Title: return "title";
|
||||
+ case PresObjKind::Outline:
|
||||
+ case PresObjKind::Text: return "body";
|
||||
+ default: return "other";
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+/// A color, `-1` for none, `-2` for mixed.
|
||||
+sal_Int32 lcl_Color(const SfxItemSet& rAttr, sal_uInt16 nStyle, sal_uInt16 nColor, bool bLine)
|
||||
+{
|
||||
+ if (rAttr.GetItemState(nStyle) == SfxItemState::INVALID)
|
||||
+ return -2;
|
||||
+ const bool bNone = bLine
|
||||
+ ? rAttr.Get(XATTR_LINESTYLE).GetValue() == css::drawing::LineStyle_NONE
|
||||
+ : rAttr.Get(XATTR_FILLSTYLE).GetValue() != css::drawing::FillStyle_SOLID;
|
||||
+ if (bNone)
|
||||
+ return -1;
|
||||
+ if (rAttr.GetItemState(nColor) == SfxItemState::INVALID)
|
||||
+ return -2;
|
||||
+ return sal_Int32(static_cast<const XColorItem&>(rAttr.Get(nColor)).GetColorValue().GetRGBColor());
|
||||
+}
|
||||
+
|
||||
+/// A flag: `0`, `1`, or `-2` for mixed.
|
||||
+sal_Int32 lcl_Flag(const SfxItemSet& rAttr, sal_uInt16 nWhich)
|
||||
+{
|
||||
+ if (rAttr.GetItemState(nWhich) == SfxItemState::INVALID)
|
||||
+ return -2;
|
||||
+ return static_cast<const SfxBoolItem&>(rAttr.Get(nWhich)).GetValue() ? 1 : 0;
|
||||
+}
|
||||
+
|
||||
+/// The marked objects' kind, look and geometry.
|
||||
+void lcl_Selection(::tools::JsonWriter& rJson, sd::View& rView)
|
||||
+{
|
||||
+ const SdrMarkList& rMarks = rView.GetMarkedObjectList();
|
||||
+ auto aNode = rJson.startNode("selection");
|
||||
+ rJson.put("count", static_cast<sal_Int32>(rMarks.GetMarkCount()));
|
||||
+ if (!rMarks.GetMarkCount())
|
||||
+ return;
|
||||
+ std::string_view aKind = lcl_ObjectKind(*rMarks.GetMark(0)->GetMarkedSdrObj());
|
||||
+ for (size_t i = 1; i < rMarks.GetMarkCount(); ++i)
|
||||
+ if (lcl_ObjectKind(*rMarks.GetMark(i)->GetMarkedSdrObj()) != aKind)
|
||||
+ aKind = "mixed";
|
||||
+ rJson.put("kind", aKind);
|
||||
+ rJson.put("canGroup", rView.IsGroupPossible());
|
||||
+ rJson.put("canUngroup", rView.IsUnGroupPossible());
|
||||
+ const SfxItemSet aAttr(rView.GetAttrFromMarked(false));
|
||||
+ rJson.put("fill", lcl_Color(aAttr, XATTR_FILLSTYLE, XATTR_FILLCOLOR, false));
|
||||
+ rJson.put("line", lcl_Color(aAttr, XATTR_LINESTYLE, XATTR_LINECOLOR, true));
|
||||
+ rJson.put("lineWidth", aAttr.GetItemState(XATTR_LINEWIDTH) == SfxItemState::INVALID
|
||||
+ ? sal_Int32(-2) : sal_Int32(aAttr.Get(XATTR_LINEWIDTH).GetValue()));
|
||||
+ rJson.put("transparency", aAttr.GetItemState(XATTR_FILLTRANSPARENCE) == SfxItemState::INVALID
|
||||
+ ? sal_Int32(-2) : sal_Int32(aAttr.Get(XATTR_FILLTRANSPARENCE).GetValue()));
|
||||
+ rJson.put("shadow", lcl_Flag(aAttr, SDRATTR_SHADOW));
|
||||
+ std::string_view aFit = "mixed";
|
||||
+ if (aAttr.GetItemState(SDRATTR_TEXT_FITTOSIZE) != SfxItemState::INVALID
|
||||
+ && aAttr.GetItemState(SDRATTR_TEXT_AUTOGROWHEIGHT) != SfxItemState::INVALID)
|
||||
+ {
|
||||
+ aFit = aAttr.Get(SDRATTR_TEXT_FITTOSIZE).GetValue() == css::drawing::TextFitToSizeType_AUTOFIT
|
||||
+ ? "shrink" : aAttr.Get(SDRATTR_TEXT_AUTOGROWHEIGHT).GetValue() ? "grow" : "off";
|
||||
+ }
|
||||
+ rJson.put("autofit", aFit);
|
||||
+ const SfxItemSet aGeo(rView.GetGeoAttrFromMarked());
|
||||
+ rJson.put("x", aGeo.Get(SID_ATTR_TRANSFORM_POS_X).GetValue());
|
||||
+ rJson.put("y", aGeo.Get(SID_ATTR_TRANSFORM_POS_Y).GetValue());
|
||||
+ rJson.put("width", sal_Int64(aGeo.Get(SID_ATTR_TRANSFORM_WIDTH).GetValue()));
|
||||
+ rJson.put("height", sal_Int64(aGeo.Get(SID_ATTR_TRANSFORM_HEIGHT).GetValue()));
|
||||
+ rJson.put("rotation", sal_Int32(aGeo.Get(SID_ATTR_TRANSFORM_ANGLE).GetValue().get()));
|
||||
+ rJson.put("rotationX", aGeo.Get(SID_ATTR_TRANSFORM_ROT_X).GetValue());
|
||||
+ rJson.put("rotationY", aGeo.Get(SID_ATTR_TRANSFORM_ROT_Y).GetValue());
|
||||
+ rJson.put("lockPosition", lcl_Flag(aGeo, SID_ATTR_TRANSFORM_PROTECT_POS));
|
||||
+ rJson.put("lockSize", lcl_Flag(aGeo, SID_ATTR_TRANSFORM_PROTECT_SIZE));
|
||||
+}
|
||||
+
|
||||
+/// The shown slide's objects, selection, guides and snapping.
|
||||
+void lcl_SlideObjects(::tools::JsonWriter& rJson, sd::DrawViewShell& rShell)
|
||||
+{
|
||||
+ sd::View& rView = *rShell.GetView();
|
||||
+ SdrPageView* pPV = rView.GetSdrPageView();
|
||||
+ SdPage* pPage = rShell.GetActualPage();
|
||||
+ const SdrMarkList& rMarks = rView.GetMarkedObjectList();
|
||||
+ {
|
||||
+ auto aObjects = rJson.startArray("objects");
|
||||
+ for (const rtl::Reference<SdrObject>& pObj : *pPage)
|
||||
+ {
|
||||
+ // Comments have their own list.
|
||||
+ if (pObj->isAnnotationObject())
|
||||
+ continue;
|
||||
+ auto aObject = rJson.startStruct();
|
||||
+ ::tools::Rectangle aRect(pObj->GetSnapRect());
|
||||
+ pPV->LogicToPagePos(aRect);
|
||||
+ rJson.put("name", pObj->GetName());
|
||||
+ rJson.put("kind", lcl_ObjectKind(*pObj));
|
||||
+ rJson.put("placeholder", lcl_Placeholder(pPage->GetPresObjKind(pObj.get())));
|
||||
+ rJson.put("x", sal_Int64(aRect.Left()));
|
||||
+ rJson.put("y", sal_Int64(aRect.Top()));
|
||||
+ rJson.put("width", sal_Int64(aRect.GetWidth()));
|
||||
+ rJson.put("height", sal_Int64(aRect.GetHeight()));
|
||||
+ rJson.put("locked", pObj->IsMoveProtect());
|
||||
+ rJson.put("selected", rMarks.FindObject(pObj.get()) != SAL_MAX_SIZE);
|
||||
+ }
|
||||
+ }
|
||||
+ lcl_Selection(rJson, rView);
|
||||
+ rJson.put("snapGrid", rView.IsGridSnap());
|
||||
+ rJson.put("snapGuides", rView.IsHlplSnap());
|
||||
+ auto aGuides = rJson.startArray("guides");
|
||||
+ const SdrHelpLineList& rLines = pPV->GetHelpLines();
|
||||
+ for (sal_uInt16 i = 0; i < rLines.GetCount(); ++i)
|
||||
+ {
|
||||
+ auto aGuide = rJson.startStruct();
|
||||
+ Point aPos(rLines[i].GetPos());
|
||||
+ pPV->LogicToPagePos(aPos);
|
||||
+ const SdrHelpLineKind eKind = rLines[i].GetKind();
|
||||
+ rJson.put("kind", eKind == SdrHelpLineKind::Horizontal ? "horizontal"
|
||||
+ : eKind == SdrHelpLineKind::Vertical ? "vertical" : "point");
|
||||
+ rJson.put("x", sal_Int64(aPos.X()));
|
||||
+ rJson.put("y", sal_Int64(aPos.Y()));
|
||||
+ }
|
||||
+}
|
||||
}
|
||||
|
||||
void SdXImpressDocument::getCommandValues(::tools::JsonWriter& rJsonWriter, std::string_view rCommand)
|
||||
@@ -2079,10 +2240,16 @@ void SdXImpressDocument::getCommandValues(::tools::JsonWriter& rJsonWriter, std:
|
||||
static constexpr OStringLiteral aExtractDocStructure(".uno:ExtractDocumentStructure");
|
||||
if (rCommand == ".uno:SlideDesign")
|
||||
{
|
||||
- if (auto pShell = dynamic_cast<sd::DrawViewShell*>(mpDocShell->GetViewShell()))
|
||||
+ if (DrawViewShell* pShell = GetViewShell())
|
||||
lcl_SlideDesign(rJsonWriter, *mpDoc, *pShell);
|
||||
return;
|
||||
}
|
||||
+ if (rCommand == ".uno:SlideObjects")
|
||||
+ {
|
||||
+ if (DrawViewShell* pShell = GetViewShell())
|
||||
+ lcl_SlideObjects(rJsonWriter, *pShell);
|
||||
+ return;
|
||||
+ }
|
||||
|
||||
std::map<OUString, OUString> aMap
|
||||
= SfxLokHelper::parseCommandParameters(OUString::fromUtf8(rCommand));
|
||||
diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx
|
||||
index b1f1461..d8b1015 100644
|
||||
--- a/sd/source/ui/view/drviews2.cxx
|
||||
+++ b/sd/source/ui/view/drviews2.cxx
|
||||
@@ -1255,7 +1255,29 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
|
||||
case SID_OUTLINE_TEXT_AUTOFIT:
|
||||
{
|
||||
SfxUndoManager* pUndoManager = GetDocSh()->GetUndoManager();
|
||||
- if( rMarkList.GetMarkCount() == 1 )
|
||||
+ const SfxStringItem* pFit = rReq.GetArg<SfxStringItem>(FN_PARAM_1);
|
||||
+ if (pFit && rMarkList.GetMarkCount() != 0)
|
||||
+ {
|
||||
+ // Fit: off, shrink or grow, for every marked object.
|
||||
+ const OUString& rFit = pFit->GetValue();
|
||||
+ if (rFit != "off" && rFit != "shrink" && rFit != "grow")
|
||||
+ break;
|
||||
+ pUndoManager->EnterListAction(u""_ustr, u""_ustr, 0, GetViewShellBase().GetViewShellId());
|
||||
+ mpDrawView->BegUndo();
|
||||
+ for (size_t i = 0; i < rMarkList.GetMarkCount(); ++i)
|
||||
+ {
|
||||
+ SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
|
||||
+ // The item change rewrites the text; undo keeps it.
|
||||
+ mpDrawView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoAttrObject(*pObj, false, true));
|
||||
+ pObj->SetMergedItem(SdrTextFitToSizeTypeItem(rFit == "shrink"
|
||||
+ ? drawing::TextFitToSizeType_AUTOFIT : drawing::TextFitToSizeType_NONE));
|
||||
+ pObj->SetMergedItem(makeSdrTextAutoGrowHeightItem(rFit == "grow"));
|
||||
+ pObj->SetMergedItem(makeSdrTextAutoGrowWidthItem(false));
|
||||
+ }
|
||||
+ mpDrawView->EndUndo();
|
||||
+ pUndoManager->LeaveListAction();
|
||||
+ }
|
||||
+ else if( rMarkList.GetMarkCount() == 1 )
|
||||
{
|
||||
pUndoManager->EnterListAction(u""_ustr, u""_ustr, 0, GetViewShellBase().GetViewShellId());
|
||||
mpDrawView->BegUndo();
|
||||
diff --git a/sd/source/ui/view/drviewse.cxx b/sd/source/ui/view/drviewse.cxx
|
||||
index 5d94d13..103534c 100644
|
||||
--- a/sd/source/ui/view/drviewse.cxx
|
||||
+++ b/sd/source/ui/view/drviewse.cxx
|
||||
@@ -156,6 +156,28 @@ void DrawViewShell::FuPermanent(SfxRequest& rReq)
|
||||
|
||||
sal_uInt16 nSId = rReq.GetSlot();
|
||||
|
||||
+ // LOK picks by place; Add alone picks none.
|
||||
+ const SfxUInt32Item* pIndex = rReq.GetArg(ID_VAL_INDEX);
|
||||
+ const SfxBoolItem* pAdd = rReq.GetArg<SfxBoolItem>(FN_PARAM_1);
|
||||
+ if (nSId == SID_OBJECT_SELECT && (pIndex || pAdd) && comphelper::LibreOfficeKit::isActive())
|
||||
+ {
|
||||
+ // Comments are not counted, as in .uno:SlideObjects.
|
||||
+ std::vector<SdrObject*> aShapes;
|
||||
+ for (const rtl::Reference<SdrObject>& pObj : *getCurrentPage())
|
||||
+ if (!pObj->isAnnotationObject())
|
||||
+ aShapes.push_back(pObj.get());
|
||||
+ if (pIndex && pIndex->GetValue() >= aShapes.size())
|
||||
+ return;
|
||||
+ if (mpDrawView->IsTextEdit())
|
||||
+ mpDrawView->SdrEndTextEdit();
|
||||
+ if (!pAdd || !pAdd->GetValue())
|
||||
+ mpDrawView->UnmarkAllObj();
|
||||
+ if (pIndex)
|
||||
+ mpDrawView->MarkObj(aShapes[pIndex->GetValue()], mpDrawView->GetSdrPageView());
|
||||
+ rReq.Done();
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
if( HasCurrentFunction() &&
|
||||
( nSId == SID_TEXTEDIT || nSId == SID_ATTR_CHAR || nSId == SID_TEXT_FITTOSIZE ||
|
||||
nSId == SID_ATTR_CHAR_VERTICAL || nSId == SID_TEXT_FITTOSIZE_VERTICAL ) )
|
||||
diff --git a/svx/sdi/svx.sdi b/svx/sdi/svx.sdi
|
||||
index 2cc2a87..9921969 100644
|
||||
--- a/svx/sdi/svx.sdi
|
||||
+++ b/svx/sdi/svx.sdi
|
||||
@@ -4579,7 +4579,7 @@ SfxBoolItem Crop SID_OBJECT_CROP
|
||||
]
|
||||
|
||||
SfxVoidItem ChangePicture SID_CHANGE_PICTURE
|
||||
-()
|
||||
+(SfxStringItem FileName SID_INSERT_GRAPHIC)
|
||||
[
|
||||
AutoUpdate = FALSE,
|
||||
FastCall = FALSE,
|
||||
@@ -8923,7 +8923,7 @@ SfxBoolItem ToolEdit SID_TEXTEDIT
|
||||
|
||||
|
||||
SfxBoolItem SelectObject SID_OBJECT_SELECT
|
||||
-
|
||||
+(SfxUInt32Item Index ID_VAL_INDEX, SfxBoolItem Add FN_PARAM_1)
|
||||
[
|
||||
AutoUpdate = TRUE,
|
||||
FastCall = FALSE,
|
||||
@@ -8961,7 +8961,7 @@ SvxULSpaceItem TopBottomMargin SID_ATTR_ULSPACE
|
||||
|
||||
|
||||
SfxVoidItem TransformDialog SID_ATTR_TRANSFORM
|
||||
-(SfxInt32Item TransformPosX SID_ATTR_TRANSFORM_POS_X, SfxInt32Item TransformPosY SID_ATTR_TRANSFORM_POS_Y, SfxUInt32Item TransformWidth SID_ATTR_TRANSFORM_WIDTH, SfxUInt32Item TransformHeight SID_ATTR_TRANSFORM_HEIGHT, SdrAngleItem TransformRotationDeltaAngle SID_ATTR_TRANSFORM_DELTA_ANGLE, SdrAngleItem TransformRotationAngle SID_ATTR_TRANSFORM_ANGLE, SfxInt32Item TransformRotationX SID_ATTR_TRANSFORM_ROT_X, SfxInt32Item TransformRotationY SID_ATTR_TRANSFORM_ROT_Y)
|
||||
+(SfxInt32Item TransformPosX SID_ATTR_TRANSFORM_POS_X, SfxInt32Item TransformPosY SID_ATTR_TRANSFORM_POS_Y, SfxUInt32Item TransformWidth SID_ATTR_TRANSFORM_WIDTH, SfxUInt32Item TransformHeight SID_ATTR_TRANSFORM_HEIGHT, SdrAngleItem TransformRotationDeltaAngle SID_ATTR_TRANSFORM_DELTA_ANGLE, SdrAngleItem TransformRotationAngle SID_ATTR_TRANSFORM_ANGLE, SfxInt32Item TransformRotationX SID_ATTR_TRANSFORM_ROT_X, SfxInt32Item TransformRotationY SID_ATTR_TRANSFORM_ROT_Y, SfxBoolItem ProtectPos SID_ATTR_TRANSFORM_PROTECT_POS, SfxBoolItem ProtectSize SID_ATTR_TRANSFORM_PROTECT_SIZE)
|
||||
[
|
||||
AutoUpdate = FALSE,
|
||||
FastCall = TRUE,
|
||||
@@ -0,0 +1,280 @@
|
||||
svx: chart look helpers a kit client can drive
|
||||
|
||||
ChartHelper gains IsChartLook, SetChartLook and WriteChartLook (type,
|
||||
titles, legend, as JSON), moved here from Calc so Impress can use them.
|
||||
The JSON keeps its types (boost.json): a field of the wrong type, such
|
||||
as a legend that is not true or false or a title that is not text, is
|
||||
refused before anything changes.
|
||||
A scatter starts as points only when the chart becomes one; a scatter
|
||||
kept as one keeps its lines.
|
||||
|
||||
diff --git a/include/svx/charthelper.hxx b/include/svx/charthelper.hxx
|
||||
index 3ad1fba..9bdf0a6 100644
|
||||
--- a/include/svx/charthelper.hxx
|
||||
+++ b/include/svx/charthelper.hxx
|
||||
@@ -31,6 +31,8 @@ namespace com::sun::star {
|
||||
}
|
||||
|
||||
namespace basegfx { class B2DRange; }
|
||||
+namespace tools { class JsonWriter; }
|
||||
+namespace com::sun::star::uno { class XInterface; }
|
||||
|
||||
class SAL_WARN_UNUSED SVXCORE_DLLPUBLIC ChartHelper
|
||||
{
|
||||
@@ -54,6 +56,13 @@ public:
|
||||
// newly created charts using this method
|
||||
static void AdaptDefaultsForChart(
|
||||
const css::uno::Reference < css::embed::XEmbeddedObject > & xEmbObj);
|
||||
+
|
||||
+ /// A kit chart look: type, titles, legend, as JSON.
|
||||
+ static bool IsChartLook(std::u16string_view rJson);
|
||||
+ static bool SetChartLook(const css::uno::Reference<css::uno::XInterface>& xChart,
|
||||
+ std::u16string_view rJson);
|
||||
+ static void WriteChartLook(::tools::JsonWriter& rJson,
|
||||
+ const css::uno::Reference<css::uno::XInterface>& xChart);
|
||||
};
|
||||
|
||||
#endif // INCLUDED_SVX_CHARTHELPER_HXX
|
||||
diff --git a/svx/Library_svxcore.mk b/svx/Library_svxcore.mk
|
||||
index e2d178b..1dfa044 100644
|
||||
--- a/svx/Library_svxcore.mk
|
||||
+++ b/svx/Library_svxcore.mk
|
||||
@@ -332,6 +332,7 @@ $(eval $(call gb_Library_add_exception_objects,svxcore,\
|
||||
svx/source/sdr/properties/e3dcompoundproperties \
|
||||
svx/source/sdr/properties/oleproperties \
|
||||
svx/source/svdraw/charthelper \
|
||||
+ svx/source/svdraw/chartlook \
|
||||
svx/source/svdraw/constructhelper \
|
||||
svx/source/svdraw/clonelist \
|
||||
svx/source/svdraw/gradtrns \
|
||||
diff --git a/svx/source/svdraw/chartjson.hxx b/svx/source/svdraw/chartjson.hxx
|
||||
new file mode 100644
|
||||
index 0000000..d105464
|
||||
--- /dev/null
|
||||
+++ b/svx/source/svdraw/chartjson.hxx
|
||||
@@ -0,0 +1,26 @@
|
||||
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
+/*
|
||||
+ * 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/.
|
||||
+ */
|
||||
+
|
||||
+#pragma once
|
||||
+
|
||||
+#include <rtl/ustring.hxx>
|
||||
+#include <boost/json.hpp>
|
||||
+
|
||||
+#include <optional>
|
||||
+#include <string_view>
|
||||
+
|
||||
+namespace svx::chartjson
|
||||
+{
|
||||
+/// The JSON object, or none if it is not one.
|
||||
+std::optional<boost::json::object> Object(std::u16string_view rJson);
|
||||
+/// Member `rKey` as text; absent is empty, another type fails.
|
||||
+std::optional<OUString> Text(const boost::json::object& rObject, std::string_view rKey);
|
||||
+}
|
||||
+
|
||||
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
diff --git a/svx/source/svdraw/chartlook.cxx b/svx/source/svdraw/chartlook.cxx
|
||||
new file mode 100644
|
||||
index 0000000..79d4e6c
|
||||
--- /dev/null
|
||||
+++ b/svx/source/svdraw/chartlook.cxx
|
||||
@@ -0,0 +1,193 @@
|
||||
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
+/*
|
||||
+ * 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 <svx/charthelper.hxx>
|
||||
+#include "chartjson.hxx"
|
||||
+
|
||||
+#include <com/sun/star/beans/XPropertySet.hpp>
|
||||
+#include <com/sun/star/chart/XAxisXSupplier.hpp>
|
||||
+#include <com/sun/star/chart/XAxisYSupplier.hpp>
|
||||
+#include <com/sun/star/chart/XChartDocument.hpp>
|
||||
+#include <com/sun/star/drawing/XShape.hpp>
|
||||
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
|
||||
+#include <tools/json_writer.hxx>
|
||||
+// One translation unit builds boost.json.
|
||||
+#include <boost/json/src.hpp>
|
||||
+
|
||||
+#include <algorithm>
|
||||
+#include <functional>
|
||||
+#include <optional>
|
||||
+
|
||||
+using namespace ::com::sun::star;
|
||||
+
|
||||
+namespace svx::chartjson
|
||||
+{
|
||||
+/// The JSON object, or none if it is not one.
|
||||
+std::optional<boost::json::object> Object(std::u16string_view rJson)
|
||||
+{
|
||||
+ boost::system::error_code aError;
|
||||
+ boost::json::value aValue = boost::json::parse(std::string(OUString(rJson).toUtf8()), aError);
|
||||
+ if (aError || !aValue.is_object())
|
||||
+ return std::nullopt;
|
||||
+ return aValue.as_object();
|
||||
+}
|
||||
+
|
||||
+/// Member `rKey` as text; absent is empty, another type fails.
|
||||
+std::optional<OUString> Text(const boost::json::object& rObject, std::string_view rKey)
|
||||
+{
|
||||
+ const boost::json::value* pValue = rObject.if_contains(rKey);
|
||||
+ if (!pValue)
|
||||
+ return OUString();
|
||||
+ if (!pValue->is_string())
|
||||
+ return std::nullopt;
|
||||
+ const boost::json::string& rText = pValue->as_string();
|
||||
+ return OUString::fromUtf8(std::string_view(rText.data(), rText.size()));
|
||||
+}
|
||||
+}
|
||||
+
|
||||
+namespace
|
||||
+{
|
||||
+/// Kit names and the diagram services they map to.
|
||||
+constexpr std::pair<std::string_view, std::u16string_view> aChartTypes[]
|
||||
+ = { { "column", u"com.sun.star.chart.BarDiagram" },
|
||||
+ { "bar", u"com.sun.star.chart.BarDiagram" },
|
||||
+ { "line", u"com.sun.star.chart.LineDiagram" },
|
||||
+ { "scatter", u"com.sun.star.chart.XYDiagram" },
|
||||
+ { "pie", u"com.sun.star.chart.PieDiagram" } };
|
||||
+
|
||||
+/// A parsed look; "other" keeps the diagram.
|
||||
+struct ChartLook
|
||||
+{
|
||||
+ std::string_view aType;
|
||||
+ OUString aTitle, aXTitle, aYTitle;
|
||||
+ bool bLegend = true;
|
||||
+};
|
||||
+
|
||||
+std::optional<ChartLook> lcl_ParseLook(std::u16string_view rJson)
|
||||
+{
|
||||
+ const std::optional<boost::json::object> oObject = svx::chartjson::Object(rJson);
|
||||
+ if (!oObject)
|
||||
+ return std::nullopt;
|
||||
+ const boost::json::value* pType = oObject->if_contains("type");
|
||||
+ if (!pType || !pType->is_string())
|
||||
+ return std::nullopt;
|
||||
+ const std::string_view aType(pType->as_string().data(), pType->as_string().size());
|
||||
+ ChartLook aLook;
|
||||
+ if (aType == "other")
|
||||
+ aLook.aType = "other";
|
||||
+ for (const auto& [rName, rService] : aChartTypes)
|
||||
+ if (rName == aType)
|
||||
+ aLook.aType = rName;
|
||||
+ const std::optional<OUString> oTitle = svx::chartjson::Text(*oObject, "title");
|
||||
+ const std::optional<OUString> oXTitle = svx::chartjson::Text(*oObject, "xtitle");
|
||||
+ const std::optional<OUString> oYTitle = svx::chartjson::Text(*oObject, "ytitle");
|
||||
+ const boost::json::value* pLegend = oObject->if_contains("legend");
|
||||
+ if (aLook.aType.empty() || !oTitle || !oXTitle || !oYTitle || (pLegend && !pLegend->is_bool()))
|
||||
+ return std::nullopt;
|
||||
+ aLook.aTitle = *oTitle;
|
||||
+ aLook.aXTitle = *oXTitle;
|
||||
+ aLook.aYTitle = *oYTitle;
|
||||
+ aLook.bLegend = !pLegend || pLegend->as_bool();
|
||||
+ return aLook;
|
||||
+}
|
||||
+
|
||||
+/// Shows a title with this text; empty hides it.
|
||||
+void lcl_SetTitle(const uno::Reference<beans::XPropertySet>& xOwner, const OUString& rHas,
|
||||
+ const std::function<uno::Reference<drawing::XShape>()>& rTitle,
|
||||
+ const OUString& rText)
|
||||
+{
|
||||
+ xOwner->setPropertyValue(rHas, uno::Any(!rText.isEmpty()));
|
||||
+ if (rText.isEmpty())
|
||||
+ return;
|
||||
+ uno::Reference<beans::XPropertySet> xTitle(rTitle(), uno::UNO_QUERY_THROW);
|
||||
+ xTitle->setPropertyValue(u"String"_ustr, uno::Any(rText));
|
||||
+}
|
||||
+
|
||||
+OUString lcl_Title(const uno::Reference<beans::XPropertySet>& xOwner, const OUString& rHas,
|
||||
+ const std::function<uno::Reference<drawing::XShape>()>& rTitle)
|
||||
+{
|
||||
+ OUString aText;
|
||||
+ if (!xOwner->getPropertyValue(rHas).get<bool>())
|
||||
+ return aText;
|
||||
+ uno::Reference<beans::XPropertySet> xTitle(rTitle(), uno::UNO_QUERY_THROW);
|
||||
+ xTitle->getPropertyValue(u"String"_ustr) >>= aText;
|
||||
+ return aText;
|
||||
+}
|
||||
+}
|
||||
+
|
||||
+bool ChartHelper::IsChartLook(std::u16string_view rJson) { return lcl_ParseLook(rJson).has_value(); }
|
||||
+
|
||||
+bool ChartHelper::SetChartLook(const uno::Reference<uno::XInterface>& xChart,
|
||||
+ std::u16string_view rJson)
|
||||
+{
|
||||
+ const std::optional<ChartLook> oLook = lcl_ParseLook(rJson);
|
||||
+ uno::Reference<chart::XChartDocument> xDoc(xChart, uno::UNO_QUERY);
|
||||
+ if (!oLook || !xDoc.is())
|
||||
+ return false;
|
||||
+ uno::Reference<chart::XDiagram> xDiagram = xDoc->getDiagram();
|
||||
+ const auto pType = std::find_if(std::begin(aChartTypes), std::end(aChartTypes),
|
||||
+ [&oLook](const auto& rPair) { return rPair.first == oLook->aType; });
|
||||
+ if (pType != std::end(aChartTypes))
|
||||
+ {
|
||||
+ const bool bNewType = xDiagram->getDiagramType() != pType->second;
|
||||
+ if (bNewType)
|
||||
+ {
|
||||
+ uno::Reference<lang::XMultiServiceFactory> xFactory(xDoc, uno::UNO_QUERY_THROW);
|
||||
+ xDiagram.set(xFactory->createInstance(OUString(pType->second)), uno::UNO_QUERY_THROW);
|
||||
+ xDoc->setDiagram(xDiagram);
|
||||
+ }
|
||||
+ uno::Reference<beans::XPropertySet> xProps(xDiagram, uno::UNO_QUERY_THROW);
|
||||
+ if (pType->second == u"com.sun.star.chart.BarDiagram")
|
||||
+ xProps->setPropertyValue(u"Vertical"_ustr, uno::Any(oLook->aType == "bar"));
|
||||
+ // A new scatter starts as points; kept ones keep lines.
|
||||
+ if (bNewType && oLook->aType == "scatter")
|
||||
+ xProps->setPropertyValue(u"Lines"_ustr, uno::Any(false));
|
||||
+ }
|
||||
+ uno::Reference<beans::XPropertySet> xDocProps(xDoc, uno::UNO_QUERY_THROW);
|
||||
+ lcl_SetTitle(xDocProps, u"HasMainTitle"_ustr, [&xDoc] { return xDoc->getTitle(); },
|
||||
+ oLook->aTitle);
|
||||
+ xDocProps->setPropertyValue(u"HasLegend"_ustr, uno::Any(oLook->bLegend));
|
||||
+ // A pie has no axes.
|
||||
+ if (xDiagram->getDiagramType() == u"com.sun.star.chart.PieDiagram")
|
||||
+ return true;
|
||||
+ uno::Reference<chart::XAxisXSupplier> xX(xDiagram, uno::UNO_QUERY_THROW);
|
||||
+ uno::Reference<chart::XAxisYSupplier> xY(xDiagram, uno::UNO_QUERY_THROW);
|
||||
+ uno::Reference<beans::XPropertySet> xProps(xDiagram, uno::UNO_QUERY_THROW);
|
||||
+ lcl_SetTitle(xProps, u"HasXAxisTitle"_ustr, [&xX] { return xX->getXAxisTitle(); },
|
||||
+ oLook->aXTitle);
|
||||
+ lcl_SetTitle(xProps, u"HasYAxisTitle"_ustr, [&xY] { return xY->getYAxisTitle(); },
|
||||
+ oLook->aYTitle);
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
+void ChartHelper::WriteChartLook(::tools::JsonWriter& rJson,
|
||||
+ const uno::Reference<uno::XInterface>& xChart)
|
||||
+{
|
||||
+ uno::Reference<chart::XChartDocument> xDoc(xChart, uno::UNO_QUERY_THROW);
|
||||
+ uno::Reference<chart::XDiagram> xDiagram = xDoc->getDiagram();
|
||||
+ uno::Reference<beans::XPropertySet> xProps(xDiagram, uno::UNO_QUERY_THROW);
|
||||
+ const OUString aService = xDiagram->getDiagramType();
|
||||
+ std::string_view aType = "other";
|
||||
+ for (const auto& [rName, rService] : aChartTypes)
|
||||
+ if (rService == aService && aType == "other")
|
||||
+ aType = rName;
|
||||
+ if (aType == "column" && xProps->getPropertyValue(u"Vertical"_ustr).get<bool>())
|
||||
+ aType = "bar";
|
||||
+ rJson.put("type", aType);
|
||||
+ uno::Reference<beans::XPropertySet> xDocProps(xDoc, uno::UNO_QUERY_THROW);
|
||||
+ rJson.put("title", lcl_Title(xDocProps, u"HasMainTitle"_ustr, [&xDoc] { return xDoc->getTitle(); }));
|
||||
+ rJson.put("legend", xDocProps->getPropertyValue(u"HasLegend"_ustr).get<bool>());
|
||||
+ uno::Reference<chart::XAxisXSupplier> xX(xDiagram, uno::UNO_QUERY_THROW);
|
||||
+ uno::Reference<chart::XAxisYSupplier> xY(xDiagram, uno::UNO_QUERY_THROW);
|
||||
+ const bool bAxes = aType != "pie";
|
||||
+ rJson.put("xtitle", bAxes ? lcl_Title(xProps, u"HasXAxisTitle"_ustr, [&xX] { return xX->getXAxisTitle(); }) : OUString());
|
||||
+ rJson.put("ytitle", bAxes ? lcl_Title(xProps, u"HasYAxisTitle"_ustr, [&xY] { return xY->getYAxisTitle(); }) : OUString());
|
||||
+}
|
||||
+
|
||||
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
@@ -0,0 +1,335 @@
|
||||
svx: chart data helpers a kit client can drive
|
||||
|
||||
ChartHelper gains IsChartData, SetChartData and WriteChartData: a
|
||||
chart's own table under "data" as categories and series values. A
|
||||
ragged table, or a value that is not a number or null, is refused. A
|
||||
missing point reads and writes as null (the chart's own not-a-number
|
||||
marker). An XY chart's categories are its X values: they must be
|
||||
numbers and go in as numbers, not text. An XY chart whose series share
|
||||
one X list reads with X as categories, from the series roles, as a
|
||||
PPTX import has it; series with their own X lists are not one table and
|
||||
the read leaves "data" out. The trailing attachData is gone: each
|
||||
setter applies itself, and attachData put numbers back as text.
|
||||
|
||||
diff --git a/include/svx/charthelper.hxx b/include/svx/charthelper.hxx
|
||||
index 9bdf0a6..1f7a6fb 100644
|
||||
--- a/include/svx/charthelper.hxx
|
||||
+++ b/include/svx/charthelper.hxx
|
||||
@@ -63,6 +63,12 @@ public:
|
||||
std::u16string_view rJson);
|
||||
static void WriteChartLook(::tools::JsonWriter& rJson,
|
||||
const css::uno::Reference<css::uno::XInterface>& xChart);
|
||||
+ /// Own data under "data"; absent when not one table.
|
||||
+ static bool IsChartData(std::u16string_view rJson);
|
||||
+ static bool SetChartData(const css::uno::Reference<css::uno::XInterface>& xChart,
|
||||
+ std::u16string_view rJson);
|
||||
+ static void WriteChartData(::tools::JsonWriter& rJson,
|
||||
+ const css::uno::Reference<css::uno::XInterface>& xChart);
|
||||
};
|
||||
|
||||
#endif // INCLUDED_SVX_CHARTHELPER_HXX
|
||||
diff --git a/svx/Library_svxcore.mk b/svx/Library_svxcore.mk
|
||||
index 1dfa044..08daa4d 100644
|
||||
--- a/svx/Library_svxcore.mk
|
||||
+++ b/svx/Library_svxcore.mk
|
||||
@@ -332,6 +332,7 @@ $(eval $(call gb_Library_add_exception_objects,svxcore,\
|
||||
svx/source/sdr/properties/e3dcompoundproperties \
|
||||
svx/source/sdr/properties/oleproperties \
|
||||
svx/source/svdraw/charthelper \
|
||||
+ svx/source/svdraw/chartdata \
|
||||
svx/source/svdraw/chartlook \
|
||||
svx/source/svdraw/constructhelper \
|
||||
svx/source/svdraw/clonelist \
|
||||
diff --git a/svx/source/svdraw/chartdata.cxx b/svx/source/svdraw/chartdata.cxx
|
||||
new file mode 100644
|
||||
index 0000000..5bf412e
|
||||
--- /dev/null
|
||||
+++ b/svx/source/svdraw/chartdata.cxx
|
||||
@@ -0,0 +1,287 @@
|
||||
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
+/*
|
||||
+ * 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 <svx/charthelper.hxx>
|
||||
+#include "chartjson.hxx"
|
||||
+
|
||||
+#include <com/sun/star/beans/XPropertySet.hpp>
|
||||
+#include <com/sun/star/chart/ChartDataRowSource.hpp>
|
||||
+#include <com/sun/star/chart/XChartDataArray.hpp>
|
||||
+#include <com/sun/star/chart/XChartDocument.hpp>
|
||||
+#include <com/sun/star/chart2/XAnyDescriptionAccess.hpp>
|
||||
+#include <com/sun/star/chart2/XChartDocument.hpp>
|
||||
+#include <com/sun/star/chart2/XChartTypeContainer.hpp>
|
||||
+#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
|
||||
+#include <com/sun/star/chart2/XDataSeriesContainer.hpp>
|
||||
+#include <com/sun/star/chart2/data/XDataSource.hpp>
|
||||
+#include <com/sun/star/chart2/data/XNumericalDataSequence.hpp>
|
||||
+#include <com/sun/star/chart2/data/XTextualDataSequence.hpp>
|
||||
+#include <comphelper/sequence.hxx>
|
||||
+#include <rtl/math.hxx>
|
||||
+#include <tools/json_writer.hxx>
|
||||
+
|
||||
+#include <algorithm>
|
||||
+#include <cmath>
|
||||
+#include <optional>
|
||||
+
|
||||
+using namespace ::com::sun::star;
|
||||
+
|
||||
+namespace
|
||||
+{
|
||||
+/// Categories and series values; empty without data.
|
||||
+struct ChartData
|
||||
+{
|
||||
+ uno::Sequence<OUString> aCategories, aSeries;
|
||||
+ uno::Sequence<uno::Sequence<double>> aRows;
|
||||
+};
|
||||
+
|
||||
+/// Whether `rText` is all one finite number.
|
||||
+bool lcl_Number(const OUString& rText)
|
||||
+{
|
||||
+ rtl_math_ConversionStatus eStatus = rtl_math_ConversionStatus_Ok;
|
||||
+ sal_Int32 nEnd = 0;
|
||||
+ const double fValue = rtl::math::stringToDouble(rText.trim(), '.', 0, &eStatus, &nEnd);
|
||||
+ return !rText.trim().isEmpty() && eStatus == rtl_math_ConversionStatus_Ok
|
||||
+ && nEnd == rText.trim().getLength() && std::isfinite(fValue);
|
||||
+}
|
||||
+
|
||||
+/// The "data" member: names and every value.
|
||||
+std::optional<ChartData> lcl_ParseData(std::u16string_view rJson)
|
||||
+{
|
||||
+ const std::optional<boost::json::object> oObject = svx::chartjson::Object(rJson);
|
||||
+ if (!oObject)
|
||||
+ return std::nullopt;
|
||||
+ ChartData aData;
|
||||
+ const boost::json::value* pData = oObject->if_contains("data");
|
||||
+ if (!pData)
|
||||
+ return aData;
|
||||
+ const boost::json::object* pTable = pData->if_object();
|
||||
+ const boost::json::value* pCategories = pTable ? pTable->if_contains("categories") : nullptr;
|
||||
+ const boost::json::value* pSeries = pTable ? pTable->if_contains("series") : nullptr;
|
||||
+ if (!pCategories || !pCategories->is_array() || !pSeries || !pSeries->is_array())
|
||||
+ return std::nullopt;
|
||||
+ std::vector<OUString> aCategories, aNames;
|
||||
+ for (const boost::json::value& rItem : pCategories->as_array())
|
||||
+ {
|
||||
+ if (!rItem.is_string())
|
||||
+ return std::nullopt;
|
||||
+ aCategories.push_back(OUString::fromUtf8(
|
||||
+ std::string_view(rItem.as_string().data(), rItem.as_string().size())));
|
||||
+ }
|
||||
+ std::vector<std::vector<double>> aColumns;
|
||||
+ for (const boost::json::value& rItem : pSeries->as_array())
|
||||
+ {
|
||||
+ const boost::json::object* pOne = rItem.if_object();
|
||||
+ const std::optional<OUString> oName = pOne ? svx::chartjson::Text(*pOne, "name") : std::nullopt;
|
||||
+ const boost::json::value* pValues = pOne ? pOne->if_contains("values") : nullptr;
|
||||
+ if (!oName || !pOne->contains("name") || !pValues || !pValues->is_array())
|
||||
+ return std::nullopt;
|
||||
+ std::vector<double> aValues;
|
||||
+ for (const boost::json::value& rValue : pValues->as_array())
|
||||
+ {
|
||||
+ // A null is a missing point.
|
||||
+ if (rValue.is_null())
|
||||
+ aValues.push_back(std::nan(""));
|
||||
+ else if (rValue.is_number())
|
||||
+ aValues.push_back(rValue.to_number<double>());
|
||||
+ else
|
||||
+ return std::nullopt;
|
||||
+ }
|
||||
+ if (aValues.size() != aCategories.size())
|
||||
+ return std::nullopt;
|
||||
+ aNames.push_back(*oName);
|
||||
+ aColumns.push_back(std::move(aValues));
|
||||
+ }
|
||||
+ if (aCategories.empty() || aNames.empty())
|
||||
+ return std::nullopt;
|
||||
+ // A scatter's categories are its X values.
|
||||
+ const boost::json::value* pType = oObject->if_contains("type");
|
||||
+ if (pType && pType->is_string() && pType->as_string() == "scatter"
|
||||
+ && !std::all_of(aCategories.begin(), aCategories.end(), lcl_Number))
|
||||
+ return std::nullopt;
|
||||
+ aData.aCategories = comphelper::containerToSequence(aCategories);
|
||||
+ aData.aSeries = comphelper::containerToSequence(aNames);
|
||||
+ aData.aRows.realloc(aCategories.size());
|
||||
+ auto pRows = aData.aRows.getArray();
|
||||
+ for (size_t nRow = 0; nRow < aCategories.size(); ++nRow)
|
||||
+ {
|
||||
+ pRows[nRow].realloc(aNames.size());
|
||||
+ for (size_t nCol = 0; nCol < aNames.size(); ++nCol)
|
||||
+ pRows[nRow].getArray()[nCol] = aColumns[nCol][nRow];
|
||||
+ }
|
||||
+ return aData;
|
||||
+}
|
||||
+
|
||||
+/// Whether series run along the data rows.
|
||||
+bool lcl_SeriesInRows(const uno::Reference<chart::XChartDocument>& xDoc)
|
||||
+{
|
||||
+ uno::Reference<beans::XPropertySet> xProps(xDoc->getDiagram(), uno::UNO_QUERY_THROW);
|
||||
+ chart::ChartDataRowSource eSource = chart::ChartDataRowSource_COLUMNS;
|
||||
+ xProps->getPropertyValue(u"DataRowSource"_ustr) >>= eSource;
|
||||
+ return eSource == chart::ChartDataRowSource_ROWS;
|
||||
+}
|
||||
+
|
||||
+/// Categories, series names, and each series' values.
|
||||
+struct Table
|
||||
+{
|
||||
+ std::vector<OUString> aCategories, aNames;
|
||||
+ std::vector<std::vector<double>> aColumns;
|
||||
+};
|
||||
+
|
||||
+/// XY series sharing one X list, X as categories.
|
||||
+std::optional<Table> lcl_XYTable(const uno::Reference<chart::XChartDocument>& xDoc)
|
||||
+{
|
||||
+ uno::Reference<chart2::XChartDocument> xModel(xDoc, uno::UNO_QUERY_THROW);
|
||||
+ uno::Reference<chart2::XCoordinateSystemContainer> xSystems(xModel->getFirstDiagram(),
|
||||
+ uno::UNO_QUERY_THROW);
|
||||
+ std::optional<uno::Sequence<double>> oX;
|
||||
+ Table aTable;
|
||||
+ for (const auto& xSystem : xSystems->getCoordinateSystems())
|
||||
+ {
|
||||
+ uno::Reference<chart2::XChartTypeContainer> xTypes(xSystem, uno::UNO_QUERY_THROW);
|
||||
+ for (const auto& xType : xTypes->getChartTypes())
|
||||
+ {
|
||||
+ uno::Reference<chart2::XDataSeriesContainer> xList(xType, uno::UNO_QUERY_THROW);
|
||||
+ for (const auto& xSeries : xList->getDataSeries())
|
||||
+ {
|
||||
+ uno::Reference<chart2::data::XDataSource> xSource(xSeries, uno::UNO_QUERY_THROW);
|
||||
+ std::optional<uno::Sequence<double>> oSeriesX, oY;
|
||||
+ OUString aName;
|
||||
+ for (const auto& xLabeled : xSource->getDataSequences())
|
||||
+ {
|
||||
+ uno::Reference<beans::XPropertySet> xValues(xLabeled->getValues(), uno::UNO_QUERY_THROW);
|
||||
+ OUString aRole;
|
||||
+ xValues->getPropertyValue(u"Role"_ustr) >>= aRole;
|
||||
+ uno::Reference<chart2::data::XNumericalDataSequence> xNumbers(xValues, uno::UNO_QUERY_THROW);
|
||||
+ if (aRole == "values-x")
|
||||
+ oSeriesX = xNumbers->getNumericalData();
|
||||
+ else if (aRole == "values-y")
|
||||
+ {
|
||||
+ oY = xNumbers->getNumericalData();
|
||||
+ uno::Reference<chart2::data::XTextualDataSequence> xLabel(xLabeled->getLabel(), uno::UNO_QUERY);
|
||||
+ for (const OUString& rPart : xLabel.is() ? xLabel->getTextualData() : uno::Sequence<OUString>())
|
||||
+ aName += rPart;
|
||||
+ }
|
||||
+ }
|
||||
+ // Missing or differing X lists are not one table.
|
||||
+ if (!oSeriesX || !oY || oY->getLength() != oSeriesX->getLength()
|
||||
+ || (oX && !std::equal(oX->begin(), oX->end(), oSeriesX->begin(), oSeriesX->end())))
|
||||
+ return std::nullopt;
|
||||
+ oX = oSeriesX;
|
||||
+ aTable.aNames.push_back(aName);
|
||||
+ aTable.aColumns.emplace_back(oY->begin(), oY->end());
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ if (!oX || !oX->hasElements()
|
||||
+ || std::any_of(oX->begin(), oX->end(), [](double f) { return !std::isfinite(f); }))
|
||||
+ return std::nullopt;
|
||||
+ for (double fX : *oX)
|
||||
+ aTable.aCategories.push_back(OUString::number(fX));
|
||||
+ return aTable;
|
||||
+}
|
||||
+}
|
||||
+
|
||||
+bool ChartHelper::IsChartData(std::u16string_view rJson) { return lcl_ParseData(rJson).has_value(); }
|
||||
+
|
||||
+bool ChartHelper::SetChartData(const uno::Reference<uno::XInterface>& xChart,
|
||||
+ std::u16string_view rJson)
|
||||
+{
|
||||
+ const std::optional<ChartData> oData = lcl_ParseData(rJson);
|
||||
+ uno::Reference<chart::XChartDocument> xDoc(xChart, uno::UNO_QUERY);
|
||||
+ if (!oData || !xDoc.is())
|
||||
+ return false;
|
||||
+ if (!oData->aRows.hasElements())
|
||||
+ return true;
|
||||
+ const bool bXY = xDoc->getDiagram()->getDiagramType() == u"com.sun.star.chart.XYDiagram";
|
||||
+ if (bXY && !std::all_of(oData->aCategories.begin(), oData->aCategories.end(), lcl_Number))
|
||||
+ return false;
|
||||
+ // Series down the columns, as a new chart has them.
|
||||
+ uno::Reference<beans::XPropertySet> xProps(xDoc->getDiagram(), uno::UNO_QUERY_THROW);
|
||||
+ xProps->setPropertyValue(u"DataRowSource"_ustr, uno::Any(chart::ChartDataRowSource_COLUMNS));
|
||||
+ uno::Reference<chart::XChartDataArray> xArray(xDoc->getData(), uno::UNO_QUERY_THROW);
|
||||
+ uno::Sequence<uno::Sequence<double>> aRows = oData->aRows;
|
||||
+ for (auto& rRow : asNonConstRange(aRows))
|
||||
+ for (double& rValue : asNonConstRange(rRow))
|
||||
+ if (std::isnan(rValue))
|
||||
+ rValue = xArray->getNotANumber();
|
||||
+ xArray->setData(aRows);
|
||||
+ xArray->setRowDescriptions(oData->aCategories);
|
||||
+ xArray->setColumnDescriptions(oData->aSeries);
|
||||
+ if (bXY)
|
||||
+ {
|
||||
+ // X values go in as numbers, not text.
|
||||
+ uno::Sequence<uno::Sequence<uno::Any>> aX(oData->aCategories.getLength());
|
||||
+ auto pX = aX.getArray();
|
||||
+ for (sal_Int32 n = 0; n < aX.getLength(); ++n)
|
||||
+ pX[n] = { uno::Any(oData->aCategories[n].trim().toDouble()) };
|
||||
+ uno::Reference<chart2::XAnyDescriptionAccess> xAny(xArray, uno::UNO_QUERY_THROW);
|
||||
+ xAny->setAnyRowDescriptions(aX);
|
||||
+ }
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
+void ChartHelper::WriteChartData(::tools::JsonWriter& rJson,
|
||||
+ const uno::Reference<uno::XInterface>& xChart)
|
||||
+{
|
||||
+ uno::Reference<chart::XChartDocument> xDoc(xChart, uno::UNO_QUERY_THROW);
|
||||
+ uno::Reference<chart::XChartDataArray> xArray(xDoc->getData(), uno::UNO_QUERY_THROW);
|
||||
+ const bool bRows = lcl_SeriesInRows(xDoc);
|
||||
+ const uno::Sequence<uno::Sequence<double>> aRows = xArray->getData();
|
||||
+ const uno::Sequence<OUString> aCategories
|
||||
+ = bRows ? xArray->getColumnDescriptions() : xArray->getRowDescriptions();
|
||||
+ const uno::Sequence<OUString> aNames
|
||||
+ = bRows ? xArray->getRowDescriptions() : xArray->getColumnDescriptions();
|
||||
+ const sal_Int32 nOuter = bRows ? aNames.getLength() : aCategories.getLength();
|
||||
+ const sal_Int32 nInner = bRows ? aCategories.getLength() : aNames.getLength();
|
||||
+ const bool bTable = nOuter > 0 && nInner > 0 && aRows.getLength() == nOuter
|
||||
+ && std::all_of(aRows.begin(), aRows.end(),
|
||||
+ [nInner](const auto& rRow) { return rRow.getLength() == nInner; });
|
||||
+ Table aTable;
|
||||
+ if (bTable)
|
||||
+ {
|
||||
+ aTable.aCategories.assign(aCategories.begin(), aCategories.end());
|
||||
+ aTable.aNames.assign(aNames.begin(), aNames.end());
|
||||
+ for (sal_Int32 nSeries = 0; nSeries < aNames.getLength(); ++nSeries)
|
||||
+ {
|
||||
+ std::vector<double>& rColumn = aTable.aColumns.emplace_back();
|
||||
+ for (sal_Int32 nCategory = 0; nCategory < aCategories.getLength(); ++nCategory)
|
||||
+ {
|
||||
+ const double fValue = bRows ? aRows[nSeries][nCategory] : aRows[nCategory][nSeries];
|
||||
+ rColumn.push_back(xArray->isNotANumber(fValue) ? std::nan("") : fValue);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ else if (xDoc->getDiagram()->getDiagramType() == u"com.sun.star.chart.XYDiagram")
|
||||
+ {
|
||||
+ std::optional<Table> oXY = lcl_XYTable(xDoc);
|
||||
+ if (!oXY)
|
||||
+ return;
|
||||
+ aTable = std::move(*oXY);
|
||||
+ }
|
||||
+ else
|
||||
+ return;
|
||||
+ auto aData = rJson.startNode("data");
|
||||
+ {
|
||||
+ auto aList = rJson.startArray("categories");
|
||||
+ for (const OUString& rName : aTable.aCategories)
|
||||
+ rJson.putSimpleValue(rName);
|
||||
+ }
|
||||
+ auto aList = rJson.startArray("series");
|
||||
+ for (size_t nSeries = 0; nSeries < aTable.aNames.size(); ++nSeries)
|
||||
+ {
|
||||
+ auto aOne = rJson.startStruct();
|
||||
+ rJson.put("name", aTable.aNames[nSeries]);
|
||||
+ auto aValues = rJson.startArray("values");
|
||||
+ for (double fValue : aTable.aColumns[nSeries])
|
||||
+ rJson.putRaw(std::isfinite(fValue) ? OString::number(fValue) : "null"_ostr);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
@@ -0,0 +1,293 @@
|
||||
sc: kit chart looks come from svx ChartHelper
|
||||
|
||||
The look code 0020 added to sc moved to svx (0028); Calc calls it there.
|
||||
|
||||
diff --git a/sc/inc/ChartTools.hxx b/sc/inc/ChartTools.hxx
|
||||
index 2e49612..4a22141 100644
|
||||
--- a/sc/inc/ChartTools.hxx
|
||||
+++ b/sc/inc/ChartTools.hxx
|
||||
@@ -13,8 +13,6 @@
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
-#include <com/sun/star/uno/Reference.hxx>
|
||||
-#include <com/sun/star/uno/XInterface.hpp>
|
||||
#include <svx/svditer.hxx>
|
||||
#include <tools/long.hxx>
|
||||
#include "types.hxx"
|
||||
@@ -24,7 +22,6 @@
|
||||
class ScDocShell;
|
||||
class ScDocument;
|
||||
class SdrOle2Obj;
|
||||
-namespace tools { class JsonWriter; }
|
||||
|
||||
namespace sctools {
|
||||
|
||||
@@ -55,14 +52,6 @@ std::vector<SdrOle2Obj*> getAllPivotChartsConnectedTo(std::u16string_view sPivot
|
||||
|
||||
/// `rText`'s ranges, when every part names existing cells.
|
||||
std::optional<ScRangeList> chartRanges(const ScDocument& rDoc, std::u16string_view rText);
|
||||
-/// Whether a kit client's chart look parses.
|
||||
-bool isChartLook(std::u16string_view rJson);
|
||||
-/// Sets type, title, legend and axis titles from JSON.
|
||||
-bool setChartLook(const css::uno::Reference<css::uno::XInterface>& xChart,
|
||||
- std::u16string_view rJson);
|
||||
-/// Writes the same look as JSON members.
|
||||
-void writeChartLook(::tools::JsonWriter& rJson,
|
||||
- const css::uno::Reference<css::uno::XInterface>& xChart);
|
||||
|
||||
} // end sctools
|
||||
|
||||
diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
|
||||
index 46f3547..78810ce 100644
|
||||
--- a/sc/source/ui/docshell/docsh4.cxx
|
||||
+++ b/sc/source/ui/docshell/docsh4.cxx
|
||||
@@ -96,6 +96,7 @@
|
||||
#include <reffact.hxx>
|
||||
#include <chartlis.hxx>
|
||||
#include <chartpos.hxx>
|
||||
+#include <svx/charthelper.hxx>
|
||||
#include <ChartTools.hxx>
|
||||
#include <com/sun/star/chart2/XChartDocument.hpp>
|
||||
#include <com/sun/star/util/XCloneable.hpp>
|
||||
@@ -1729,7 +1730,7 @@ void ScDocShell::ExecuteChartSource(SfxRequest& rReq)
|
||||
// A kit client's look; it must parse before anything changes.
|
||||
const SfxStringItem* pLook = rReq.GetArg<SfxStringItem>(FN_PARAM_3);
|
||||
if (pLook
|
||||
- && (!bColInit || !bRowInit || !sctools::isChartLook(pLook->GetValue())
|
||||
+ && (!bColInit || !bRowInit || !ChartHelper::IsChartLook(pLook->GetValue())
|
||||
|| !sctools::chartRanges(rDoc, aRangeName)))
|
||||
{
|
||||
SAL_WARN("sc.lok", "chart look needs headers and must parse: " << pLook->GetValue());
|
||||
@@ -1800,7 +1801,7 @@ void ScDocShell::ExecuteChartSource(SfxRequest& rReq)
|
||||
pUndoManager->EnterListAction(ScResId(STR_UNDO_CHARTDATA), u""_ustr, 0, pViewSh->GetViewShellId());
|
||||
auto xChart = m_pDocument->GetChartByName(aChartName);
|
||||
ChartState aOld = lcl_ChartState(xChart);
|
||||
- sctools::setChartLook(xChart, pLook->GetValue());
|
||||
+ ChartHelper::SetChartLook(xChart, pLook->GetValue());
|
||||
if (bUndo)
|
||||
pUndoManager->AddUndoAction(std::make_unique<ScUndoChartLook>(
|
||||
*this, aChartName, std::move(aOld), lcl_ChartState(xChart)));
|
||||
diff --git a/sc/source/ui/drawfunc/fuins2.cxx b/sc/source/ui/drawfunc/fuins2.cxx
|
||||
index 78e4a9c..b0169d0 100644
|
||||
--- a/sc/source/ui/drawfunc/fuins2.cxx
|
||||
+++ b/sc/source/ui/drawfunc/fuins2.cxx
|
||||
@@ -63,6 +63,7 @@
|
||||
#include <PivotTableDataProvider.hxx>
|
||||
#include <chart2uno.hxx>
|
||||
#include <fuinsert.hxx>
|
||||
+#include <svx/charthelper.hxx>
|
||||
#include <ChartTools.hxx>
|
||||
#include <tabvwsh.hxx>
|
||||
#include <sc.hrc>
|
||||
@@ -424,7 +425,7 @@ FuInsertChart::FuInsertChart(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawV
|
||||
|
||||
// A kit client's look must parse before anything lands.
|
||||
const SfxStringItem* pLook = rReq.GetArg<SfxStringItem>(FN_PARAM_3);
|
||||
- if (pLook && !sctools::isChartLook(pLook->GetValue()))
|
||||
+ if (pLook && !ChartHelper::IsChartLook(pLook->GetValue()))
|
||||
{
|
||||
SAL_WARN("sc.lok", "chart look does not parse: " << pLook->GetValue());
|
||||
return;
|
||||
@@ -643,7 +644,7 @@ FuInsertChart::FuInsertChart(ScTabViewShell& rViewSh, vcl::Window* pWin, ScDrawV
|
||||
// No wizard: one undo step, the look from the request.
|
||||
pView->AddUndo(std::make_unique<SdrUndoNewObj>(*pObj));
|
||||
if (pLook)
|
||||
- sctools::setChartLook(xChartModel, pLook->GetValue());
|
||||
+ ChartHelper::SetChartLook(xChartModel, pLook->GetValue());
|
||||
if (xChartModel.is())
|
||||
xChartModel->unlockControllers();
|
||||
}
|
||||
diff --git a/sc/source/ui/unoobj/ChartTools.cxx b/sc/source/ui/unoobj/ChartTools.cxx
|
||||
index caba334..5fb13a4 100644
|
||||
--- a/sc/source/ui/unoobj/ChartTools.cxx
|
||||
+++ b/sc/source/ui/unoobj/ChartTools.cxx
|
||||
@@ -13,18 +13,8 @@
|
||||
#include <document.hxx>
|
||||
#include <drwlayer.hxx>
|
||||
|
||||
-#include <com/sun/star/beans/XPropertySet.hpp>
|
||||
-#include <com/sun/star/chart/XAxisXSupplier.hpp>
|
||||
-#include <com/sun/star/chart/XAxisYSupplier.hpp>
|
||||
-#include <com/sun/star/chart/XChartDocument.hpp>
|
||||
#include <com/sun/star/chart2/XChartDocument.hpp>
|
||||
-#include <com/sun/star/drawing/XShape.hpp>
|
||||
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
|
||||
-#include <functional>
|
||||
#include <optional>
|
||||
-#include <sstream>
|
||||
-#include <tools/json_writer.hxx>
|
||||
-#include <boost/property_tree/json_parser.hpp>
|
||||
#include <com/sun/star/embed/XEmbeddedObject.hpp>
|
||||
#include <chart2/AbstractPivotTableDataProvider.hxx>
|
||||
#include <svx/svditer.hxx>
|
||||
@@ -181,76 +171,6 @@ std::vector<SdrOle2Obj*> getAllPivotChartsConnectedTo(std::u16string_view sPivot
|
||||
return aObjects;
|
||||
}
|
||||
|
||||
-namespace
|
||||
-{
|
||||
-/// Kit names and the diagram services they map to.
|
||||
-constexpr std::pair<std::string_view, std::u16string_view> aChartTypes[]
|
||||
- = { { "column", u"com.sun.star.chart.BarDiagram" },
|
||||
- { "bar", u"com.sun.star.chart.BarDiagram" },
|
||||
- { "line", u"com.sun.star.chart.LineDiagram" },
|
||||
- { "scatter", u"com.sun.star.chart.XYDiagram" },
|
||||
- { "pie", u"com.sun.star.chart.PieDiagram" } };
|
||||
-
|
||||
-/// A parsed look; "other" keeps the diagram.
|
||||
-struct ChartLook
|
||||
-{
|
||||
- std::string_view aType;
|
||||
- OUString aTitle, aXTitle, aYTitle;
|
||||
- bool bLegend = true;
|
||||
-};
|
||||
-
|
||||
-std::optional<ChartLook> lcl_ParseLook(std::u16string_view rJson)
|
||||
-{
|
||||
- boost::property_tree::ptree aTree;
|
||||
- std::stringstream aStream{ std::string(OUString(rJson).toUtf8()) };
|
||||
- try
|
||||
- {
|
||||
- boost::property_tree::read_json(aStream, aTree);
|
||||
- }
|
||||
- catch (const boost::property_tree::json_parser_error&)
|
||||
- {
|
||||
- return std::nullopt;
|
||||
- }
|
||||
- const std::string aType = aTree.get<std::string>("type", "");
|
||||
- ChartLook aLook;
|
||||
- if (aType == "other")
|
||||
- aLook.aType = "other";
|
||||
- for (const auto& [rName, rService] : aChartTypes)
|
||||
- if (rName == aType)
|
||||
- aLook.aType = rName;
|
||||
- if (aLook.aType.empty())
|
||||
- return std::nullopt;
|
||||
- aLook.aTitle = OUString::fromUtf8(aTree.get<std::string>("title", ""));
|
||||
- aLook.aXTitle = OUString::fromUtf8(aTree.get<std::string>("xtitle", ""));
|
||||
- aLook.aYTitle = OUString::fromUtf8(aTree.get<std::string>("ytitle", ""));
|
||||
- aLook.bLegend = aTree.get<bool>("legend", true);
|
||||
- return aLook;
|
||||
-}
|
||||
-
|
||||
-/// Shows a title with this text; empty hides it.
|
||||
-void lcl_SetTitle(const uno::Reference<beans::XPropertySet>& xOwner, const OUString& rHas,
|
||||
- const std::function<uno::Reference<drawing::XShape>()>& rTitle,
|
||||
- const OUString& rText)
|
||||
-{
|
||||
- xOwner->setPropertyValue(rHas, uno::Any(!rText.isEmpty()));
|
||||
- if (rText.isEmpty())
|
||||
- return;
|
||||
- uno::Reference<beans::XPropertySet> xTitle(rTitle(), uno::UNO_QUERY_THROW);
|
||||
- xTitle->setPropertyValue(u"String"_ustr, uno::Any(rText));
|
||||
-}
|
||||
-
|
||||
-OUString lcl_Title(const uno::Reference<beans::XPropertySet>& xOwner, const OUString& rHas,
|
||||
- const std::function<uno::Reference<drawing::XShape>()>& rTitle)
|
||||
-{
|
||||
- OUString aText;
|
||||
- if (!xOwner->getPropertyValue(rHas).get<bool>())
|
||||
- return aText;
|
||||
- uno::Reference<beans::XPropertySet> xTitle(rTitle(), uno::UNO_QUERY_THROW);
|
||||
- xTitle->getPropertyValue(u"String"_ustr) >>= aText;
|
||||
- return aText;
|
||||
-}
|
||||
-}
|
||||
-
|
||||
std::optional<ScRangeList> chartRanges(const ScDocument& rDoc, std::u16string_view rText)
|
||||
{
|
||||
ScRangeList aRanges;
|
||||
@@ -264,71 +184,6 @@ std::optional<ScRangeList> chartRanges(const ScDocument& rDoc, std::u16string_vi
|
||||
return aRanges;
|
||||
}
|
||||
|
||||
-bool isChartLook(std::u16string_view rJson) { return lcl_ParseLook(rJson).has_value(); }
|
||||
-
|
||||
-bool setChartLook(const uno::Reference<uno::XInterface>& xChart, std::u16string_view rJson)
|
||||
-{
|
||||
- const std::optional<ChartLook> oLook = lcl_ParseLook(rJson);
|
||||
- uno::Reference<chart::XChartDocument> xDoc(xChart, uno::UNO_QUERY);
|
||||
- if (!oLook || !xDoc.is())
|
||||
- return false;
|
||||
- uno::Reference<chart::XDiagram> xDiagram = xDoc->getDiagram();
|
||||
- const auto pType = std::find_if(std::begin(aChartTypes), std::end(aChartTypes),
|
||||
- [&oLook](const auto& rPair) { return rPair.first == oLook->aType; });
|
||||
- if (pType != std::end(aChartTypes))
|
||||
- {
|
||||
- if (xDiagram->getDiagramType() != pType->second)
|
||||
- {
|
||||
- uno::Reference<lang::XMultiServiceFactory> xFactory(xDoc, uno::UNO_QUERY_THROW);
|
||||
- xDiagram.set(xFactory->createInstance(OUString(pType->second)), uno::UNO_QUERY_THROW);
|
||||
- xDoc->setDiagram(xDiagram);
|
||||
- }
|
||||
- uno::Reference<beans::XPropertySet> xProps(xDiagram, uno::UNO_QUERY_THROW);
|
||||
- if (pType->second == u"com.sun.star.chart.BarDiagram")
|
||||
- xProps->setPropertyValue(u"Vertical"_ustr, uno::Any(oLook->aType == "bar"));
|
||||
- if (oLook->aType == "scatter")
|
||||
- xProps->setPropertyValue(u"Lines"_ustr, uno::Any(false));
|
||||
- }
|
||||
- uno::Reference<beans::XPropertySet> xDocProps(xDoc, uno::UNO_QUERY_THROW);
|
||||
- lcl_SetTitle(xDocProps, u"HasMainTitle"_ustr, [&xDoc] { return xDoc->getTitle(); },
|
||||
- oLook->aTitle);
|
||||
- xDocProps->setPropertyValue(u"HasLegend"_ustr, uno::Any(oLook->bLegend));
|
||||
- // A pie has no axes.
|
||||
- if (xDiagram->getDiagramType() == u"com.sun.star.chart.PieDiagram")
|
||||
- return true;
|
||||
- uno::Reference<chart::XAxisXSupplier> xX(xDiagram, uno::UNO_QUERY_THROW);
|
||||
- uno::Reference<chart::XAxisYSupplier> xY(xDiagram, uno::UNO_QUERY_THROW);
|
||||
- uno::Reference<beans::XPropertySet> xProps(xDiagram, uno::UNO_QUERY_THROW);
|
||||
- lcl_SetTitle(xProps, u"HasXAxisTitle"_ustr, [&xX] { return xX->getXAxisTitle(); },
|
||||
- oLook->aXTitle);
|
||||
- lcl_SetTitle(xProps, u"HasYAxisTitle"_ustr, [&xY] { return xY->getYAxisTitle(); },
|
||||
- oLook->aYTitle);
|
||||
- return true;
|
||||
-}
|
||||
-
|
||||
-void writeChartLook(::tools::JsonWriter& rJson, const uno::Reference<uno::XInterface>& xChart)
|
||||
-{
|
||||
- uno::Reference<chart::XChartDocument> xDoc(xChart, uno::UNO_QUERY_THROW);
|
||||
- uno::Reference<chart::XDiagram> xDiagram = xDoc->getDiagram();
|
||||
- uno::Reference<beans::XPropertySet> xProps(xDiagram, uno::UNO_QUERY_THROW);
|
||||
- const OUString aService = xDiagram->getDiagramType();
|
||||
- std::string_view aType = "other";
|
||||
- for (const auto& [rName, rService] : aChartTypes)
|
||||
- if (rService == aService && aType == "other")
|
||||
- aType = rName;
|
||||
- if (aType == "column" && xProps->getPropertyValue(u"Vertical"_ustr).get<bool>())
|
||||
- aType = "bar";
|
||||
- rJson.put("type", aType);
|
||||
- uno::Reference<beans::XPropertySet> xDocProps(xDoc, uno::UNO_QUERY_THROW);
|
||||
- rJson.put("title", lcl_Title(xDocProps, u"HasMainTitle"_ustr, [&xDoc] { return xDoc->getTitle(); }));
|
||||
- rJson.put("legend", xDocProps->getPropertyValue(u"HasLegend"_ustr).get<bool>());
|
||||
- uno::Reference<chart::XAxisXSupplier> xX(xDiagram, uno::UNO_QUERY_THROW);
|
||||
- uno::Reference<chart::XAxisYSupplier> xY(xDiagram, uno::UNO_QUERY_THROW);
|
||||
- const bool bAxes = aType != "pie";
|
||||
- rJson.put("xtitle", bAxes ? lcl_Title(xProps, u"HasXAxisTitle"_ustr, [&xX] { return xX->getXAxisTitle(); }) : OUString());
|
||||
- rJson.put("ytitle", bAxes ? lcl_Title(xProps, u"HasYAxisTitle"_ustr, [&xY] { return xY->getYAxisTitle(); }) : OUString());
|
||||
-}
|
||||
-
|
||||
} // end sctools
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
|
||||
index b850504..cf42499 100644
|
||||
--- a/sc/source/ui/unoobj/docuno.cxx
|
||||
+++ b/sc/source/ui/unoobj/docuno.cxx
|
||||
@@ -154,6 +154,7 @@
|
||||
#include <output.hxx>
|
||||
#include <stlpool.hxx>
|
||||
#include <SheetViewManager.hxx>
|
||||
+#include <svx/charthelper.hxx>
|
||||
#include <ChartTools.hxx>
|
||||
#include <dpobject.hxx>
|
||||
#include <dpshttab.hxx>
|
||||
@@ -947,7 +948,7 @@ void lcl_Chart(tools::JsonWriter& rJson, ScDocument& rDoc, ScViewData& rData)
|
||||
rJson.put("range", aRange);
|
||||
rJson.put("colHeaders", bColHeaders);
|
||||
rJson.put("rowHeaders", bRowHeaders);
|
||||
- sctools::writeChartLook(rJson, rDoc.GetChartByName(aName));
|
||||
+ ChartHelper::WriteChartLook(rJson, rDoc.GetChartByName(aName));
|
||||
}
|
||||
|
||||
/// A repeated row or column span, 1-based.
|
||||
@@ -0,0 +1,396 @@
|
||||
LOK: Impress charts, notes and comments without dialogs
|
||||
|
||||
- .uno:InsertObjectChart takes Chart (look and data as JSON): it inserts
|
||||
a chart at the slide centre with no chart UI, or, with one chart
|
||||
marked, changes that chart on a copy that replaces it (one undo step).
|
||||
A look or table that does not parse is refused. The look goes in
|
||||
before the data, so the data sees the chart's type.
|
||||
- .uno:Chart reads the marked chart's name, look and data.
|
||||
- .uno:SlideNotes (new) sets slide Part's notes as plain text in one
|
||||
undo step. Text with one look throughout, paragraph and character
|
||||
(PowerPoint sets the full look on every run), keeps it; text whose
|
||||
look varies is refused, as plain text would lose it. Its read gives
|
||||
the shown slide's index, the text and whether the look varies
|
||||
("rich").
|
||||
- Comments read with their slide's index.
|
||||
- A new comment or reply takes the user's name when the view has no
|
||||
author (a kit client sets the name with setOption("author")); it was
|
||||
left blank.
|
||||
|
||||
diff --git a/sd/inc/app.hrc b/sd/inc/app.hrc
|
||||
index d63a4d3..1944bbe 100644
|
||||
--- a/sd/inc/app.hrc
|
||||
+++ b/sd/inc/app.hrc
|
||||
@@ -426,5 +426,6 @@
|
||||
#define SID_ALIGN_PAGE (SID_SD_START+451)
|
||||
|
||||
#define FN_TRANSFORM_DOCUMENT_STRUCTURE (SID_SD_START+452)
|
||||
+#define SID_SLIDE_NOTES (SID_SD_START+453)
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
diff --git a/sd/sdi/_drvwsh.sdi b/sd/sdi/_drvwsh.sdi
|
||||
index c574c2c..cf3acd6 100644
|
||||
--- a/sd/sdi/_drvwsh.sdi
|
||||
+++ b/sd/sdi/_drvwsh.sdi
|
||||
@@ -3033,6 +3033,11 @@ interface DrawView
|
||||
ExecMethod = FuTemporary ;
|
||||
StateMethod = GetMenuState;
|
||||
]
|
||||
+ SID_SLIDE_NOTES
|
||||
+ [
|
||||
+ ExecMethod = FuTemporary ;
|
||||
+ StateMethod = GetMenuState;
|
||||
+ ]
|
||||
SID_COPY_SLIDE
|
||||
[
|
||||
ExecMethod = FuTemporary ;
|
||||
diff --git a/sd/sdi/sdraw.sdi b/sd/sdi/sdraw.sdi
|
||||
index ccc665d..728b670 100644
|
||||
--- a/sd/sdi/sdraw.sdi
|
||||
+++ b/sd/sdi/sdraw.sdi
|
||||
@@ -4198,6 +4198,23 @@ SfxVoidItem AlignOnPage SID_ALIGN_PAGE
|
||||
GroupId = SfxGroupId::Modify;
|
||||
]
|
||||
|
||||
+SfxVoidItem SlideNotes SID_SLIDE_NOTES
|
||||
+(SfxStringItem Text FN_PARAM_1, SfxInt32Item Part FN_PARAM_2)
|
||||
+[
|
||||
+ AutoUpdate = FALSE,
|
||||
+ FastCall = FALSE,
|
||||
+ ReadOnlyDoc = FALSE,
|
||||
+ Toggle = FALSE,
|
||||
+ Container = FALSE,
|
||||
+ RecordAbsolute = FALSE,
|
||||
+ RecordPerSet;
|
||||
+
|
||||
+ AccelConfig = FALSE,
|
||||
+ MenuConfig = FALSE,
|
||||
+ ToolBoxConfig = FALSE,
|
||||
+ GroupId = SfxGroupId::Modify;
|
||||
+]
|
||||
+
|
||||
SfxVoidItem CopySlide SID_COPY_SLIDE
|
||||
()
|
||||
[
|
||||
diff --git a/sd/source/ui/annotations/annotationmanager.cxx b/sd/source/ui/annotations/annotationmanager.cxx
|
||||
index bd882b1..75cd8a6 100644
|
||||
--- a/sd/source/ui/annotations/annotationmanager.cxx
|
||||
+++ b/sd/source/ui/annotations/annotationmanager.cxx
|
||||
@@ -537,7 +537,8 @@ void AnnotationManagerImpl::InsertAnnotation(const OUString& rText)
|
||||
OUString sAuthor;
|
||||
if (comphelper::LibreOfficeKit::isActive())
|
||||
sAuthor = mrBase.GetMainViewShell()->GetView()->GetAuthor();
|
||||
- else
|
||||
+ // A kit client without a view author: the user's name.
|
||||
+ if (sAuthor.isEmpty())
|
||||
{
|
||||
SvtUserOptions aUserOptions;
|
||||
sAuthor = aUserOptions.GetFullName();
|
||||
@@ -656,7 +657,8 @@ void AnnotationManagerImpl::ExecuteReplyToAnnotation( SfxRequest const & rReq )
|
||||
OUString sReplyAuthor;
|
||||
if (comphelper::LibreOfficeKit::isActive())
|
||||
sReplyAuthor = mrBase.GetMainViewShell()->GetView()->GetAuthor();
|
||||
- else
|
||||
+ // A kit client without a view author: the user's name.
|
||||
+ if (sReplyAuthor.isEmpty())
|
||||
{
|
||||
SvtUserOptions aUserOptions;
|
||||
sReplyAuthor = aUserOptions.GetFullName();
|
||||
diff --git a/sd/source/ui/func/fuinsert.cxx b/sd/source/ui/func/fuinsert.cxx
|
||||
index bbe3705..63774f7 100644
|
||||
--- a/sd/source/ui/func/fuinsert.cxx
|
||||
+++ b/sd/source/ui/func/fuinsert.cxx
|
||||
@@ -295,8 +295,35 @@ rtl::Reference<FuPoor> FuInsertOLE::Create( ViewShell& rViewSh, ::sd::Window* pW
|
||||
return xFunc;
|
||||
}
|
||||
|
||||
+/// Sets the marked chart from JSON via a copy.
|
||||
+bool FuInsertOLE::ChangeChart(std::u16string_view rJson)
|
||||
+{
|
||||
+ const SdrMarkList& rMarks = mpView->GetMarkedObjectList();
|
||||
+ if (rMarks.GetMarkCount() != 1)
|
||||
+ return false;
|
||||
+ SdrOle2Obj* pOld = dynamic_cast<SdrOle2Obj*>(rMarks.GetMark(0)->GetMarkedSdrObj());
|
||||
+ if (!pOld || !pOld->IsChart())
|
||||
+ return false;
|
||||
+ rtl::Reference<SdrObject> pNew = pOld->CloneSdrObject(pOld->getSdrModelFromSdrObject());
|
||||
+ const uno::Reference<uno::XInterface> xModel = static_cast<SdrOle2Obj&>(*pNew).getXModel();
|
||||
+ // The look first: data reads its type.
|
||||
+ if (!ChartHelper::SetChartLook(xModel, rJson) || !ChartHelper::SetChartData(xModel, rJson))
|
||||
+ return false;
|
||||
+ mpView->ReplaceObjectAtView(pOld, *mpView->GetSdrPageView(), pNew.get());
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
void FuInsertOLE::DoExecute( SfxRequest& rReq )
|
||||
{
|
||||
+ // A kit client sets the chart from JSON.
|
||||
+ const SfxStringItem* pChart
|
||||
+ = nSlotId == SID_INSERT_DIAGRAM ? rReq.GetArg<SfxStringItem>(FN_PARAM_3) : nullptr;
|
||||
+ if (pChart && (!ChartHelper::IsChartLook(pChart->GetValue())
|
||||
+ || !ChartHelper::IsChartData(pChart->GetValue())))
|
||||
+ return;
|
||||
+ if (pChart && ChangeChart(pChart->GetValue()))
|
||||
+ return;
|
||||
+
|
||||
if ( nSlotId == SID_ATTR_TABLE ||
|
||||
nSlotId == SID_INSERT_DIAGRAM ||
|
||||
nSlotId == SID_INSERT_MATH )
|
||||
@@ -367,7 +394,10 @@ void FuInsertOLE::DoExecute( SfxRequest& rReq )
|
||||
aSize = OutputDevice::LogicToLogic(aSize, MapMode(aUnit), MapMode(MapUnit::Map100thMM));
|
||||
}
|
||||
|
||||
- Point aPos = mpWindow->GetVisibleCenter();
|
||||
+ // LOK's window area means nothing; use the slide.
|
||||
+ Point aPos = comphelper::LibreOfficeKit::isActive()
|
||||
+ ? ::tools::Rectangle(Point(), mpView->GetSdrPageView()->GetPage()->GetSize()).Center()
|
||||
+ : mpWindow->GetVisibleCenter();
|
||||
aPos.AdjustX( -(aSize.Width() / 2) );
|
||||
aPos.AdjustY( -(aSize.Height() / 2) );
|
||||
aRect = ::tools::Rectangle(aPos, aSize);
|
||||
@@ -405,7 +435,14 @@ void FuInsertOLE::DoExecute( SfxRequest& rReq )
|
||||
else
|
||||
bRet = mpView->InsertObjectAtView(pOleObj.get(), *pPV, SdrInsertFlags::SETDEFLAYER);
|
||||
|
||||
- if (bRet && !comphelper::LibreOfficeKit::isActive())
|
||||
+ if (bRet && pChart)
|
||||
+ {
|
||||
+ ChartHelper::AdaptDefaultsForChart(xObj);
|
||||
+ const uno::Reference<uno::XInterface> xModel = pOleObj->getXModel();
|
||||
+ ChartHelper::SetChartLook(xModel, pChart->GetValue());
|
||||
+ ChartHelper::SetChartData(xModel, pChart->GetValue());
|
||||
+ }
|
||||
+ else if (bRet && !comphelper::LibreOfficeKit::isActive())
|
||||
{
|
||||
// Let the chart be activated after the inserting (unless
|
||||
// via LibreOfficeKit)
|
||||
diff --git a/sd/source/ui/inc/DrawViewShell.hxx b/sd/source/ui/inc/DrawViewShell.hxx
|
||||
index abac2af..6e42423 100644
|
||||
--- a/sd/source/ui/inc/DrawViewShell.hxx
|
||||
+++ b/sd/source/ui/inc/DrawViewShell.hxx
|
||||
@@ -35,6 +35,7 @@ namespace com::sun::star::lang { class XEventListener; }
|
||||
namespace com::sun::star::scanner { class XScannerManager2; }
|
||||
namespace com::sun::star::presentation { class XSlideShow; }
|
||||
|
||||
+class EditTextObject;
|
||||
class Outliner;
|
||||
class SdPage;
|
||||
class SdStyleSheet;
|
||||
@@ -281,6 +282,8 @@ public:
|
||||
void SetZoomOnPage( bool bZoom ) { mbZoomOnPage = bZoom; }
|
||||
bool IsZoomOnPage() const { return mbZoomOnPage; }
|
||||
static void CheckLineTo (SfxRequest& rReq);
|
||||
+ /// The text's one look; none when it varies.
|
||||
+ static std::optional<SfxItemSet> NotesLook(const EditTextObject& rText, SfxItemPool& rPool);
|
||||
void SetChildWindowState( SfxItemSet& rSet );
|
||||
|
||||
void UpdateIMapDlg( SdrObject* pObj );
|
||||
diff --git a/sd/source/ui/inc/fuinsert.hxx b/sd/source/ui/inc/fuinsert.hxx
|
||||
index ca1adfc..3b79e19 100644
|
||||
--- a/sd/source/ui/inc/fuinsert.hxx
|
||||
+++ b/sd/source/ui/inc/fuinsert.hxx
|
||||
@@ -77,6 +77,8 @@ class FuInsertOLE final
|
||||
virtual void DoExecute( SfxRequest& rReq ) override;
|
||||
|
||||
private:
|
||||
+ bool ChangeChart(std::u16string_view rJson);
|
||||
+
|
||||
FuInsertOLE (
|
||||
ViewShell& rViewSh,
|
||||
::sd::Window* pWin,
|
||||
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
|
||||
index b5ccc0d..8418d71 100644
|
||||
--- a/sd/source/ui/unoidl/unomodel.cxx
|
||||
+++ b/sd/source/ui/unoidl/unomodel.cxx
|
||||
@@ -121,6 +121,9 @@
|
||||
#include <svx/sdshitm.hxx>
|
||||
#include <svx/svdhlpln.hxx>
|
||||
#include <svx/sdangitm.hxx>
|
||||
+#include <svx/charthelper.hxx>
|
||||
+#include <editeng/editobj.hxx>
|
||||
+#include <editeng/outlobj.hxx>
|
||||
#include <svx/svxids.hrc>
|
||||
#include <svtools/unoimap.hxx>
|
||||
#include <svx/unoshape.hxx>
|
||||
@@ -2060,7 +2063,8 @@ void SdXImpressDocument::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
|
||||
|
||||
bool SdXImpressDocument::supportsCommand(std::u16string_view rCommand)
|
||||
{
|
||||
- return rCommand == u"SlideDesign" || rCommand == u"SlideObjects";
|
||||
+ return rCommand == u"SlideDesign" || rCommand == u"SlideObjects" || rCommand == u"Chart"
|
||||
+ || rCommand == u"SlideNotes";
|
||||
}
|
||||
|
||||
namespace
|
||||
@@ -2191,6 +2195,34 @@ void lcl_Selection(::tools::JsonWriter& rJson, sd::View& rView)
|
||||
rJson.put("lockSize", lcl_Flag(aGeo, SID_ATTR_TRANSFORM_PROTECT_SIZE));
|
||||
}
|
||||
|
||||
+/// The one marked chart's name, look and data; nothing otherwise.
|
||||
+void lcl_Chart(::tools::JsonWriter& rJson, sd::View& rView)
|
||||
+{
|
||||
+ const SdrMarkList& rMarks = rView.GetMarkedObjectList();
|
||||
+ auto pOle = rMarks.GetMarkCount() == 1
|
||||
+ ? dynamic_cast<SdrOle2Obj*>(rMarks.GetMark(0)->GetMarkedSdrObj()) : nullptr;
|
||||
+ if (!pOle || !pOle->IsChart())
|
||||
+ return;
|
||||
+ const uno::Reference<uno::XInterface> xModel = pOle->getXModel();
|
||||
+ rJson.put("name", pOle->GetName());
|
||||
+ ChartHelper::WriteChartLook(rJson, xModel);
|
||||
+ ChartHelper::WriteChartData(rJson, xModel);
|
||||
+}
|
||||
+
|
||||
+/// The shown slide's notes as text; rich with character formats.
|
||||
+void lcl_SlideNotes(::tools::JsonWriter& rJson, SdDrawDocument& rDoc, sd::DrawViewShell& rShell)
|
||||
+{
|
||||
+ SdPage* pPage = rShell.GetActualPage();
|
||||
+ SdPage* pNotes = pPage->IsMasterPage()
|
||||
+ ? nullptr : rDoc.GetSdPage((pPage->GetPageNum() - 1) / 2, PageKind::Notes);
|
||||
+ auto pObj = pNotes ? dynamic_cast<SdrTextObj*>(pNotes->GetPresObj(PresObjKind::Notes)) : nullptr;
|
||||
+ rJson.put("part", pPage->IsMasterPage() ? sal_Int32(-1) : sal_Int32((pPage->GetPageNum() - 1) / 2));
|
||||
+ rJson.put("editable", pObj != nullptr);
|
||||
+ const OutlinerParaObject* pText = pObj && !pObj->IsEmptyPresObj() ? pObj->GetOutlinerParaObject() : nullptr;
|
||||
+ rJson.put("text", pText ? pText->GetTextObject().GetText(LINEEND_LF) : OUString());
|
||||
+ rJson.put("rich", pText && !sd::DrawViewShell::NotesLook(pText->GetTextObject(), rDoc.GetPool()));
|
||||
+}
|
||||
+
|
||||
/// The shown slide's objects, selection, guides and snapping.
|
||||
void lcl_SlideObjects(::tools::JsonWriter& rJson, sd::DrawViewShell& rShell)
|
||||
{
|
||||
@@ -2247,6 +2279,18 @@ void SdXImpressDocument::getCommandValues(::tools::JsonWriter& rJsonWriter, std:
|
||||
lcl_SlideDesign(rJsonWriter, *mpDoc, *pShell);
|
||||
return;
|
||||
}
|
||||
+ if (rCommand == ".uno:Chart")
|
||||
+ {
|
||||
+ if (DrawViewShell* pShell = GetViewShell())
|
||||
+ lcl_Chart(rJsonWriter, *pShell->GetView());
|
||||
+ return;
|
||||
+ }
|
||||
+ if (rCommand == ".uno:SlideNotes")
|
||||
+ {
|
||||
+ if (DrawViewShell* pShell = GetViewShell())
|
||||
+ lcl_SlideNotes(rJsonWriter, *mpDoc, *pShell);
|
||||
+ return;
|
||||
+ }
|
||||
if (rCommand == ".uno:SlideObjects")
|
||||
{
|
||||
if (DrawViewShell* pShell = GetViewShell())
|
||||
@@ -4423,6 +4467,8 @@ void SdXImpressDocument::getPostIts(::tools::JsonWriter& rJsonWriter)
|
||||
uno::Reference<text::XText> xText(xAnnotation->getTextRange());
|
||||
rJsonWriter.put("text", xText->getString());
|
||||
rJsonWriter.put("parthash", pPage->GetUniqueID());
|
||||
+ // The slide's place, for clients that show slides by index.
|
||||
+ rJsonWriter.put("part", static_cast<sal_Int32>((pPage->GetPageNum() - 1) / 2));
|
||||
geometry::RealPoint2D const aPoint = xAnnotation->getPosition();
|
||||
geometry::RealSize2D const aSize = xAnnotation->getSize();
|
||||
::tools::Rectangle aRectangle(Point(aPoint.X * 100.0, aPoint.Y * 100.0), Size(aSize.Width * 100.0, aSize.Height * 100.0));
|
||||
diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx
|
||||
index d8b1015..8b734af 100644
|
||||
--- a/sd/source/ui/view/drviews2.cxx
|
||||
+++ b/sd/source/ui/view/drviews2.cxx
|
||||
@@ -3840,6 +3840,46 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
|
||||
}
|
||||
break;
|
||||
|
||||
+ case SID_SLIDE_NOTES:
|
||||
+ {
|
||||
+ // Slide Part's notes, as plain text.
|
||||
+ const SfxStringItem* pText = rReq.GetArg<SfxStringItem>(FN_PARAM_1);
|
||||
+ const SfxInt32Item* pPart = rReq.GetArg<SfxInt32Item>(FN_PARAM_2);
|
||||
+ const sal_Int32 nPart = pPart ? pPart->GetValue() : -1;
|
||||
+ SdPage* pNotes = pText && nPart >= 0
|
||||
+ && nPart < GetDoc()->GetSdPageCount(PageKind::Standard)
|
||||
+ ? GetDoc()->GetSdPage(nPart, PageKind::Notes) : nullptr;
|
||||
+ auto pObj = pNotes ? dynamic_cast<SdrTextObj*>(pNotes->GetPresObj(PresObjKind::Notes)) : nullptr;
|
||||
+ const OutlinerParaObject* pOld = pObj && !pObj->IsEmptyPresObj() ? pObj->GetOutlinerParaObject() : nullptr;
|
||||
+ std::optional<SfxItemSet> oLook = pOld
|
||||
+ ? NotesLook(pOld->GetTextObject(), GetDoc()->GetPool())
|
||||
+ : SfxItemSet(GetDoc()->GetPool(), svl::Items<EE_PARA_START, EE_CHAR_END>);
|
||||
+ // Varied formatting would be lost.
|
||||
+ if (pObj && oLook)
|
||||
+ {
|
||||
+ const OUString& rText = pText->GetValue();
|
||||
+ const bool bEmpty = rText.isEmpty();
|
||||
+ GetDoc()->BegUndo(SdResId(STR_NOTES_MODE));
|
||||
+ GetDoc()->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoObjectSetText(*pObj, 0));
|
||||
+ pNotes->SetObjText(pObj, nullptr, PresObjKind::Notes,
|
||||
+ bEmpty ? pNotes->GetPresObjText(PresObjKind::Notes) : rText);
|
||||
+ if (!bEmpty && oLook->Count())
|
||||
+ {
|
||||
+ SdOutliner* pOutl = GetDoc()->GetInternalOutliner();
|
||||
+ pOutl->Clear();
|
||||
+ pOutl->SetText(*pObj->GetOutlinerParaObject());
|
||||
+ pOutl->QuickSetAttribs(*oLook, ESelection::All());
|
||||
+ pObj->SetOutlinerParaObject(pOutl->CreateParaObject());
|
||||
+ pOutl->Clear();
|
||||
+ }
|
||||
+ pObj->SetEmptyPresObj(bEmpty);
|
||||
+ GetDoc()->EndUndo();
|
||||
+ rReq.Done();
|
||||
+ }
|
||||
+ Cancel();
|
||||
+ }
|
||||
+ break;
|
||||
+
|
||||
case SID_ALIGN_PAGE:
|
||||
{
|
||||
mpDrawView->AlignMarkedObjects(SdrHorAlign::Center, SdrVertAlign::Center);
|
||||
@@ -4776,6 +4816,44 @@ void DrawViewShell::GetStatePropPanelAttr(SfxItemSet& rSet)
|
||||
}
|
||||
}
|
||||
|
||||
+std::optional<SfxItemSet> DrawViewShell::NotesLook(const EditTextObject& rText, SfxItemPool& rPool)
|
||||
+{
|
||||
+ std::optional<SfxItemSet> oPara, oChar;
|
||||
+ for (sal_Int32 i = 0; i < rText.GetParagraphCount(); ++i)
|
||||
+ {
|
||||
+ SfxItemSet aPara(rPool, svl::Items<EE_PARA_START, EE_PARA_END>);
|
||||
+ aPara.Put(rText.GetParaAttribs(i));
|
||||
+ // The outliner keeps this one itself.
|
||||
+ aPara.ClearItem(EE_PARA_BULLETSTATE);
|
||||
+ if (oPara && *oPara != aPara)
|
||||
+ return {};
|
||||
+ oPara.emplace(aPara);
|
||||
+ const sal_Int32 nLen = rText.GetText(i).getLength();
|
||||
+ if (!nLen)
|
||||
+ continue;
|
||||
+ SfxItemSet aChar(rPool, svl::Items<EE_CHAR_START, EE_CHAR_END>);
|
||||
+ std::vector<EECharAttrib> aAttribs;
|
||||
+ rText.GetCharAttribs(i, aAttribs);
|
||||
+ for (const EECharAttrib& rAttrib : aAttribs)
|
||||
+ {
|
||||
+ if (rAttrib.nStart == rAttrib.nEnd)
|
||||
+ continue;
|
||||
+ if (rAttrib.nStart > 0 || rAttrib.nEnd < nLen)
|
||||
+ return {};
|
||||
+ aChar.Put(*rAttrib.pAttr);
|
||||
+ }
|
||||
+ if (oChar && *oChar != aChar)
|
||||
+ return {};
|
||||
+ oChar.emplace(aChar);
|
||||
+ }
|
||||
+ SfxItemSet aLook(rPool, svl::Items<EE_PARA_START, EE_CHAR_END>);
|
||||
+ if (oPara)
|
||||
+ aLook.Put(*oPara);
|
||||
+ if (oChar)
|
||||
+ aLook.Put(*oChar);
|
||||
+ return aLook;
|
||||
+}
|
||||
+
|
||||
} // end of namespace sd
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
diff --git a/svx/sdi/svx.sdi b/svx/sdi/svx.sdi
|
||||
index 9921969..0be9429 100644
|
||||
--- a/svx/sdi/svx.sdi
|
||||
+++ b/svx/sdi/svx.sdi
|
||||
@@ -5052,7 +5052,7 @@ SfxVoidItem InsertObject SID_INSERT_OBJECT
|
||||
|
||||
|
||||
SfxVoidItem InsertObjectChart SID_INSERT_DIAGRAM
|
||||
-(SfxBoolItem ColHeaders FN_PARAM_1,SfxBoolItem RowHeaders FN_PARAM_2,SfxBoolItem InNewTable FN_PARAM_4,SfxStringItem RangeList FN_PARAM_5)
|
||||
+(SfxBoolItem ColHeaders FN_PARAM_1,SfxBoolItem RowHeaders FN_PARAM_2,SfxStringItem Chart FN_PARAM_3,SfxBoolItem InNewTable FN_PARAM_4,SfxStringItem RangeList FN_PARAM_5)
|
||||
[
|
||||
AutoUpdate = FALSE,
|
||||
FastCall = FALSE,
|
||||
@@ -0,0 +1,28 @@
|
||||
oox: a scatter's numeric X values export as numbers
|
||||
|
||||
A scatter chart whose X values come from its categories wrote them as
|
||||
a string reference (strRef) to PPTX. PowerPoint and LibreOffice read
|
||||
string X values as point indices, so X became 1, 2, 3 after a round
|
||||
trip. When every category is a number, write a numRef instead.
|
||||
|
||||
diff --git a/oox/source/export/chartexport.cxx b/oox/source/export/chartexport.cxx
|
||||
index 3947280..03f3d78 100644
|
||||
--- a/oox/source/export/chartexport.cxx
|
||||
+++ b/oox/source/export/chartexport.cxx
|
||||
@@ -4066,6 +4066,16 @@ void ChartExport::exportSeriesCategory( const Reference< chart2::data::XDataSequ
|
||||
if (aNumberFormatString.isEmpty())
|
||||
bWriteDateCategories = false;
|
||||
}
|
||||
+ // Numeric X values stay numbers.
|
||||
+ if (nValueType == XML_xVal)
|
||||
+ {
|
||||
+ const std::vector<double> aX = lcl_getAllValuesFromSequence(xValueSeq);
|
||||
+ if (!aX.empty() && std::none_of(aX.begin(), aX.end(), [](double f) { return std::isnan(f); }))
|
||||
+ {
|
||||
+ bWriteDateCategories = true;
|
||||
+ aNumberFormatString = u"General"_ustr;
|
||||
+ }
|
||||
+ }
|
||||
|
||||
pFS->startElement(FSNS(XML_c, bWriteDateCategories ? XML_numRef : XML_strRef));
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
LOK: Impress slide layers render on macOS
|
||||
|
||||
SlideshowLayerRenderer painted into the client's buffer, which Aqua
|
||||
devices cannot do: every layer came back empty. On macOS paint into an
|
||||
alpha device of its own and copy the pixels out, as tile painting does.
|
||||
|
||||
diff --git a/sd/source/ui/tools/SlideshowLayerRenderer.cxx b/sd/source/ui/tools/SlideshowLayerRenderer.cxx
|
||||
index 8675630..7ecd4ad 100644
|
||||
--- a/sd/source/ui/tools/SlideshowLayerRenderer.cxx
|
||||
+++ b/sd/source/ui/tools/SlideshowLayerRenderer.cxx
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <svx/xflclit.hxx>
|
||||
#include <svx/xlnclit.hxx>
|
||||
|
||||
+#include <vcl/BitmapTools.hxx>
|
||||
#include <vcl/virdev.hxx>
|
||||
#include <tools/json_writer.hxx>
|
||||
#include <editeng/editeng.hxx>
|
||||
@@ -87,6 +88,10 @@ private:
|
||||
|
||||
EEControlBits mnSavedControlBits;
|
||||
Color maSavedBackgroundColor;
|
||||
+#if defined(MACOSX)
|
||||
+ unsigned char* mpBuffer;
|
||||
+ Size maBufferSize;
|
||||
+#endif
|
||||
|
||||
public:
|
||||
ScopedVclPtrInstance<VirtualDevice> maVirtualDevice;
|
||||
@@ -98,6 +103,10 @@ public:
|
||||
, maVirtualDevice(
|
||||
CoreGraphics::getiOSGraphicsData(pBuffer, rSlideSize.Width(), rSlideSize.Height()),
|
||||
Size(1, 1), DeviceFormat::WITHOUT_ALPHA)
|
||||
+#elif defined(MACOSX)
|
||||
+ , mpBuffer(pBuffer)
|
||||
+ , maBufferSize(rSlideSize)
|
||||
+ , maVirtualDevice(DeviceFormat::WITH_ALPHA)
|
||||
#else
|
||||
, maVirtualDevice(DeviceFormat::WITHOUT_ALPHA)
|
||||
#endif
|
||||
@@ -114,8 +123,14 @@ public:
|
||||
|
||||
maVirtualDevice->SetBackground(Wallpaper(COL_TRANSPARENT));
|
||||
|
||||
+#if defined(MACOSX)
|
||||
+ // Aqua devices cannot paint client buffers: paint, then copy.
|
||||
+ (void)rScale;
|
||||
+ maVirtualDevice->SetOutputSizePixel(rSlideSize);
|
||||
+#else
|
||||
maVirtualDevice->SetOutputSizePixelScaleOffsetAndLOKBuffer(rSlideSize, rScale, Point(),
|
||||
pBuffer);
|
||||
+#endif
|
||||
Size aPageSize(rPage.GetSize());
|
||||
|
||||
MapMode aMapMode(MapUnit::Map100thMM);
|
||||
@@ -139,6 +154,11 @@ public:
|
||||
|
||||
#ifdef IOS
|
||||
CoreGraphics::CGContextRelease(maVirtualDevice->GetSystemGfxData().rCGContext);
|
||||
+#endif
|
||||
+#if defined(MACOSX)
|
||||
+ maVirtualDevice->EnableMapMode(false);
|
||||
+ vcl::bitmap::fillWithData(mpBuffer,
|
||||
+ maVirtualDevice->GetBitmap(Point(), maBufferSize));
|
||||
#endif
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,499 @@
|
||||
LOK: Impress transitions and animations without the sidebar
|
||||
|
||||
.uno:SetSlideTransition takes a JSON transition (preset, duration,
|
||||
click or auto with a time, all slides); .uno:AddAnimation adds a preset
|
||||
to the marked objects; .uno:ChangeAnimation sets an effect's start,
|
||||
duration, delay, place or removal. Each is one undo step; a JSON that
|
||||
does not fit, or a preset the kernel lacks, changes nothing. Reads:
|
||||
.uno:SlideTransition, and .uno:SlideAnimations with each effect's
|
||||
target in .uno:SlideObjects order and its slideshow layer hash.
|
||||
|
||||
diff --git a/sd/Library_sd.mk b/sd/Library_sd.mk
|
||||
index d1bf7fc..f29e8f2 100644
|
||||
--- a/sd/Library_sd.mk
|
||||
+++ b/sd/Library_sd.mk
|
||||
@@ -492,6 +492,7 @@ $(eval $(call gb_Library_add_exception_objects,sd,\
|
||||
sd/source/ui/view/drviewsc \
|
||||
sd/source/ui/view/drviewsd \
|
||||
sd/source/ui/view/drviewse \
|
||||
+ sd/source/ui/view/drviewskit \
|
||||
sd/source/ui/view/drviewsf \
|
||||
sd/source/ui/view/drviewsg \
|
||||
sd/source/ui/view/drviewsh \
|
||||
diff --git a/sd/inc/app.hrc b/sd/inc/app.hrc
|
||||
index 1944bbe..548a95e 100644
|
||||
--- a/sd/inc/app.hrc
|
||||
+++ b/sd/inc/app.hrc
|
||||
@@ -427,5 +427,8 @@
|
||||
|
||||
#define FN_TRANSFORM_DOCUMENT_STRUCTURE (SID_SD_START+452)
|
||||
#define SID_SLIDE_NOTES (SID_SD_START+453)
|
||||
+#define SID_SLIDE_TRANSITION_SET (SID_SD_START+454)
|
||||
+#define SID_SLIDE_ANIMATION_ADD (SID_SD_START+455)
|
||||
+#define SID_SLIDE_ANIMATION_CHANGE (SID_SD_START+456)
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
diff --git a/sd/sdi/_drvwsh.sdi b/sd/sdi/_drvwsh.sdi
|
||||
index cf3acd6..c903f04 100644
|
||||
--- a/sd/sdi/_drvwsh.sdi
|
||||
+++ b/sd/sdi/_drvwsh.sdi
|
||||
@@ -3038,6 +3038,21 @@ interface DrawView
|
||||
ExecMethod = FuTemporary ;
|
||||
StateMethod = GetMenuState;
|
||||
]
|
||||
+ SID_SLIDE_TRANSITION_SET
|
||||
+ [
|
||||
+ ExecMethod = FuTemporary ;
|
||||
+ StateMethod = GetMenuState;
|
||||
+ ]
|
||||
+ SID_SLIDE_ANIMATION_ADD
|
||||
+ [
|
||||
+ ExecMethod = FuTemporary ;
|
||||
+ StateMethod = GetMenuState;
|
||||
+ ]
|
||||
+ SID_SLIDE_ANIMATION_CHANGE
|
||||
+ [
|
||||
+ ExecMethod = FuTemporary ;
|
||||
+ StateMethod = GetMenuState;
|
||||
+ ]
|
||||
SID_COPY_SLIDE
|
||||
[
|
||||
ExecMethod = FuTemporary ;
|
||||
diff --git a/sd/sdi/sdraw.sdi b/sd/sdi/sdraw.sdi
|
||||
index 728b670..df3c91c 100644
|
||||
--- a/sd/sdi/sdraw.sdi
|
||||
+++ b/sd/sdi/sdraw.sdi
|
||||
@@ -4215,6 +4215,57 @@ SfxVoidItem SlideNotes SID_SLIDE_NOTES
|
||||
GroupId = SfxGroupId::Modify;
|
||||
]
|
||||
|
||||
+SfxVoidItem SetSlideTransition SID_SLIDE_TRANSITION_SET
|
||||
+(SfxStringItem Transition FN_PARAM_1)
|
||||
+[
|
||||
+ AutoUpdate = FALSE,
|
||||
+ FastCall = FALSE,
|
||||
+ ReadOnlyDoc = FALSE,
|
||||
+ Toggle = FALSE,
|
||||
+ Container = FALSE,
|
||||
+ RecordAbsolute = FALSE,
|
||||
+ RecordPerSet;
|
||||
+
|
||||
+ AccelConfig = FALSE,
|
||||
+ MenuConfig = FALSE,
|
||||
+ ToolBoxConfig = FALSE,
|
||||
+ GroupId = SfxGroupId::Modify;
|
||||
+]
|
||||
+
|
||||
+SfxVoidItem AddAnimation SID_SLIDE_ANIMATION_ADD
|
||||
+(SfxStringItem Animation FN_PARAM_1)
|
||||
+[
|
||||
+ AutoUpdate = FALSE,
|
||||
+ FastCall = FALSE,
|
||||
+ ReadOnlyDoc = FALSE,
|
||||
+ Toggle = FALSE,
|
||||
+ Container = FALSE,
|
||||
+ RecordAbsolute = FALSE,
|
||||
+ RecordPerSet;
|
||||
+
|
||||
+ AccelConfig = FALSE,
|
||||
+ MenuConfig = FALSE,
|
||||
+ ToolBoxConfig = FALSE,
|
||||
+ GroupId = SfxGroupId::Modify;
|
||||
+]
|
||||
+
|
||||
+SfxVoidItem ChangeAnimation SID_SLIDE_ANIMATION_CHANGE
|
||||
+(SfxStringItem Animation FN_PARAM_1)
|
||||
+[
|
||||
+ AutoUpdate = FALSE,
|
||||
+ FastCall = FALSE,
|
||||
+ ReadOnlyDoc = FALSE,
|
||||
+ Toggle = FALSE,
|
||||
+ Container = FALSE,
|
||||
+ RecordAbsolute = FALSE,
|
||||
+ RecordPerSet;
|
||||
+
|
||||
+ AccelConfig = FALSE,
|
||||
+ MenuConfig = FALSE,
|
||||
+ ToolBoxConfig = FALSE,
|
||||
+ GroupId = SfxGroupId::Modify;
|
||||
+]
|
||||
+
|
||||
SfxVoidItem CopySlide SID_COPY_SLIDE
|
||||
()
|
||||
[
|
||||
diff --git a/sd/source/ui/inc/DrawViewShell.hxx b/sd/source/ui/inc/DrawViewShell.hxx
|
||||
index 6e42423..c9e74e3 100644
|
||||
--- a/sd/source/ui/inc/DrawViewShell.hxx
|
||||
+++ b/sd/source/ui/inc/DrawViewShell.hxx
|
||||
@@ -36,6 +36,7 @@ namespace com::sun::star::scanner { class XScannerManager2; }
|
||||
namespace com::sun::star::presentation { class XSlideShow; }
|
||||
|
||||
class EditTextObject;
|
||||
+namespace tools { class JsonWriter; }
|
||||
class Outliner;
|
||||
class SdPage;
|
||||
class SdStyleSheet;
|
||||
@@ -284,6 +285,12 @@ public:
|
||||
static void CheckLineTo (SfxRequest& rReq);
|
||||
/// The text's one look; none when it varies.
|
||||
static std::optional<SfxItemSet> NotesLook(const EditTextObject& rText, SfxItemPool& rPool);
|
||||
+ /// Kit edits of transitions and animations, from JSON.
|
||||
+ bool KitTransition(std::u16string_view rJson);
|
||||
+ bool KitAddAnimation(std::u16string_view rJson);
|
||||
+ bool KitChangeAnimation(std::u16string_view rJson);
|
||||
+ static void WriteKitTransition(::tools::JsonWriter& rJson, SdPage& rPage);
|
||||
+ static void WriteKitAnimations(::tools::JsonWriter& rJson, SdPage& rPage);
|
||||
void SetChildWindowState( SfxItemSet& rSet );
|
||||
|
||||
void UpdateIMapDlg( SdrObject* pObj );
|
||||
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
|
||||
index 8418d71..40a4bca 100644
|
||||
--- a/sd/source/ui/unoidl/unomodel.cxx
|
||||
+++ b/sd/source/ui/unoidl/unomodel.cxx
|
||||
@@ -2064,7 +2064,8 @@ void SdXImpressDocument::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
|
||||
bool SdXImpressDocument::supportsCommand(std::u16string_view rCommand)
|
||||
{
|
||||
return rCommand == u"SlideDesign" || rCommand == u"SlideObjects" || rCommand == u"Chart"
|
||||
- || rCommand == u"SlideNotes";
|
||||
+ || rCommand == u"SlideNotes" || rCommand == u"SlideTransition"
|
||||
+ || rCommand == u"SlideAnimations";
|
||||
}
|
||||
|
||||
namespace
|
||||
@@ -2291,6 +2292,19 @@ void SdXImpressDocument::getCommandValues(::tools::JsonWriter& rJsonWriter, std:
|
||||
lcl_SlideNotes(rJsonWriter, *mpDoc, *pShell);
|
||||
return;
|
||||
}
|
||||
+ if (rCommand == ".uno:SlideTransition" || rCommand == ".uno:SlideAnimations")
|
||||
+ {
|
||||
+ DrawViewShell* pShell = GetViewShell();
|
||||
+ SdPage* pPage = pShell ? pShell->GetActualPage() : nullptr;
|
||||
+ if (pPage && !pPage->IsMasterPage())
|
||||
+ {
|
||||
+ if (rCommand == ".uno:SlideTransition")
|
||||
+ DrawViewShell::WriteKitTransition(rJsonWriter, *pPage);
|
||||
+ else
|
||||
+ DrawViewShell::WriteKitAnimations(rJsonWriter, *pPage);
|
||||
+ }
|
||||
+ return;
|
||||
+ }
|
||||
if (rCommand == ".uno:SlideObjects")
|
||||
{
|
||||
if (DrawViewShell* pShell = GetViewShell())
|
||||
diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx
|
||||
index 8b734af..ff603da 100644
|
||||
--- a/sd/source/ui/view/drviews2.cxx
|
||||
+++ b/sd/source/ui/view/drviews2.cxx
|
||||
@@ -3880,6 +3880,22 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq)
|
||||
}
|
||||
break;
|
||||
|
||||
+ case SID_SLIDE_TRANSITION_SET:
|
||||
+ case SID_SLIDE_ANIMATION_ADD:
|
||||
+ case SID_SLIDE_ANIMATION_CHANGE:
|
||||
+ {
|
||||
+ // Kit edits; a JSON that does not fit changes nothing.
|
||||
+ const SfxStringItem* pJson = rReq.GetArg<SfxStringItem>(FN_PARAM_1);
|
||||
+ const bool bDone = pJson
|
||||
+ && (nSId == SID_SLIDE_TRANSITION_SET ? KitTransition(pJson->GetValue())
|
||||
+ : nSId == SID_SLIDE_ANIMATION_ADD ? KitAddAnimation(pJson->GetValue())
|
||||
+ : KitChangeAnimation(pJson->GetValue()));
|
||||
+ if (bDone)
|
||||
+ rReq.Done();
|
||||
+ Cancel();
|
||||
+ }
|
||||
+ break;
|
||||
+
|
||||
case SID_ALIGN_PAGE:
|
||||
{
|
||||
mpDrawView->AlignMarkedObjects(SdrHorAlign::Center, SdrVertAlign::Center);
|
||||
diff --git a/sd/source/ui/view/drviewskit.cxx b/sd/source/ui/view/drviewskit.cxx
|
||||
new file mode 100644
|
||||
index 0000000..10ece10
|
||||
--- /dev/null
|
||||
+++ b/sd/source/ui/view/drviewskit.cxx
|
||||
@@ -0,0 +1,284 @@
|
||||
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
+/*
|
||||
+ * 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 <DrawViewShell.hxx>
|
||||
+
|
||||
+#include <CustomAnimationEffect.hxx>
|
||||
+#include <CustomAnimationPreset.hxx>
|
||||
+#include <DrawDocShell.hxx>
|
||||
+#include <TransitionPreset.hxx>
|
||||
+#include <ViewShellBase.hxx>
|
||||
+#include <drawdoc.hxx>
|
||||
+#include <drawview.hxx>
|
||||
+#include <sdpage.hxx>
|
||||
+#include <sdresid.hxx>
|
||||
+#include <sdundogr.hxx>
|
||||
+#include <strings.hrc>
|
||||
+#include <undoanim.hxx>
|
||||
+
|
||||
+#include <com/sun/star/presentation/EffectNodeType.hpp>
|
||||
+#include <com/sun/star/presentation/EffectPresetClass.hpp>
|
||||
+#include <svx/svdundo.hxx>
|
||||
+#include <animations/animationnodehelper.hxx>
|
||||
+#include <tools/json_writer.hxx>
|
||||
+#include <boost/json.hpp>
|
||||
+// This translation unit builds boost.json for sd.
|
||||
+#include <boost/json/src.hpp>
|
||||
+
|
||||
+#include <optional>
|
||||
+#include <string>
|
||||
+
|
||||
+using namespace ::com::sun::star;
|
||||
+namespace EffectNodeType = css::presentation::EffectNodeType;
|
||||
+namespace EffectPresetClass = css::presentation::EffectPresetClass;
|
||||
+
|
||||
+namespace
|
||||
+{
|
||||
+std::optional<boost::json::object> lcl_Object(std::u16string_view rJson)
|
||||
+{
|
||||
+ boost::system::error_code aError;
|
||||
+ boost::json::value aValue = boost::json::parse(std::string(OUString(rJson).toUtf8()), aError);
|
||||
+ if (aError || !aValue.is_object())
|
||||
+ return std::nullopt;
|
||||
+ return aValue.as_object();
|
||||
+}
|
||||
+
|
||||
+OUString lcl_String(const boost::json::value& rValue)
|
||||
+{
|
||||
+ return OUString::fromUtf8(std::string_view(rValue.as_string().data(), rValue.as_string().size()));
|
||||
+}
|
||||
+
|
||||
+/// Member `rKey` as a number; absent is `fDefault`; else fails.
|
||||
+std::optional<double> lcl_Number(const boost::json::object& rObject, std::string_view rKey,
|
||||
+ double fDefault)
|
||||
+{
|
||||
+ const boost::json::value* pValue = rObject.if_contains(rKey);
|
||||
+ if (!pValue)
|
||||
+ return fDefault;
|
||||
+ if (!pValue->is_number())
|
||||
+ return std::nullopt;
|
||||
+ return pValue->to_number<double>();
|
||||
+}
|
||||
+
|
||||
+/// The slide's objects, comments left out, as .uno:SlideObjects lists them.
|
||||
+std::vector<SdrObject*> lcl_Shapes(SdPage& rPage)
|
||||
+{
|
||||
+ std::vector<SdrObject*> aShapes;
|
||||
+ for (const rtl::Reference<SdrObject>& pObj : rPage)
|
||||
+ if (!pObj->isAnnotationObject())
|
||||
+ aShapes.push_back(pObj.get());
|
||||
+ return aShapes;
|
||||
+}
|
||||
+
|
||||
+/// Start kinds as the kit names them.
|
||||
+constexpr std::pair<sal_Int16, std::u16string_view> aStarts[]
|
||||
+ = { { EffectNodeType::ON_CLICK, u"click" },
|
||||
+ { EffectNodeType::WITH_PREVIOUS, u"with" },
|
||||
+ { EffectNodeType::AFTER_PREVIOUS, u"after" } };
|
||||
+
|
||||
+/// Preset classes as the kit names them; others are "other".
|
||||
+constexpr std::pair<sal_Int16, std::string_view> aClasses[]
|
||||
+ = { { EffectPresetClass::ENTRANCE, "entrance" },
|
||||
+ { EffectPresetClass::EMPHASIS, "emphasis" },
|
||||
+ { EffectPresetClass::EXIT, "exit" } };
|
||||
+
|
||||
+/// The main sequence's effects, in order.
|
||||
+std::vector<sd::CustomAnimationEffectPtr> lcl_Effects(SdPage& rPage)
|
||||
+{
|
||||
+ const sd::MainSequencePtr& pSequence = rPage.getMainSequence();
|
||||
+ return std::vector<sd::CustomAnimationEffectPtr>(pSequence->getBegin(), pSequence->getEnd());
|
||||
+}
|
||||
+}
|
||||
+
|
||||
+namespace sd
|
||||
+{
|
||||
+bool DrawViewShell::KitTransition(std::u16string_view rJson)
|
||||
+{
|
||||
+ const std::optional<boost::json::object> oObject = lcl_Object(rJson);
|
||||
+ if (!oObject)
|
||||
+ return false;
|
||||
+ const boost::json::value* pPreset = oObject->if_contains("preset");
|
||||
+ const boost::json::value* pAdvance = oObject->if_contains("advance");
|
||||
+ const boost::json::value* pAll = oObject->if_contains("all");
|
||||
+ const std::optional<double> oDuration = lcl_Number(*oObject, "duration", 2.0);
|
||||
+ const std::optional<double> oTime = lcl_Number(*oObject, "time", 0.0);
|
||||
+ if (!pPreset || !pPreset->is_string() || !oDuration || *oDuration <= 0 || !oTime
|
||||
+ || *oTime < 0 || (pAdvance && !pAdvance->is_string()) || (pAll && !pAll->is_bool()))
|
||||
+ return false;
|
||||
+ const OUString aId = lcl_String(*pPreset);
|
||||
+ TransitionPresetPtr pFound;
|
||||
+ for (const TransitionPresetPtr& pOne : TransitionPreset::getTransitionPresetList())
|
||||
+ if (pOne->getPresetId() == aId)
|
||||
+ pFound = pOne;
|
||||
+ const OUString aAdvance = pAdvance ? lcl_String(*pAdvance) : u"click"_ustr;
|
||||
+ if ((!aId.isEmpty() && !pFound) || (aAdvance != "click" && aAdvance != "auto"))
|
||||
+ return false;
|
||||
+ std::vector<SdPage*> aPages;
|
||||
+ if (pAll && pAll->as_bool())
|
||||
+ for (sal_uInt16 n = 0; n < GetDoc()->GetSdPageCount(PageKind::Standard); ++n)
|
||||
+ aPages.push_back(GetDoc()->GetSdPage(n, PageKind::Standard));
|
||||
+ else if (getCurrentPage() && !getCurrentPage()->IsMasterPage())
|
||||
+ aPages.push_back(getCurrentPage());
|
||||
+ if (aPages.empty())
|
||||
+ return false;
|
||||
+ SfxUndoManager* pManager = GetDocSh()->GetUndoManager();
|
||||
+ const OUString aComment(SdResId(STR_UNDO_SLIDE_PARAMS));
|
||||
+ pManager->EnterListAction(aComment, aComment, 0, GetViewShellBase().GetViewShellId());
|
||||
+ std::unique_ptr<SdUndoGroup> pGroup(new SdUndoGroup(*GetDoc()));
|
||||
+ pGroup->SetComment(aComment);
|
||||
+ for (SdPage* pPage : aPages)
|
||||
+ {
|
||||
+ pGroup->AddAction(new UndoTransition(*GetDoc(), pPage));
|
||||
+ pPage->setTransitionType(pFound ? pFound->getTransition() : 0);
|
||||
+ pPage->setTransitionSubtype(pFound ? pFound->getSubtype() : 0);
|
||||
+ pPage->setTransitionDirection(pFound ? pFound->getDirection() : true);
|
||||
+ pPage->setTransitionFadeColor(pFound ? pFound->getFadeColor() : 0);
|
||||
+ pPage->setTransitionDuration(*oDuration);
|
||||
+ pPage->SetPresChange(aAdvance == "auto" ? PresChange::Auto : PresChange::Manual);
|
||||
+ pPage->SetTime(*oTime);
|
||||
+ }
|
||||
+ pManager->AddUndoAction(std::move(pGroup));
|
||||
+ pManager->LeaveListAction();
|
||||
+ GetDocSh()->SetModified();
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
+bool DrawViewShell::KitAddAnimation(std::u16string_view rJson)
|
||||
+{
|
||||
+ const std::optional<boost::json::object> oObject = lcl_Object(rJson);
|
||||
+ const boost::json::value* pPreset = oObject ? oObject->if_contains("preset") : nullptr;
|
||||
+ if (!pPreset || !pPreset->is_string())
|
||||
+ return false;
|
||||
+ const CustomAnimationPresetPtr pDescriptor
|
||||
+ = CustomAnimationPresets::getCustomAnimationPresets().getEffectDescriptor(lcl_String(*pPreset));
|
||||
+ const std::optional<double> oDuration
|
||||
+ = pDescriptor ? lcl_Number(*oObject, "duration", pDescriptor->getDuration()) : std::nullopt;
|
||||
+ const SdrMarkList& rMarks = mpDrawView->GetMarkedObjectList();
|
||||
+ SdPage* pPage = getCurrentPage();
|
||||
+ if (!oDuration || *oDuration <= 0 || rMarks.GetMarkCount() == 0 || !pPage)
|
||||
+ return false;
|
||||
+ const MainSequencePtr& pSequence = pPage->getMainSequence();
|
||||
+ pSequence->getRootNode();
|
||||
+ GetDocSh()->GetUndoManager()->AddUndoAction(std::make_unique<UndoAnimation>(GetDoc(), pPage));
|
||||
+ for (size_t n = 0; n < rMarks.GetMarkCount(); ++n)
|
||||
+ {
|
||||
+ uno::Any aTarget(rMarks.GetMark(n)->GetMarkedSdrObj()->getUnoShape());
|
||||
+ CustomAnimationEffectPtr pEffect = pSequence->append(pDescriptor, aTarget, *oDuration);
|
||||
+ // Several objects at once go together.
|
||||
+ if (n > 0)
|
||||
+ pEffect->setNodeType(EffectNodeType::WITH_PREVIOUS);
|
||||
+ }
|
||||
+ pSequence->getRootNode();
|
||||
+ GetDocSh()->SetModified();
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
+bool DrawViewShell::KitChangeAnimation(std::u16string_view rJson)
|
||||
+{
|
||||
+ const std::optional<boost::json::object> oObject = lcl_Object(rJson);
|
||||
+ SdPage* pPage = getCurrentPage();
|
||||
+ if (!oObject || !pPage)
|
||||
+ return false;
|
||||
+ const std::vector<CustomAnimationEffectPtr> aEffects = lcl_Effects(*pPage);
|
||||
+ const boost::json::value* pIndex = oObject->if_contains("index");
|
||||
+ if (!pIndex || !pIndex->is_int64() || pIndex->as_int64() < 0
|
||||
+ || pIndex->as_int64() >= sal_Int64(aEffects.size()))
|
||||
+ return false;
|
||||
+ const CustomAnimationEffectPtr& pEffect = aEffects[pIndex->as_int64()];
|
||||
+ const boost::json::value* pStart = oObject->if_contains("start");
|
||||
+ const boost::json::value* pMove = oObject->if_contains("move");
|
||||
+ const boost::json::value* pRemove = oObject->if_contains("remove");
|
||||
+ const std::optional<double> oDuration = lcl_Number(*oObject, "duration", pEffect->getDuration());
|
||||
+ const std::optional<double> oDelay = lcl_Number(*oObject, "delay", pEffect->getBegin());
|
||||
+ std::optional<sal_Int16> oNode;
|
||||
+ for (const auto& [nType, rName] : aStarts)
|
||||
+ if (pStart && pStart->is_string() && rName == lcl_String(*pStart))
|
||||
+ oNode = nType;
|
||||
+ const sal_Int64 nTo = pMove && pMove->is_int64() ? pIndex->as_int64() + pMove->as_int64() : 0;
|
||||
+ if ((pStart && !oNode) || !oDuration || *oDuration <= 0 || !oDelay || *oDelay < 0
|
||||
+ || (pMove && (!pMove->is_int64() || nTo < 0 || nTo >= sal_Int64(aEffects.size())))
|
||||
+ || (pRemove && !pRemove->is_bool()))
|
||||
+ return false;
|
||||
+ const MainSequencePtr& pSequence = pPage->getMainSequence();
|
||||
+ pSequence->getRootNode();
|
||||
+ GetDocSh()->GetUndoManager()->AddUndoAction(std::make_unique<UndoAnimation>(GetDoc(), pPage));
|
||||
+ if (pRemove && pRemove->as_bool())
|
||||
+ pSequence->remove(pEffect);
|
||||
+ else
|
||||
+ {
|
||||
+ if (oNode)
|
||||
+ pEffect->setNodeType(*oNode);
|
||||
+ pEffect->setDuration(*oDuration);
|
||||
+ pEffect->setBegin(*oDelay);
|
||||
+ if (pMove)
|
||||
+ {
|
||||
+ EffectSequence& rList = pSequence->getSequence();
|
||||
+ rList.erase(pSequence->find(pEffect));
|
||||
+ rList.insert(std::next(rList.begin(), nTo), pEffect);
|
||||
+ }
|
||||
+ pSequence->rebuild();
|
||||
+ }
|
||||
+ pSequence->getRootNode();
|
||||
+ GetDocSh()->SetModified();
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
+void DrawViewShell::WriteKitTransition(::tools::JsonWriter& rJson, SdPage& rPage)
|
||||
+{
|
||||
+ OUString aId;
|
||||
+ for (const TransitionPresetPtr& pOne : TransitionPreset::getTransitionPresetList())
|
||||
+ if (rPage.getTransitionType() && pOne->getTransition() == rPage.getTransitionType()
|
||||
+ && pOne->getSubtype() == rPage.getTransitionSubtype()
|
||||
+ && pOne->getDirection() == rPage.getTransitionDirection()
|
||||
+ && pOne->getFadeColor() == rPage.getTransitionFadeColor() && aId.isEmpty())
|
||||
+ aId = pOne->getPresetId();
|
||||
+ // A transition no preset matches.
|
||||
+ if (rPage.getTransitionType() && aId.isEmpty())
|
||||
+ aId = "other";
|
||||
+ rJson.put("preset", aId);
|
||||
+ rJson.put("duration", rPage.getTransitionDuration());
|
||||
+ rJson.put("advance", rPage.GetPresChange() == PresChange::Manual ? "click" : "auto");
|
||||
+ rJson.put("time", rPage.GetTime());
|
||||
+}
|
||||
+
|
||||
+void DrawViewShell::WriteKitAnimations(::tools::JsonWriter& rJson, SdPage& rPage)
|
||||
+{
|
||||
+ const std::vector<SdrObject*> aShapes = lcl_Shapes(rPage);
|
||||
+ const CustomAnimationPresets& rPresets = CustomAnimationPresets::getCustomAnimationPresets();
|
||||
+ auto aList = rJson.startArray("effects");
|
||||
+ for (const CustomAnimationEffectPtr& pEffect : lcl_Effects(rPage))
|
||||
+ {
|
||||
+ auto aOne = rJson.startStruct();
|
||||
+ rJson.put("preset", pEffect->getPresetId());
|
||||
+ const CustomAnimationPresetPtr pDescriptor = rPresets.getEffectDescriptor(pEffect->getPresetId());
|
||||
+ rJson.put("label", pDescriptor ? pDescriptor->getLabel() : OUString());
|
||||
+ std::string_view aClass = "other";
|
||||
+ for (const auto& [nClass, rName] : aClasses)
|
||||
+ if (nClass == pEffect->getPresetClass())
|
||||
+ aClass = rName;
|
||||
+ rJson.put("class", aClass);
|
||||
+ SdrObject* pTarget = SdrObject::getSdrObjectFromXShape(pEffect->getTargetShape());
|
||||
+ const auto pAt = std::find(aShapes.begin(), aShapes.end(), pTarget);
|
||||
+ rJson.put("target", pAt == aShapes.end() ? sal_Int64(-1) : sal_Int64(pAt - aShapes.begin()));
|
||||
+ // The slideshow layer of the same shape has this hash.
|
||||
+ OStringBuffer aHash;
|
||||
+ anim::convertTarget(aHash, pEffect->getTarget());
|
||||
+ rJson.put("hash", aHash.makeStringAndClear());
|
||||
+ std::u16string_view aStart = u"click";
|
||||
+ for (const auto& [nType, rName] : aStarts)
|
||||
+ if (nType == pEffect->getNodeType())
|
||||
+ aStart = rName;
|
||||
+ rJson.put("start", OUString(aStart));
|
||||
+ rJson.put("duration", pEffect->getDuration());
|
||||
+ rJson.put("delay", pEffect->getBegin());
|
||||
+ }
|
||||
+}
|
||||
+}
|
||||
+
|
||||
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
@@ -0,0 +1,127 @@
|
||||
LOK: Impress media without dialogs, and what plays
|
||||
|
||||
.uno:InsertAVMedia takes Width and Height in 1/100 mm from a kit client:
|
||||
with them it inserts at the slide's centre, no media dialog and no size
|
||||
probe through the kernel's own player. .uno:SlideMedia reads the shown
|
||||
slide's media: place in the object list, URL, whether linked, the file
|
||||
that plays (the link, or the kernel's copy of embedded media) and
|
||||
whether that file is missing.
|
||||
|
||||
diff --git a/sd/source/ui/func/fuinsert.cxx b/sd/source/ui/func/fuinsert.cxx
|
||||
index 63774f7..0aa7add 100644
|
||||
--- a/sd/source/ui/func/fuinsert.cxx
|
||||
+++ b/sd/source/ui/func/fuinsert.cxx
|
||||
@@ -84,6 +84,7 @@
|
||||
#include <vcl/GraphicNativeMetadata.hxx>
|
||||
|
||||
#include <comphelper/lok.hxx>
|
||||
+#include <svl/intitem.hxx>
|
||||
|
||||
using namespace com::sun::star;
|
||||
|
||||
@@ -749,6 +750,20 @@ void FuInsertAVMedia::DoExecute( SfxRequest& rReq )
|
||||
}
|
||||
|
||||
bool bLink(pLinkItem ? pLinkItem->GetValue() : true);
|
||||
+ // A kit client gives 1/100 mm sizes; it goes mid-slide.
|
||||
+ const SfxInt32Item* pWidth = rReq.GetArg<SfxInt32Item>(FN_PARAM_3);
|
||||
+ const SfxInt32Item* pHeight = rReq.GetArg<SfxInt32Item>(FN_PARAM_4);
|
||||
+ if (comphelper::LibreOfficeKit::isActive() && bAPI && pWidth && pHeight
|
||||
+ && pWidth->GetValue() > 0 && pHeight->GetValue() > 0)
|
||||
+ {
|
||||
+ const Size aSize(pWidth->GetValue(), pHeight->GetValue());
|
||||
+ const Size aPage(mrViewShell.GetActualPage()->GetSize());
|
||||
+ const Point aPos((aPage.Width() - aSize.Width()) / 2, (aPage.Height() - aSize.Height()) / 2);
|
||||
+ sal_Int8 nAction = DND_ACTION_COPY;
|
||||
+ mpView->InsertMediaURL(aURL, nAction, aPos, aSize, bLink);
|
||||
+ rReq.Done();
|
||||
+ return;
|
||||
+ }
|
||||
if (!(bAPI
|
||||
|| ::avmedia::MediaWindow::executeMediaURLDialog(mpWindow ? mpWindow->GetFrameWeld() : nullptr, aURL, & bLink)
|
||||
))
|
||||
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
|
||||
index 40a4bca..d8f1dee 100644
|
||||
--- a/sd/source/ui/unoidl/unomodel.cxx
|
||||
+++ b/sd/source/ui/unoidl/unomodel.cxx
|
||||
@@ -101,6 +101,8 @@
|
||||
#include <svx/svdsob.hxx>
|
||||
#include <svx/svdundo.hxx>
|
||||
#include <svx/svdomedia.hxx>
|
||||
+#include <avmedia/mediaitem.hxx>
|
||||
+#include <osl/file.hxx>
|
||||
#include <svx/unoapi.hxx>
|
||||
#include <svx/unofill.hxx>
|
||||
#include <svx/sdrpagewindow.hxx>
|
||||
@@ -2065,7 +2067,7 @@ bool SdXImpressDocument::supportsCommand(std::u16string_view rCommand)
|
||||
{
|
||||
return rCommand == u"SlideDesign" || rCommand == u"SlideObjects" || rCommand == u"Chart"
|
||||
|| rCommand == u"SlideNotes" || rCommand == u"SlideTransition"
|
||||
- || rCommand == u"SlideAnimations";
|
||||
+ || rCommand == u"SlideAnimations" || rCommand == u"SlideMedia";
|
||||
}
|
||||
|
||||
namespace
|
||||
@@ -2224,6 +2226,34 @@ void lcl_SlideNotes(::tools::JsonWriter& rJson, SdDrawDocument& rDoc, sd::DrawVi
|
||||
rJson.put("rich", pText && !sd::DrawViewShell::NotesLook(pText->GetTextObject(), rDoc.GetPool()));
|
||||
}
|
||||
|
||||
+/// The shown slide's media: list place, file, link.
|
||||
+void lcl_SlideMedia(::tools::JsonWriter& rJson, sd::DrawViewShell& rShell)
|
||||
+{
|
||||
+ sal_Int64 nAt = 0;
|
||||
+ auto aList = rJson.startArray("media");
|
||||
+ for (const rtl::Reference<SdrObject>& pObj : *rShell.GetActualPage())
|
||||
+ {
|
||||
+ if (pObj->isAnnotationObject())
|
||||
+ continue;
|
||||
+ if (auto pMedia = dynamic_cast<const SdrMediaObj*>(pObj.get()))
|
||||
+ {
|
||||
+ const avmedia::MediaItem& rItem = pMedia->getMediaProperties();
|
||||
+ const bool bLink = !rItem.getURL().startsWithIgnoreAsciiCase("vnd.sun.star.Package:");
|
||||
+ // Links play their file; embedded media a temp copy.
|
||||
+ const OUString aFile = bLink ? rItem.getURL() : rItem.getTempURL();
|
||||
+ osl::DirectoryItem aItem;
|
||||
+ auto aOne = rJson.startStruct();
|
||||
+ rJson.put("index", nAt);
|
||||
+ rJson.put("url", rItem.getURL());
|
||||
+ rJson.put("link", bLink);
|
||||
+ rJson.put("file", aFile);
|
||||
+ rJson.put("missing", aFile.isEmpty() || osl::DirectoryItem::get(aFile, aItem) != osl::FileBase::E_None);
|
||||
+ rJson.put("loop", rItem.isLoop());
|
||||
+ }
|
||||
+ ++nAt;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
/// The shown slide's objects, selection, guides and snapping.
|
||||
void lcl_SlideObjects(::tools::JsonWriter& rJson, sd::DrawViewShell& rShell)
|
||||
{
|
||||
@@ -2292,6 +2322,12 @@ void SdXImpressDocument::getCommandValues(::tools::JsonWriter& rJsonWriter, std:
|
||||
lcl_SlideNotes(rJsonWriter, *mpDoc, *pShell);
|
||||
return;
|
||||
}
|
||||
+ if (rCommand == ".uno:SlideMedia")
|
||||
+ {
|
||||
+ if (DrawViewShell* pShell = GetViewShell())
|
||||
+ lcl_SlideMedia(rJsonWriter, *pShell);
|
||||
+ return;
|
||||
+ }
|
||||
if (rCommand == ".uno:SlideTransition" || rCommand == ".uno:SlideAnimations")
|
||||
{
|
||||
DrawViewShell* pShell = GetViewShell();
|
||||
diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi
|
||||
index 76af1e2..558b25c 100644
|
||||
--- a/sfx2/sdi/sfx.sdi
|
||||
+++ b/sfx2/sdi/sfx.sdi
|
||||
@@ -5599,7 +5599,9 @@ SfxVoidItem InsertAVMedia SID_INSERT_AVMEDIA
|
||||
(
|
||||
SfxStringItem URL SID_INSERT_AVMEDIA,
|
||||
SvxSizeItem Size FN_PARAM_1,
|
||||
- SfxBoolItem IsLink FN_PARAM_2
|
||||
+ SfxBoolItem IsLink FN_PARAM_2,
|
||||
+ SfxInt32Item Width FN_PARAM_3,
|
||||
+ SfxInt32Item Height FN_PARAM_4
|
||||
)
|
||||
[
|
||||
AutoUpdate = FALSE,
|
||||
@@ -0,0 +1,90 @@
|
||||
LOK: Impress reads every slide as a show plays it
|
||||
|
||||
.uno:SlideShow lists each slide: hidden, notes as text, the transition
|
||||
and effects in the .uno:SlideTransition and .uno:SlideAnimations shapes,
|
||||
and its media with frames. .uno:SlideMedia entries carry their frame,
|
||||
x, y, width and height in 1/100 mm.
|
||||
|
||||
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
|
||||
index d8f1dee..035566a 100644
|
||||
--- a/sd/source/ui/unoidl/unomodel.cxx
|
||||
+++ b/sd/source/ui/unoidl/unomodel.cxx
|
||||
@@ -2067,7 +2067,8 @@ bool SdXImpressDocument::supportsCommand(std::u16string_view rCommand)
|
||||
{
|
||||
return rCommand == u"SlideDesign" || rCommand == u"SlideObjects" || rCommand == u"Chart"
|
||||
|| rCommand == u"SlideNotes" || rCommand == u"SlideTransition"
|
||||
- || rCommand == u"SlideAnimations" || rCommand == u"SlideMedia";
|
||||
+ || rCommand == u"SlideAnimations" || rCommand == u"SlideMedia"
|
||||
+ || rCommand == u"SlideShow";
|
||||
}
|
||||
|
||||
namespace
|
||||
@@ -2226,12 +2227,12 @@ void lcl_SlideNotes(::tools::JsonWriter& rJson, SdDrawDocument& rDoc, sd::DrawVi
|
||||
rJson.put("rich", pText && !sd::DrawViewShell::NotesLook(pText->GetTextObject(), rDoc.GetPool()));
|
||||
}
|
||||
|
||||
-/// The shown slide's media: list place, file, link.
|
||||
-void lcl_SlideMedia(::tools::JsonWriter& rJson, sd::DrawViewShell& rShell)
|
||||
+/// A slide's media: list place, frame, file, link.
|
||||
+void lcl_SlideMedia(::tools::JsonWriter& rJson, SdPage& rPage)
|
||||
{
|
||||
sal_Int64 nAt = 0;
|
||||
auto aList = rJson.startArray("media");
|
||||
- for (const rtl::Reference<SdrObject>& pObj : *rShell.GetActualPage())
|
||||
+ for (const rtl::Reference<SdrObject>& pObj : rPage)
|
||||
{
|
||||
if (pObj->isAnnotationObject())
|
||||
continue;
|
||||
@@ -2249,11 +2250,38 @@ void lcl_SlideMedia(::tools::JsonWriter& rJson, sd::DrawViewShell& rShell)
|
||||
rJson.put("file", aFile);
|
||||
rJson.put("missing", aFile.isEmpty() || osl::DirectoryItem::get(aFile, aItem) != osl::FileBase::E_None);
|
||||
rJson.put("loop", rItem.isLoop());
|
||||
+ const ::tools::Rectangle& rRect = pMedia->GetLogicRect();
|
||||
+ rJson.put("x", sal_Int64(rRect.Left()));
|
||||
+ rJson.put("y", sal_Int64(rRect.Top()));
|
||||
+ rJson.put("width", sal_Int64(rRect.GetWidth()));
|
||||
+ rJson.put("height", sal_Int64(rRect.GetHeight()));
|
||||
}
|
||||
++nAt;
|
||||
}
|
||||
}
|
||||
|
||||
+/// Each slide for a show: hidden, notes, motion, media.
|
||||
+void lcl_SlideShow(::tools::JsonWriter& rJson, SdDrawDocument& rDoc)
|
||||
+{
|
||||
+ auto aList = rJson.startArray("slides");
|
||||
+ for (sal_uInt16 i = 0; i < rDoc.GetSdPageCount(PageKind::Standard); ++i)
|
||||
+ {
|
||||
+ SdPage* pPage = rDoc.GetSdPage(i, PageKind::Standard);
|
||||
+ SdPage* pNotes = rDoc.GetSdPage(i, PageKind::Notes);
|
||||
+ auto pObj = pNotes ? dynamic_cast<SdrTextObj*>(pNotes->GetPresObj(PresObjKind::Notes)) : nullptr;
|
||||
+ const OutlinerParaObject* pText = pObj && !pObj->IsEmptyPresObj() ? pObj->GetOutlinerParaObject() : nullptr;
|
||||
+ auto aOne = rJson.startStruct();
|
||||
+ rJson.put("hidden", pPage->IsExcluded());
|
||||
+ rJson.put("notes", pText ? pText->GetTextObject().GetText(LINEEND_LF) : OUString());
|
||||
+ {
|
||||
+ auto aTransition = rJson.startNode("transition");
|
||||
+ DrawViewShell::WriteKitTransition(rJson, *pPage);
|
||||
+ }
|
||||
+ DrawViewShell::WriteKitAnimations(rJson, *pPage);
|
||||
+ lcl_SlideMedia(rJson, *pPage);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
/// The shown slide's objects, selection, guides and snapping.
|
||||
void lcl_SlideObjects(::tools::JsonWriter& rJson, sd::DrawViewShell& rShell)
|
||||
{
|
||||
@@ -2325,7 +2353,12 @@ void SdXImpressDocument::getCommandValues(::tools::JsonWriter& rJsonWriter, std:
|
||||
if (rCommand == ".uno:SlideMedia")
|
||||
{
|
||||
if (DrawViewShell* pShell = GetViewShell())
|
||||
- lcl_SlideMedia(rJsonWriter, *pShell);
|
||||
+ lcl_SlideMedia(rJsonWriter, *pShell->GetActualPage());
|
||||
+ return;
|
||||
+ }
|
||||
+ if (rCommand == ".uno:SlideShow")
|
||||
+ {
|
||||
+ lcl_SlideShow(rJsonWriter, *mpDoc);
|
||||
return;
|
||||
}
|
||||
if (rCommand == ".uno:SlideTransition" || rCommand == ".uno:SlideAnimations")
|
||||
@@ -0,0 +1,252 @@
|
||||
PDF: Impress handouts
|
||||
|
||||
A PDF export with ExportHandouts (slides per handout page: 1, 2, 3,
|
||||
4, 6 or 9) lays the shown slides of PageRange on handout pages, the
|
||||
print dialog's way; three a page leave lines for notes. Other counts
|
||||
give no pages, and the export fails.
|
||||
|
||||
diff --git a/filter/source/pdf/pdfexport.cxx b/filter/source/pdf/pdfexport.cxx
|
||||
index c70cb59..838f861 100644
|
||||
--- a/filter/source/pdf/pdfexport.cxx
|
||||
+++ b/filter/source/pdf/pdfexport.cxx
|
||||
@@ -411,6 +411,7 @@ bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >&
|
||||
bool bExportNotes = true;
|
||||
bool bExportNotesInMargin = false;
|
||||
bool bExportNotesPages = false;
|
||||
+ sal_Int32 nExportHandouts = 0;
|
||||
bool bExportOnlyNotesPages = false;
|
||||
bool bUseTransitionEffects = true;
|
||||
bool bExportFormFields = false;
|
||||
@@ -570,6 +571,8 @@ bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >&
|
||||
rProp.Value >>= bExportNotes;
|
||||
else if ( rProp.Name == "ExportNotesInMargin" )
|
||||
rProp.Value >>= bExportNotesInMargin;
|
||||
+ else if ( rProp.Name == "ExportHandouts" )
|
||||
+ rProp.Value >>= nExportHandouts;
|
||||
else if ( rProp.Name == "ExportNotesPages" )
|
||||
rProp.Value >>= bExportNotesPages;
|
||||
else if ( rProp.Name == "ExportOnlyNotesPages" )
|
||||
@@ -1074,7 +1077,8 @@ bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >&
|
||||
comphelper::makePropertyValue(u"PageRange"_ustr, aPageRange),
|
||||
comphelper::makePropertyValue(u"ExportPlaceholders"_ustr, bExportPlaceholders),
|
||||
comphelper::makePropertyValue(u"SinglePageSheets"_ustr, bSinglePageSheets),
|
||||
- comphelper::makePropertyValue(u"ExportNotesInMargin"_ustr, bExportNotesInMargin)
|
||||
+ comphelper::makePropertyValue(u"ExportNotesInMargin"_ustr, bExportNotesInMargin),
|
||||
+ comphelper::makePropertyValue(u"ExportHandouts"_ustr, nExportHandouts)
|
||||
};
|
||||
if (oMathTitleRow)
|
||||
aRenderOptionsVector.push_back(*oMathTitleRow);
|
||||
@@ -1157,7 +1161,8 @@ bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >&
|
||||
bExportNotesPages = false;
|
||||
const bool bExportPages = !bExportNotesPages || !bExportOnlyNotesPages;
|
||||
|
||||
- if( aPageRange.isEmpty() || bSinglePageSheets)
|
||||
+ // Handout ranges name slides; every handout page goes out.
|
||||
+ if( aPageRange.isEmpty() || bSinglePageSheets || nExportHandouts)
|
||||
{
|
||||
aPageRange = OUString::number( 1 ) + "-" + OUString::number(nPageCount );
|
||||
}
|
||||
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
|
||||
index 035566a..3aa98bc 100644
|
||||
--- a/sd/source/ui/unoidl/unomodel.cxx
|
||||
+++ b/sd/source/ui/unoidl/unomodel.cxx
|
||||
@@ -198,6 +198,10 @@
|
||||
#include <tools/UnitConversion.hxx>
|
||||
#include <svx/ColorSets.hxx>
|
||||
#include <docmodel/theme/Theme.hxx>
|
||||
+#include <svx/svdopage.hxx>
|
||||
+#include <svx/svdopath.hxx>
|
||||
+#include <tools/multisel.hxx>
|
||||
+#include <basegfx/matrix/b2dhommatrix.hxx>
|
||||
|
||||
#include <frozen/bits/defines.h>
|
||||
#include <frozen/bits/elsa_std.h>
|
||||
@@ -3393,8 +3397,103 @@ uno::Reference< css::ucb::XAnyCompare > SAL_CALL SdXImpressDocument::createAnyCo
|
||||
}
|
||||
|
||||
// XRenderable
|
||||
+namespace
|
||||
+{
|
||||
+/// Slides per handout page asked; 0 is none.
|
||||
+sal_Int32 lcl_Handouts(const uno::Sequence<beans::PropertyValue>& rOptions)
|
||||
+{
|
||||
+ sal_Int32 nPer = 0;
|
||||
+ for (const auto& rOption : rOptions)
|
||||
+ if (rOption.Name == "ExportHandouts")
|
||||
+ rOption.Value >>= nPer;
|
||||
+ return nPer;
|
||||
+}
|
||||
+
|
||||
+/// The shown slides in the options' range.
|
||||
+std::vector<sal_uInt16> lcl_HandoutSlides(SdDrawDocument& rDoc, const uno::Sequence<beans::PropertyValue>& rOptions)
|
||||
+{
|
||||
+ const sal_uInt16 nCount = rDoc.GetSdPageCount(PageKind::Standard);
|
||||
+ OUString aRange;
|
||||
+ for (const auto& rOption : rOptions)
|
||||
+ if (rOption.Name == "PageRange")
|
||||
+ rOption.Value >>= aRange;
|
||||
+ if (aRange.isEmpty())
|
||||
+ aRange = "1-" + OUString::number(nCount);
|
||||
+ std::vector<sal_uInt16> aSlides;
|
||||
+ for (sal_Int32 nAt : StringRangeEnumerator(aRange, 0, nCount - 1))
|
||||
+ if (!rDoc.GetSdPage(nAt, PageKind::Standard)->IsExcluded())
|
||||
+ aSlides.push_back(nAt);
|
||||
+ return aSlides;
|
||||
+}
|
||||
+
|
||||
+/// Lays out the handout page as printing does.
|
||||
+bool lcl_HandoutTemplate(SdDrawDocument& rDoc, sal_Int32 nPer)
|
||||
+{
|
||||
+ AutoLayout eLayout = AUTOLAYOUT_NONE;
|
||||
+ switch (nPer)
|
||||
+ {
|
||||
+ case 1: eLayout = AUTOLAYOUT_HANDOUT1; break;
|
||||
+ case 2: eLayout = AUTOLAYOUT_HANDOUT2; break;
|
||||
+ case 3: eLayout = AUTOLAYOUT_HANDOUT3; break;
|
||||
+ case 4: eLayout = AUTOLAYOUT_HANDOUT4; break;
|
||||
+ case 6: eLayout = AUTOLAYOUT_HANDOUT6; break;
|
||||
+ case 9: eLayout = AUTOLAYOUT_HANDOUT9; break;
|
||||
+ default: return false;
|
||||
+ }
|
||||
+ SdPage* pHandout = rDoc.GetSdPage(0, PageKind::Handout);
|
||||
+ if (!pHandout)
|
||||
+ return false;
|
||||
+ while (pHandout->GetObjCount())
|
||||
+ pHandout->NbcRemoveObject(0);
|
||||
+ const Size aSize = pHandout->GetSize();
|
||||
+ std::vector<::tools::Rectangle> aAreas;
|
||||
+ SdPage::CalculateHandoutAreas(rDoc, eLayout, false, aAreas,
|
||||
+ aSize.Width() > aSize.Height() ? Orientation::Landscape : Orientation::Portrait);
|
||||
+ for (auto it = aAreas.begin(); it != aAreas.end();)
|
||||
+ {
|
||||
+ pHandout->NbcInsertObject(new SdrPageObj(rDoc, *it++));
|
||||
+ // Three a page leave lines for notes.
|
||||
+ if (eLayout != AUTOLAYOUT_HANDOUT3 || it == aAreas.end())
|
||||
+ continue;
|
||||
+ const ::tools::Rectangle aRect(*it++);
|
||||
+ basegfx::B2DPolygon aLine;
|
||||
+ aLine.append(basegfx::B2DPoint(aRect.Left(), aRect.Top()));
|
||||
+ aLine.append(basegfx::B2DPoint(aRect.Right(), aRect.Top()));
|
||||
+ basegfx::B2DHomMatrix aStep;
|
||||
+ aStep.translate(0.0, static_cast<double>(aRect.GetHeight() / 7));
|
||||
+ basegfx::B2DPolyPolygon aLines;
|
||||
+ for (int n = 0; n < 7; ++n)
|
||||
+ {
|
||||
+ aLine.transform(aStep);
|
||||
+ aLines.append(aLine);
|
||||
+ }
|
||||
+ rtl::Reference<SdrPathObj> pPath = new SdrPathObj(rDoc, SdrObjKind::PathLine, std::move(aLines));
|
||||
+ pPath->SetMergedItem(XLineStyleItem(drawing::LineStyle_SOLID));
|
||||
+ pPath->SetMergedItem(XLineColorItem(OUString(), COL_BLACK));
|
||||
+ pHandout->NbcInsertObject(pPath.get());
|
||||
+ }
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
+/// Shows handout page `nPage` of `rSlides`; empty frames hide.
|
||||
+void lcl_HandoutPage(SdDrawDocument& rDoc, const std::vector<sal_uInt16>& rSlides, sal_Int32 nPage)
|
||||
+{
|
||||
+ SdPage& rHandout = *rDoc.GetSdPage(0, PageKind::Handout);
|
||||
+ std::vector<SdrPageObj*> aFrames;
|
||||
+ for (const rtl::Reference<SdrObject>& pObj : rHandout)
|
||||
+ if (auto pFrame = dynamic_cast<SdrPageObj*>(pObj.get()))
|
||||
+ aFrames.push_back(pFrame);
|
||||
+ for (size_t n = 0; n < aFrames.size(); ++n)
|
||||
+ {
|
||||
+ const size_t nAt = nPage * aFrames.size() + n;
|
||||
+ aFrames[n]->SetReferencedPage(nAt < rSlides.size()
|
||||
+ ? rDoc.GetSdPage(rSlides[nAt], PageKind::Standard) : nullptr);
|
||||
+ }
|
||||
+}
|
||||
+}
|
||||
+
|
||||
sal_Int32 SAL_CALL SdXImpressDocument::getRendererCount( const uno::Any& rSelection,
|
||||
- const uno::Sequence< beans::PropertyValue >& )
|
||||
+ const uno::Sequence< beans::PropertyValue >& rxOptions )
|
||||
{
|
||||
::SolarMutexGuard aGuard;
|
||||
sal_Int32 nRet = 0;
|
||||
@@ -3408,7 +3507,14 @@ sal_Int32 SAL_CALL SdXImpressDocument::getRendererCount( const uno::Any& rSelect
|
||||
|
||||
rSelection >>= xModel;
|
||||
|
||||
- if( xModel == mpDocShell->GetModel() )
|
||||
+ const sal_Int32 nPer = lcl_Handouts(rxOptions);
|
||||
+ if (xModel == mpDocShell->GetModel() && nPer)
|
||||
+ {
|
||||
+ // An unknown layout gives no pages; the export fails.
|
||||
+ const size_t nSlides = lcl_HandoutSlides(*mpDoc, rxOptions).size();
|
||||
+ nRet = lcl_HandoutTemplate(*mpDoc, nPer) ? (nSlides + nPer - 1) / nPer : 0;
|
||||
+ }
|
||||
+ else if( xModel == mpDocShell->GetModel() )
|
||||
nRet = mpDoc->GetSdPageCount( PageKind::Standard );
|
||||
else
|
||||
{
|
||||
@@ -3441,7 +3547,12 @@ uno::Sequence< beans::PropertyValue > SAL_CALL SdXImpressDocument::getRenderer(
|
||||
if (mpDocShell)
|
||||
{
|
||||
awt::Size aPageSize;
|
||||
- if ( bExportNotesPages )
|
||||
+ if (lcl_Handouts(rxOptions))
|
||||
+ {
|
||||
+ const Size aHandout = mpDoc->GetSdPage(0, PageKind::Handout)->GetSize();
|
||||
+ aPageSize = awt::Size(aHandout.Width(), aHandout.Height());
|
||||
+ }
|
||||
+ else if ( bExportNotesPages )
|
||||
{
|
||||
Size aNotesPageSize = mpDoc->GetSdPage( 0, PageKind::Notes )->GetSize();
|
||||
aPageSize = awt::Size( aNotesPageSize.Width(), aNotesPageSize.Height() );
|
||||
@@ -3830,7 +3941,16 @@ void SAL_CALL SdXImpressDocument::render( sal_Int32 nRenderer, const uno::Any& r
|
||||
}
|
||||
}
|
||||
|
||||
- if( !(xRenderDevice.is() && nPageNumber && ( nPageNumber <= mpDoc->GetSdPageCount( ePageKind ) )) )
|
||||
+ const sal_Int32 nHandouts = lcl_Handouts(rxOptions);
|
||||
+ if (nHandouts)
|
||||
+ {
|
||||
+ ePageKind = PageKind::Handout;
|
||||
+ lcl_HandoutPage(*mpDoc, lcl_HandoutSlides(*mpDoc, rxOptions), nRenderer);
|
||||
+ }
|
||||
+ SdPage* pShown = nHandouts ? mpDoc->GetSdPage(0, PageKind::Handout)
|
||||
+ : nPageNumber <= mpDoc->GetSdPageCount(ePageKind)
|
||||
+ ? mpDoc->GetSdPage(static_cast<sal_uInt16>(nPageNumber) - 1, ePageKind) : nullptr;
|
||||
+ if( !(xRenderDevice.is() && pShown) )
|
||||
return;
|
||||
|
||||
VCLXDevice* pDevice = dynamic_cast<VCLXDevice*>( xRenderDevice.get() );
|
||||
@@ -3841,7 +3961,7 @@ void SAL_CALL SdXImpressDocument::render( sal_Int32 nRenderer, const uno::Any& r
|
||||
|
||||
vcl::PDFExtOutDevData* pPDFExtOutDevData = dynamic_cast<vcl::PDFExtOutDevData* >( pOut->GetExtOutDevData() );
|
||||
|
||||
- if ( mpDoc->GetSdPage(static_cast<sal_Int16>(nPageNumber)-1, PageKind::Standard)->IsExcluded() &&
|
||||
+ if ( !nHandouts && mpDoc->GetSdPage(static_cast<sal_Int16>(nPageNumber)-1, PageKind::Standard)->IsExcluded() &&
|
||||
!(pPDFExtOutDevData && pPDFExtOutDevData->GetIsExportHiddenSlides()) )
|
||||
return;
|
||||
|
||||
@@ -3852,7 +3972,7 @@ void SAL_CALL SdXImpressDocument::render( sal_Int32 nRenderer, const uno::Any& r
|
||||
}
|
||||
|
||||
::sd::ClientView aView( mpDocShell, pOut );
|
||||
- ::tools::Rectangle aVisArea( Point(), mpDoc->GetSdPage( static_cast<sal_uInt16>(nPageNumber) - 1, ePageKind )->GetSize() );
|
||||
+ ::tools::Rectangle aVisArea( Point(), pShown->GetSize() );
|
||||
vcl::Region aRegion( aVisArea );
|
||||
|
||||
::sd::ViewShell* pOldViewSh = mpDocShell->GetViewShell();
|
||||
@@ -3875,7 +3995,7 @@ void SAL_CALL SdXImpressDocument::render( sal_Int32 nRenderer, const uno::Any& r
|
||||
|
||||
if( xModel == mpDocShell->GetModel() )
|
||||
{
|
||||
- aView.ShowSdrPage( mpDoc->GetSdPage( static_cast<sal_uInt16>(nPageNumber) - 1, ePageKind ));
|
||||
+ aView.ShowSdrPage( pShown );
|
||||
SdrPageView* pPV = aView.GetSdrPageView();
|
||||
|
||||
if( pOldSdView )
|
||||
@@ -4092,7 +4212,7 @@ void SAL_CALL SdXImpressDocument::render( sal_Int32 nRenderer, const uno::Any& r
|
||||
rBookmarks.clear();
|
||||
//---> #i56629, #i40318
|
||||
//get the page name, will be used as outline element in PDF bookmark pane
|
||||
- OUString aPageName = mpDoc->GetSdPage( static_cast<sal_uInt16>(nPageNumber) - 1 , PageKind::Standard )->GetName();
|
||||
+ OUString aPageName = nHandouts ? OUString() : mpDoc->GetSdPage( static_cast<sal_uInt16>(nPageNumber) - 1 , PageKind::Standard )->GetName();
|
||||
if( !aPageName.isEmpty() )
|
||||
{
|
||||
// Destination PageNum
|
||||
@@ -0,0 +1,157 @@
|
||||
LOK: Impress checks a deck before a show
|
||||
|
||||
.uno:SlideCheck lists, for every slide and master, the font families
|
||||
its text asks for, its linked files (pictures, OLE) and whether each is
|
||||
missing, and the objects the kernel cannot show (unreadable pictures,
|
||||
OLE objects with no data, pictures that do not decode). A missing
|
||||
linked picture is listed once.
|
||||
|
||||
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
|
||||
index 3aa98bc..8027106 100644
|
||||
--- a/sd/source/ui/unoidl/unomodel.cxx
|
||||
+++ b/sd/source/ui/unoidl/unomodel.cxx
|
||||
@@ -199,6 +199,11 @@
|
||||
#include <svx/ColorSets.hxx>
|
||||
#include <docmodel/theme/Theme.hxx>
|
||||
#include <svx/svdopage.hxx>
|
||||
+#include <svx/svdograf.hxx>
|
||||
+#include <svx/svditer.hxx>
|
||||
+#include <editeng/editdata.hxx>
|
||||
+#include <com/sun/star/embed/XLinkageSupport.hpp>
|
||||
+#include <svtools/embedhlp.hxx>
|
||||
#include <svx/svdopath.hxx>
|
||||
#include <tools/multisel.hxx>
|
||||
#include <basegfx/matrix/b2dhommatrix.hxx>
|
||||
@@ -2072,7 +2077,7 @@ bool SdXImpressDocument::supportsCommand(std::u16string_view rCommand)
|
||||
return rCommand == u"SlideDesign" || rCommand == u"SlideObjects" || rCommand == u"Chart"
|
||||
|| rCommand == u"SlideNotes" || rCommand == u"SlideTransition"
|
||||
|| rCommand == u"SlideAnimations" || rCommand == u"SlideMedia"
|
||||
- || rCommand == u"SlideShow";
|
||||
+ || rCommand == u"SlideShow" || rCommand == u"SlideCheck";
|
||||
}
|
||||
|
||||
namespace
|
||||
@@ -2264,6 +2269,111 @@ void lcl_SlideMedia(::tools::JsonWriter& rJson, SdPage& rPage)
|
||||
}
|
||||
}
|
||||
|
||||
+/// Fonts a text object asks for, all scripts.
|
||||
+void lcl_TextFonts(const SdrTextObj& rObj, std::set<OUString>& rFonts)
|
||||
+{
|
||||
+ for (const auto& nWhich : { EE_CHAR_FONTINFO, EE_CHAR_FONTINFO_CJK, EE_CHAR_FONTINFO_CTL })
|
||||
+ rFonts.insert(rObj.GetMergedItem(nWhich).GetFamilyName());
|
||||
+ for (sal_Int32 nText = 0; nText < rObj.getTextCount(); ++nText)
|
||||
+ {
|
||||
+ const OutlinerParaObject* pText = rObj.getText(nText)->GetOutlinerParaObject();
|
||||
+ if (!pText)
|
||||
+ continue;
|
||||
+ const EditTextObject& rEdit = pText->GetTextObject();
|
||||
+ for (sal_Int32 nPara = 0; nPara < rEdit.GetParagraphCount(); ++nPara)
|
||||
+ {
|
||||
+ std::vector<EECharAttrib> aAttribs;
|
||||
+ rEdit.GetCharAttribs(nPara, aAttribs);
|
||||
+ for (const EECharAttrib& rAttrib : aAttribs)
|
||||
+ if (auto pFont = dynamic_cast<const SvxFontItem*>(rAttrib.pAttr))
|
||||
+ rFonts.insert(pFont->GetFamilyName());
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+/// Fonts asked for, linked files, objects the kernel cannot show.
|
||||
+void lcl_PageCheck(::tools::JsonWriter& rJson, SdPage& rPage)
|
||||
+{
|
||||
+ std::set<OUString> aFonts;
|
||||
+ std::vector<std::pair<OUString, bool>> aLinks;
|
||||
+ std::vector<OUString> aBroken;
|
||||
+ SdrObjListIter aIter(&rPage, SdrIterMode::DeepNoGroups);
|
||||
+ while (aIter.IsMore())
|
||||
+ {
|
||||
+ SdrObject* pObj = aIter.Next();
|
||||
+ if (pObj->isAnnotationObject() || pObj->IsEmptyPresObj())
|
||||
+ continue;
|
||||
+ if (auto pText = DynCastSdrTextObj(pObj); pText && pText->HasText())
|
||||
+ lcl_TextFonts(*pText, aFonts);
|
||||
+ if (auto pGraf = dynamic_cast<SdrGrafObj*>(pObj))
|
||||
+ {
|
||||
+ bool bThere = true;
|
||||
+ if (pGraf->IsLinkedGraphic())
|
||||
+ {
|
||||
+ osl::DirectoryItem aItem;
|
||||
+ bThere = osl::DirectoryItem::get(pGraf->GetFileName(), aItem) == osl::FileBase::E_None;
|
||||
+ aLinks.emplace_back(pGraf->GetFileName(), !bThere);
|
||||
+ }
|
||||
+ // Loads a link; a failed decode leaves the placeholder.
|
||||
+ const GraphicType eType = pGraf->GetGraphicObject(true).GetType();
|
||||
+ // A missing link is said once, as a link.
|
||||
+ if (bThere && (eType == GraphicType::NONE || eType == GraphicType::Default))
|
||||
+ aBroken.push_back(pObj->GetName());
|
||||
+ }
|
||||
+ if (auto pOle = dynamic_cast<SdrOle2Obj*>(pObj))
|
||||
+ {
|
||||
+ uno::Reference<embed::XLinkageSupport> xLink(pOle->getEmbeddedObjectRef().GetObject(), uno::UNO_QUERY);
|
||||
+ if (xLink.is() && xLink->isLink())
|
||||
+ {
|
||||
+ osl::DirectoryItem aItem;
|
||||
+ const OUString aUrl = xLink->getLinkURL();
|
||||
+ aLinks.emplace_back(aUrl, osl::DirectoryItem::get(aUrl, aItem) != osl::FileBase::E_None);
|
||||
+ }
|
||||
+ if (pOle->IsEmpty())
|
||||
+ aBroken.push_back(pObj->GetName());
|
||||
+ }
|
||||
+ }
|
||||
+ {
|
||||
+ auto aList = rJson.startArray("fonts");
|
||||
+ for (const OUString& rFont : aFonts)
|
||||
+ if (!rFont.isEmpty())
|
||||
+ rJson.putSimpleValue(rFont);
|
||||
+ }
|
||||
+ {
|
||||
+ auto aList = rJson.startArray("links");
|
||||
+ for (const auto& [rUrl, bMissing] : aLinks)
|
||||
+ {
|
||||
+ auto aOne = rJson.startStruct();
|
||||
+ rJson.put("url", rUrl);
|
||||
+ rJson.put("missing", bMissing);
|
||||
+ }
|
||||
+ }
|
||||
+ auto aList = rJson.startArray("broken");
|
||||
+ for (const OUString& rName : aBroken)
|
||||
+ rJson.putSimpleValue(rName);
|
||||
+}
|
||||
+
|
||||
+/// Every slide and master, checked before a show.
|
||||
+void lcl_SlideCheck(::tools::JsonWriter& rJson, SdDrawDocument& rDoc)
|
||||
+{
|
||||
+ {
|
||||
+ auto aList = rJson.startArray("slides");
|
||||
+ for (sal_uInt16 i = 0; i < rDoc.GetSdPageCount(PageKind::Standard); ++i)
|
||||
+ {
|
||||
+ auto aOne = rJson.startStruct();
|
||||
+ lcl_PageCheck(rJson, *rDoc.GetSdPage(i, PageKind::Standard));
|
||||
+ }
|
||||
+ }
|
||||
+ auto aList = rJson.startArray("masters");
|
||||
+ for (sal_uInt16 i = 0; i < rDoc.GetMasterSdPageCount(PageKind::Standard); ++i)
|
||||
+ {
|
||||
+ SdPage* pMaster = rDoc.GetMasterSdPage(i, PageKind::Standard);
|
||||
+ auto aOne = rJson.startStruct();
|
||||
+ rJson.put("name", pMaster->GetName());
|
||||
+ lcl_PageCheck(rJson, *pMaster);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
/// Each slide for a show: hidden, notes, motion, media.
|
||||
void lcl_SlideShow(::tools::JsonWriter& rJson, SdDrawDocument& rDoc)
|
||||
{
|
||||
@@ -2365,6 +2475,11 @@ void SdXImpressDocument::getCommandValues(::tools::JsonWriter& rJsonWriter, std:
|
||||
lcl_SlideShow(rJsonWriter, *mpDoc);
|
||||
return;
|
||||
}
|
||||
+ if (rCommand == ".uno:SlideCheck")
|
||||
+ {
|
||||
+ lcl_SlideCheck(rJsonWriter, *mpDoc);
|
||||
+ return;
|
||||
+ }
|
||||
if (rCommand == ".uno:SlideTransition" || rCommand == ".uno:SlideAnimations")
|
||||
{
|
||||
DrawViewShell* pShell = GetViewShell();
|
||||
@@ -0,0 +1,70 @@
|
||||
macOS Skia: no unused font manager on the first text draw
|
||||
|
||||
AquaSkiaSalGraphicsImpl::drawTextLayout built a static SkFontMgr from a
|
||||
fresh CoreText list of every system font the first time it drew text.
|
||||
Nothing reads it: the typeface comes from the CTFont itself. Building
|
||||
it enumerated and sorted all system fonts on the main thread, about
|
||||
175 ms with 370 fonts, so the first character typed into a new
|
||||
document (or the first text painted) landed late.
|
||||
|
||||
diff --git a/vcl/inc/skia/osx/gdiimpl.hxx b/vcl/inc/skia/osx/gdiimpl.hxx
|
||||
index 6e1656e59..29aa5a46e 100644
|
||||
--- a/vcl/inc/skia/osx/gdiimpl.hxx
|
||||
+++ b/vcl/inc/skia/osx/gdiimpl.hxx
|
||||
@@ -16,7 +16,6 @@
|
||||
#include <skia/gdiimpl.hxx>
|
||||
#include <skia/utils.hxx>
|
||||
|
||||
-#include <SkFontMgr.h>
|
||||
|
||||
class VCL_PLUGIN_PUBLIC AquaSkiaSalGraphicsImpl final : public SkiaSalGraphicsImpl,
|
||||
public AquaGraphicsBackendBase
|
||||
@@ -48,7 +47,6 @@ private:
|
||||
virtual int getWindowScaling() const override;
|
||||
virtual void createWindowSurfaceInternal(bool forceRaster = false) override;
|
||||
virtual void flushSurfaceToWindowContext() override;
|
||||
- static inline sk_sp<SkFontMgr> fontManager;
|
||||
};
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
diff --git a/vcl/skia/osx/gdiimpl.cxx b/vcl/skia/osx/gdiimpl.cxx
|
||||
index 8043fb2e2..b6b856c76 100644
|
||||
--- a/vcl/skia/osx/gdiimpl.cxx
|
||||
+++ b/vcl/skia/osx/gdiimpl.cxx
|
||||
@@ -26,7 +26,6 @@
|
||||
//#include <tools/window/mac/WindowContextFactory_mac.h>
|
||||
|
||||
#include <quartz/CoreTextFont.hxx>
|
||||
-#include <quartz/SystemFontList.hxx>
|
||||
#include <osx/salnativewidgets.h>
|
||||
#include <skia/quartz/cgutils.h>
|
||||
#include <tools/window/mac/MacWindowInfo.h>
|
||||
@@ -35,7 +34,6 @@
|
||||
#include <SkBitmap.h>
|
||||
#include <SkCanvas.h>
|
||||
#include <SkFont.h>
|
||||
-#include <SkFontMgr_mac_ct.h>
|
||||
#include <SkTypeface_mac.h>
|
||||
|
||||
using namespace SkiaHelper;
|
||||
@@ -367,20 +365,6 @@ void AquaSkiaSalGraphicsImpl::drawTextLayout(const GenericSalLayout& rLayout)
|
||||
return;
|
||||
}
|
||||
|
||||
- if (!fontManager)
|
||||
- {
|
||||
- std::unique_ptr<SystemFontList> fontList = GetCoretextFontList();
|
||||
- if (fontList == nullptr)
|
||||
- {
|
||||
- SAL_WARN("vcl.skia", "DrawTextLayout(): No coretext font list");
|
||||
- fontManager = SkFontMgr_New_CoreText(nullptr);
|
||||
- }
|
||||
- else
|
||||
- {
|
||||
- fontManager = SkFontMgr_New_CoreText(fontList->fontCollection());
|
||||
- }
|
||||
- }
|
||||
-
|
||||
sk_sp<SkTypeface> typeface = SkMakeTypefaceFromCTFont(rFont.GetCTFont());
|
||||
SkFont font(typeface);
|
||||
font.setSize(nHeight);
|
||||
@@ -0,0 +1,19 @@
|
||||
Snapshots keep the incremental sections: undo works after a save.
|
||||
|
||||
pdf_save_snapshot promises the document stays unchanged, yet the
|
||||
write marked every incremental section saved; undoing an earlier
|
||||
step then restored nothing (Ely's PDF save and extract).
|
||||
|
||||
--- a/source/pdf/pdf-write.c 2026-10-06 09:03:50
|
||||
+++ b/source/pdf/pdf-write.c 2026-10-06 09:03:50
|
||||
@@ -2869,7 +2869,9 @@
|
||||
pdf_sync_open_pages(ctx, doc);
|
||||
|
||||
// mark incremental sections as having been saved
|
||||
- doc->num_incremental_sections = 0;
|
||||
+ // A snapshot keeps them, and the undo history.
|
||||
+ if (!in_opts->do_snapshot)
|
||||
+ doc->num_incremental_sections = 0;
|
||||
|
||||
pdf_end_operation(ctx, doc);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
Embedding a file ends its operation; a new link target drops /Dest.
|
||||
|
||||
pdf_add_embedded_file began an operation and never ended it on
|
||||
success; the journal stayed inside it and later undo, redo or
|
||||
state reads threw (Ely attachments).
|
||||
|
||||
pdf_set_link_uri wrote /A but kept an old /Dest, which readers
|
||||
take first; the link kept its old target (Ely link editing).
|
||||
|
||||
--- a/source/pdf/pdf-link.c 2026-10-06 15:47:19
|
||||
+++ b/source/pdf/pdf-link.c 2026-10-06 15:47:47
|
||||
@@ -506,6 +506,7 @@
|
||||
}
|
||||
|
||||
filespec = pdf_add_filespec(ctx, doc, filename, file);
|
||||
+ pdf_end_operation(ctx, doc);
|
||||
}
|
||||
fz_always(ctx)
|
||||
pdf_drop_obj(ctx, file);
|
||||
@@ -630,6 +631,7 @@
|
||||
{
|
||||
pdf_dict_put_drop(ctx, link->obj, PDF_NAME(A),
|
||||
pdf_new_action_from_link(ctx, link->page->doc, uri));
|
||||
+ pdf_dict_del(ctx, link->obj, PDF_NAME(Dest));
|
||||
fz_free(ctx, link->super.uri);
|
||||
link->super.uri = fz_strdup(ctx, uri);
|
||||
pdf_end_operation(ctx, link->page->doc);
|
||||
@@ -0,0 +1,29 @@
|
||||
OCR fails when a requested language does not load.
|
||||
|
||||
Tesseract initialises with the languages it can load and drops the
|
||||
rest; a page asked for in eng+chi_sim was read in English alone and
|
||||
reported as a success (Ely OCR).
|
||||
|
||||
--- a/source/fitz/tessocr.cpp 2026-10-06 16:20:56
|
||||
+++ b/source/fitz/tessocr.cpp 2026-10-06 16:20:56
|
||||
@@ -144,6 +144,20 @@
|
||||
delete api;
|
||||
fz_clear_leptonica_mem(ctx);
|
||||
fz_throw(ctx, FZ_ERROR_LIBRARY, "Tesseract language initialisation failed");
|
||||
+ }
|
||||
+
|
||||
+ {
|
||||
+ std::vector<std::string> loaded;
|
||||
+ int wanted = 1;
|
||||
+ for (const char *s = language; *s; s++)
|
||||
+ wanted += *s == '+';
|
||||
+ api->GetLoadedLanguagesAsVector(&loaded);
|
||||
+ if ((int)loaded.size() < wanted)
|
||||
+ {
|
||||
+ delete api;
|
||||
+ fz_clear_leptonica_mem(ctx);
|
||||
+ fz_throw(ctx, FZ_ERROR_LIBRARY, "Tesseract loaded %d of %d languages in %s", (int)loaded.size(), wanted, language);
|
||||
+ }
|
||||
}
|
||||
|
||||
n = fz_count_options(ctx, options);
|
||||
@@ -0,0 +1,83 @@
|
||||
A signature records its reason and location.
|
||||
|
||||
pdf_sign_signature drew the reason and location into the appearance
|
||||
only; readers look for them in the signature dictionary. Set after
|
||||
signing, they land in a second update and break the byte range, so
|
||||
they are written with the value (Ely signing).
|
||||
|
||||
--- a/include/mupdf/pdf/form.h 2026-10-06 18:45:38
|
||||
+++ b/include/mupdf/pdf/form.h 2026-10-06 18:45:38
|
||||
@@ -252,6 +252,8 @@
|
||||
|
||||
int pdf_signature_is_signed(fz_context *ctx, pdf_document *doc, pdf_obj *field);
|
||||
void pdf_signature_set_value(fz_context *ctx, pdf_document *doc, pdf_obj *field, pdf_pkcs7_signer *signer, int64_t stime);
|
||||
+/* Also records reason and location; NULL or empty skips. */
|
||||
+void pdf_signature_set_value_said(fz_context *ctx, pdf_document *doc, pdf_obj *field, pdf_pkcs7_signer *signer, int64_t stime, const char *reason, const char *location);
|
||||
|
||||
int pdf_count_signatures(fz_context *ctx, pdf_document *doc);
|
||||
|
||||
--- a/source/pdf/pdf-form.c 2026-10-06 18:45:38
|
||||
+++ b/source/pdf/pdf-form.c 2026-10-06 18:45:49
|
||||
@@ -1923,6 +1923,11 @@
|
||||
|
||||
void pdf_signature_set_value(fz_context *ctx, pdf_document *doc, pdf_obj *field, pdf_pkcs7_signer *signer, int64_t stime)
|
||||
{
|
||||
+ pdf_signature_set_value_said(ctx, doc, field, signer, stime, NULL, NULL);
|
||||
+}
|
||||
+
|
||||
+void pdf_signature_set_value_said(fz_context *ctx, pdf_document *doc, pdf_obj *field, pdf_pkcs7_signer *signer, int64_t stime, const char *reason, const char *location)
|
||||
+{
|
||||
pdf_obj *v = NULL;
|
||||
pdf_obj *o = NULL;
|
||||
pdf_obj *r = NULL;
|
||||
@@ -1966,6 +1971,11 @@
|
||||
pdf_dict_put(ctx, v, PDF_NAME(SubFilter), PDF_NAME(adbe_pkcs7_detached));
|
||||
pdf_dict_put(ctx, v, PDF_NAME(Type), PDF_NAME(Sig));
|
||||
pdf_dict_put_date(ctx, v, PDF_NAME(M), stime);
|
||||
+ /* Before storing: later edits open a new section. */
|
||||
+ if (reason && *reason)
|
||||
+ pdf_dict_put_text_string(ctx, v, PDF_NAME(Reason), reason);
|
||||
+ if (location && *location)
|
||||
+ pdf_dict_put_text_string(ctx, v, PDF_NAME(Location), location);
|
||||
|
||||
o = pdf_dict_put_array(ctx, v, PDF_NAME(Reference), 1);
|
||||
r = pdf_array_put_dict(ctx, o, 0, 4);
|
||||
--- a/source/pdf/pdf-signature.c 2026-10-06 18:45:38
|
||||
+++ b/source/pdf/pdf-signature.c 2026-10-06 18:45:49
|
||||
@@ -233,9 +233,18 @@
|
||||
}
|
||||
}
|
||||
|
||||
+static void
|
||||
+sign_with_appearance(fz_context *ctx, pdf_annot *widget, pdf_pkcs7_signer *signer, int64_t t, fz_display_list *disp_list, const char *reason, const char *location);
|
||||
+
|
||||
void
|
||||
pdf_sign_signature_with_appearance(fz_context *ctx, pdf_annot *widget, pdf_pkcs7_signer *signer, int64_t t, fz_display_list *disp_list)
|
||||
{
|
||||
+ sign_with_appearance(ctx, widget, signer, t, disp_list, NULL, NULL);
|
||||
+}
|
||||
+
|
||||
+static void
|
||||
+sign_with_appearance(fz_context *ctx, pdf_annot *widget, pdf_pkcs7_signer *signer, int64_t t, fz_display_list *disp_list, const char *reason, const char *location)
|
||||
+{
|
||||
pdf_document *doc;
|
||||
|
||||
if (pdf_dict_get_inheritable(ctx, widget->obj, PDF_NAME(FT)) != PDF_NAME(Sig))
|
||||
@@ -273,7 +282,7 @@
|
||||
if ((sf & (PDF_SIGFLAGS_SIGSEXIST | PDF_SIGFLAGS_APPENDONLY)) != (PDF_SIGFLAGS_SIGSEXIST | PDF_SIGFLAGS_APPENDONLY))
|
||||
pdf_dict_put_int(ctx, form, PDF_NAME(SigFlags), sf | PDF_SIGFLAGS_SIGSEXIST | PDF_SIGFLAGS_APPENDONLY);
|
||||
|
||||
- pdf_signature_set_value(ctx, doc, wobj, signer, t);
|
||||
+ pdf_signature_set_value_said(ctx, doc, wobj, signer, t, reason, location);
|
||||
end_widget_op(ctx, widget);
|
||||
}
|
||||
fz_catch(ctx)
|
||||
@@ -359,7 +368,7 @@
|
||||
else
|
||||
dlist = pdf_signature_appearance_signed(ctx, rect, lang, NULL, NULL, info, logo);
|
||||
}
|
||||
- pdf_sign_signature_with_appearance(ctx, widget, signer, now, dlist);
|
||||
+ sign_with_appearance(ctx, widget, signer, now, dlist, reason, location);
|
||||
}
|
||||
fz_always(ctx)
|
||||
{
|
||||
@@ -0,0 +1,46 @@
|
||||
A save that cannot open its file still journals later edits.
|
||||
|
||||
prepare_for_save sets save_in_progress and only the writer clears
|
||||
it; when the output file cannot be opened, the flag stayed set and
|
||||
every later change bypassed the journal: edits made no undo step
|
||||
(Ely save to a missing folder).
|
||||
|
||||
--- a/source/pdf/pdf-write.c 2026-10-06 19:50:43
|
||||
+++ b/source/pdf/pdf-write.c 2026-10-06 19:50:43
|
||||
@@ -2186,7 +2186,15 @@
|
||||
doc->save_in_progress = 1;
|
||||
|
||||
if (!in_opts->do_snapshot)
|
||||
- presize_unsaved_signature_byteranges(ctx, doc);
|
||||
+ {
|
||||
+ fz_try(ctx)
|
||||
+ presize_unsaved_signature_byteranges(ctx, doc);
|
||||
+ fz_catch(ctx)
|
||||
+ {
|
||||
+ doc->save_in_progress = 0;
|
||||
+ fz_rethrow(ctx);
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
|
||||
static pdf_obj *
|
||||
@@ -3021,13 +3029,13 @@
|
||||
|
||||
prepare_for_save(ctx, doc, in_opts);
|
||||
|
||||
- if (in_opts->do_incremental)
|
||||
+ fz_try(ctx)
|
||||
+ opts.out = fz_new_output_with_path(ctx, filename, in_opts->do_incremental ? 1 : 0);
|
||||
+ fz_catch(ctx)
|
||||
{
|
||||
- opts.out = fz_new_output_with_path(ctx, filename, 1);
|
||||
- }
|
||||
- else
|
||||
- {
|
||||
- opts.out = fz_new_output_with_path(ctx, filename, 0);
|
||||
+ /* No write follows to clear it; edits stay journalled. */
|
||||
+ doc->save_in_progress = 0;
|
||||
+ fz_rethrow(ctx);
|
||||
}
|
||||
fz_try(ctx)
|
||||
{
|
||||
Reference in new issue
Block a user