sd: store "HasCanvasPage" boolean in settings.xml
and validate the incoming canvas page Signed-off-by: Mohit Marathe <mohit.marathe@collabora.com> Change-Id: I2a110a8cd674e8a6d5be61b9623f9373deaa6f2d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193243 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Michael Stahl <michael.stahl@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196805 Tested-by: Jenkins
This commit is contained in:
committed by
Michael Stahl
parent
8de6df8135
commit
d95feee32d
@@ -1005,6 +1005,9 @@ public:
|
||||
|
||||
SAL_DLLPRIVATE bool HasCanvasPage() const { return mpCanvasPage.is(); }
|
||||
|
||||
SAL_DLLPRIVATE void ImportCanvasPage();
|
||||
SAL_DLLPRIVATE bool ValidateCanvasPage(const SdPage* pPage) const;
|
||||
|
||||
SAL_DLLPRIVATE sal_uInt16 GetOrInsertCanvasPage ();
|
||||
|
||||
/** return the document fonts for latin, cjk and ctl according to the current
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include <unordered_set>
|
||||
#include <vcl/settings.hxx>
|
||||
|
||||
#include <sal/log.hxx>
|
||||
@@ -1471,6 +1472,47 @@ void SdDrawDocument::SetupNewPage (
|
||||
}
|
||||
}
|
||||
|
||||
bool SdDrawDocument::ValidateCanvasPage(const SdPage* pPage) const
|
||||
{
|
||||
std::unordered_set<SdrPage*> aPreviewPageSet;
|
||||
SdrObjListIter aIter(pPage, SdrIterMode::Flat);
|
||||
for (SdrObject* pObj = aIter.Next(); pObj; pObj = aIter.Next())
|
||||
{
|
||||
if (pObj->GetObjIdentifier() != SdrObjKind::Page)
|
||||
continue;
|
||||
SdrPageObj* pPageObj = static_cast<SdrPageObj*>(pObj);
|
||||
SdrPage* pPreviewPage = pPageObj->GetReferencedPage();
|
||||
if (aPreviewPageSet.contains(pPreviewPage))
|
||||
return false;
|
||||
else
|
||||
aPreviewPageSet.insert(pPreviewPage);
|
||||
}
|
||||
if (aPreviewPageSet.size() != o3tl::make_unsigned(GetSdPageCount(PageKind::Standard) - 1))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void SdDrawDocument::ImportCanvasPage()
|
||||
{
|
||||
sal_uInt16 nStdPageCnt = GetSdPageCount(PageKind::Standard);
|
||||
|
||||
// what if canvas page is not the last page?
|
||||
SdPage* pPage = GetSdPage(nStdPageCnt - 1, PageKind::Standard);
|
||||
bool bIsCanvasPageValid = ValidateCanvasPage(pPage);
|
||||
pPage->SetCanvasPage();
|
||||
mpCanvasPage = pPage;
|
||||
// re-populate the previews grid if not valid
|
||||
if (!bIsCanvasPageValid)
|
||||
{
|
||||
while (pPage->GetObjCount() > 0)
|
||||
{
|
||||
// maybe only SdrPageObj(s) should be removed?
|
||||
pPage->NbcRemoveObject(0);
|
||||
}
|
||||
populatePagePreviewsGrid();
|
||||
}
|
||||
}
|
||||
|
||||
void SdDrawDocument::ReshufflePages()
|
||||
{
|
||||
SdrObjList* pObjList = mpCanvasPage.get();
|
||||
|
||||
@@ -113,4 +113,6 @@ inline constexpr OUString sUNO_View_VisibleAreaHeight = u"VisibleAreaHeight"_ust
|
||||
|
||||
inline constexpr OUString sUNO_View_ZoomOnPage = u"ZoomOnPage"_ustr;
|
||||
|
||||
inline constexpr OUString sUNO_View_HasCanvasPage = u"HasCanvasPage"_ustr;
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
||||
@@ -405,6 +405,7 @@ void FrameView::WriteUserDataSequence ( css::uno::Sequence < css::beans::Propert
|
||||
{
|
||||
std::vector< std::pair< OUString, Any > > aUserData;
|
||||
aUserData.reserve(41); // worst case
|
||||
SdDrawDocument* pDrawDocument = dynamic_cast<SdDrawDocument*>(&GetModel());
|
||||
|
||||
aUserData.emplace_back( sUNO_View_GridIsVisible, Any( IsGridVisible() ) );
|
||||
aUserData.emplace_back( sUNO_View_GridIsFront, Any( IsGridFront() ) );
|
||||
@@ -479,6 +480,7 @@ void FrameView::WriteUserDataSequence ( css::uno::Sequence < css::beans::Propert
|
||||
aUserData.emplace_back( sUNO_View_GridSnapWidthYDenominator, Any( GetSnapGridWidthY().GetDenominator() ) );
|
||||
aUserData.emplace_back( sUNO_View_IsAngleSnapEnabled, Any( IsAngleSnapEnabled() ) );
|
||||
aUserData.emplace_back( sUNO_View_SnapAngle, Any( static_cast<sal_Int32>(GetSnapAngle()) ) );
|
||||
aUserData.emplace_back( sUNO_View_HasCanvasPage, Any( pDrawDocument->HasCanvasPage() ) );
|
||||
|
||||
const sal_Int32 nOldLength = rValues.getLength();
|
||||
rValues.realloc( nOldLength + aUserData.size() );
|
||||
@@ -910,6 +912,11 @@ void FrameView::ReadUserDataSequence ( const css::uno::Sequence < css::beans::Pr
|
||||
aSdrLayerIDSets.PutValue( rValue.Value );
|
||||
SetLockedLayers( aSdrLayerIDSets );
|
||||
}
|
||||
else if ( bImpress && rValue.Name == sUNO_View_HasCanvasPage )
|
||||
{
|
||||
if ( (rValue.Value >>= bBool) && bBool )
|
||||
pDrawDocument->ImportCanvasPage();
|
||||
}
|
||||
}
|
||||
|
||||
SetViewShEditModeOnLoad(EditMode::Page);
|
||||
|
||||
Reference in New Issue
Block a user