summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver Specht <os@openoffice.org>2001-01-19 11:45:03 +0000
committerOliver Specht <os@openoffice.org>2001-01-19 11:45:03 +0000
commit17e1ca955b7239d14f06d81165332346cdc00a70 (patch)
tree2b9cc01181b5621b79530e7cdf3203d9673fb943
parenta411edfb5c0874d5b6123df39a6a72a1fa5d93ed (diff)
#82944# save/load grid options
-rw-r--r--sw/source/ui/config/usrpref.cxx121
-rw-r--r--sw/source/ui/inc/usrpref.hxx26
2 files changed, 142 insertions, 5 deletions
diff --git a/sw/source/ui/config/usrpref.cxx b/sw/source/ui/config/usrpref.cxx
index 5846e626c701..e3a7ff9d987b 100644
--- a/sw/source/ui/config/usrpref.cxx
+++ b/sw/source/ui/config/usrpref.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: usrpref.cxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: tl $ $Date: 2000-11-19 11:37:07 $
+ * last change: $Author: os $ $Date: 2001-01-19 12:45:03 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -116,10 +116,12 @@ void SwMasterUsrPref::SetUsrPref(const SwViewOption &rCopy)
SwMasterUsrPref::SwMasterUsrPref(BOOL bWeb) :
aContentConfig(bWeb, *this),
- aLayoutConfig(bWeb, *this)
+ aLayoutConfig(bWeb, *this),
+ aGridConfig(bWeb, *this)
{
aContentConfig.Load();
aLayoutConfig.Load();
+ aGridConfig.Load();
}
/*-- 28.09.00 09:55:32---------------------------------------------------
@@ -407,3 +409,116 @@ void SwLayoutViewConfig::Load()
}
}
}
+/* -----------------------------19.01.01 13:07--------------------------------
+
+ ---------------------------------------------------------------------------*/
+Sequence<OUString> SwGridConfig::GetPropertyNames()
+{
+ static const char* aPropNames[] =
+ {
+ "Option/SnapToGrid", // 0
+ "Option/VisibleGrid", // 1
+ "Option/Synchronize", // 2
+ "Resolution/XAxis", // 3
+ "Resolution/YAxis", // 4
+ "Subdivision/XAxis", // 5
+ "Subdivision/YAxis" // 6
+ };
+ const int nCount = 7;
+ Sequence<OUString> aNames(nCount);
+ OUString* pNames = aNames.getArray();
+ for(int i = 0; i < nCount; i++)
+ {
+ pNames[i] = OUString::createFromAscii(aPropNames[i]);
+ }
+ return aNames;
+}
+/* -----------------------------19.01.01 13:07--------------------------------
+
+ ---------------------------------------------------------------------------*/
+SwGridConfig::SwGridConfig(BOOL bIsWeb, SwMasterUsrPref& rPar) :
+ ConfigItem(bIsWeb ? C2U("Office.WriterWeb/Grid") : C2U("Office.Writer/Grid")),
+ rParent(rPar),
+ bWeb(bIsWeb)
+{
+}
+/* -----------------------------19.01.01 13:07--------------------------------
+
+ ---------------------------------------------------------------------------*/
+SwGridConfig::~SwGridConfig()
+{
+}
+/* -----------------------------19.01.01 13:07--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SwGridConfig::Notify( const com::sun::star::uno::Sequence<rtl::OUString>& aPropertyNames)
+{
+ Load();
+}
+/* -----------------------------19.01.01 13:07--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SwGridConfig::Commit()
+{
+ Sequence<OUString> aNames = GetPropertyNames();
+
+ OUString* pNames = aNames.getArray();
+ Sequence<Any> aValues(aNames.getLength());
+ Any* pValues = aValues.getArray();
+
+ const Type& rType = ::getBooleanCppuType();
+ for(int nProp = 0; nProp < aNames.getLength(); nProp++)
+ {
+ sal_Bool bSet;
+ switch(nProp)
+ {
+ case 0: bSet = rParent.IsSnap(); break;// "Option/SnapToGrid",
+ case 1: bSet = rParent.IsGridVisible(); break;//"Option/VisibleGrid",
+ case 2: bSet = rParent.IsSynchronize(); break;// "Option/Synchronize",
+ case 3: pValues[nProp] <<= (sal_Int32)TWIP_TO_MM100(rParent.GetSnapSize().Width()); break;// "Resolution/XAxis",
+ case 4: pValues[nProp] <<= (sal_Int32)TWIP_TO_MM100(rParent.GetSnapSize().Height()); break;// "Resolution/YAxis",
+ case 5: pValues[nProp] <<= (sal_Int16)rParent.GetDivisionX(); break;// "Subdivision/XAxis",
+ case 6: pValues[nProp] <<= (sal_Int16)rParent.GetDivisionY(); break;// "Subdivision/YAxis"
+ }
+ if(nProp < 3)
+ pValues[nProp].setValue(&bSet, ::getBooleanCppuType());
+ }
+ PutProperties(aNames, aValues);
+}
+/* -----------------------------19.01.01 13:07--------------------------------
+
+ ---------------------------------------------------------------------------*/
+void SwGridConfig::Load()
+{
+ Sequence<OUString> aNames = GetPropertyNames();
+ Sequence<Any> aValues = GetProperties(aNames);
+ EnableNotification(aNames);
+ const Any* pValues = aValues.getConstArray();
+ DBG_ASSERT(aValues.getLength() == aNames.getLength(), "GetProperties failed")
+ if(aValues.getLength() == aNames.getLength())
+ {
+ Size aSnap(rParent.GetSnapSize());
+ for(int nProp = 0; nProp < aNames.getLength(); nProp++)
+ {
+ if(pValues[nProp].hasValue())
+ {
+ sal_Bool bSet = nProp < 3 ? *(sal_Bool*)pValues[nProp].getValue() : sal_False;
+ sal_Int32 nSet;
+ if(nProp >= 3)
+ pValues[nProp] >>= nSet;
+ switch(nProp)
+ {
+ case 0: rParent.SetSnap(bSet); break;// "Option/SnapToGrid",
+ case 1: rParent.SetGridVisible(bSet); break;//"Option/VisibleGrid",
+ case 2: rParent.SetSynchronize(bSet); break;// "Option/Synchronize",
+ case 3: aSnap.Width() = MM100_TO_TWIP(nSet); break;// "Resolution/XAxis",
+ case 4: aSnap.Height() = MM100_TO_TWIP(nSet); break;// "Resolution/YAxis",
+ case 5: rParent.SetDivisionX(nSet); break;// "Subdivision/XAxis",
+ case 6: rParent.SetDivisionY(nSet); break;// "Subdivision/YAxis"
+ }
+ }
+ }
+ rParent.SetSnapSize(aSnap);
+ }
+}
+
diff --git a/sw/source/ui/inc/usrpref.hxx b/sw/source/ui/inc/usrpref.hxx
index 2af0407ef83f..86029e937ccf 100644
--- a/sw/source/ui/inc/usrpref.hxx
+++ b/sw/source/ui/inc/usrpref.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: usrpref.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: os $ $Date: 2000-09-28 15:23:36 $
+ * last change: $Author: os $ $Date: 2001-01-19 12:44:17 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -108,6 +108,24 @@ class SwLayoutViewConfig : public utl::ConfigItem
void Load();
void SetModified(){ConfigItem::SetModified();}
};
+/* -----------------------------19.01.01 13:06--------------------------------
+
+ ---------------------------------------------------------------------------*/
+class SwGridConfig : public utl::ConfigItem
+{
+ SwMasterUsrPref& rParent;
+ BOOL bWeb;
+
+ com::sun::star::uno::Sequence<rtl::OUString> GetPropertyNames();
+ public:
+ SwGridConfig(BOOL bWeb, SwMasterUsrPref& rParent);
+ ~SwGridConfig();
+
+ virtual void Notify( const com::sun::star::uno::Sequence<rtl::OUString>& aPropertyNames);
+ virtual void Commit();
+ void Load();
+ void SetModified(){ConfigItem::SetModified();}
+};
/* -----------------------------28.09.00 09:45--------------------------------
---------------------------------------------------------------------------*/
@@ -115,9 +133,11 @@ class SwMasterUsrPref : public SwViewOption
{
friend class SwContentViewConfig;
friend class SwLayoutViewConfig;
+ friend class SwGridConfig;
SwContentViewConfig aContentConfig;
SwLayoutViewConfig aLayoutConfig;
+ SwGridConfig aGridConfig;
sal_Int32 nFldUpdateFlags; //udpate of fields and charts
sal_Int32 nLinkUpdateMode;
@@ -134,11 +154,13 @@ public:
{
aContentConfig.Commit();
aLayoutConfig.Commit();
+ aGridConfig.Commit();
}
void SetModified()
{
aContentConfig.SetModified();
aLayoutConfig.SetModified();
+ aGridConfig.SetModified();
}
void SetUpdateLinkMode(sal_Int32 nSet) {nLinkUpdateMode = nSet; SetModified();}