[Libreoffice-commits] .: 3 commits - sc/source sw/qa
Markus Mohrhard
mmohrhard at kemper.freedesktop.org
Tue Nov 29 01:44:01 PST 2011
sc/source/ui/inc/namemgrtable.hxx | 13 +++++++-
sc/source/ui/namedlg/namemgrtable.cxx | 54 ++++++++++++++++++++++++++++++----
sc/source/ui/src/namedefdlg.src | 2 -
sw/qa/core/macros-test.cxx | 34 +++------------------
4 files changed, 67 insertions(+), 36 deletions(-)
New commits:
commit 792fb5b96f1008804ab51dc0ebf4f07a07ad9537
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Tue Nov 29 10:39:01 2011 +0100
ManageNames: only calculate formula for visible range names
diff --git a/sc/source/ui/inc/namemgrtable.hxx b/sc/source/ui/inc/namemgrtable.hxx
index b95002e..bbbcab6 100644
--- a/sc/source/ui/inc/namemgrtable.hxx
+++ b/sc/source/ui/inc/namemgrtable.hxx
@@ -36,6 +36,7 @@
#include <boost/ptr_container/ptr_map.hpp>
class ScRangeName;
+class ScRangeData;
struct ScRangeNameLine
{
@@ -64,8 +65,17 @@ private:
HeaderBar maHeaderBar;
rtl::OUString maGlobalString;
+ // should be const because we should not modify it here
+ const boost::ptr_map<rtl::OUString, ScRangeName>& mrRangeMap;
+ // for performance, save which entries already have the formula entry
+ // otherwise opening the dialog with a lot of range names is extremelly slow because
+ // we would calculate all formula strings during opening
+ std::map<SvLBoxEntry*, bool> maCalculatedFormulaEntries;
+
void GetLine(ScRangeNameLine& aLine, SvLBoxEntry* pEntry);
- void Init( const boost::ptr_map<rtl::OUString, ScRangeName>& rRangeMap );
+ void Init();
+ void CheckForFormulaString();
+ const ScRangeData* findRangeData(const ScRangeNameLine& rLine);
public:
ScRangeManagerTable( Window* pParent, boost::ptr_map<rtl::OUString, ScRangeName>& aTabRangeNames );
@@ -78,6 +88,7 @@ public:
bool IsMultiSelection();
std::vector<ScRangeNameLine> GetSelectedEntries();
+ DECL_LINK( ScrollHdl, void*);
DECL_LINK( HeaderEndDragHdl, void*);
};
diff --git a/sc/source/ui/namedlg/namemgrtable.cxx b/sc/source/ui/namedlg/namemgrtable.cxx
index d471c74..de9e386 100644
--- a/sc/source/ui/namedlg/namemgrtable.cxx
+++ b/sc/source/ui/namedlg/namemgrtable.cxx
@@ -60,7 +60,8 @@ String createEntryString(const ScRangeNameLine& rLine)
ScRangeManagerTable::ScRangeManagerTable( Window* pWindow, boost::ptr_map<rtl::OUString, ScRangeName>& rRangeMap ):
SvTabListBox( pWindow, WB_SORT | WB_HSCROLL | WB_CLIPCHILDREN | WB_TABSTOP ),
maHeaderBar( pWindow, WB_BUTTONSTYLE | WB_BOTTOMBORDER ),
- maGlobalString( ScGlobal::GetRscString(STR_GLOBAL_SCOPE))
+ maGlobalString( ScGlobal::GetRscString(STR_GLOBAL_SCOPE)),
+ mrRangeMap( rRangeMap )
{
Size aBoxSize( pWindow->GetOutputSizePixel() );
@@ -84,12 +85,16 @@ ScRangeManagerTable::ScRangeManagerTable( Window* pWindow, boost::ptr_map<rtl::O
maHeaderBar.SetEndDragHdl( LINK( this, ScRangeManagerTable, HeaderEndDragHdl ) );
+ Init();
Show();
maHeaderBar.Show();
SetSelectionMode(MULTIPLE_SELECTION);
- Init(rRangeMap);
if (GetEntryCount())
+ {
SetCurEntry(GetEntryOnPos(0));
+ CheckForFormulaString();
+ }
+ SetScrolledHdl( LINK( this, ScRangeManagerTable, ScrollHdl ) );
}
ScRangeManagerTable::~ScRangeManagerTable()
@@ -116,11 +121,11 @@ void ScRangeManagerTable::GetLine(ScRangeNameLine& rLine, SvLBoxEntry* pEntry)
rLine.aScope = GetEntryText(pEntry, 2);
}
-void ScRangeManagerTable::Init(const boost::ptr_map<rtl::OUString, ScRangeName>& rRangeMap)
+void ScRangeManagerTable::Init()
{
Clear();
- for (boost::ptr_map<rtl::OUString, ScRangeName>::const_iterator itr = rRangeMap.begin();
- itr != rRangeMap.end(); ++itr)
+ for (boost::ptr_map<rtl::OUString, ScRangeName>::const_iterator itr = mrRangeMap.begin();
+ itr != mrRangeMap.end(); ++itr)
{
const ScRangeName* pLocalRangeName = itr->second;
ScRangeNameLine aLine;
@@ -134,13 +139,44 @@ void ScRangeManagerTable::Init(const boost::ptr_map<rtl::OUString, ScRangeName>&
if (!it->second->HasType(RT_DATABASE) && !it->second->HasType(RT_SHARED))
{
aLine.aName = it->second->GetName();
- it->second->GetSymbol(aLine.aExpression);
addEntry(aLine);
}
}
}
}
+const ScRangeData* ScRangeManagerTable::findRangeData(const ScRangeNameLine& rLine)
+{
+ const ScRangeName* pRangeName;
+ if (rLine.aScope == maGlobalString)
+ pRangeName = mrRangeMap.find(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(STR_GLOBAL_RANGE_NAME)))->second;
+ else
+ pRangeName = mrRangeMap.find(rLine.aScope)->second;
+
+ return pRangeName->findByUpperName(ScGlobal::pCharClass->upper(rLine.aName));
+}
+
+
+
+void ScRangeManagerTable::CheckForFormulaString()
+{
+ for (SvLBoxEntry* pEntry = GetFirstEntryInView(); pEntry ; pEntry = GetNextEntryInView(pEntry))
+ {
+ std::map<SvLBoxEntry*, bool>::const_iterator itr = maCalculatedFormulaEntries.find(pEntry);
+ if (itr == maCalculatedFormulaEntries.end() || itr->second == false)
+ {
+ ScRangeNameLine aLine;
+ GetLine( aLine, pEntry);
+ const ScRangeData* pData = findRangeData( aLine );
+ rtl::OUString aFormulaString;
+ pData->GetSymbol(aFormulaString);
+ SetEntryText(aFormulaString, pEntry, 1);
+ maCalculatedFormulaEntries.insert( std::pair<SvLBoxEntry*, bool>(pEntry, true) );
+ }
+
+ }
+}
+
void ScRangeManagerTable::DeleteSelectedEntries()
{
if (GetSelectionCount())
@@ -237,5 +273,11 @@ IMPL_LINK( ScRangeManagerTable, HeaderEndDragHdl, void*, EMPTYARG)
return 0;
}
+IMPL_LINK( ScRangeManagerTable, ScrollHdl, void*, EMPTYARG)
+{
+ CheckForFormulaString();
+ return 0;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit c21b1126b1d72ea9ada5304109964d31a6159507
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Mon Nov 28 16:05:21 2011 +0100
fix typo RangeOptions->Range Options
diff --git a/sc/source/ui/src/namedefdlg.src b/sc/source/ui/src/namedefdlg.src
index 1896918..4181015 100644
--- a/sc/source/ui/src/namedefdlg.src
+++ b/sc/source/ui/src/namedefdlg.src
@@ -56,7 +56,7 @@ ModelessDialog RID_SCDLG_NAMES_DEFINE
{
Pos = MAP_APPFONT( 5, 82 );
Size = MAP_APPFONT( 60, 15 );
- Text [en-US] = "RangeOptions";
+ Text [en-US] = "Range Options";
};
FixedText FT_INFO
{
commit 5881881e592c42929f1d32f17f06538dfda040e2
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Sun Nov 27 13:47:35 2011 +0100
make sw's macros_test use the new base class
diff --git a/sw/qa/core/macros-test.cxx b/sw/qa/core/macros-test.cxx
index d4ddbca..bac6ac9 100644
--- a/sw/qa/core/macros-test.cxx
+++ b/sw/qa/core/macros-test.cxx
@@ -29,7 +29,7 @@
*/
#include <sal/config.h>
-#include <unotest/filters-test.hxx>
+#include <unotest/macros_test.hxx>
#include <test/bootstrapfixture.hxx>
#include <rtl/strbuf.hxx>
#include <osl/file.hxx>
@@ -58,14 +58,13 @@ using namespace ::com::sun::star::uno;
/* Implementation of Macros test */
-class SwMacrosTest : public test::BootstrapFixture
+class SwMacrosTest : public test::BootstrapFixture, public unotest::MacrosTest
{
public:
SwMacrosTest();
SwDocShellRef load(const rtl::OUString &rFilter, const rtl::OUString &rURL,
const rtl::OUString &rUserData, const rtl::OUString& rTypeName, sal_uLong nFormatType=0);
- uno::Reference< com::sun::star::lang::XComponent > loadFromDesktop(const rtl::OUString& rURL);
void createFileURL(const rtl::OUString& aFileBase, const rtl::OUString& aFileExtension, rtl::OUString& rFilePath);
@@ -85,26 +84,10 @@ public:
CPPUNIT_TEST_SUITE_END();
private:
- uno::Reference<uno::XInterface> m_xCalcComponent;
- uno::Reference<frame::XDesktop> mxDesktop;
+ uno::Reference<uno::XInterface> m_xWriterComponent;
::rtl::OUString m_aBaseString;
};
-uno::Reference< com::sun::star::lang::XComponent > SwMacrosTest::loadFromDesktop(const rtl::OUString& rURL)
-{
- uno::Reference< com::sun::star::frame::XComponentLoader> xLoader = uno::Reference< com::sun::star::frame::XComponentLoader >( mxDesktop, UNO_QUERY );
- com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > args(1);
- args[0].Name = rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM("MacroExecutionMode"));
- args[0].Handle = -1;
- args[0].Value <<=
- com::sun::star::document::MacroExecMode::ALWAYS_EXECUTE_NO_WARN;
- args[0].State = com::sun::star::beans::PropertyState_DIRECT_VALUE;
- uno::Reference< com::sun::star::lang::XComponent> xComponent= xLoader->loadComponentFromURL(rURL, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_default")), 0, args);
- CPPUNIT_ASSERT_MESSAGE("loading failed", xComponent.is());
- return xComponent;
-}
-
void SwMacrosTest::createFileURL(const rtl::OUString& aFileBase, const rtl::OUString& aFileExtension, rtl::OUString& rFilePath)
{
rtl::OUString aSep(RTL_CONSTASCII_USTRINGPARAM("/"));
@@ -143,11 +126,6 @@ void SwMacrosTest::testStarBasic()
#endif
-struct TestMacroInfo
-{
- rtl::OUString sFileBaseName;
- rtl::OUString sMacroUrl;
-};
void SwMacrosTest::testVba()
{
TestMacroInfo testInfo[] = {
@@ -195,10 +173,10 @@ void SwMacrosTest::setUp()
// This is a bit of a fudge, we do this to ensure that SwGlobals::ensure,
// which is a private symbol to us, gets called
- m_xCalcComponent =
+ m_xWriterComponent =
getMultiServiceFactory()->createInstance(rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.Writer.TextDocument")));
- CPPUNIT_ASSERT_MESSAGE("no calc component!", m_xCalcComponent.is());
+ CPPUNIT_ASSERT_MESSAGE("no calc component!", m_xWriterComponent.is());
mxDesktop = Reference<com::sun::star::frame::XDesktop>( getMultiServiceFactory()->createInstance(
rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop" ))), UNO_QUERY );
CPPUNIT_ASSERT_MESSAGE("", mxDesktop.is());
@@ -206,7 +184,7 @@ void SwMacrosTest::setUp()
void SwMacrosTest::tearDown()
{
- uno::Reference< lang::XComponent >( m_xCalcComponent, UNO_QUERY_THROW )->dispose();
+ uno::Reference< lang::XComponent >( m_xWriterComponent, UNO_QUERY_THROW )->dispose();
test::BootstrapFixture::tearDown();
}
More information about the Libreoffice-commits
mailing list