[Libreoffice-commits] core.git: include/svx sc/source sd/source svx/source sw/source
Mike Kaganski
mike.kaganski at collabora.com
Tue Jun 28 07:06:32 UTC 2016
include/svx/svdmodel.hxx | 4 ++++
sc/source/ui/view/prevwsh.cxx | 7 ++++++-
sc/source/ui/view/viewdata.cxx | 13 ++++++++++++-
sd/source/ui/view/drviews5.cxx | 5 +++++
svx/source/svdraw/svdmodel.cxx | 29 +++++++++++++++++++++++++++++
sw/source/uibase/uiview/view.cxx | 5 +++++
6 files changed, 61 insertions(+), 2 deletions(-)
New commits:
commit 3f9acf02b0a45deb258c96b638c6fddd9af31ff9
Author: Mike Kaganski <mike.kaganski at collabora.com>
Date: Tue Jun 28 00:30:29 2016 +1000
tdf#99729 prerequisite: model-level user data r/w
This commit introduces a system for reading/writing common
model-level user data (like compatibility flags from settings.xml).
It is designed to reduce code duplication in cases where an option
is applicable to any type of document.
Change-Id: Id4e31df14f49cbb673f4a6df943ccec6d98eb9aa
Reviewed-on: https://gerrit.libreoffice.org/26719
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
diff --git a/include/svx/svdmodel.hxx b/include/svx/svdmodel.hxx
index 3f617c2..fa24d55 100644
--- a/include/svx/svdmodel.hxx
+++ b/include/svx/svdmodel.hxx
@@ -550,6 +550,10 @@ public:
bool IsWriter() const { return !bMyPool; }
+ // Used as a fallback in *::ReadUserDataSequence() to process common properties
+ void ReadUserDataSequenceValue(const css::beans::PropertyValue *pValue);
+ void WriteUserDataSequence(css::uno::Sequence < css::beans::PropertyValue >& rValues, bool bBrowse = false);
+
/** returns the numbering type that is used to format page fields in drawing shapes */
virtual SvxNumType GetPageNumType() const;
diff --git a/sc/source/ui/view/prevwsh.cxx b/sc/source/ui/view/prevwsh.cxx
index 885273f..b363f7c6 100644
--- a/sc/source/ui/view/prevwsh.cxx
+++ b/sc/source/ui/view/prevwsh.cxx
@@ -947,6 +947,9 @@ void ScPreviewShell::WriteUserDataSequence(uno::Sequence < beans::PropertyValue
pSeq[2].Name = "PageNumber";
pSeq[2].Value <<= pPreview->GetPageNo();
}
+
+ // Common SdrModel processing
+ GetDocument().GetDrawLayer()->WriteUserDataSequence(rSeq);
}
void ScPreviewShell::ReadUserDataSequence(const uno::Sequence < beans::PropertyValue >& rSeq)
@@ -972,7 +975,9 @@ void ScPreviewShell::ReadUserDataSequence(const uno::Sequence < beans::PropertyV
if (pSeq->Value >>= nTemp)
pPreview->SetPageNo(nTemp);
}
- }
+ // Fallback to common SdrModel processing
+ else GetDocument().GetDrawLayer()->ReadUserDataSequenceValue(pSeq);
+ }
}
}
}
diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx
index 7ef5dbc..d188643 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -112,7 +112,7 @@ ScViewDataTable::~ScViewDataTable()
{
}
-void ScViewDataTable::WriteUserDataSequence(uno::Sequence <beans::PropertyValue>& rSettings, const ScViewData& /*rViewData*/, SCTAB /*nTab*/) const
+void ScViewDataTable::WriteUserDataSequence(uno::Sequence <beans::PropertyValue>& rSettings, const ScViewData& rViewData, SCTAB /*nTab*/) const
{
rSettings.realloc(SC_TABLE_VIEWSETTINGS_COUNT);
beans::PropertyValue* pSettings = rSettings.getArray();
@@ -159,6 +159,9 @@ void ScViewDataTable::WriteUserDataSequence(uno::Sequence <beans::PropertyValue>
pSettings[SC_TABLE_SHOWGRID].Name = SC_UNO_SHOWGRID;
pSettings[SC_TABLE_SHOWGRID].Value <<= bShowGrid;
}
+
+ // Common SdrModel processing
+ rViewData.GetDocument()->GetDrawLayer()->WriteUserDataSequence(rSettings);
}
void ScViewDataTable::ReadUserDataSequence(const uno::Sequence <beans::PropertyValue>& aSettings, ScViewData& rViewData, SCTAB nTab, bool& rHasZoom )
@@ -288,6 +291,8 @@ void ScViewDataTable::ReadUserDataSequence(const uno::Sequence <beans::PropertyV
pDoc->SetTabBgColor(nTab, Color(static_cast<ColorData>(nColor)));
}
}
+ // Fallback to common SdrModel processing
+ else rViewData.GetDocument()->GetDrawLayer()->ReadUserDataSequenceValue(&aSettings[i]);
}
if (eHSplitMode == SC_SPLIT_FIX)
nFixPosX = SanitizeCol( static_cast<SCCOL>( bHasHSplitInTwips ? nTempPosHTw : nTempPosH ));
@@ -2728,6 +2733,9 @@ void ScViewData::WriteUserDataSequence(uno::Sequence <beans::PropertyValue>& rSe
pSettings[SC_RASTERSYNC].Value <<= aGridOpt.GetSynchronize();
}
}
+
+ // Common SdrModel processing
+ GetDocument()->GetDrawLayer()->WriteUserDataSequence(rSettings);
}
void ScViewData::ReadUserDataSequence(const uno::Sequence <beans::PropertyValue>& rSettings)
@@ -2881,6 +2889,9 @@ void ScViewData::ReadUserDataSequence(const uno::Sequence <beans::PropertyValue>
aGridOpt.SetFieldDivisionY( static_cast <sal_uInt32> ( ScUnoHelpFunctions::GetInt32FromAny( rSettings[i].Value ) ) );
else if ( sName == SC_UNO_RASTERSYNC )
aGridOpt.SetSynchronize( ScUnoHelpFunctions::GetBoolFromAny( rSettings[i].Value ) );
+ // Fallback to common SdrModel processing
+ else GetDocument()->GetDrawLayer()->ReadUserDataSequenceValue(&rSettings[i]);
+
pOptions->SetGridOptions(aGridOpt);
}
}
diff --git a/sd/source/ui/view/drviews5.cxx b/sd/source/ui/view/drviews5.cxx
index de08b44..b4e3319 100644
--- a/sd/source/ui/view/drviews5.cxx
+++ b/sd/source/ui/view/drviews5.cxx
@@ -452,6 +452,9 @@ void DrawViewShell::WriteUserDataSequence ( css::uno::Sequence < css::beans::Pro
rSequence.realloc( nIndex + 1 );
rSequence[nIndex].Name = sUNO_View_ZoomOnPage ;
rSequence[nIndex].Value <<= mbZoomOnPage;
+
+ // Common SdrModel processing
+ GetDocSh()->GetDoc()->WriteUserDataSequence(rSequence, bBrowse);
}
void DrawViewShell::ReadUserDataSequence ( const css::uno::Sequence < css::beans::PropertyValue >& rSequence, bool bBrowse )
@@ -472,6 +475,8 @@ void DrawViewShell::ReadUserDataSequence ( const css::uno::Sequence < css::beans
mbZoomOnPage = bZoomPage;
}
}
+ // Fallback to common SdrModel processing
+ else GetDocSh()->GetDoc()->ReadUserDataSequenceValue(pValue);
}
if( mpFrameView->GetPageKind() != mePageKind )
diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx
index 5edce8f..f537e07 100644
--- a/svx/source/svdraw/svdmodel.cxx
+++ b/svx/source/svdraw/svdmodel.cxx
@@ -1925,6 +1925,35 @@ SvxNumType SdrModel::GetPageNumType() const
return SVX_ARABIC;
}
+void SdrModel::ReadUserDataSequenceValue(const css::beans::PropertyValue* /*pValue*/)
+{
+ // TODO: Read common model-level values
+}
+
+template <typename T>
+inline void addPair(std::vector< std::pair< OUString, Any > >& aUserData, const OUString& name, const T val)
+{
+ aUserData.push_back(std::pair< OUString, Any >(name, css::uno::makeAny(val)));
+}
+
+void SdrModel::WriteUserDataSequence(css::uno::Sequence < css::beans::PropertyValue >& rValues, bool /*bBrowse*/)
+{
+ std::vector< std::pair< OUString, Any > > aUserData;
+ // TODO: addPair(aUserData, "PropName", PropValue);
+
+ const sal_Int32 nOldLength = rValues.getLength();
+ rValues.realloc(nOldLength + aUserData.size());
+
+ css::beans::PropertyValue* pValue = &(rValues.getArray()[nOldLength]);
+
+ for (const auto &aIter : aUserData)
+ {
+ pValue->Name = aIter.first;
+ pValue->Value = aIter.second;
+ ++pValue;
+ }
+}
+
const SdrPage* SdrModel::GetPage(sal_uInt16 nPgNum) const
{
DBG_ASSERT(nPgNum < maPages.size(), "SdrModel::GetPage: Access out of range (!)");
diff --git a/sw/source/uibase/uiview/view.cxx b/sw/source/uibase/uiview/view.cxx
index 4114310..7821da5 100644
--- a/sw/source/uibase/uiview/view.cxx
+++ b/sw/source/uibase/uiview/view.cxx
@@ -1326,6 +1326,8 @@ void SwView::ReadUserDataSequence ( const uno::Sequence < beans::PropertyValue >
pValue->Value >>= bSelectedFrame;
bGotIsSelectedFrame = true;
}
+ // Fallback to common SdrModel processing
+ else GetDocShell()->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->ReadUserDataSequenceValue(pValue);
pValue++;
}
if (bGotVisibleBottom)
@@ -1490,6 +1492,9 @@ void SwView::WriteUserDataSequence ( uno::Sequence < beans::PropertyValue >& rSe
aVector.push_back(comphelper::makePropertyValue("IsSelectedFrame", FrameTypeFlags::NONE != m_pWrtShell->GetSelFrameType()));
rSequence = comphelper::containerToSequence(aVector);
+
+ // Common SdrModel processing
+ GetDocShell()->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->WriteUserDataSequence(rSequence);
}
void SwView::ShowCursor( bool bOn )
More information about the Libreoffice-commits
mailing list