[Libreoffice-commits] core.git: cui/source include/unotools sw/source unotools/source
Vitaliy Anderson
vanderson at smartru.com
Fri Jan 27 07:36:20 UTC 2017
cui/source/options/optgdlg.cxx | 2
include/unotools/compatibility.hxx | 243 +++++----
sw/source/core/doc/DocumentSettingManager.cxx | 24
sw/source/ui/config/optcomp.cxx | 338 ++++--------
unotools/source/config/compatibility.cxx | 697 ++++++--------------------
5 files changed, 444 insertions(+), 860 deletions(-)
New commits:
commit 91ccb4dbf7cbe7e684c7a8183863e597d7205e57
Author: Vitaliy Anderson <vanderson at smartru.com>
Date: Thu Jan 19 02:09:04 2017 -0800
Compatibility options refactoring. Part 1
It relate to reduce the nubmer of copy-paste the same code
and simplify adding compability options.
Also using enum class instead enum can eliminate to occurrence
an error relate to access to out of range an array.
Change-Id: I07b862aac5f88da4a98e2273cb14daa09e70eacb
Reviewed-on: https://gerrit.libreoffice.org/33543
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/cui/source/options/optgdlg.cxx b/cui/source/options/optgdlg.cxx
index 8f4412a..f8244f5 100644
--- a/cui/source/options/optgdlg.cxx
+++ b/cui/source/options/optgdlg.cxx
@@ -1426,7 +1426,7 @@ bool OfaLanguagesTabPage::FillItemSet( SfxItemSet* rSet )
SvtScriptType nNewType = SvtLanguageOptions::GetScriptTypeOfLanguage( eNewLocale );
bool bNewCJK = bool( nNewType & SvtScriptType::ASIAN );
SvtCompatibilityOptions aCompatOpts;
- aCompatOpts.SetDefault( COMPATIBILITY_PROPERTYNAME_EXPANDWORDSPACE, !bNewCJK );
+ aCompatOpts.SetDefault( SvtCompatibilityEntry::Index::ExpandWordSpace, !bNewCJK );
}
if(m_pDecimalSeparatorCB->IsValueChangedFromSaved())
diff --git a/include/unotools/compatibility.hxx b/include/unotools/compatibility.hxx
index 551627b..8d18092 100644
--- a/include/unotools/compatibility.hxx
+++ b/include/unotools/compatibility.hxx
@@ -19,54 +19,152 @@
#ifndef INCLUDED_UNOTOOLS_COMPATIBILITY_HXX
#define INCLUDED_UNOTOOLS_COMPATIBILITY_HXX
-#include <unotools/unotoolsdllapi.h>
#include <sal/types.h>
#include <osl/mutex.hxx>
#include <com/sun/star/uno/Sequence.h>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <unotools/options.hxx>
+#include <unotools/unotoolsdllapi.h>
+#include <rtl/ustring.hxx>
#include <memory>
-enum CompatibilityOptions
-{
- COPT_USE_PRINTERDEVICE = 0,
- COPT_ADD_SPACING,
- COPT_ADD_SPACING_AT_PAGES,
- COPT_USE_OUR_TABSTOPS,
- COPT_NO_EXTLEADING,
- COPT_USE_LINESPACING,
- COPT_ADD_TABLESPACING,
- COPT_USE_OBJECTPOSITIONING,
- COPT_USE_OUR_TEXTWRAPPING,
- COPT_CONSIDER_WRAPPINGSTYLE,
- COPT_EXPAND_WORDSPACE,
- COPT_PROTECT_FORM,
- COPT_MS_WORD_COMP_TRAILING_BLANKS
-};
-
/*-************************************************************************************************************
- @descr The method GetList() returns a list of property values.
- Use follow defines to separate values by names.
+ @descr Struct to hold information about one compatibility entry
*//*-*************************************************************************************************************/
-#define COMPATIBILITY_PROPERTYNAME_NAME "Name"
-#define COMPATIBILITY_PROPERTYNAME_MODULE "Module"
-#define COMPATIBILITY_PROPERTYNAME_USEPRTMETRICS "UsePrinterMetrics"
-#define COMPATIBILITY_PROPERTYNAME_ADDSPACING "AddSpacing"
-#define COMPATIBILITY_PROPERTYNAME_ADDSPACINGATPAGES "AddSpacingAtPages"
-#define COMPATIBILITY_PROPERTYNAME_USEOURTABSTOPS "UseOurTabStopFormat"
-#define COMPATIBILITY_PROPERTYNAME_NOEXTLEADING "NoExternalLeading"
-#define COMPATIBILITY_PROPERTYNAME_USELINESPACING "UseLineSpacing"
-#define COMPATIBILITY_PROPERTYNAME_ADDTABLESPACING "AddTableSpacing"
-#define COMPATIBILITY_PROPERTYNAME_USEOBJECTPOSITIONING "UseObjectPositioning"
-#define COMPATIBILITY_PROPERTYNAME_USEOURTEXTWRAPPING "UseOurTextWrapping"
-#define COMPATIBILITY_PROPERTYNAME_CONSIDERWRAPPINGSTYLE "ConsiderWrappingStyle"
-#define COMPATIBILITY_PROPERTYNAME_EXPANDWORDSPACE "ExpandWordSpace"
-#define COMPATIBILITY_PROPERTYNAME_PROTECTFORM "ProtectForm"
-#define COMPATIBILITY_PROPERTYNAME_MSWORDTRAILINGBLANKS "MsWordCompTrailingBlanks"
-
-#define COMPATIBILITY_DEFAULT_NAME "_default"
-
-// forward declarations
+class UNOTOOLS_DLLPUBLIC SvtCompatibilityEntry
+{
+ public:
+ /*-************************************************************************************************************
+ @descr The method SvtCompatibilityOptions::GetList() returns a list of property values.
+ Use follow enum class to separate values by names.
+ Sync it with sPropertyName in SvtCompatibilityEntry::getName()
+ *//*-*************************************************************************************************************/
+ enum class Index
+ {
+ /* Should be in the start. Do not remove it. */
+ Name,
+ Module,
+
+ /* Editable list of compatibility options. */
+ UsePrtMetrics,
+ AddSpacing,
+ AddSpacingAtPages,
+ UseOurTabStops,
+ NoExtLeading,
+ UseLineSpacing,
+ AddTableSpacing,
+ UseObjectPositioning,
+ UseOurTextWrapping,
+ ConsiderWrappingStyle,
+ ExpandWordSpace,
+ ProtectForm,
+ MsWordTrailingBlanks,
+
+ /* Should be at the end. Do not remove it. */
+ INVALID
+ };
+
+ SvtCompatibilityEntry();
+ ~SvtCompatibilityEntry();
+
+ static OUString getName( const Index rIdx );
+
+ static inline OUString getUserEntryName()
+ {
+ return OUString( "_user" );
+ }
+
+ static inline OUString getDefaultEntryName()
+ {
+ return OUString( "_default" );
+ }
+
+ static inline Index getIndex( const OUString& rName )
+ {
+ for ( int i = static_cast<int>(Index::Name); i < static_cast<int>(Index::INVALID); ++i )
+ if ( getName( Index(i) ) == rName )
+ return Index(i);
+
+ /* SvtCompatibilityEntry::getIndex() Undeclared compatibility property name */
+ assert(false);
+
+ return Index::INVALID;
+ }
+
+ static inline size_t getElementCount()
+ {
+ return static_cast<size_t>(Index::INVALID);
+ }
+
+ inline css::uno::Any getValue( const Index rIdx ) const
+ {
+ if ( static_cast<size_t>(rIdx) < getElementCount() )
+ {
+ return m_aPropertyValue[ static_cast<int>(rIdx) ];
+ } else
+ {
+ /* Wrong index. */
+ assert( false );
+ return css::uno::Any();
+ }
+ }
+
+ template<typename T>
+ inline T getValue( const Index rIdx ) const
+ {
+ T aValue = T();
+
+ if ( static_cast<size_t>(rIdx) < getElementCount() )
+ {
+ m_aPropertyValue[ static_cast<int>(rIdx) ] >>= aValue;
+ } else
+ {
+ /* Wrong index. */
+ assert( false );
+ }
+
+ return aValue;
+ }
+
+ inline void setValue( const Index rIdx, css::uno::Any& rValue )
+ {
+ if ( static_cast<size_t>(rIdx) < getElementCount() )
+ {
+ m_aPropertyValue[ static_cast<int>(rIdx) ] = rValue;
+ } else
+ {
+ /* Wrong index. */
+ assert( false );
+ }
+ }
+
+ template<typename T>
+ inline void setValue( const Index rIdx, T rValue )
+ {
+ if ( static_cast<size_t>(rIdx) < getElementCount() )
+ {
+ m_aPropertyValue[ static_cast<int>(rIdx) ] = css::uno::Any(rValue);
+ } else
+ {
+ /* Wrong index. */
+ assert( false );
+ }
+ }
+
+ inline bool isDefaultEntry() const
+ {
+ return m_bDefaultEntry;
+ }
+
+ inline void setDefaultEntry( bool rValue )
+ {
+ m_bDefaultEntry = rValue;
+ }
+
+ private:
+ std::vector<css::uno::Any> m_aPropertyValue;
+ bool m_bDefaultEntry;
+};
/*-************************************************************************************************************
@short forward declaration to our private date container implementation
@@ -74,7 +172,6 @@ enum CompatibilityOptions
You can create the container if it is necessary. The class which use these mechanism
is faster and smaller then a complete implementation!
*//*-*************************************************************************************************************/
-
class SvtCompatibilityOptions_Impl;
/*-************************************************************************************************************
@@ -82,23 +179,30 @@ class SvtCompatibilityOptions_Impl;
@descr Make it possible to configure dynamic menu structures of menus like "new" or "wizard".
@devstatus ready to use
*//*-*************************************************************************************************************/
-
class UNOTOOLS_DLLPUBLIC SvtCompatibilityOptions: public utl::detail::Options
{
public:
- SvtCompatibilityOptions();
+ SvtCompatibilityOptions();
virtual ~SvtCompatibilityOptions() override;
- // interface
+ /*-****************************************************************************************************
+ @short append a new item
+ @descr
+
+ @seealso method Clear()
+
+ @param "aItem" SvtCompatibilityEntry
+ *//*-*****************************************************************************************************/
+ void AppendItem( const SvtCompatibilityEntry& aItem );
/*-****************************************************************************************************
@short clear complete specified list
@descr Call this methods to clear the whole list.
*//*-*****************************************************************************************************/
-
void Clear();
- void SetDefault( const OUString & sName, bool bValue );
+ void SetDefault( SvtCompatibilityEntry::Index rIdx, bool rValue );
+ bool GetDefault( SvtCompatibilityEntry::Index rIdx ) const;
/*-****************************************************************************************************
@short return complete specified list
@@ -108,49 +212,10 @@ class UNOTOOLS_DLLPUBLIC SvtCompatibilityOptions: public utl::detail::Options
@onerror We return an empty list.
*//*-*****************************************************************************************************/
-
css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > > GetList() const;
- /*-****************************************************************************************************
- @short append a new item
- @descr
-
- @seealso method Clear()
-
- @param "sName" Name
- @param "sModule" Module
- *//*-*****************************************************************************************************/
-
- void AppendItem( const OUString& sName,
- const OUString& sModule,
- bool bUsePrtMetrics,
- bool bAddSpacing,
- bool bAddSpacingAtPages,
- bool bUseOurTabStops,
- bool bNoExtLeading,
- bool bUseLineSpacing,
- bool bAddTableSpacing,
- bool bUseObjectPositioning,
- bool bUseOurTextWrapping,
- bool bConsiderWrappingStyle,
- bool bExpandWordSpace,
- bool bProtectForm,
- bool bMsWordCompTrailingBlanks );
-
- bool IsUsePrtDevice() const;
- bool IsAddSpacing() const;
- bool IsAddSpacingAtPages() const;
- bool IsUseOurTabStops() const;
- bool IsNoExtLeading() const;
- bool IsUseLineSpacing() const;
- bool IsAddTableSpacing() const;
- bool IsUseObjectPositioning() const;
- bool IsUseOurTextWrapping() const;
- bool IsConsiderWrappingStyle() const;
- bool IsExpandWordSpace() const;
- bool IsMsWordCompTrailingBlanks() const;
-
private:
+ std::shared_ptr<SvtCompatibilityOptions_Impl> m_pImpl;
/*-****************************************************************************************************
@short return a reference to a static mutex
@@ -159,12 +224,8 @@ class UNOTOOLS_DLLPUBLIC SvtCompatibilityOptions: public utl::detail::Options
We create a static mutex only for one ime and use at different times.
@return A reference to a static mutex member.
*//*-*****************************************************************************************************/
-
- UNOTOOLS_DLLPRIVATE static ::osl::Mutex& GetOwnStaticMutex();
-
- std::shared_ptr<SvtCompatibilityOptions_Impl> m_pImpl;
-
-}; // class SvtCompatibilityOptions
+ UNOTOOLS_DLLPRIVATE static osl::Mutex& GetOwnStaticMutex();
+};
#endif // INCLUDED_UNOTOOLS_COMPATIBILITY_HXX
diff --git a/sw/source/core/doc/DocumentSettingManager.cxx b/sw/source/core/doc/DocumentSettingManager.cxx
index 22a2581..ec0eb82 100644
--- a/sw/source/core/doc/DocumentSettingManager.cxx
+++ b/sw/source/core/doc/DocumentSettingManager.cxx
@@ -98,18 +98,18 @@ sw::DocumentSettingManager::DocumentSettingManager(SwDoc &rDoc)
if (!utl::ConfigManager::IsAvoidConfig())
{
const SvtCompatibilityOptions aOptions;
- mbParaSpaceMax = aOptions.IsAddSpacing();
- mbParaSpaceMaxAtPages = aOptions.IsAddSpacingAtPages();
- mbTabCompat = !aOptions.IsUseOurTabStops();
- mbUseVirtualDevice = !aOptions.IsUsePrtDevice();
- mbAddExternalLeading = !aOptions.IsNoExtLeading();
- mbOldLineSpacing = aOptions.IsUseLineSpacing();
- mbAddParaSpacingToTableCells = aOptions.IsAddTableSpacing();
- mbUseFormerObjectPos = aOptions.IsUseObjectPositioning();
- mbUseFormerTextWrapping = aOptions.IsUseOurTextWrapping();
- mbConsiderWrapOnObjPos = aOptions.IsConsiderWrappingStyle();
- mbDoNotJustifyLinesWithManualBreak = !aOptions.IsExpandWordSpace();
- mbMsWordCompTrailingBlanks = aOptions.IsMsWordCompTrailingBlanks();
+ mbParaSpaceMax = aOptions.GetDefault( SvtCompatibilityEntry::Index::AddSpacing );
+ mbParaSpaceMaxAtPages = aOptions.GetDefault( SvtCompatibilityEntry::Index::AddSpacingAtPages );
+ mbTabCompat = !aOptions.GetDefault( SvtCompatibilityEntry::Index::UseOurTabStops );
+ mbUseVirtualDevice = !aOptions.GetDefault( SvtCompatibilityEntry::Index::UsePrtMetrics );
+ mbAddExternalLeading = !aOptions.GetDefault( SvtCompatibilityEntry::Index::NoExtLeading );
+ mbOldLineSpacing = aOptions.GetDefault( SvtCompatibilityEntry::Index::UseLineSpacing );
+ mbAddParaSpacingToTableCells = aOptions.GetDefault( SvtCompatibilityEntry::Index::AddTableSpacing );
+ mbUseFormerObjectPos = aOptions.GetDefault( SvtCompatibilityEntry::Index::UseObjectPositioning );
+ mbUseFormerTextWrapping = aOptions.GetDefault( SvtCompatibilityEntry::Index::UseOurTextWrapping );
+ mbConsiderWrapOnObjPos = aOptions.GetDefault( SvtCompatibilityEntry::Index::ConsiderWrappingStyle );
+ mbDoNotJustifyLinesWithManualBreak = !aOptions.GetDefault( SvtCompatibilityEntry::Index::ExpandWordSpace );
+ mbMsWordCompTrailingBlanks = aOptions.GetDefault( SvtCompatibilityEntry::Index::MsWordTrailingBlanks );
}
else
{
diff --git a/sw/source/ui/config/optcomp.cxx b/sw/source/ui/config/optcomp.cxx
index 69e54a3..59d7143 100644
--- a/sw/source/ui/config/optcomp.cxx
+++ b/sw/source/ui/config/optcomp.cxx
@@ -41,60 +41,15 @@ using namespace ::com::sun::star::document;
using namespace ::com::sun::star::uno;
using namespace ::std;
-struct CompatibilityItem
-{
- OUString m_sName;
- OUString m_sModule;
- bool m_bUsePrtMetrics;
- bool m_bAddSpacing;
- bool m_bAddSpacingAtPages;
- bool m_bUseOurTabStops;
- bool m_bNoExtLeading;
- bool m_bUseLineSpacing;
- bool m_bAddTableSpacing;
- bool m_bUseObjPos;
- bool m_bUseOurTextWrapping;
- bool m_bConsiderWrappingStyle;
- bool m_bExpandWordSpace;
- bool m_bProtectForm;
- bool m_bMsWordCompTrailingBlanks;
- bool m_bIsDefault;
-
- CompatibilityItem( const OUString& _rName, const OUString& _rModule,
- bool _bUsePrtMetrics, bool _bAddSpacing, bool _bAddSpacingAtPages,
- bool _bUseOurTabStops, bool _bNoExtLeading, bool _bUseLineSpacing,
- bool _bAddTableSpacing, bool _bUseObjPos, bool _bUseOurTextWrapping,
- bool _bConsiderWrappingStyle, bool _bExpandWordSpace, bool _bProtectForm,
- bool _bMsWordCompTrailingBlanks, bool _bIsDefault ) :
-
- m_sName ( _rName ),
- m_sModule ( _rModule ),
- m_bUsePrtMetrics ( _bUsePrtMetrics ),
- m_bAddSpacing ( _bAddSpacing ),
- m_bAddSpacingAtPages ( _bAddSpacingAtPages ),
- m_bUseOurTabStops ( _bUseOurTabStops ),
- m_bNoExtLeading ( _bNoExtLeading ),
- m_bUseLineSpacing ( _bUseLineSpacing ),
- m_bAddTableSpacing ( _bAddTableSpacing ),
- m_bUseObjPos ( _bUseObjPos ),
- m_bUseOurTextWrapping ( _bUseOurTextWrapping ),
- m_bConsiderWrappingStyle( _bConsiderWrappingStyle ),
- m_bExpandWordSpace ( _bExpandWordSpace ),
- m_bProtectForm ( _bProtectForm),
- m_bMsWordCompTrailingBlanks( _bMsWordCompTrailingBlanks),
- m_bIsDefault ( _bIsDefault ) {}
-};
-
struct SwCompatibilityOptPage_Impl
{
- typedef vector< CompatibilityItem > SwCompatibilityItemList;
+ typedef vector< SvtCompatibilityEntry > SwCompatibilityItemList;
- SwCompatibilityItemList m_aList;
+ SwCompatibilityItemList m_aList;
};
SwCompatibilityOptPage::SwCompatibilityOptPage(vcl::Window* pParent, const SfxItemSet& rSet)
- : SfxTabPage(pParent, "OptCompatPage",
- "modules/swriter/ui/optcompatpage.ui", &rSet)
+ : SfxTabPage(pParent, "OptCompatPage", "modules/swriter/ui/optcompatpage.ui", &rSet)
, m_pWrtShell(nullptr)
, m_pImpl(new SwCompatibilityOptPage_Impl)
, m_nSavedOptions(0)
@@ -104,15 +59,18 @@ SwCompatibilityOptPage::SwCompatibilityOptPage(vcl::Window* pParent, const SfxIt
get(m_pOptionsLB, "options");
get(m_pDefaultPB, "default");
- for (sal_Int32 nId = COPT_USE_PRINTERDEVICE; nId <= COPT_MS_WORD_COMP_TRAILING_BLANKS; ++nId)
+ for ( int i = (static_cast<int>(SvtCompatibilityEntry::Index::Module) + 1); i < static_cast<int>(SvtCompatibilityEntry::Index::INVALID); ++i )
{
- const OUString sEntry = m_pFormattingLB->GetEntry(nId);
+ int nCoptIdx = i - 2; /* Do not consider "Name" & "Module" indexes */
+
+ const OUString sEntry = m_pFormattingLB->GetEntry( nCoptIdx );
SvTreeListEntry* pEntry = m_pOptionsLB->SvTreeListBox::InsertEntry( sEntry );
if ( pEntry )
{
m_pOptionsLB->SetCheckButtonState( pEntry, SvButtonState::Unchecked );
}
}
+
m_sUserEntry = m_pFormattingLB->GetEntry(m_pFormattingLB->GetEntryCount()-1);
m_pFormattingLB->Clear();
@@ -227,21 +185,10 @@ void SwCompatibilityOptPage::InitControls( const SfxItemSet& rSet )
// loading file formats
Sequence< Sequence< PropertyValue > > aList = m_aConfigItem.GetList();
- OUString sName;
- OUString sModule;
- bool bUsePrtMetrics = false;
- bool bAddSpacing = false;
- bool bAddSpacingAtPages = false;
- bool bUseOurTabStops = false;
- bool bNoExtLeading = false;
- bool bUseLineSpacing = false;
- bool bAddTableSpacing = false;
- bool bUseObjPos = false;
- bool bUseOurTextWrapping = false;
- bool bConsiderWrappingStyle = false;
- bool bExpandWordSpace = false;
- bool bProtectForm = false;
- bool bMsWordCompTrailingBlanks = false;
+
+ SvtCompatibilityEntry aEntry;
+ aEntry.setValue<bool>( SvtCompatibilityEntry::Index::ExpandWordSpace, false );
+
const sal_Int32 nCount = aList.getLength();
for ( sal_Int32 i = 0; i < nCount; ++i )
{
@@ -250,73 +197,51 @@ void SwCompatibilityOptPage::InitControls( const SfxItemSet& rSet )
for ( sal_Int32 j = 0; j < nEntries; j++ )
{
PropertyValue aValue = rEntry[j];
- if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_NAME )
- aValue.Value >>= sName;
- else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_MODULE )
- aValue.Value >>= sModule;
- else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_USEPRTMETRICS )
- aValue.Value >>= bUsePrtMetrics;
- else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_ADDSPACING )
- aValue.Value >>= bAddSpacing;
- else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_ADDSPACINGATPAGES )
- aValue.Value >>= bAddSpacingAtPages;
- else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_USEOURTABSTOPS )
- aValue.Value >>= bUseOurTabStops;
- else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_NOEXTLEADING )
- aValue.Value >>= bNoExtLeading;
- else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_USELINESPACING )
- aValue.Value >>= bUseLineSpacing;
- else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_ADDTABLESPACING )
- aValue.Value >>= bAddTableSpacing;
- else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_USEOBJECTPOSITIONING )
- aValue.Value >>= bUseObjPos;
- else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_USEOURTEXTWRAPPING )
- aValue.Value >>= bUseOurTextWrapping;
- else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_CONSIDERWRAPPINGSTYLE )
- aValue.Value >>= bConsiderWrappingStyle;
- else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_EXPANDWORDSPACE )
- aValue.Value >>= bExpandWordSpace;
- else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_PROTECTFORM )
- aValue.Value >>= bProtectForm;
- else if ( aValue.Name == COMPATIBILITY_PROPERTYNAME_MSWORDTRAILINGBLANKS )
- aValue.Value >>= bMsWordCompTrailingBlanks;
+ aEntry.setValue( SvtCompatibilityEntry::getIndex(aValue.Name), aValue.Value );
}
- const bool bIsUserEntry = sName == "_user";
- const bool bIsDefaultEntry = sName == COMPATIBILITY_DEFAULT_NAME;
+ const OUString sEntryName = aEntry.getValue<OUString>( SvtCompatibilityEntry::Index::Name );
+
+ const bool bIsUserEntry = ( sEntryName == SvtCompatibilityEntry::getUserEntryName() );
+ const bool bIsDefaultEntry = ( sEntryName == SvtCompatibilityEntry::getDefaultEntryName() );
+
+ aEntry.setDefaultEntry( bIsDefaultEntry );
- CompatibilityItem aItem(
- sName, sModule, bUsePrtMetrics, bAddSpacing,
- bAddSpacingAtPages, bUseOurTabStops, bNoExtLeading,
- bUseLineSpacing, bAddTableSpacing, bUseObjPos,
- bUseOurTextWrapping, bConsiderWrappingStyle, bExpandWordSpace,
- bProtectForm, bMsWordCompTrailingBlanks, bIsDefaultEntry );
- m_pImpl->m_aList.push_back( aItem );
+ m_pImpl->m_aList.push_back( aEntry );
- if ( aItem.m_bIsDefault )
+ if ( aEntry.isDefaultEntry() )
continue;
OUString sNewEntry;
if ( bIsUserEntry )
sNewEntry = m_sUserEntry;
- else if ( pObjShell && !sName.isEmpty() )
+
+ else if ( pObjShell && !sEntryName.isEmpty() )
{
SfxFilterContainer* pFacCont = pObjShell->GetFactory().GetFilterContainer();
- std::shared_ptr<const SfxFilter> pFilter = pFacCont->GetFilter4FilterName( sName );
+ std::shared_ptr<const SfxFilter> pFilter = pFacCont->GetFilter4FilterName( sEntryName );
if ( pFilter )
sNewEntry = pFilter->GetUIName();
}
if ( sNewEntry.isEmpty() )
- sNewEntry = sName;
+ sNewEntry = sEntryName;
const sal_Int32 nPos = m_pFormattingLB->InsertEntry( sNewEntry );
sal_uLong nOptions = convertBools2Ulong_Impl(
- bUsePrtMetrics, bAddSpacing, bAddSpacingAtPages,
- bUseOurTabStops, bNoExtLeading, bUseLineSpacing,
- bAddTableSpacing, bUseObjPos, bUseOurTextWrapping,
- bConsiderWrappingStyle, bExpandWordSpace, bProtectForm,
- bMsWordCompTrailingBlanks );
+ aEntry.getValue<bool>( SvtCompatibilityEntry::Index::UsePrtMetrics ),
+ aEntry.getValue<bool>( SvtCompatibilityEntry::Index::AddSpacing ),
+ aEntry.getValue<bool>( SvtCompatibilityEntry::Index::AddSpacingAtPages ),
+ aEntry.getValue<bool>( SvtCompatibilityEntry::Index::UseOurTabStops ),
+ aEntry.getValue<bool>( SvtCompatibilityEntry::Index::NoExtLeading ),
+ aEntry.getValue<bool>( SvtCompatibilityEntry::Index::UseLineSpacing ),
+ aEntry.getValue<bool>( SvtCompatibilityEntry::Index::AddTableSpacing ),
+ aEntry.getValue<bool>( SvtCompatibilityEntry::Index::UseObjectPositioning ),
+ aEntry.getValue<bool>( SvtCompatibilityEntry::Index::UseOurTextWrapping ),
+ aEntry.getValue<bool>( SvtCompatibilityEntry::Index::ConsiderWrappingStyle ),
+ aEntry.getValue<bool>( SvtCompatibilityEntry::Index::ExpandWordSpace ),
+ aEntry.getValue<bool>( SvtCompatibilityEntry::Index::ProtectForm ),
+ aEntry.getValue<bool>( SvtCompatibilityEntry::Index::MsWordTrailingBlanks ) );
m_pFormattingLB->SetEntryData( nPos, reinterpret_cast<void*>((sal_IntPtr)nOptions) );
}
@@ -336,36 +261,18 @@ IMPL_LINK_NOARG(SwCompatibilityOptPage, UseAsDefaultHdl, Button*, void)
"modules/swriter/ui/querydefaultcompatdialog.ui");
if (aQuery->Execute() == RET_YES)
{
- for ( vector< CompatibilityItem >::iterator pItem = m_pImpl->m_aList.begin();
+ for ( vector< SvtCompatibilityEntry >::iterator pItem = m_pImpl->m_aList.begin();
pItem != m_pImpl->m_aList.end(); ++pItem )
{
- if ( pItem->m_bIsDefault )
+ if ( pItem->isDefaultEntry() )
{
const sal_Int32 nCount = m_pOptionsLB->GetEntryCount();
for ( sal_Int32 i = 0; i < nCount; ++i )
{
bool bChecked = m_pOptionsLB->IsChecked(static_cast< sal_uLong >( i ));
- CompatibilityOptions eOption = static_cast< CompatibilityOptions >(i);
- switch ( eOption )
- {
- case COPT_USE_PRINTERDEVICE : pItem->m_bUsePrtMetrics = bChecked; break;
- case COPT_ADD_SPACING : pItem->m_bAddSpacing = bChecked; break;
- case COPT_ADD_SPACING_AT_PAGES : pItem->m_bAddSpacingAtPages = bChecked; break;
- case COPT_USE_OUR_TABSTOPS : pItem->m_bUseOurTabStops = bChecked; break;
- case COPT_NO_EXTLEADING : pItem->m_bNoExtLeading = bChecked; break;
- case COPT_USE_LINESPACING : pItem->m_bUseLineSpacing = bChecked; break;
- case COPT_ADD_TABLESPACING : pItem->m_bAddTableSpacing = bChecked; break;
- case COPT_USE_OBJECTPOSITIONING: pItem->m_bUseObjPos = bChecked; break;
- case COPT_USE_OUR_TEXTWRAPPING: pItem->m_bUseOurTextWrapping = bChecked; break;
- case COPT_CONSIDER_WRAPPINGSTYLE: pItem->m_bConsiderWrappingStyle = bChecked; break;
- case COPT_EXPAND_WORDSPACE: pItem->m_bExpandWordSpace = bChecked; break;
- case COPT_PROTECT_FORM: pItem->m_bProtectForm = bChecked; break;
- case COPT_MS_WORD_COMP_TRAILING_BLANKS: pItem->m_bMsWordCompTrailingBlanks = bChecked; break;
- default:
- {
- OSL_FAIL("SwCompatibilityOptPage::UseAsDefaultHdl(): wrong option" );
- }
- }
+
+ int nCoptIdx = i + 2; /* Consider "Name" & "Module" indexes */
+ pItem->setValue<bool>( SvtCompatibilityEntry::Index(nCoptIdx), bChecked );
}
break;
}
@@ -394,19 +301,19 @@ sal_uLong SwCompatibilityOptPage::GetDocumentOptions() const
{
const IDocumentSettingAccess& rIDocumentSettingAccess = m_pWrtShell->getIDocumentSettingAccess();
nRet = convertBools2Ulong_Impl(
- !rIDocumentSettingAccess.get(DocumentSettingId::USE_VIRTUAL_DEVICE),
- rIDocumentSettingAccess.get(DocumentSettingId::PARA_SPACE_MAX),
- rIDocumentSettingAccess.get(DocumentSettingId::PARA_SPACE_MAX_AT_PAGES),
- !rIDocumentSettingAccess.get(DocumentSettingId::TAB_COMPAT),
- !rIDocumentSettingAccess.get(DocumentSettingId::ADD_EXT_LEADING),
- rIDocumentSettingAccess.get(DocumentSettingId::OLD_LINE_SPACING),
- rIDocumentSettingAccess.get(DocumentSettingId::ADD_PARA_SPACING_TO_TABLE_CELLS),
- rIDocumentSettingAccess.get(DocumentSettingId::USE_FORMER_OBJECT_POS),
- rIDocumentSettingAccess.get(DocumentSettingId::USE_FORMER_TEXT_WRAPPING),
- rIDocumentSettingAccess.get(DocumentSettingId::CONSIDER_WRAP_ON_OBJECT_POSITION),
- !rIDocumentSettingAccess.get(DocumentSettingId::DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK),
- rIDocumentSettingAccess.get(DocumentSettingId::PROTECT_FORM),
- rIDocumentSettingAccess.get(DocumentSettingId::MS_WORD_COMP_TRAILING_BLANKS));
+ !rIDocumentSettingAccess.get( DocumentSettingId::USE_VIRTUAL_DEVICE ),
+ rIDocumentSettingAccess.get( DocumentSettingId::PARA_SPACE_MAX ),
+ rIDocumentSettingAccess.get( DocumentSettingId::PARA_SPACE_MAX_AT_PAGES ),
+ !rIDocumentSettingAccess.get( DocumentSettingId::TAB_COMPAT ),
+ !rIDocumentSettingAccess.get( DocumentSettingId::ADD_EXT_LEADING ),
+ rIDocumentSettingAccess.get( DocumentSettingId::OLD_LINE_SPACING ),
+ rIDocumentSettingAccess.get( DocumentSettingId::ADD_PARA_SPACING_TO_TABLE_CELLS ),
+ rIDocumentSettingAccess.get( DocumentSettingId::USE_FORMER_OBJECT_POS ),
+ rIDocumentSettingAccess.get( DocumentSettingId::USE_FORMER_TEXT_WRAPPING ),
+ rIDocumentSettingAccess.get( DocumentSettingId::CONSIDER_WRAP_ON_OBJECT_POSITION ),
+ !rIDocumentSettingAccess.get( DocumentSettingId::DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK ),
+ rIDocumentSettingAccess.get( DocumentSettingId::PROTECT_FORM ),
+ rIDocumentSettingAccess.get( DocumentSettingId::MS_WORD_COMP_TRAILING_BLANKS ) );
}
return nRet;
}
@@ -414,16 +321,9 @@ sal_uLong SwCompatibilityOptPage::GetDocumentOptions() const
void SwCompatibilityOptPage::WriteOptions()
{
m_aConfigItem.Clear();
- for ( vector< CompatibilityItem >::const_iterator pItem = m_pImpl->m_aList.begin();
+ for ( vector< SvtCompatibilityEntry >::const_iterator pItem = m_pImpl->m_aList.begin();
pItem != m_pImpl->m_aList.end(); ++pItem )
- m_aConfigItem.AppendItem(
- pItem->m_sName, pItem->m_sModule, pItem->m_bUsePrtMetrics, pItem->m_bAddSpacing,
- pItem->m_bAddSpacingAtPages, pItem->m_bUseOurTabStops,
- pItem->m_bNoExtLeading, pItem->m_bUseLineSpacing,
- pItem->m_bAddTableSpacing, pItem->m_bUseObjPos,
- pItem->m_bUseOurTextWrapping, pItem->m_bConsiderWrappingStyle,
- pItem->m_bExpandWordSpace, pItem->m_bProtectForm,
- pItem->m_bMsWordCompTrailingBlanks );
+ m_aConfigItem.AppendItem(*pItem);
}
VclPtr<SfxTabPage> SwCompatibilityOptPage::Create( vcl::Window* pParent, const SfxItemSet* rAttrSet )
@@ -440,83 +340,75 @@ bool SwCompatibilityOptPage::FillItemSet( SfxItemSet* )
const sal_uLong nCount = m_pOptionsLB->GetEntryCount();
OSL_ENSURE( nCount <= 32, "SwCompatibilityOptPage::Reset(): entry overflow" );
- bool bSetParaSpaceMax = false;
-
for ( sal_uLong i = 0; i < nCount; ++i )
{
- CompatibilityOptions nOption = static_cast< CompatibilityOptions >(i);
bool bChecked = m_pOptionsLB->IsChecked(i);
bool bSavedChecked = ( ( nSavedOptions & 0x00000001 ) == 0x00000001 );
if ( bChecked != bSavedChecked )
{
- if ( COPT_USE_PRINTERDEVICE == nOption )
- {
- m_pWrtShell->SetUseVirDev( !bChecked );
- bModified = true;
- }
- else if ( ( COPT_ADD_SPACING == nOption || COPT_ADD_SPACING_AT_PAGES == nOption ) && !bSetParaSpaceMax )
- bSetParaSpaceMax = true;
- else if ( COPT_USE_OUR_TABSTOPS == nOption )
- {
- m_pWrtShell->SetTabCompat( !bChecked );
- bModified = true;
- }
- else if ( COPT_NO_EXTLEADING == nOption )
- {
- m_pWrtShell->SetAddExtLeading( !bChecked );
- bModified = true;
- }
- else if ( COPT_USE_LINESPACING == nOption )
- {
- m_pWrtShell->SetUseFormerLineSpacing( bChecked );
- bModified = true;
- }
- else if ( COPT_ADD_TABLESPACING == nOption )
- {
- m_pWrtShell->SetAddParaSpacingToTableCells( bChecked );
- bModified = true;
- }
- else if ( COPT_USE_OBJECTPOSITIONING == nOption )
- {
- m_pWrtShell->SetUseFormerObjectPositioning( bChecked );
- bModified = true;
- }
- else if ( COPT_USE_OUR_TEXTWRAPPING == nOption )
+ int nCoptIdx = i + 2; /* Consider "Name" & "Module" indexes */
+ switch ( SvtCompatibilityEntry::Index(nCoptIdx) )
{
- m_pWrtShell->SetUseFormerTextWrapping( bChecked );
- bModified = true;
- }
- else if ( COPT_CONSIDER_WRAPPINGSTYLE == nOption )
- {
- m_pWrtShell->SetConsiderWrapOnObjPos( bChecked );
- bModified = true;
- }
- else if ( COPT_EXPAND_WORDSPACE == nOption )
- {
- m_pWrtShell->SetDoNotJustifyLinesWithManualBreak( !bChecked );
- bModified = true;
- }
- else if ( COPT_PROTECT_FORM == nOption )
- {
- m_pWrtShell->SetProtectForm( bChecked );
- bModified = true;
- }
- else if ( COPT_MS_WORD_COMP_TRAILING_BLANKS == nOption )
- {
- m_pWrtShell->SetMsWordCompTrailingBlanks( bChecked );
- bModified = true;
+ case SvtCompatibilityEntry::Index::UsePrtMetrics:
+ m_pWrtShell->SetUseVirDev( !bChecked );
+ break;
+
+ case SvtCompatibilityEntry::Index::AddSpacing:
+ m_pWrtShell->SetParaSpaceMax( bChecked );
+ break;
+
+ case SvtCompatibilityEntry::Index::AddSpacingAtPages:
+ m_pWrtShell->SetParaSpaceMaxAtPages( bChecked );
+ break;
+
+ case SvtCompatibilityEntry::Index::UseOurTabStops:
+ m_pWrtShell->SetTabCompat( !bChecked );
+ break;
+
+ case SvtCompatibilityEntry::Index::NoExtLeading:
+ m_pWrtShell->SetAddExtLeading( !bChecked );
+ break;
+
+ case SvtCompatibilityEntry::Index::UseLineSpacing:
+ m_pWrtShell->SetUseFormerLineSpacing( bChecked );
+ break;
+
+ case SvtCompatibilityEntry::Index::AddTableSpacing:
+ m_pWrtShell->SetAddParaSpacingToTableCells( bChecked );
+ break;
+
+ case SvtCompatibilityEntry::Index::UseObjectPositioning:
+ m_pWrtShell->SetUseFormerObjectPositioning( bChecked );
+ break;
+
+ case SvtCompatibilityEntry::Index::UseOurTextWrapping:
+ m_pWrtShell->SetUseFormerTextWrapping( bChecked );
+ break;
+
+ case SvtCompatibilityEntry::Index::ConsiderWrappingStyle:
+ m_pWrtShell->SetConsiderWrapOnObjPos( bChecked );
+ break;
+
+ case SvtCompatibilityEntry::Index::ExpandWordSpace:
+ m_pWrtShell->SetDoNotJustifyLinesWithManualBreak( !bChecked );
+ break;
+
+ case SvtCompatibilityEntry::Index::ProtectForm:
+ m_pWrtShell->SetProtectForm( bChecked );
+ break;
+
+ case SvtCompatibilityEntry::Index::MsWordTrailingBlanks:
+ m_pWrtShell->SetMsWordCompTrailingBlanks( bChecked );
+ break;
+
+ default:
+ break;
}
+ bModified = true;
}
nSavedOptions = nSavedOptions >> 1;
}
-
- if ( bSetParaSpaceMax )
- {
- m_pWrtShell->SetParaSpaceMax( m_pOptionsLB->IsChecked( (sal_uLong)COPT_ADD_SPACING ) );
- m_pWrtShell->SetParaSpaceMaxAtPages( m_pOptionsLB->IsChecked( (sal_uLong)COPT_ADD_SPACING_AT_PAGES ) );
- bModified = true;
- }
}
if ( bModified )
diff --git a/unotools/source/config/compatibility.cxx b/unotools/source/config/compatibility.cxx
index 795f2b7..b1d713e 100644
--- a/unotools/source/config/compatibility.cxx
+++ b/unotools/source/config/compatibility.cxx
@@ -25,13 +25,10 @@
#include <com/sun/star/uno/Any.hxx>
#include <com/sun/star/uno/Sequence.hxx>
-#include <vector>
-
#include "itemholder1.hxx"
#include <algorithm>
-
-// namespaces
+#include <vector>
using namespace ::std;
using namespace ::utl;
@@ -43,196 +40,87 @@ using namespace ::com::sun::star::beans;
#define PATHDELIMITER "/"
#define SETNODE_ALLFILEFORMATS "AllFileFormats"
-#define PROPERTYNAME_NAME COMPATIBILITY_PROPERTYNAME_NAME
-#define PROPERTYNAME_MODULE COMPATIBILITY_PROPERTYNAME_MODULE
-#define PROPERTYNAME_USEPRTMETRICS COMPATIBILITY_PROPERTYNAME_USEPRTMETRICS
-#define PROPERTYNAME_ADDSPACING COMPATIBILITY_PROPERTYNAME_ADDSPACING
-#define PROPERTYNAME_ADDSPACINGATPAGES COMPATIBILITY_PROPERTYNAME_ADDSPACINGATPAGES
-#define PROPERTYNAME_USEOURTABSTOPS COMPATIBILITY_PROPERTYNAME_USEOURTABSTOPS
-#define PROPERTYNAME_NOEXTLEADING COMPATIBILITY_PROPERTYNAME_NOEXTLEADING
-#define PROPERTYNAME_USELINESPACING COMPATIBILITY_PROPERTYNAME_USELINESPACING
-#define PROPERTYNAME_ADDTABLESPACING COMPATIBILITY_PROPERTYNAME_ADDTABLESPACING
-#define PROPERTYNAME_USEOBJPOS COMPATIBILITY_PROPERTYNAME_USEOBJECTPOSITIONING
-#define PROPERTYNAME_USEOURTEXTWRAP COMPATIBILITY_PROPERTYNAME_USEOURTEXTWRAPPING
-#define PROPERTYNAME_CONSIDERWRAPSTYLE COMPATIBILITY_PROPERTYNAME_CONSIDERWRAPPINGSTYLE
-#define PROPERTYNAME_EXPANDWORDSPACE COMPATIBILITY_PROPERTYNAME_EXPANDWORDSPACE
-#define PROPERTYNAME_PROTECTFORM COMPATIBILITY_PROPERTYNAME_PROTECTFORM
-#define PROPERTYNAME_MSWORDTRAILINGBLANKS COMPATIBILITY_PROPERTYNAME_MSWORDTRAILINGBLANKS
-
-#define PROPERTYCOUNT 15
-
-#define OFFSET_NAME 0
-#define OFFSET_MODULE 1
-#define OFFSET_USEPRTMETRICS 2
-#define OFFSET_ADDSPACING 3
-#define OFFSET_ADDSPACINGATPAGES 4
-#define OFFSET_USEOURTABSTOPS 5
-#define OFFSET_NOEXTLEADING 6
-#define OFFSET_USELINESPACING 7
-#define OFFSET_ADDTABLESPACING 8
-#define OFFSET_USEOBJPOS 9
-#define OFFSET_USEOURTEXTWRAPPING 10
-#define OFFSET_CONSIDERWRAPPINGSTYLE 11
-#define OFFSET_EXPANDWORDSPACE 12
-#define OFFSET_PROTECTFORM 13
-#define OFFSET_MSWORDTRAILINGBLANKS 14
-
-// private declarations!
+SvtCompatibilityEntry::SvtCompatibilityEntry()
+ : m_aPropertyValue( SvtCompatibilityEntry::getElementCount() )
+{
+ /* Should be in the start. Do not remove it. */
+ setValue<OUString>( Index::Name, OUString("") );
+ setValue<OUString>( Index::Module, OUString("") );
+
+ /* Editable list of default values. Sync it with the SvtCompatibilityEntry::Index enum class. */
+ setValue<bool>( Index::UsePrtMetrics, false );
+ setValue<bool>( Index::AddSpacing, false );
+ setValue<bool>( Index::AddSpacingAtPages, false );
+ setValue<bool>( Index::UseOurTabStops, false );
+ setValue<bool>( Index::NoExtLeading, false );
+ setValue<bool>( Index::UseLineSpacing, false );
+ setValue<bool>( Index::AddTableSpacing, false );
+ setValue<bool>( Index::UseObjectPositioning, false );
+ setValue<bool>( Index::UseOurTextWrapping, false );
+ setValue<bool>( Index::ConsiderWrappingStyle, false );
+ setValue<bool>( Index::ExpandWordSpace, true );
+ setValue<bool>( Index::ProtectForm, false );
+ setValue<bool>( Index::MsWordTrailingBlanks, false );
+
+ setDefaultEntry( false );
+}
-/*-****************************************************************************************************************
- @descr struct to hold information about one compatibility entry
-****************************************************************************************************************-*/
-struct SvtCompatibilityEntry
+SvtCompatibilityEntry::~SvtCompatibilityEntry()
{
- public:
- SvtCompatibilityEntry() :
- bUsePrtMetrics( false ), bAddSpacing( false ),
- bAddSpacingAtPages( false ), bUseOurTabStops( false ),
- bNoExtLeading( false ), bUseLineSpacing( false ),
- bAddTableSpacing( false ), bUseObjPos( false ),
- bUseOurTextWrapping( false ), bConsiderWrappingStyle( false ),
- bExpandWordSpace( true ), bProtectForm( false ),
- bMsWordCompTrailingBlanks ( false ) {}
-
- SvtCompatibilityEntry(
- const OUString& _rName, const OUString& _rNewModule ) :
- sName( _rName ), sModule( _rNewModule ),
- bUsePrtMetrics( false ), bAddSpacing( false ),
- bAddSpacingAtPages( false ), bUseOurTabStops( false ),
- bNoExtLeading( false ), bUseLineSpacing( false ),
- bAddTableSpacing( false ), bUseObjPos( false ),
- bUseOurTextWrapping( false ), bConsiderWrappingStyle( false ),
- bExpandWordSpace( true ), bProtectForm( false ),
- bMsWordCompTrailingBlanks( false ) {}
-
- inline void SetUsePrtMetrics( bool _bSet ) { bUsePrtMetrics = _bSet; }
- inline void SetAddSpacing( bool _bSet ) { bAddSpacing = _bSet; }
- inline void SetAddSpacingAtPages( bool _bSet ) { bAddSpacingAtPages = _bSet; }
- inline void SetUseOurTabStops( bool _bSet ) { bUseOurTabStops = _bSet; }
- inline void SetNoExtLeading( bool _bSet ) { bNoExtLeading = _bSet; }
- inline void SetUseLineSpacing( bool _bSet ) { bUseLineSpacing = _bSet; }
- inline void SetAddTableSpacing( bool _bSet ) { bAddTableSpacing = _bSet; }
- inline void SetUseObjPos( bool _bSet ) { bUseObjPos = _bSet; }
- inline void SetUseOurTextWrapping( bool _bSet ) { bUseOurTextWrapping = _bSet; }
- inline void SetConsiderWrappingStyle( bool _bSet ) { bConsiderWrappingStyle = _bSet; }
- inline void SetExpandWordSpace( bool _bSet ) { bExpandWordSpace = _bSet; }
- inline void SetProtectForm( bool _bSet ) { bProtectForm = _bSet; }
- inline void SetMsWordCompTrailingBlanks( bool _bSet ) { bMsWordCompTrailingBlanks = _bSet; }
+}
- public:
- OUString sName;
- OUString sModule;
- bool bUsePrtMetrics;
- bool bAddSpacing;
- bool bAddSpacingAtPages;
- bool bUseOurTabStops;
- bool bNoExtLeading;
- bool bUseLineSpacing;
- bool bAddTableSpacing;
- bool bUseObjPos;
- bool bUseOurTextWrapping;
- bool bConsiderWrappingStyle;
- bool bExpandWordSpace;
- bool bProtectForm;
- bool bMsWordCompTrailingBlanks;
-};
+OUString SvtCompatibilityEntry::getName( const Index rIdx )
+{
+ static const char* sPropertyName[] =
+ {
+ /* Should be in the start. Do not remove it. */
+ "Name",
+ "Module",
+
+ /* Editable list of compatibility option names. Sync it with the SvtCompatibilityEntry::Index enum class. */
+ "UsePrinterMetrics",
+ "AddSpacing",
+ "AddSpacingAtPages",
+ "UseOurTabStopFormat",
+ "NoExternalLeading",
+ "UseLineSpacing",
+ "AddTableSpacing",
+ "UseObjectPositioning",
+ "UseOurTextWrapping",
+ "ConsiderWrappingStyle",
+ "ExpandWordSpace",
+ "ProtectForm",
+ "MsWordCompTrailingBlanks"
+ };
+
+ /* Size of sPropertyName array not equal size of the SvtCompatibilityEntry::Index enum class */
+ assert( SAL_N_ELEMENTS(sPropertyName) == static_cast<int>( SvtCompatibilityEntry::getElementCount() ) );
+
+ return OUString::createFromAscii( sPropertyName[ static_cast<int>(rIdx) ] );
+}
/*-****************************************************************************************************************
@descr support simple menu structures and operations on it
****************************************************************************************************************-*/
-class SvtCompatibility
-{
- public:
-
- // append one entry
- void AppendEntry( const SvtCompatibilityEntry& rEntry )
- {
- lEntries.push_back( rEntry );
- }
-
- // the only way to free memory!
- void Clear()
- {
- lEntries.clear();
- }
-
- // convert internal list to external format
- Sequence< Sequence< PropertyValue > > GetList() const
- {
- sal_Int32 nCount = (sal_Int32)lEntries.size();
- sal_Int32 nStep = 0;
- Sequence< PropertyValue > lProperties( PROPERTYCOUNT );
- Sequence< Sequence< PropertyValue > > lResult( nCount );
- const vector< SvtCompatibilityEntry >* pList = &lEntries;
-
- lProperties[ OFFSET_NAME ].Name = PROPERTYNAME_NAME;
- lProperties[ OFFSET_MODULE ].Name = PROPERTYNAME_MODULE;
- lProperties[ OFFSET_USEPRTMETRICS ].Name = PROPERTYNAME_USEPRTMETRICS;
- lProperties[ OFFSET_ADDSPACING ].Name = PROPERTYNAME_ADDSPACING;
- lProperties[ OFFSET_ADDSPACINGATPAGES ].Name = PROPERTYNAME_ADDSPACINGATPAGES;
- lProperties[ OFFSET_USEOURTABSTOPS ].Name = PROPERTYNAME_USEOURTABSTOPS;
- lProperties[ OFFSET_NOEXTLEADING ].Name = PROPERTYNAME_NOEXTLEADING;
- lProperties[ OFFSET_USELINESPACING ].Name = PROPERTYNAME_USELINESPACING;
- lProperties[ OFFSET_ADDTABLESPACING ].Name = PROPERTYNAME_ADDTABLESPACING;
- lProperties[ OFFSET_USEOBJPOS ].Name = PROPERTYNAME_USEOBJPOS;
- lProperties[ OFFSET_USEOURTEXTWRAPPING ].Name = PROPERTYNAME_USEOURTEXTWRAP;
- lProperties[ OFFSET_CONSIDERWRAPPINGSTYLE ].Name = PROPERTYNAME_CONSIDERWRAPSTYLE;
- lProperties[ OFFSET_EXPANDWORDSPACE ].Name = PROPERTYNAME_EXPANDWORDSPACE;
- lProperties[ OFFSET_MSWORDTRAILINGBLANKS ].Name = PROPERTYNAME_MSWORDTRAILINGBLANKS;
-
- for ( vector< SvtCompatibilityEntry >::const_iterator pItem = pList->begin();
- pItem != pList->end(); ++pItem )
- {
- lProperties[ OFFSET_NAME ].Value <<= pItem->sName;
- lProperties[ OFFSET_MODULE ].Value <<= pItem->sModule;
- lProperties[ OFFSET_USEPRTMETRICS ].Value <<= pItem->bUsePrtMetrics;
- lProperties[ OFFSET_ADDSPACING ].Value <<= pItem->bAddSpacing;
- lProperties[ OFFSET_ADDSPACINGATPAGES ].Value <<= pItem->bAddSpacingAtPages;
- lProperties[ OFFSET_USEOURTABSTOPS ].Value <<= pItem->bUseOurTabStops;
- lProperties[ OFFSET_NOEXTLEADING ].Value <<= pItem->bNoExtLeading;
- lProperties[ OFFSET_USELINESPACING ].Value <<= pItem->bUseLineSpacing;
- lProperties[ OFFSET_ADDTABLESPACING ].Value <<= pItem->bAddTableSpacing;
- lProperties[ OFFSET_USEOBJPOS ].Value <<= pItem->bUseObjPos;
- lProperties[ OFFSET_USEOURTEXTWRAPPING ].Value <<= pItem->bUseOurTextWrapping;
- lProperties[ OFFSET_CONSIDERWRAPPINGSTYLE ].Value <<= pItem->bConsiderWrappingStyle;
- lProperties[ OFFSET_EXPANDWORDSPACE ].Value <<= pItem->bExpandWordSpace;
- lProperties[ OFFSET_MSWORDTRAILINGBLANKS ].Value <<= pItem->bMsWordCompTrailingBlanks;
- lResult[ nStep ] = lProperties;
- ++nStep;
- }
-
- return lResult;
- }
-
- int size() const
- {
- return lEntries.size();
- }
-
- const SvtCompatibilityEntry& operator[]( int i ) const
- {
- return lEntries[i];
- }
-
- private:
- vector< SvtCompatibilityEntry > lEntries;
-};
+/*-****************************************************************************************************
+ @short base implementation of public interface for "SvtCompatibilityOptions"!
+ @descr These class is used as static member of "SvtCompatibilityOptions" ...
+ => The code exist only for one time and isn't duplicated for every instance!
+*//*-*****************************************************************************************************/
class SvtCompatibilityOptions_Impl : public ConfigItem
{
-
- // public methods
-
public:
-
- // constructor / destructor
-
- SvtCompatibilityOptions_Impl();
+ SvtCompatibilityOptions_Impl();
virtual ~SvtCompatibilityOptions_Impl() override;
- void SetDefault( const OUString & sName, bool bValue );
+ void AppendItem( const SvtCompatibilityEntry& aItem );
+ void Clear();
- // override methods of baseclass
+ void SetDefault( SvtCompatibilityEntry::Index rIdx, bool rValue );
+ bool GetDefault( SvtCompatibilityEntry::Index rIdx ) const;
+
+ Sequence< Sequence< PropertyValue > > GetList() const;
/*-****************************************************************************************************
@short called for notify of configmanager
@@ -244,52 +132,9 @@ class SvtCompatibilityOptions_Impl : public ConfigItem
@param "lPropertyNames" is the list of properties which should be updated.
*//*-*****************************************************************************************************/
-
virtual void Notify( const Sequence< OUString >& lPropertyNames ) override;
- // public interface
-
- /*-****************************************************************************************************
- @short base implementation of public interface for "SvtCompatibilityOptions"!
- @descr These class is used as static member of "SvtCompatibilityOptions" ...
- => The code exist only for one time and isn't duplicated for every instance!
- *//*-*****************************************************************************************************/
-
- void Clear();
- Sequence< Sequence< PropertyValue > > GetList() const;
- void AppendItem( const OUString& _sName,
- const OUString& _sModule,
- bool _bUsePrtMetrics,
- bool _bAddSpacing,
- bool _bAddSpacingAtPages,
- bool _bUseOurTabStops,
- bool _bNoExtLeading,
- bool _bUseLineSpacing,
- bool _bAddTableSpacing,
- bool _bUseObjPos,
- bool _bUseOurTextWrapping,
- bool _bConsiderWrappingStyle,
- bool _bExpandWordSpace,
- bool _bProtectForm,
- bool _bMsWordCompTrailingBlanks );
-
- inline bool IsUsePrtDevice() const { return m_aDefOptions.bUsePrtMetrics; }
- inline bool IsAddSpacing() const { return m_aDefOptions.bAddSpacing; }
- inline bool IsAddSpacingAtPages() const { return m_aDefOptions.bAddSpacingAtPages; }
- inline bool IsUseOurTabStops() const { return m_aDefOptions.bUseOurTabStops; }
- inline bool IsNoExtLeading() const { return m_aDefOptions.bNoExtLeading; }
- inline bool IsUseLineSpacing() const { return m_aDefOptions.bUseLineSpacing; }
- inline bool IsAddTableSpacing() const { return m_aDefOptions.bAddTableSpacing; }
- inline bool IsUseObjPos() const { return m_aDefOptions.bUseObjPos; }
- inline bool IsUseOurTextWrapping() const { return m_aDefOptions.bUseOurTextWrapping; }
- inline bool IsConsiderWrappingStyle() const { return m_aDefOptions.bConsiderWrappingStyle; }
- inline bool IsExpandWordSpace() const { return m_aDefOptions.bExpandWordSpace; }
- inline bool IsMsWordCompTrailingBlanks() const { return m_aDefOptions.bMsWordCompTrailingBlanks; }
-
- // private methods
-
private:
-
virtual void ImplCommit() override;
/*-****************************************************************************************************
@@ -298,7 +143,6 @@ class SvtCompatibilityOptions_Impl : public ConfigItem
configuration management and support dynamical menu item lists!
@return A list of configuration key names is returned.
*//*-*****************************************************************************************************/
-
Sequence< OUString > impl_GetPropertyNames( Sequence< OUString >& rItems );
/*-****************************************************************************************************
@@ -309,68 +153,48 @@ class SvtCompatibilityOptions_Impl : public ConfigItem
@param "lDestination" , destination of operation
@return A list of configuration key names is returned.
*//*-*****************************************************************************************************/
-
static void impl_ExpandPropertyNames( const Sequence< OUString >& lSource,
Sequence< OUString >& lDestination );
- // private member
-
private:
-
- SvtCompatibility m_aOptions;
- SvtCompatibilityEntry m_aDefOptions;
+ std::vector< SvtCompatibilityEntry > m_aOptions;
+ SvtCompatibilityEntry m_aDefOptions;
};
-// constructor
-
-SvtCompatibilityOptions_Impl::SvtCompatibilityOptions_Impl()
- // Init baseclasses first
- : ConfigItem( ROOTNODE_OPTIONS )
- // Init member then...
+SvtCompatibilityOptions_Impl::SvtCompatibilityOptions_Impl() : ConfigItem( ROOTNODE_OPTIONS )
{
// Get names and values of all accessible menu entries and fill internal structures.
// See impl_GetPropertyNames() for further information.
Sequence< OUString > lNodes;
- Sequence< OUString > lNames = impl_GetPropertyNames( lNodes );
- sal_uInt32 nCount = lNodes.getLength();
- Sequence< Any > lValues = GetProperties( lNames );
+ Sequence< OUString > lNames = impl_GetPropertyNames( lNodes );
+ sal_uInt32 nCount = lNodes.getLength();
+ Sequence< Any > lValues = GetProperties( lNames );
// Safe impossible cases.
// We need values from ALL configuration keys.
// Follow assignment use order of values in relation to our list of key names!
DBG_ASSERT( !( lNames.getLength()!=lValues.getLength() ), "SvtCompatibilityOptions_Impl::SvtCompatibilityOptions_Impl()\nI miss some values of configuration keys!\n" );
- SvtCompatibilityEntry aItem;
- sal_uInt32 nItem = 0;
- sal_uInt32 nPosition = 0;
-
// Get names/values for new menu.
// 4 subkeys for every item!
bool bDefaultFound = false;
- for( nItem = 0; nItem < nCount; ++nItem )
+ for ( sal_uInt32 nItem = 0; nItem < nCount; ++nItem )
{
- aItem.sName = lNodes[ nItem ];
- lValues[ nPosition++ ] >>= aItem.sModule;
- lValues[ nPosition++ ] >>= aItem.bUsePrtMetrics;
- lValues[ nPosition++ ] >>= aItem.bAddSpacing;
- lValues[ nPosition++ ] >>= aItem.bAddSpacingAtPages;
- lValues[ nPosition++ ] >>= aItem.bUseOurTabStops;
- lValues[ nPosition++ ] >>= aItem.bNoExtLeading;
- lValues[ nPosition++ ] >>= aItem.bUseLineSpacing;
- lValues[ nPosition++ ] >>= aItem.bAddTableSpacing;
- lValues[ nPosition++ ] >>= aItem.bUseObjPos;
- lValues[ nPosition++ ] >>= aItem.bUseOurTextWrapping;
- lValues[ nPosition++ ] >>= aItem.bConsiderWrappingStyle;
- lValues[ nPosition++ ] >>= aItem.bExpandWordSpace;
- lValues[ nPosition++ ] >>= aItem.bMsWordCompTrailingBlanks;
- m_aOptions.AppendEntry( aItem );
-
- if ( !bDefaultFound && aItem.sName == COMPATIBILITY_DEFAULT_NAME )
+ SvtCompatibilityEntry aItem;
+
+ aItem.setValue<OUString>( SvtCompatibilityEntry::Index::Name, lNodes[ nItem ] );
+
+ for ( int i = static_cast<int>(SvtCompatibilityEntry::Index::Module); i < static_cast<int>(SvtCompatibilityEntry::Index::INVALID); ++i )
+ aItem.setValue( SvtCompatibilityEntry::Index(i), lValues[ i - 1 ] );
+
+ m_aOptions.push_back( aItem );
+
+ if ( !bDefaultFound && aItem.getValue<OUString>( SvtCompatibilityEntry::Index::Name ) == SvtCompatibilityEntry::getDefaultEntryName() )
{
SvtSysLocale aSysLocale;
css::lang::Locale aLocale = aSysLocale.GetLanguageTag().getLocale();
if ( aLocale.Language == "zh" || aLocale.Language == "ja" || aLocale.Language == "ko" )
- aItem.bExpandWordSpace = false;
+ aItem.setValue<bool>( SvtCompatibilityEntry::Index::ExpandWordSpace, false );
m_aDefOptions = aItem;
bDefaultFound = true;
@@ -378,233 +202,124 @@ SvtCompatibilityOptions_Impl::SvtCompatibilityOptions_Impl()
}
}
-// destructor
-
SvtCompatibilityOptions_Impl::~SvtCompatibilityOptions_Impl()
{
- assert(!IsModified()); // should have been committed
+ assert( !IsModified() ); // should have been committed
}
-void SvtCompatibilityOptions_Impl::SetDefault( const OUString & sName, bool bValue )
+void SvtCompatibilityOptions_Impl::AppendItem( const SvtCompatibilityEntry& aItem )
{
- if ( sName == COMPATIBILITY_PROPERTYNAME_USEPRTMETRICS )
- m_aDefOptions.SetUsePrtMetrics( bValue );
- else if ( sName == COMPATIBILITY_PROPERTYNAME_ADDSPACING )
- m_aDefOptions.SetAddSpacing( bValue );
- else if ( sName == COMPATIBILITY_PROPERTYNAME_ADDSPACINGATPAGES )
- m_aDefOptions.SetAddSpacingAtPages( bValue );
- else if ( sName == COMPATIBILITY_PROPERTYNAME_USEOURTABSTOPS )
- m_aDefOptions.SetUseOurTabStops( bValue );
- else if ( sName == COMPATIBILITY_PROPERTYNAME_NOEXTLEADING )
- m_aDefOptions.SetNoExtLeading( bValue );
- else if ( sName == COMPATIBILITY_PROPERTYNAME_USELINESPACING )
- m_aDefOptions.SetUseLineSpacing( bValue );
- else if ( sName == COMPATIBILITY_PROPERTYNAME_ADDTABLESPACING )
- m_aDefOptions.SetAddTableSpacing( bValue );
- else if ( sName == COMPATIBILITY_PROPERTYNAME_USEOBJECTPOSITIONING )
- m_aDefOptions.SetUseObjPos( bValue );
- else if ( sName == COMPATIBILITY_PROPERTYNAME_USEOURTEXTWRAPPING )
- m_aDefOptions.SetUseOurTextWrapping( bValue );
- else if ( sName == COMPATIBILITY_PROPERTYNAME_CONSIDERWRAPPINGSTYLE )
- m_aDefOptions.SetConsiderWrappingStyle( bValue );
- else if ( sName == COMPATIBILITY_PROPERTYNAME_EXPANDWORDSPACE )
- m_aDefOptions.SetExpandWordSpace( bValue );
- else if ( sName == COMPATIBILITY_PROPERTYNAME_MSWORDTRAILINGBLANKS )
- m_aDefOptions.SetExpandWordSpace( bValue );
+ m_aOptions.push_back( aItem );
+
+ // default item reset?
+ if ( aItem.getValue<OUString>( SvtCompatibilityEntry::Index::Name ) == SvtCompatibilityEntry::getDefaultEntryName() )
+ m_aDefOptions = aItem;
+
+ SetModified();
}
-// public method
+void SvtCompatibilityOptions_Impl::Clear()
+{
+ m_aOptions.clear();
-void SvtCompatibilityOptions_Impl::Notify( const Sequence< OUString >& )
+ SetModified();
+}
+
+void SvtCompatibilityOptions_Impl::SetDefault( SvtCompatibilityEntry::Index rIdx, bool rValue )
{
- SAL_WARN( "unotools.config", "SvtCompatibilityOptions_Impl::Notify()\nNot implemented yet! I don't know how I can handle a dynamical list of unknown properties ...\n" );
+ /* Are not set Name and Module */
+ assert( rIdx != SvtCompatibilityEntry::Index::Name && rIdx != SvtCompatibilityEntry::Index::Module );
+
+ m_aDefOptions.setValue<bool>( rIdx, rValue );
}
-// public method
+bool SvtCompatibilityOptions_Impl::GetDefault( SvtCompatibilityEntry::Index rIdx ) const
+{
+ /* Are not set Name and Module */
+ assert( rIdx != SvtCompatibilityEntry::Index::Name && rIdx != SvtCompatibilityEntry::Index::Module );
-void SvtCompatibilityOptions_Impl::ImplCommit()
+ return m_aDefOptions.getValue<bool>( rIdx );
+}
+
+Sequence< Sequence< PropertyValue > > SvtCompatibilityOptions_Impl::GetList() const
{
- // Write all properties!
- // Delete complete set first.
- ClearNodeSet( SETNODE_ALLFILEFORMATS );
+ Sequence< PropertyValue > lProperties( SvtCompatibilityEntry::getElementCount() );
+ Sequence< Sequence< PropertyValue > > lResult( m_aOptions.size() );
- SvtCompatibilityEntry aItem;
- OUString sNode;
- Sequence< PropertyValue > lPropertyValues( PROPERTYCOUNT - 1 );
- sal_uInt32 nItem = 0;
- sal_uInt32 nNewCount = m_aOptions.size();
- for( nItem = 0; nItem < nNewCount; ++nItem )
- {
- aItem = m_aOptions[ nItem ];
- sNode = SETNODE_ALLFILEFORMATS PATHDELIMITER + aItem.sName + PATHDELIMITER;
-
- lPropertyValues[ OFFSET_MODULE - 1 ].Name = sNode + PROPERTYNAME_MODULE;
- lPropertyValues[ OFFSET_USEPRTMETRICS - 1 ].Name = sNode + PROPERTYNAME_USEPRTMETRICS;
- lPropertyValues[ OFFSET_ADDSPACING - 1 ].Name = sNode + PROPERTYNAME_ADDSPACING;
- lPropertyValues[ OFFSET_ADDSPACINGATPAGES - 1 ].Name = sNode + PROPERTYNAME_ADDSPACINGATPAGES;
- lPropertyValues[ OFFSET_USEOURTABSTOPS - 1 ].Name = sNode + PROPERTYNAME_USEOURTABSTOPS;
- lPropertyValues[ OFFSET_NOEXTLEADING - 1 ].Name = sNode + PROPERTYNAME_NOEXTLEADING;
- lPropertyValues[ OFFSET_USELINESPACING - 1 ].Name = sNode + PROPERTYNAME_USELINESPACING;
- lPropertyValues[ OFFSET_ADDTABLESPACING - 1 ].Name = sNode + PROPERTYNAME_ADDTABLESPACING;
- lPropertyValues[ OFFSET_USEOBJPOS - 1 ].Name = sNode + PROPERTYNAME_USEOBJPOS;
- lPropertyValues[ OFFSET_USEOURTEXTWRAPPING - 1 ].Name = sNode + PROPERTYNAME_USEOURTEXTWRAP;
- lPropertyValues[ OFFSET_CONSIDERWRAPPINGSTYLE - 1 ].Name = sNode + PROPERTYNAME_CONSIDERWRAPSTYLE;
- lPropertyValues[ OFFSET_EXPANDWORDSPACE - 1 ].Name = sNode + PROPERTYNAME_EXPANDWORDSPACE;
- lPropertyValues[ OFFSET_PROTECTFORM - 1 ].Name = sNode + PROPERTYNAME_PROTECTFORM;
- lPropertyValues[ OFFSET_MSWORDTRAILINGBLANKS - 1 ].Name = sNode + PROPERTYNAME_MSWORDTRAILINGBLANKS;
-
- lPropertyValues[ OFFSET_MODULE - 1 ].Value <<= aItem.sModule;
- lPropertyValues[ OFFSET_USEPRTMETRICS - 1 ].Value <<= aItem.bUsePrtMetrics;
- lPropertyValues[ OFFSET_ADDSPACING - 1 ].Value <<= aItem.bAddSpacing;
- lPropertyValues[ OFFSET_ADDSPACINGATPAGES - 1 ].Value <<= aItem.bAddSpacingAtPages;
- lPropertyValues[ OFFSET_USEOURTABSTOPS - 1 ].Value <<= aItem.bUseOurTabStops;
- lPropertyValues[ OFFSET_NOEXTLEADING - 1 ].Value <<= aItem.bNoExtLeading;
- lPropertyValues[ OFFSET_USELINESPACING - 1 ].Value <<= aItem.bUseLineSpacing;
- lPropertyValues[ OFFSET_ADDTABLESPACING - 1 ].Value <<= aItem.bAddTableSpacing;
- lPropertyValues[ OFFSET_USEOBJPOS - 1 ].Value <<= aItem.bUseObjPos;
- lPropertyValues[ OFFSET_USEOURTEXTWRAPPING - 1 ].Value <<= aItem.bUseOurTextWrapping;
- lPropertyValues[ OFFSET_CONSIDERWRAPPINGSTYLE - 1 ].Value <<= aItem.bConsiderWrappingStyle;
- lPropertyValues[ OFFSET_EXPANDWORDSPACE - 1 ].Value <<= aItem.bExpandWordSpace;
- lPropertyValues[ OFFSET_PROTECTFORM - 1 ].Value <<= aItem.bProtectForm;
- lPropertyValues[ OFFSET_MSWORDTRAILINGBLANKS - 1 ].Value <<= aItem.bMsWordCompTrailingBlanks;
+ for ( int i = static_cast<int>(SvtCompatibilityEntry::Index::Name); i < static_cast<int>(SvtCompatibilityEntry::Index::INVALID); ++i )
+ lProperties[i].Name = SvtCompatibilityEntry::getName( SvtCompatibilityEntry::Index(i) );
- SetSetProperties( SETNODE_ALLFILEFORMATS, lPropertyValues );
+ sal_Int32 j = 0;
+ for ( std::vector< SvtCompatibilityEntry >::const_iterator pItem = m_aOptions.begin(); pItem != m_aOptions.end(); ++pItem )
+ {
+ for ( int i = static_cast<int>(SvtCompatibilityEntry::Index::Name); i < static_cast<int>(SvtCompatibilityEntry::Index::INVALID); ++i )
+ lProperties[i].Value = pItem->getValue( SvtCompatibilityEntry::Index(i) );
+ lResult[ j++ ] = lProperties;
}
-}
-
-// public method
-void SvtCompatibilityOptions_Impl::Clear()
-{
- m_aOptions.Clear();
- SetModified();
+ return lResult;
}
-// public method
-
-Sequence< Sequence< PropertyValue > > SvtCompatibilityOptions_Impl::GetList() const
+void SvtCompatibilityOptions_Impl::Notify( const Sequence< OUString >& )
{
- Sequence< Sequence< PropertyValue > > lReturn;
- lReturn = m_aOptions.GetList();
- return lReturn;
+ SAL_WARN( "unotools.config", "SvtCompatibilityOptions_Impl::Notify()\nNot implemented yet! I don't know how I can handle a dynamical list of unknown properties ...\n" );
}
-// public method
-
-void SvtCompatibilityOptions_Impl::AppendItem( const OUString& _sName,
- const OUString& _sModule,
- bool _bUsePrtMetrics,
- bool _bAddSpacing,
- bool _bAddSpacingAtPages,
- bool _bUseOurTabStops,
- bool _bNoExtLeading,
- bool _bUseLineSpacing,
- bool _bAddTableSpacing,
- bool _bUseObjPos,
- bool _bUseOurTextWrapping,
- bool _bConsiderWrappingStyle,
- bool _bExpandWordSpace,
- bool _bProtectForm,
- bool _bMsWordCompTrailingBlanks )
+void SvtCompatibilityOptions_Impl::ImplCommit()
{
- SvtCompatibilityEntry aItem( _sName, _sModule );
- aItem.SetUsePrtMetrics( _bUsePrtMetrics );
- aItem.SetAddSpacing( _bAddSpacing );
- aItem.SetAddSpacingAtPages( _bAddSpacingAtPages );
- aItem.SetUseOurTabStops( _bUseOurTabStops );
- aItem.SetNoExtLeading( _bNoExtLeading );
- aItem.SetUseLineSpacing( _bUseLineSpacing );
- aItem.SetAddTableSpacing( _bAddTableSpacing );
- aItem.SetUseObjPos( _bUseObjPos );
- aItem.SetUseOurTextWrapping( _bUseOurTextWrapping );
- aItem.SetConsiderWrappingStyle( _bConsiderWrappingStyle );
- aItem.SetExpandWordSpace( _bExpandWordSpace );
- aItem.SetProtectForm( _bProtectForm );
- aItem.SetMsWordCompTrailingBlanks( _bMsWordCompTrailingBlanks );
- m_aOptions.AppendEntry( aItem );
+ // Write all properties!
+ // Delete complete set first.
+ ClearNodeSet( SETNODE_ALLFILEFORMATS );
- // default item reset?
- if ( _sName == COMPATIBILITY_DEFAULT_NAME )
- m_aDefOptions = aItem;
+ Sequence< PropertyValue > lPropertyValues( SvtCompatibilityEntry::getElementCount() - 1 );
+ sal_uInt32 nNewCount = m_aOptions.size();
+ for ( sal_uInt32 nItem = 0; nItem < nNewCount; ++nItem )
+ {
+ SvtCompatibilityEntry aItem = m_aOptions[ nItem ];
+ OUString sNode = SETNODE_ALLFILEFORMATS PATHDELIMITER + aItem.getValue<OUString>( SvtCompatibilityEntry::Index::Name ) + PATHDELIMITER;
- SetModified();
-}
+ for ( int i = static_cast<int>(SvtCompatibilityEntry::Index::Module); i < static_cast<int>(SvtCompatibilityEntry::Index::INVALID); ++i )
+ {
+ lPropertyValues[ i - 1 ].Name = sNode + SvtCompatibilityEntry::getName( SvtCompatibilityEntry::Index(i) );
+ lPropertyValues[ i - 1 ].Value = aItem.getValue( SvtCompatibilityEntry::Index(i) );
+ }
-// private method
+ SetSetProperties( SETNODE_ALLFILEFORMATS, lPropertyValues );
+ }
+}
Sequence< OUString > SvtCompatibilityOptions_Impl::impl_GetPropertyNames( Sequence< OUString >& rItems )
{
// First get ALL names of current existing list items in configuration!
rItems = GetNodeNames( SETNODE_ALLFILEFORMATS );
// expand list to result list ...
- Sequence< OUString > lProperties( rItems.getLength() * ( PROPERTYCOUNT - 1 ) );
+ Sequence< OUString > lProperties( rItems.getLength() * ( SvtCompatibilityEntry::getElementCount() - 1 ) );
impl_ExpandPropertyNames( rItems, lProperties );
// Return result.
return lProperties;
}
-// private method
-
void SvtCompatibilityOptions_Impl::impl_ExpandPropertyNames(
const Sequence< OUString >& lSource, Sequence< OUString >& lDestination )
{
- OUString sFixPath;
- sal_Int32 nDestStep = 0;
sal_Int32 nSourceCount = lSource.getLength();
// Copy entries to destination and expand every item with 2 supported sub properties.
- for( sal_Int32 nSourceStep = 0; nSourceStep < nSourceCount; ++nSourceStep )
+ for ( sal_Int32 nSourceStep = 0; nSourceStep < nSourceCount; ++nSourceStep )
{
+ OUString sFixPath;
sFixPath = SETNODE_ALLFILEFORMATS;
sFixPath += PATHDELIMITER;
sFixPath += lSource[ nSourceStep ];
sFixPath += PATHDELIMITER;
- lDestination[nDestStep] = sFixPath;
- lDestination[nDestStep] += PROPERTYNAME_MODULE;
- ++nDestStep;
- lDestination[nDestStep] = sFixPath;
- lDestination[nDestStep] += PROPERTYNAME_USEPRTMETRICS;
- ++nDestStep;
- lDestination[nDestStep] = sFixPath;
- lDestination[nDestStep] += PROPERTYNAME_ADDSPACING;
- ++nDestStep;
- lDestination[nDestStep] = sFixPath;
- lDestination[nDestStep] += PROPERTYNAME_ADDSPACINGATPAGES;
- ++nDestStep;
- lDestination[nDestStep] = sFixPath;
- lDestination[nDestStep] += PROPERTYNAME_USEOURTABSTOPS;
- ++nDestStep;
- lDestination[nDestStep] = sFixPath;
- lDestination[nDestStep] += PROPERTYNAME_NOEXTLEADING;
- ++nDestStep;
- lDestination[nDestStep] = sFixPath;
- lDestination[nDestStep] += PROPERTYNAME_USELINESPACING;
- ++nDestStep;
- lDestination[nDestStep] = sFixPath;
- lDestination[nDestStep] += PROPERTYNAME_ADDTABLESPACING;
- ++nDestStep;
- lDestination[nDestStep] = sFixPath;
- lDestination[nDestStep] += PROPERTYNAME_USEOBJPOS;
- ++nDestStep;
- lDestination[nDestStep] = sFixPath;
- lDestination[nDestStep] += PROPERTYNAME_USEOURTEXTWRAP;
- ++nDestStep;
- lDestination[nDestStep] = sFixPath;
- lDestination[nDestStep] += PROPERTYNAME_CONSIDERWRAPSTYLE;
- ++nDestStep;
- lDestination[nDestStep] = sFixPath;
- lDestination[nDestStep] += PROPERTYNAME_EXPANDWORDSPACE;
- ++nDestStep;
- lDestination[nDestStep] = sFixPath;
- lDestination[nDestStep] += PROPERTYNAME_MSWORDTRAILINGBLANKS;
- ++nDestStep;
+ for ( int i = static_cast<int>(SvtCompatibilityEntry::Index::Module); i < static_cast<int>(SvtCompatibilityEntry::Index::INVALID); ++i )
+ lDestination[ i - 1 ] = sFixPath + SvtCompatibilityEntry::getName( SvtCompatibilityEntry::Index(i) );
}
}
-namespace {
-
-std::weak_ptr<SvtCompatibilityOptions_Impl> theOptions;
-
+namespace
+{
+ std::weak_ptr<SvtCompatibilityOptions_Impl> theOptions;
}
SvtCompatibilityOptions::SvtCompatibilityOptions()
@@ -613,11 +328,11 @@ SvtCompatibilityOptions::SvtCompatibilityOptions()
MutexGuard aGuard( GetOwnStaticMutex() );
m_pImpl = theOptions.lock();
- if( !m_pImpl )
+ if ( !m_pImpl )
{
- m_pImpl = std::make_shared<SvtCompatibilityOptions_Impl>();
+ m_pImpl = std::make_shared<SvtCompatibilityOptions_Impl>();
theOptions = m_pImpl;
- ItemHolder1::holdConfigItem(E_COMPATIBILITY);
+ ItemHolder1::holdConfigItem( E_COMPATIBILITY );
}
}
@@ -628,112 +343,28 @@ SvtCompatibilityOptions::~SvtCompatibilityOptions()
m_pImpl.reset();
}
-void SvtCompatibilityOptions::Clear()
+void SvtCompatibilityOptions::AppendItem( const SvtCompatibilityEntry& aItem )
{
MutexGuard aGuard( GetOwnStaticMutex() );
- m_pImpl->Clear();
-}
-
-void SvtCompatibilityOptions::SetDefault( const OUString & sName, bool bValue )
-{
- m_pImpl->SetDefault( sName, bValue );
+ m_pImpl->AppendItem( aItem );
}
-void SvtCompatibilityOptions::AppendItem( const OUString& sName,
- const OUString& sModule,
- bool bUsePrtMetrics,
- bool bAddSpacing,
- bool bAddSpacingAtPages,
- bool bUseOurTabStops,
- bool bNoExtLeading,
- bool bUseLineSpacing,
- bool bAddTableSpacing,
- bool bUseObjPos,
- bool bUseOurTextWrapping,
- bool bConsiderWrappingStyle,
- bool bExpandWordSpace,
- bool bProtectForm,
- bool bMsWordCompTrailingBlanks )
-{
- MutexGuard aGuard( GetOwnStaticMutex() );
- m_pImpl->AppendItem(
- sName, sModule, bUsePrtMetrics, bAddSpacing,
- bAddSpacingAtPages, bUseOurTabStops, bNoExtLeading,
- bUseLineSpacing, bAddTableSpacing, bUseObjPos,
- bUseOurTextWrapping, bConsiderWrappingStyle, bExpandWordSpace,
- bProtectForm, bMsWordCompTrailingBlanks );
-}
-
-bool SvtCompatibilityOptions::IsUsePrtDevice() const
-{
- MutexGuard aGuard( GetOwnStaticMutex() );
- return m_pImpl->IsUsePrtDevice();
-}
-
-bool SvtCompatibilityOptions::IsAddSpacing() const
-{
- MutexGuard aGuard( GetOwnStaticMutex() );
- return m_pImpl->IsAddSpacing();
-}
-
-bool SvtCompatibilityOptions::IsAddSpacingAtPages() const
-{
- MutexGuard aGuard( GetOwnStaticMutex() );
- return m_pImpl->IsAddSpacingAtPages();
-}
-
-bool SvtCompatibilityOptions::IsUseOurTabStops() const
-{
- MutexGuard aGuard( GetOwnStaticMutex() );
- return m_pImpl->IsUseOurTabStops();
-}
-
-bool SvtCompatibilityOptions::IsNoExtLeading() const
-{
- MutexGuard aGuard( GetOwnStaticMutex() );
- return m_pImpl->IsNoExtLeading();
-}
-
-bool SvtCompatibilityOptions::IsUseLineSpacing() const
-{
- MutexGuard aGuard( GetOwnStaticMutex() );
- return m_pImpl->IsUseLineSpacing();
-}
-
-bool SvtCompatibilityOptions::IsAddTableSpacing() const
-{
- MutexGuard aGuard( GetOwnStaticMutex() );
- return m_pImpl->IsAddTableSpacing();
-}
-
-bool SvtCompatibilityOptions::IsUseObjectPositioning() const
-{
- MutexGuard aGuard( GetOwnStaticMutex() );
- return m_pImpl->IsUseObjPos();
-}
-
-bool SvtCompatibilityOptions::IsUseOurTextWrapping() const
-{
- MutexGuard aGuard( GetOwnStaticMutex() );
- return m_pImpl->IsUseOurTextWrapping();
-}
-
-bool SvtCompatibilityOptions::IsConsiderWrappingStyle() const
+void SvtCompatibilityOptions::Clear()
{
MutexGuard aGuard( GetOwnStaticMutex() );
- return m_pImpl->IsConsiderWrappingStyle();
+ m_pImpl->Clear();
}
-bool SvtCompatibilityOptions::IsExpandWordSpace() const
+void SvtCompatibilityOptions::SetDefault( SvtCompatibilityEntry::Index rIdx, bool rValue )
{
MutexGuard aGuard( GetOwnStaticMutex() );
- return m_pImpl->IsExpandWordSpace();
+ m_pImpl->SetDefault( rIdx, rValue );
}
-bool SvtCompatibilityOptions::IsMsWordCompTrailingBlanks() const
+bool SvtCompatibilityOptions::GetDefault( SvtCompatibilityEntry::Index rIdx ) const
{
MutexGuard aGuard( GetOwnStaticMutex() );
- return m_pImpl->IsMsWordCompTrailingBlanks();
+ return m_pImpl->GetDefault( rIdx );
}
Sequence< Sequence< PropertyValue > > SvtCompatibilityOptions::GetList() const
More information about the Libreoffice-commits
mailing list