diff options
author | Ocke Janssen [oj] <Ocke.Janssen@sun.com> | 2010-01-28 10:39:25 +0100 |
---|---|---|
committer | Ocke Janssen [oj] <Ocke.Janssen@sun.com> | 2010-01-28 10:39:25 +0100 |
commit | e81dc7f26f4c65ede3a3bab6ad810dac121ba52e (patch) | |
tree | 250780a0ca2c378fe50595843b4ecd557ad90a4f /reportdesign | |
parent | f29cae73b29868dad9021f87d800c4d115bc7bf3 (diff) |
dba33f: #i108548# handle Label property from parse column and rowsetcolumn
Diffstat (limited to 'reportdesign')
-rw-r--r-- | reportdesign/source/core/api/Section.cxx | 2 | ||||
-rw-r--r-- | reportdesign/source/ui/dlg/AddField.cxx | 28 | ||||
-rw-r--r-- | reportdesign/source/ui/dlg/GroupsSorting.cxx | 49 | ||||
-rw-r--r-- | reportdesign/source/ui/inc/ColumnInfo.hxx | 57 | ||||
-rw-r--r-- | reportdesign/source/ui/inc/GroupsSorting.hxx | 1 | ||||
-rw-r--r-- | reportdesign/source/ui/inc/ReportController.hxx | 5 | ||||
-rw-r--r-- | reportdesign/source/ui/report/FormattedFieldBeautifier.cxx | 17 | ||||
-rw-r--r-- | reportdesign/source/ui/report/ReportController.cxx | 27 | ||||
-rw-r--r-- | reportdesign/source/ui/report/SectionWindow.cxx | 19 |
9 files changed, 167 insertions, 38 deletions
diff --git a/reportdesign/source/core/api/Section.cxx b/reportdesign/source/core/api/Section.cxx index 14118e0baaad..8fa311c5d6ed 100644 --- a/reportdesign/source/core/api/Section.cxx +++ b/reportdesign/source/core/api/Section.cxx @@ -459,7 +459,7 @@ uno::Reference< report::XReportDefinition > SAL_CALL OSection::getReportDefiniti uno::Reference< report::XGroup > xGroup = m_xGroup; if ( !xRet.is() && xGroup.is() ) { - uno::Reference< report::XGroups> xGroups(xGroup->getParent(),uno::UNO_QUERY); + uno::Reference< report::XGroups> xGroups(xGroup->getGroups()); if ( xGroups.is() ) xRet = xGroups->getReportDefinition(); } diff --git a/reportdesign/source/ui/dlg/AddField.cxx b/reportdesign/source/ui/dlg/AddField.cxx index 44bb03f1ec90..b0e284b6960d 100644 --- a/reportdesign/source/ui/dlg/AddField.cxx +++ b/reportdesign/source/ui/dlg/AddField.cxx @@ -50,6 +50,8 @@ #include "CondFormat.hrc" #include "ModuleHelper.hxx" #include "uistrings.hrc" +#include "ColumnInfo.hxx" + #include <comphelper/property.hxx> #include <svtools/imgdef.hxx> @@ -70,23 +72,6 @@ using namespace lang; using namespace container; using namespace ::svx; -struct ColumnInfo -{ - ::rtl::OUString sColumnName; - ::rtl::OUString sLabel; - bool bColumn; - ColumnInfo(const ::rtl::OUString& i_sColumnName,const ::rtl::OUString& i_sLabel) - : sColumnName(i_sColumnName) - , sLabel(i_sLabel) - , bColumn(true) - { - } - ColumnInfo(const ::rtl::OUString& i_sColumnName) - : sColumnName(i_sColumnName) - , bColumn(false) - { - } -}; class OAddFieldWindowListBox : public SvTreeListBox { OAddFieldWindow* m_pTabWin; @@ -247,6 +232,15 @@ OAddFieldWindow::OAddFieldWindow(Window* pParent //----------------------------------------------------------------------- OAddFieldWindow::~OAddFieldWindow() { + if ( m_pListBox.get() ) + { + SvLBoxTreeList* pModel = m_pListBox->GetModel(); + ULONG nCount = pModel->GetEntryCount(); + for(ULONG i = 0; i< nCount;++i) + { + delete pModel->GetEntry(i)->GetUserData(); + } + } if (m_pChangeListener.is()) m_pChangeListener->dispose(); if ( m_pContainerListener.is() ) diff --git a/reportdesign/source/ui/dlg/GroupsSorting.cxx b/reportdesign/source/ui/dlg/GroupsSorting.cxx index 2f20d75c3fa4..5af42bf61a0d 100644 --- a/reportdesign/source/ui/dlg/GroupsSorting.cxx +++ b/reportdesign/source/ui/dlg/GroupsSorting.cxx @@ -52,6 +52,7 @@ #include "UndoActions.hxx" #include "uistrings.hrc" #include "ReportController.hxx" +#include "ColumnInfo.hxx" #include <cppuhelper/implbase1.hxx> #include <comphelper/property.hxx> @@ -73,6 +74,25 @@ using namespace ::com::sun::star; using namespace svt; using namespace ::comphelper; + void lcl_addToList_throw( ComboBoxControl& _rListBox, ::std::vector<ColumnInfo>& o_aColumnList,const uno::Reference< container::XNameAccess>& i_xColumns ) + { + uno::Sequence< ::rtl::OUString > aEntries = i_xColumns->getElementNames(); + const ::rtl::OUString* pEntries = aEntries.getConstArray(); + sal_Int32 nEntries = aEntries.getLength(); + for ( sal_Int32 i = 0; i < nEntries; ++i, ++pEntries ) + { + uno::Reference< beans::XPropertySet> xColumn(i_xColumns->getByName(*pEntries),uno::UNO_QUERY_THROW); + ::rtl::OUString sLabel; + if ( xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_LABEL) ) + xColumn->getPropertyValue(PROPERTY_LABEL) >>= sLabel; + o_aColumnList.push_back( ColumnInfo(*pEntries,sLabel) ); + if ( sLabel.getLength() ) + _rListBox.InsertEntry( sLabel ); + else + _rListBox.InsertEntry( *pEntries ); + } + } + typedef ::svt::EditBrowseBox OFieldExpressionControl_Base; typedef ::cppu::WeakImplHelper1< container::XContainerListener > TContainerListenerBase; class OFieldExpressionControl : public TContainerListenerBase @@ -80,6 +100,7 @@ class OFieldExpressionControl : public TContainerListenerBase { ::osl::Mutex m_aMutex; ::std::vector<sal_Int32> m_aGroupPositions; + ::std::vector<ColumnInfo> m_aColumnInfo; ::svt::ComboBoxControl* m_pComboCell; sal_Int32 m_nDataPos; sal_Int32 m_nCurrentPos; @@ -335,13 +356,7 @@ void OFieldExpressionControl::fillColumns(const uno::Reference< container::XName { m_pComboCell->Clear(); if ( _xColumns.is() ) - { - uno::Sequence< ::rtl::OUString> aColumnNames = _xColumns->getElementNames(); - const ::rtl::OUString* pIter = aColumnNames.getConstArray(); - const ::rtl::OUString* pEnd = pIter + aColumnNames.getLength(); - for(;pIter != pEnd;++pIter) - m_pComboCell->InsertEntry(*pIter); - } // if ( _xColumns.is() ) + lcl_addToList_throw(*m_pComboCell,m_aColumnInfo,_xColumns); } //------------------------------------------------------------------------------ void OFieldExpressionControl::lateInit() @@ -480,7 +495,7 @@ BOOL OFieldExpressionControl::SaveModified(bool _bAppendRow) sExpression = m_pComboCell->GetText(); else { - sExpression = m_pComboCell->GetEntry(nPos); + sExpression = m_aColumnInfo[nPos].sColumnName; } xGroup->setExpression( sExpression ); @@ -519,7 +534,18 @@ String OFieldExpressionControl::GetCellText( long nRow, USHORT /*nColId*/ ) cons try { uno::Reference< report::XGroup> xGroup = m_pParent->getGroup(m_aGroupPositions[nRow]); - sText = xGroup->getExpression(); + ::rtl::OUString sExpression = xGroup->getExpression(); + + for(::std::vector<ColumnInfo>::const_iterator aIter = m_aColumnInfo.begin(); aIter != m_aColumnInfo.end();++aIter) + { + if ( aIter->sColumnName == sExpression ) + { + if ( aIter->sLabel.getLength() ) + sExpression = aIter->sLabel; + break; + } + } + sText = sExpression; } catch(uno::Exception&) { @@ -1311,10 +1337,7 @@ void OGroupsSortingDialog::_propertyChanged(const beans::PropertyChangeEvent& _r // ----------------------------------------------------------------------------- void OGroupsSortingDialog::fillColumns() { - m_xColumns.clear(); - uno::Reference< report::XReportDefinition> xReport = m_pController->getReportDefinition(); - if ( xReport->getCommand().getLength() ) - m_xColumns = dbtools::getFieldsByCommandDescriptor(m_pController->getConnection(),xReport->getCommandType(),xReport->getCommand(),m_xHoldAlive); + m_xColumns = m_pController->getColumns(); m_pFieldExpression->fillColumns(m_xColumns); } // ----------------------------------------------------------------------------- diff --git a/reportdesign/source/ui/inc/ColumnInfo.hxx b/reportdesign/source/ui/inc/ColumnInfo.hxx new file mode 100644 index 000000000000..392a141e6382 --- /dev/null +++ b/reportdesign/source/ui/inc/ColumnInfo.hxx @@ -0,0 +1,57 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: AddField.cxx,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef RPTUI_COLUMNINFO_HXX +#define RPTUI_COLUMNINFO_HXX + +#include <rtl/ustring.hxx> + +namespace rptui +{ + struct ColumnInfo + { + ::rtl::OUString sColumnName; + ::rtl::OUString sLabel; + bool bColumn; + ColumnInfo(const ::rtl::OUString& i_sColumnName,const ::rtl::OUString& i_sLabel) + : sColumnName(i_sColumnName) + , sLabel(i_sLabel) + , bColumn(true) + { + } + ColumnInfo(const ::rtl::OUString& i_sColumnName) + : sColumnName(i_sColumnName) + , bColumn(false) + { + } + }; +// ============================================================================= +} // namespace rptui +// ============================================================================= +#endif // RPTUI_COLUMNINFO_HXX diff --git a/reportdesign/source/ui/inc/GroupsSorting.hxx b/reportdesign/source/ui/inc/GroupsSorting.hxx index fc26581ba37d..441121d7a471 100644 --- a/reportdesign/source/ui/inc/GroupsSorting.hxx +++ b/reportdesign/source/ui/inc/GroupsSorting.hxx @@ -105,7 +105,6 @@ class OGroupsSortingDialog : public FloatingWindow ::rtl::Reference< comphelper::OPropertyChangeMultiplexer> m_pReportListener; ::com::sun::star::uno::Reference< ::com::sun::star::report::XGroups> m_xGroups; ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xColumns; - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > m_xHoldAlive; sal_Bool m_bReadOnly; private: DECL_LINK( OnControlFocusLost, Control* ); diff --git a/reportdesign/source/ui/inc/ReportController.hxx b/reportdesign/source/ui/inc/ReportController.hxx index 03ccda9d2209..28b64f2adf02 100644 --- a/reportdesign/source/ui/inc/ReportController.hxx +++ b/reportdesign/source/ui/inc/ReportController.hxx @@ -116,6 +116,8 @@ namespace rptui ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet > m_xRowSet; ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener > m_xRowSetMediator; ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > m_xFormatter; // a number formatter working with the report's NumberFormatsSupplier + mutable ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > m_xHoldAlive; + mutable ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xColumns; ::com::sun::star::awt::Size m_aVisualAreaSize; ::boost::shared_ptr<rptui::OReportModel> @@ -474,6 +476,9 @@ namespace rptui ::boost::shared_ptr<OSectionWindow> getSectionWindow(const ::com::sun::star::uno::Reference< ::com::sun::star::report::XSection>& _xSection) const; + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > getColumns() const; + ::rtl::OUString getColumnLabel_throw(const ::rtl::OUString& i_sColumnName) const; + private: virtual void onLoadedMenu( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager >& _xLayoutManager ); virtual void impl_initialize( ); diff --git a/reportdesign/source/ui/report/FormattedFieldBeautifier.cxx b/reportdesign/source/ui/report/FormattedFieldBeautifier.cxx index f50ca36bcd4d..0e5b0ebb45a9 100644 --- a/reportdesign/source/ui/report/FormattedFieldBeautifier.cxx +++ b/reportdesign/source/ui/report/FormattedFieldBeautifier.cxx @@ -103,7 +103,22 @@ namespace rptui if ( sDataField.getLength() ) { ReportFormula aFormula( sDataField ); - sDataField = aFormula.getEqualUndecoratedContent(); + bool bSet = true; + if ( aFormula.getType() == ReportFormula::Field ) + { + const ::rtl::OUString sColumnName = aFormula.getFieldName(); + ::rtl::OUString sLabel = m_rReportController.getColumnLabel_throw(sColumnName); + if ( sLabel.getLength() ) + { + ::rtl::OUStringBuffer aBuffer; + aBuffer.appendAscii( "=" ); + aBuffer.append( sLabel ); + sDataField = aBuffer.makeStringAndClear(); + bSet = false; + } + } + if ( bSet ) + sDataField = aFormula.getEqualUndecoratedContent(); } } diff --git a/reportdesign/source/ui/report/ReportController.cxx b/reportdesign/source/ui/report/ReportController.cxx index 5cb2f60d32fd..556f94818c70 100644 --- a/reportdesign/source/ui/report/ReportController.cxx +++ b/reportdesign/source/ui/report/ReportController.cxx @@ -354,6 +354,8 @@ void OReportController::disposing() try { + m_xHoldAlive.clear(); + m_xColumns.clear(); ::comphelper::disposeComponent( m_xRowSet ); ::comphelper::disposeComponent( m_xRowSetMediator ); ::comphelper::disposeComponent( m_xFormatter ); @@ -2303,6 +2305,8 @@ void SAL_CALL OReportController::propertyChange( const beans::PropertyChangeEven || evt.PropertyName.equals( PROPERTY_FILTER ) ) { + m_xColumns.clear(); + m_xHoldAlive.clear(); InvalidateFeature(SID_FM_ADD_FIELD); if ( !m_pMyOwnView->isAddFieldVisible() && isUiVisible() ) m_pMyOwnView->toggleAddField(); @@ -4384,3 +4388,26 @@ embed::VisualRepresentation SAL_CALL OReportController::getPreferredVisualRepres { return embed::EmbedMapUnits::ONE_100TH_MM; } +// ----------------------------------------------------------------------------- +uno::Reference< container::XNameAccess > OReportController::getColumns() const +{ + if ( !m_xColumns.is() && m_xReportDefinition.is() && m_xReportDefinition->getCommand().getLength() ) + { + m_xColumns = dbtools::getFieldsByCommandDescriptor(getConnection(),m_xReportDefinition->getCommandType(),m_xReportDefinition->getCommand(),m_xHoldAlive); + } + return m_xColumns; +} +// ----------------------------------------------------------------------------- +::rtl::OUString OReportController::getColumnLabel_throw(const ::rtl::OUString& i_sColumnName) const +{ + ::rtl::OUString sLabel; + uno::Reference< container::XNameAccess > xColumns = getColumns(); + if ( xColumns.is() && xColumns->hasByName(i_sColumnName) ) + { + uno::Reference< beans::XPropertySet> xColumn(xColumns->getByName(i_sColumnName),uno::UNO_QUERY_THROW); + if ( xColumn->getPropertySetInfo()->hasPropertyByName(PROPERTY_LABEL) ) + xColumn->getPropertyValue(PROPERTY_LABEL) >>= sLabel; + } + return sLabel; +} +// ----------------------------------------------------------------------------- diff --git a/reportdesign/source/ui/report/SectionWindow.cxx b/reportdesign/source/ui/report/SectionWindow.cxx index a781a9f654d7..686a6515854a 100644 --- a/reportdesign/source/ui/report/SectionWindow.cxx +++ b/reportdesign/source/ui/report/SectionWindow.cxx @@ -32,7 +32,6 @@ #include "ReportWindow.hxx" #include "ReportRuler.hxx" #include "rptui_slotid.hrc" -#include <svtools/colorcfg.hxx> #include "ReportController.hxx" #include "SectionView.hxx" #include "RptDef.hxx" @@ -41,13 +40,16 @@ #include "uistrings.hrc" #include "helpids.hrc" #include "RptResId.hrc" +#include "StartMarker.hxx" +#include "EndMarker.hxx" +#include "ViewsWindow.hxx" + +#include <svtools/colorcfg.hxx> #include <boost/bind.hpp> #include <functional> #include <algorithm> #include <vcl/svapp.hxx> -#include "StartMarker.hxx" -#include "EndMarker.hxx" -#include "ViewsWindow.hxx" +#include <connectivity/dbtools.hxx> namespace rptui { @@ -195,8 +197,15 @@ bool OSectionWindow::setGroupSectionTitle(const uno::Reference< report::XGroup>& const bool bRet = _pIsSectionOn(&aGroupHelper) && _pGetSection(&aGroupHelper) == m_aReportSection.getSection() ; if ( bRet ) { + ::rtl::OUString sExpression = _xGroup->getExpression(); + ::rtl::OUString sLabel = getViewsWindow()->getView()->getReportView()->getController().getColumnLabel_throw(sExpression); + if ( sLabel.getLength() ) + { + sExpression = sLabel; + } + String sTitle = String(ModuleRes(_nResId)); - sTitle.SearchAndReplace('#',_xGroup->getExpression()); + sTitle.SearchAndReplace('#',sExpression); m_aStartMarker.setTitle(sTitle); m_aStartMarker.Invalidate(INVALIDATE_CHILDREN); } // if ( _pIsSectionOn(&aGroupHelper) ) |