summaryrefslogtreecommitdiff
path: root/dbaccess/source
diff options
context:
space:
mode:
Diffstat (limited to 'dbaccess/source')
-rw-r--r--dbaccess/source/core/recovery/subcomponentrecovery.cxx36
-rw-r--r--dbaccess/source/ui/inc/JoinController.hxx6
-rw-r--r--dbaccess/source/ui/inc/QueryDesignView.hxx4
-rw-r--r--dbaccess/source/ui/inc/QueryViewSwitch.hxx5
-rw-r--r--dbaccess/source/ui/inc/TableFieldDescription.hxx13
-rw-r--r--dbaccess/source/ui/inc/querycontainerwindow.hxx1
-rw-r--r--dbaccess/source/ui/inc/querycontroller.hxx9
-rw-r--r--dbaccess/source/ui/querydesign/JoinController.cxx82
-rw-r--r--dbaccess/source/ui/querydesign/QueryDesignView.cxx25
-rw-r--r--dbaccess/source/ui/querydesign/QueryViewSwitch.cxx87
-rw-r--r--dbaccess/source/ui/querydesign/TableFieldDescription.cxx117
-rw-r--r--dbaccess/source/ui/querydesign/querycontainerwindow.cxx6
-rw-r--r--dbaccess/source/ui/querydesign/querycontroller.cxx102
13 files changed, 312 insertions, 181 deletions
diff --git a/dbaccess/source/core/recovery/subcomponentrecovery.cxx b/dbaccess/source/core/recovery/subcomponentrecovery.cxx
index 4551c83083ee..bcfc3131892f 100644
--- a/dbaccess/source/core/recovery/subcomponentrecovery.cxx
+++ b/dbaccess/source/core/recovery/subcomponentrecovery.cxx
@@ -636,10 +636,40 @@ namespace dbaccess
aDesignInput.import( pDocHandler.get() );
const ::comphelper::NamedValueCollection& rSettings( pDocHandler->getSettings() );
+ const Any aCurrentQueryDesign = rSettings.get( lcl_getCurrentQueryDesignName() );
+#if OSL_DEBUG_LEVEL > 0
+ Sequence< PropertyValue > aQueryDesignLayout;
+ OSL_VERIFY( aCurrentQueryDesign >>= aQueryDesignLayout );
+#endif
- // TODO
- (void)i_rComponentName;
- (void)i_bForEditing;
+ // then load the query designer
+ ::comphelper::NamedValueCollection aLoadArgs;
+ aLoadArgs.put( "CurrentQueryDesign", aCurrentQueryDesign );
+
+ // TODO: load the thing hidden, and show when the main doc window is shown
+
+ if ( i_rComponentName.getLength() )
+ {
+ xSubComponent.set( m_xDocumentUI->loadComponentWithArguments(
+ m_eType,
+ i_rComponentName,
+ i_bForEditing,
+ aLoadArgs.getPropertyValues()
+ ),
+ UNO_SET_THROW
+ );
+ }
+ else
+ {
+ Reference< XComponent > xDummy;
+ xSubComponent.set( m_xDocumentUI->createComponentWithArguments(
+ m_eType,
+ aLoadArgs.getPropertyValues(),
+ xDummy
+ ),
+ UNO_SET_THROW
+ );
+ }
return xSubComponent;
}
diff --git a/dbaccess/source/ui/inc/JoinController.hxx b/dbaccess/source/ui/inc/JoinController.hxx
index 72e61c4bab3d..6561e7b9f282 100644
--- a/dbaccess/source/ui/inc/JoinController.hxx
+++ b/dbaccess/source/ui/inc/JoinController.hxx
@@ -87,16 +87,16 @@ namespace dbaui
virtual void Execute(sal_uInt16 nId, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& aArgs);
/** loads the information for the windows.
- @param _aViewProps
+ @param i_rViewSettings
The properties which comes from the layout information.
*/
- void loadTableWindows(const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& _aViewProps);
+ void loadTableWindows( const ::comphelper::NamedValueCollection& i_rViewSettings );
/** loads the information for one window.
@param _rTable
The properties which comes from the layout information.
*/
- void loadTableWindow(const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue>& _rTable);
+ void loadTableWindow( const ::comphelper::NamedValueCollection& i_rTableWindowSettings );
/** saves the TableWindows structure in a sequence of property values
@param _rViewProps
diff --git a/dbaccess/source/ui/inc/QueryDesignView.hxx b/dbaccess/source/ui/inc/QueryDesignView.hxx
index 6a97719e0c27..cf501441e4ee 100644
--- a/dbaccess/source/ui/inc/QueryDesignView.hxx
+++ b/dbaccess/source/ui/inc/QueryDesignView.hxx
@@ -167,6 +167,10 @@ namespace dbaui
*/
bool initByParseIterator( ::dbtools::SQLExceptionInfo* _pErrorInfo );
+ void initByFieldDescriptions(
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& i_rFieldDescriptions
+ );
+
::connectivity::OSQLParseNode* getPredicateTreeFromEntry( OTableFieldDescRef pEntry,
const String& _sCriteria,
::rtl::OUString& _rsErrorMessage,
diff --git a/dbaccess/source/ui/inc/QueryViewSwitch.hxx b/dbaccess/source/ui/inc/QueryViewSwitch.hxx
index c0692ba48af0..abeccbac4ce2 100644
--- a/dbaccess/source/ui/inc/QueryViewSwitch.hxx
+++ b/dbaccess/source/ui/inc/QueryViewSwitch.hxx
@@ -78,6 +78,7 @@ namespace dbaui
old state)
*/
bool switchView( ::dbtools::SQLExceptionInfo* _pErrorInfo );
+ void forceInitialView();
sal_Bool isSlotEnabled(sal_Int32 _nSlotId);
void setSlotEnabled(sal_Int32 _nSlotId,sal_Bool _bEnable);
void setNoneVisbleRow(sal_Int32 _nRows);
@@ -96,6 +97,10 @@ namespace dbaui
protected:
// return the Rectangle where I can paint myself
virtual void resizeDocumentView(Rectangle& rRect);
+
+ private:
+ void impl_forceSQLView();
+ bool impl_postViewSwitch( const bool i_bGraphicalDesign, const bool i_bSuccess );
};
}
#endif // DBAUI_QUERYVIEWSWITCH_HXX
diff --git a/dbaccess/source/ui/inc/TableFieldDescription.hxx b/dbaccess/source/ui/inc/TableFieldDescription.hxx
index dd4489821331..64d17909fcce 100644
--- a/dbaccess/source/ui/inc/TableFieldDescription.hxx
+++ b/dbaccess/source/ui/inc/TableFieldDescription.hxx
@@ -58,7 +58,8 @@ namespace dbaui
class OTableFieldDesc : public ::vos::OReference
{
private:
- ::std::vector< ::rtl::OUString> m_vecCriteria;
+ ::std::vector< ::rtl::OUString >
+ m_aCriteria;
::rtl::OUString m_aTableName;
::rtl::OUString m_aAliasName; // table range
@@ -136,18 +137,18 @@ namespace dbaui
sal_Bool HasCriteria() const
{
- ::std::vector< ::rtl::OUString>::const_iterator aIter = m_vecCriteria.begin();
- ::std::vector< ::rtl::OUString>::const_iterator aEnd = m_vecCriteria.end();
+ ::std::vector< ::rtl::OUString>::const_iterator aIter = m_aCriteria.begin();
+ ::std::vector< ::rtl::OUString>::const_iterator aEnd = m_aCriteria.end();
for(;aIter != aEnd;++aIter)
if(aIter->getLength())
break;
return aIter != aEnd;
}
- const ::std::vector< ::rtl::OUString>& GetCriteria() const { return m_vecCriteria;}
+ const ::std::vector< ::rtl::OUString>& GetCriteria() const { return m_aCriteria; }
- void Load(const ::com::sun::star::beans::PropertyValue& _rProperty);
- void Save( ::comphelper::NamedValueCollection& o_rSettings );
+ void Load( const ::com::sun::star::beans::PropertyValue& i_rSettings, const bool i_bIncludingCriteria );
+ void Save( ::comphelper::NamedValueCollection& o_rSettings, const bool i_bIncludingCriteria );
};
//------------------------------------------------------------------
diff --git a/dbaccess/source/ui/inc/querycontainerwindow.hxx b/dbaccess/source/ui/inc/querycontainerwindow.hxx
index 44af65ed2b2a..8d7bb4f7999f 100644
--- a/dbaccess/source/ui/inc/querycontainerwindow.hxx
+++ b/dbaccess/source/ui/inc/querycontainerwindow.hxx
@@ -118,6 +118,7 @@ namespace dbaui
bool reset( ::dbtools::SQLExceptionInfo* _pErrorInfo ) { return m_pViewSwitch->reset( _pErrorInfo ); }
bool switchView( ::dbtools::SQLExceptionInfo* _pErrorInfo );
+ void forceInitialView();
virtual void GetFocus();
diff --git a/dbaccess/source/ui/inc/querycontroller.hxx b/dbaccess/source/ui/inc/querycontroller.hxx
index eeabaa13192b..c119095c28bb 100644
--- a/dbaccess/source/ui/inc/querycontroller.hxx
+++ b/dbaccess/source/ui/inc/querycontroller.hxx
@@ -130,8 +130,8 @@ namespace dbaui
void executeQuery();
bool doSaveAsDoc(sal_Bool _bSaveAs);
- void saveViewSettings( ::comphelper::NamedValueCollection& o_rViewSettings, const bool i_includngCriteria ) const;
- void loadViewSettings( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& i_rViewData );
+ void saveViewSettings( ::comphelper::NamedValueCollection& o_rViewSettings, const bool i_includingCriteria ) const;
+ void loadViewSettings( const ::comphelper::NamedValueCollection& o_rViewSettings );
::rtl::OUString translateStatement( bool _bFireStatementChange = true );
::rtl::OUString getDefaultName() const;
@@ -175,6 +175,9 @@ namespace dbaui
sal_Int32 getColWidth(sal_uInt16 _nColPos) const;
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >&
+ getFieldInformation() const { return m_aFieldInformation; }
+
::connectivity::OSQLParser& getParser() { return m_aSqlParser; }
::connectivity::OSQLParseTreeIterator& getParseIterator() { return *m_pSqlIterator; }
@@ -231,7 +234,7 @@ namespace dbaui
virtual void reset();
virtual void impl_initialize();
- void impl_reset();
+ void impl_reset( const bool i_bIgnoreQuerySettings = false );
/// tells the user that we needed to switch to SQL view automatically
void impl_showAutoSQLViewError( const ::com::sun::star::uno::Any& _rErrorDetails );
diff --git a/dbaccess/source/ui/querydesign/JoinController.cxx b/dbaccess/source/ui/querydesign/JoinController.cxx
index 7191bf6252b6..0582230e0191 100644
--- a/dbaccess/source/ui/querydesign/JoinController.cxx
+++ b/dbaccess/source/ui/querydesign/JoinController.cxx
@@ -455,73 +455,45 @@ sal_Bool SAL_CALL OJoinController::suspend(sal_Bool _bSuspend) throw( RuntimeExc
return bCheck;
}
// -----------------------------------------------------------------------------
-void OJoinController::loadTableWindows(const Sequence<PropertyValue>& aViewProps)
+void OJoinController::loadTableWindows( const ::comphelper::NamedValueCollection& i_rViewSettings )
{
m_vTableData.clear();
- const PropertyValue *pIter = aViewProps.getConstArray();
- const PropertyValue *pEnd = pIter + aViewProps.getLength();
- for (; pIter != pEnd; ++pIter)
+ m_aMinimumTableViewSize = Point();
+
+ Sequence< PropertyValue > aWindowData;
+ aWindowData = i_rViewSettings.getOrDefault( "Tables", aWindowData );
+
+ const PropertyValue* pTablesIter = aWindowData.getConstArray();
+ const PropertyValue* pTablesEnd = pTablesIter + aWindowData.getLength();
+ for ( ; pTablesIter != pTablesEnd; ++pTablesIter )
{
- if ( pIter->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "Tables" ) ) )
- {
- m_aMinimumTableViewSize = Point();
- Sequence<PropertyValue> aWindow;
- pIter->Value >>= aWindow;
- const PropertyValue *pTablesIter = aWindow.getConstArray();
- const PropertyValue *pTablesEnd = pTablesIter + aWindow.getLength();
- for (; pTablesIter != pTablesEnd; ++pTablesIter)
- {
- Sequence<PropertyValue> aTable;
- pTablesIter->Value >>= aTable;
- loadTableWindow(aTable);
- }
- if ( m_aMinimumTableViewSize != Point() )
- {
- getJoinView()->getScrollHelper()->resetRange(m_aMinimumTableViewSize);
- }
- break;
- }
+ ::comphelper::NamedValueCollection aSingleTableData( pTablesIter->Value );
+ loadTableWindow( aSingleTableData );
+ }
+ if ( m_aMinimumTableViewSize != Point() )
+ {
+ getJoinView()->getScrollHelper()->resetRange( m_aMinimumTableViewSize );
}
}
+
// -----------------------------------------------------------------------------
-void OJoinController::loadTableWindow(const Sequence<PropertyValue>& _rTable)
+void OJoinController::loadTableWindow( const ::comphelper::NamedValueCollection& i_rTableWindowSettings )
{
sal_Int32 nX = -1, nY = -1, nHeight = -1, nWidth = -1;
::rtl::OUString sComposedName,sTableName,sWindowName;
sal_Bool bShowAll = false;
- const PropertyValue *pIter = _rTable.getConstArray();
- const PropertyValue *pEnd = pIter + _rTable.getLength();
- for (; pIter != pEnd; ++pIter)
- {
- if ( pIter->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "ComposedName" ) ) )
- pIter->Value >>= sComposedName;
- else if ( pIter->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "TableName" ) ) )
- pIter->Value >>= sTableName;
- else if ( pIter->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "WindowName" ) ) )
- pIter->Value >>= sWindowName;
- else if ( pIter->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "WindowTop" ) ) )
- {
- pIter->Value >>= nY;
- }
- else if ( pIter->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "WindowLeft" ) ) )
- {
- pIter->Value >>= nX;
- }
- else if ( pIter->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "WindowWidth" ) ) )
- {
- pIter->Value >>= nWidth;
- }
- else if ( pIter->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "WindowHeight" ) ) )
- {
- pIter->Value >>= nHeight;
- }
- else if ( pIter->Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( "ShowAll" ) ) )
- {
- pIter->Value >>= bShowAll;
- }
- }
+
+ sComposedName = i_rTableWindowSettings.getOrDefault( "ComposedName", sComposedName );
+ sTableName = i_rTableWindowSettings.getOrDefault( "TableName", sTableName );
+ sWindowName = i_rTableWindowSettings.getOrDefault( "WindowName", sWindowName );
+ nY = i_rTableWindowSettings.getOrDefault( "WindowTop", nY );
+ nX = i_rTableWindowSettings.getOrDefault( "WindowLeft", nX );
+ nWidth = i_rTableWindowSettings.getOrDefault( "WindowWidth", nWidth );
+ nHeight = i_rTableWindowSettings.getOrDefault( "WindowHeight", nHeight );
+ bShowAll = i_rTableWindowSettings.getOrDefault( "ShowAll", bShowAll );
+
TTableWindowData::value_type pData = createTableWindowData(sComposedName,sTableName,sWindowName);
if ( pData )
{
diff --git a/dbaccess/source/ui/querydesign/QueryDesignView.cxx b/dbaccess/source/ui/querydesign/QueryDesignView.cxx
index 624763306d04..3f927076f4a9 100644
--- a/dbaccess/source/ui/querydesign/QueryDesignView.cxx
+++ b/dbaccess/source/ui/querydesign/QueryDesignView.cxx
@@ -1992,6 +1992,7 @@ namespace
(*aIter) = NULL;
OTableFields().swap( rUnUsedFields );
}
+
//------------------------------------------------------------------------------
SqlParseError InitFromParseNodeImpl(OQueryDesignView* _pView,OSelectionBrowseBox* _pSelectionBrw)
{
@@ -3180,6 +3181,30 @@ void OQueryDesignView::setNoneVisbleRow(sal_Int32 _nRows)
{
m_pSelectionBox->SetNoneVisbleRow(_nRows);
}
+
+// -----------------------------------------------------------------------------
+void OQueryDesignView::initByFieldDescriptions( const Sequence< PropertyValue >& i_rFieldDescriptions )
+{
+ OQueryController& rController = static_cast< OQueryController& >( getController() );
+
+ m_pSelectionBox->PreFill();
+ m_pSelectionBox->SetReadOnly( rController.isReadOnly() );
+ m_pSelectionBox->Fill();
+
+ for ( const PropertyValue* field = i_rFieldDescriptions.getConstArray();
+ field != i_rFieldDescriptions.getConstArray() + i_rFieldDescriptions.getLength();
+ ++field
+ )
+ {
+ ::vos::ORef< OTableFieldDesc > pField( new OTableFieldDesc() );
+ pField->Load( *field, true );
+ InsertField( pField, sal_True, sal_False );
+ }
+
+ rController.getUndoMgr()->Clear();
+ m_pSelectionBox->Invalidate();
+}
+
// -----------------------------------------------------------------------------
bool OQueryDesignView::initByParseIterator( ::dbtools::SQLExceptionInfo* _pErrorInfo )
{
diff --git a/dbaccess/source/ui/querydesign/QueryViewSwitch.cxx b/dbaccess/source/ui/querydesign/QueryViewSwitch.cxx
index 36b7afe6d727..90ff0685e229 100644
--- a/dbaccess/source/ui/querydesign/QueryViewSwitch.cxx
+++ b/dbaccess/source/ui/querydesign/QueryViewSwitch.cxx
@@ -208,37 +208,68 @@ OQueryContainerWindow* OQueryViewSwitch::getContainer() const
}
// -----------------------------------------------------------------------------
-bool OQueryViewSwitch::switchView( ::dbtools::SQLExceptionInfo* _pErrorInfo )
+void OQueryViewSwitch::impl_forceSQLView()
{
- sal_Bool bRet = sal_True;
- sal_Bool bGraphicalDesign = static_cast<OQueryController&>(m_pDesignView->getController()).isGraphicalDesign();
-
OAddTableDlg* pAddTabDialog( getAddTableDialog() );
- OQueryContainerWindow* pContainer = getContainer();
+ // hide the "Add Table" dialog
+ m_bAddTableDialogWasVisible = pAddTabDialog ? pAddTabDialog->IsVisible() : false;
+ if ( m_bAddTableDialogWasVisible )
+ pAddTabDialog->Hide();
+
+ // tell the views they're in/active
+ m_pDesignView->stopTimer();
+ m_pTextView->getSqlEdit()->startTimer();
+
+ // set the most recent statement at the text view
+ m_pTextView->clear();
+ m_pTextView->setStatement(static_cast<OQueryController&>(m_pDesignView->getController()).getStatement());
+}
+
+// -----------------------------------------------------------------------------
+void OQueryViewSwitch::forceInitialView()
+{
+ OQueryController& rQueryController( static_cast< OQueryController& >( m_pDesignView->getController() ) );
+ const sal_Bool bGraphicalDesign = rQueryController.isGraphicalDesign();
if ( !bGraphicalDesign )
+ impl_forceSQLView();
+ else
{
- // hide the "Add Table" dialog
- m_bAddTableDialogWasVisible = pAddTabDialog ? pAddTabDialog->IsVisible() : false;
- if ( m_bAddTableDialogWasVisible )
- pAddTabDialog->Hide();
+ // tell the text view it's inactive now
+ m_pTextView->getSqlEdit()->stopTimer();
+
+ // update the "Add Table" dialog
+ OAddTableDlg* pAddTabDialog( getAddTableDialog() );
+ if ( pAddTabDialog )
+ pAddTabDialog->Update();
- // tell the views they're in/active
- m_pDesignView->stopTimer();
- m_pTextView->getSqlEdit()->startTimer();
+ // initialize the design view
+ m_pDesignView->initByFieldDescriptions( rQueryController.getFieldInformation() );
- // set the most recent statement at the text view
- m_pTextView->clear();
- m_pTextView->setStatement(static_cast<OQueryController&>(m_pDesignView->getController()).getStatement());
+ // tell the design view it's active now
+ m_pDesignView->startTimer();
+ }
+
+ impl_postViewSwitch( bGraphicalDesign, true );
+}
+
+// -----------------------------------------------------------------------------
+bool OQueryViewSwitch::switchView( ::dbtools::SQLExceptionInfo* _pErrorInfo )
+{
+ sal_Bool bRet = sal_True;
+ sal_Bool bGraphicalDesign = static_cast<OQueryController&>(m_pDesignView->getController()).isGraphicalDesign();
+
+ if ( !bGraphicalDesign )
+ {
+ impl_forceSQLView();
}
else
{
// tell the text view it's inactive now
m_pTextView->getSqlEdit()->stopTimer();
- ::rtl::OUString sOldStatement = static_cast<OQueryController&>(m_pDesignView->getController()).getStatement();
-
// update the "Add Table" dialog
+ OAddTableDlg* pAddTabDialog( getAddTableDialog() );
if ( pAddTabDialog )
pAddTabDialog->Update();
@@ -249,24 +280,34 @@ bool OQueryViewSwitch::switchView( ::dbtools::SQLExceptionInfo* _pErrorInfo )
m_pDesignView->startTimer();
}
- if ( bRet )
+ return impl_postViewSwitch( bGraphicalDesign, bRet );
+}
+
+// -----------------------------------------------------------------------------
+bool OQueryViewSwitch::impl_postViewSwitch( const bool i_bGraphicalDesign, const bool i_bSuccess )
+{
+ if ( i_bSuccess )
{
- m_pTextView->Show ( !bGraphicalDesign );
- m_pDesignView->Show ( bGraphicalDesign );
- if ( bGraphicalDesign && m_bAddTableDialogWasVisible && pAddTabDialog )
- pAddTabDialog->Show();
+ m_pTextView->Show ( !i_bGraphicalDesign );
+ m_pDesignView->Show ( i_bGraphicalDesign );
+ OAddTableDlg* pAddTabDialog( getAddTableDialog() );
+ if ( pAddTabDialog )
+ if ( i_bGraphicalDesign && m_bAddTableDialogWasVisible )
+ pAddTabDialog->Show();
GrabFocus();
}
+ OQueryContainerWindow* pContainer = getContainer();
if ( pContainer )
pContainer->Resize();
m_pDesignView->getController().getUndoMgr()->Clear();
m_pDesignView->getController().InvalidateAll();
- return bRet;
+ return i_bSuccess;
}
+
// -----------------------------------------------------------------------------
OAddTableDlg* OQueryViewSwitch::getAddTableDialog()
{
diff --git a/dbaccess/source/ui/querydesign/TableFieldDescription.cxx b/dbaccess/source/ui/querydesign/TableFieldDescription.cxx
index 4b053661df1b..577f6a0f48ba 100644
--- a/dbaccess/source/ui/querydesign/TableFieldDescription.cxx
+++ b/dbaccess/source/ui/querydesign/TableFieldDescription.cxx
@@ -97,7 +97,7 @@ OTableFieldDesc& OTableFieldDesc::operator=( const OTableFieldDesc& rRS )
if (&rRS == this)
return *this;
- m_vecCriteria = rRS.m_vecCriteria;
+ m_aCriteria = rRS.GetCriteria();
m_aTableName = rRS.GetTable();
m_aAliasName = rRS.GetAlias(); // table range
m_aFieldName = rRS.GetField(); // column
@@ -128,7 +128,7 @@ sal_Bool OTableFieldDesc::operator==( const OTableFieldDesc& rDesc )
m_aFieldName != rDesc.GetField() ||
m_aTableName != rDesc.GetTable() ||
m_bGroupBy != rDesc.IsGroupBy() ||
- m_vecCriteria != rDesc.GetCriteria() ||
+ m_aCriteria != rDesc.GetCriteria() ||
m_bVisible != rDesc.IsVisible() );
}
@@ -137,13 +137,13 @@ sal_Bool OTableFieldDesc::operator==( const OTableFieldDesc& rDesc )
void OTableFieldDesc::SetCriteria( sal_uInt16 nIdx, const ::rtl::OUString& rCrit)
{
DBG_CHKTHIS(OTableFieldDesc,NULL);
- if (nIdx < m_vecCriteria.size())
- m_vecCriteria[nIdx] = rCrit;
+ if (nIdx < m_aCriteria.size())
+ m_aCriteria[nIdx] = rCrit;
else
{
- for(sal_Int32 i=m_vecCriteria.size();i<nIdx;++i)
- m_vecCriteria.push_back( ::rtl::OUString());
- m_vecCriteria.push_back(rCrit);
+ for(sal_Int32 i=m_aCriteria.size();i<nIdx;++i)
+ m_aCriteria.push_back( ::rtl::OUString());
+ m_aCriteria.push_back(rCrit);
}
}
@@ -152,60 +152,60 @@ void OTableFieldDesc::SetCriteria( sal_uInt16 nIdx, const ::rtl::OUString& rCrit
{
DBG_CHKTHIS(OTableFieldDesc,NULL);
::rtl::OUString aRetStr;
- if( nIdx < m_vecCriteria.size())
- aRetStr = m_vecCriteria[nIdx];
+ if( nIdx < m_aCriteria.size())
+ aRetStr = m_aCriteria[nIdx];
return aRetStr;
}
// -----------------------------------------------------------------------------
-void OTableFieldDesc::Load(const ::com::sun::star::beans::PropertyValue& _rProperty)
+namespace
{
- DBG_CHKTHIS(OTableFieldDesc,NULL);
- Sequence<PropertyValue> aFieldDesc;
- _rProperty.Value >>= aFieldDesc;
- //if ( aFieldDesc.getLength() == 12 )
+ struct SelectPropertyValueAsString : public ::std::unary_function< PropertyValue, ::rtl::OUString >
{
- sal_Int32 nCount = aFieldDesc.getLength();
- for (sal_Int32 nPos = 0; nPos < nCount; ++nPos)
+ ::rtl::OUString operator()( const PropertyValue& i_rPropValue ) const
{
- if ( aFieldDesc[nPos].Name.equalsAscii("AliasName") )
- aFieldDesc[nPos].Value >>= m_aAliasName;
- else if ( aFieldDesc[nPos].Name.equalsAscii("TableName") )
- aFieldDesc[nPos].Value >>= m_aTableName;
- else if ( aFieldDesc[nPos].Name.equalsAscii("FieldName") )
- aFieldDesc[nPos].Value >>= m_aFieldName;
- else if ( aFieldDesc[nPos].Name.equalsAscii("FieldAlias") )
- aFieldDesc[nPos].Value >>= m_aFieldAlias;
- else if ( aFieldDesc[nPos].Name.equalsAscii("FunctionName") )
- aFieldDesc[nPos].Value >>= m_aFunctionName;
- else if ( aFieldDesc[nPos].Name.equalsAscii("DataType") )
- aFieldDesc[nPos].Value >>= m_eDataType;
- else if ( aFieldDesc[nPos].Name.equalsAscii("FunctionType") )
- aFieldDesc[nPos].Value >>= m_eFunctionType;
- else if ( aFieldDesc[nPos].Name.equalsAscii("FieldType") )
- {
- sal_Int32 nTemp = 0;
- aFieldDesc[nPos].Value >>= nTemp;
- m_eFieldType = static_cast<ETableFieldType>(nTemp);
- }
- else if ( aFieldDesc[nPos].Name.equalsAscii("OrderDir") )
- {
- sal_Int32 nTemp = 0;
- aFieldDesc[nPos].Value >>= nTemp;
- m_eOrderDir = static_cast<EOrderDir>(nTemp);
- }
- else if ( aFieldDesc[nPos].Name.equalsAscii("ColWidth") )
- aFieldDesc[nPos].Value >>= m_nColWidth;
- else if ( aFieldDesc[nPos].Name.equalsAscii("GroupBy") )
- aFieldDesc[nPos].Value >>= m_bGroupBy;
- else if ( aFieldDesc[nPos].Name.equalsAscii("Visible") )
- aFieldDesc[nPos].Value >>= m_bVisible;
+ ::rtl::OUString sValue;
+ OSL_VERIFY( i_rPropValue.Value >>= sValue );
+ return sValue;
}
+ };
+}
+
+// -----------------------------------------------------------------------------
+void OTableFieldDesc::Load( const ::com::sun::star::beans::PropertyValue& i_rSettings, const bool i_bIncludingCriteria )
+{
+ DBG_CHKTHIS(OTableFieldDesc,NULL);
+
+ ::comphelper::NamedValueCollection aFieldDesc( i_rSettings.Value );
+ m_aAliasName = aFieldDesc.getOrDefault( "AliasName", m_aAliasName );
+ m_aTableName = aFieldDesc.getOrDefault( "TableName", m_aTableName );
+ m_aFieldName = aFieldDesc.getOrDefault( "FieldName", m_aFieldName );
+ m_aFieldAlias = aFieldDesc.getOrDefault( "FieldAlias", m_aFieldAlias );
+ m_aFunctionName = aFieldDesc.getOrDefault( "FunctionName", m_aFunctionName );
+ m_eDataType = aFieldDesc.getOrDefault( "DataType", m_eDataType );
+ m_eFunctionType = aFieldDesc.getOrDefault( "FunctionType", m_eFunctionType );
+ m_nColWidth = aFieldDesc.getOrDefault( "ColWidth", m_nColWidth );
+ m_bGroupBy = aFieldDesc.getOrDefault( "GroupBy", m_bGroupBy );
+ m_bVisible = aFieldDesc.getOrDefault( "Visible", m_bVisible );
+
+ m_eFieldType = static_cast< ETableFieldType >( aFieldDesc.getOrDefault( "FieldType", static_cast< sal_Int32 >( m_eFieldType ) ) );
+ m_eOrderDir = static_cast< EOrderDir >( aFieldDesc.getOrDefault( "OrderDir", static_cast< sal_Int32 >( m_eOrderDir ) ) );
+
+ if ( i_bIncludingCriteria )
+ {
+ const Sequence< PropertyValue > aCriteria( aFieldDesc.getOrDefault( "Criteria", Sequence< PropertyValue >() ) );
+ m_aCriteria.resize( aCriteria.getLength() );
+ ::std::transform(
+ aCriteria.getConstArray(),
+ aCriteria.getConstArray() + aCriteria.getLength(),
+ m_aCriteria.begin(),
+ SelectPropertyValueAsString()
+ );
}
}
//------------------------------------------------------------------------------
-void OTableFieldDesc::Save( ::comphelper::NamedValueCollection& o_rSettings )
+void OTableFieldDesc::Save( ::comphelper::NamedValueCollection& o_rSettings, const bool i_bIncludingCriteria )
{
DBG_CHKTHIS(OTableFieldDesc,NULL);
@@ -221,6 +221,25 @@ void OTableFieldDesc::Save( ::comphelper::NamedValueCollection& o_rSettings )
o_rSettings.put( "ColWidth", m_nColWidth );
o_rSettings.put( "GroupBy", m_bGroupBy );
o_rSettings.put( "Visible", m_bVisible );
+
+ if ( i_bIncludingCriteria )
+ {
+ if ( !m_aCriteria.empty() )
+ {
+ sal_Int32 c = 0;
+ Sequence< PropertyValue > aCriteria( m_aCriteria.size() );
+ for ( ::std::vector< ::rtl::OUString >::const_iterator crit = m_aCriteria.begin();
+ crit != m_aCriteria.end();
+ ++crit, ++c
+ )
+ {
+ aCriteria[c].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Criterion_" ) ) + ::rtl::OUString::valueOf( c );
+ aCriteria[c].Value <<= *crit;
+ }
+
+ o_rSettings.put( "Criteria", aCriteria );
+ }
+ }
}
// -----------------------------------------------------------------------------
diff --git a/dbaccess/source/ui/querydesign/querycontainerwindow.cxx b/dbaccess/source/ui/querydesign/querycontainerwindow.cxx
index 785e29bb9a0c..91e85454a399 100644
--- a/dbaccess/source/ui/querydesign/querycontainerwindow.cxx
+++ b/dbaccess/source/ui/querydesign/querycontainerwindow.cxx
@@ -126,6 +126,12 @@ namespace dbaui
}
// -----------------------------------------------------------------------------
+ void OQueryContainerWindow::forceInitialView()
+ {
+ return m_pViewSwitch->forceInitialView();
+ }
+
+ // -----------------------------------------------------------------------------
void OQueryContainerWindow::resizeAll( const Rectangle& _rPlayground )
{
Rectangle aPlayground( _rPlayground );
diff --git a/dbaccess/source/ui/querydesign/querycontroller.cxx b/dbaccess/source/ui/querydesign/querycontroller.cxx
index aab0703b364c..05bac818cdee 100644
--- a/dbaccess/source/ui/querydesign/querycontroller.cxx
+++ b/dbaccess/source/ui/querydesign/querycontroller.cxx
@@ -401,6 +401,7 @@ void SAL_CALL OQueryController::getFastPropertyValue( Any& o_rValue, sal_Int32 i
{
getContainer()->SaveUIConfig();
saveViewSettings( aCurrentDesign, true );
+ aCurrentDesign.put( "Statement", m_sStatement );
}
else
{
@@ -858,6 +859,9 @@ void OQueryController::impl_initialize()
::rtl::OUString sCommand;
m_nCommandType = CommandType::QUERY;
+ // °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
+ // ° reading parameters
+ // °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
// legacy parameters first (later overwritten by regular parameters)
::rtl::OUString sIndependentSQLCommand;
if ( rArguments.get_ensureType( "IndependentSQLCommand", sIndependentSQLCommand ) )
@@ -927,6 +931,37 @@ void OQueryController::impl_initialize()
m_bGraphicalDesign = false;
}
+ // .................................................................................................................
+ // . initial design
+ bool bForceInitialDesign = false;
+ Sequence< PropertyValue > aCurrentQueryDesignProps;
+ aCurrentQueryDesignProps = rArguments.getOrDefault( "CurrentQueryDesign", aCurrentQueryDesignProps );
+
+ if ( aCurrentQueryDesignProps.getLength() )
+ {
+ ::comphelper::NamedValueCollection aCurrentQueryDesign( aCurrentQueryDesignProps );
+ if ( aCurrentQueryDesign.has( (::rtl::OUString)PROPERTY_GRAPHICAL_DESIGN ) )
+ {
+ aCurrentQueryDesign.get_ensureType( (::rtl::OUString)PROPERTY_GRAPHICAL_DESIGN, m_bGraphicalDesign );
+ }
+ if ( aCurrentQueryDesign.has( (::rtl::OUString)PROPERTY_ESCAPE_PROCESSING ) )
+ {
+ aCurrentQueryDesign.get_ensureType( (::rtl::OUString)PROPERTY_ESCAPE_PROCESSING, m_bEscapeProcessing );
+ }
+ if ( aCurrentQueryDesign.has( "Statement" ) )
+ {
+ ::rtl::OUString sStatement;
+ aCurrentQueryDesign.get_ensureType( "Statement", sStatement );
+ aCurrentQueryDesign.remove( "Statement" );
+ setStatement_fireEvent( sStatement );
+ }
+
+ loadViewSettings( aCurrentQueryDesign );
+
+ bForceInitialDesign = true;
+ }
+
+ // °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
if ( !ensureConnected( sal_False ) )
{ // we have no connection so what else should we do
m_bGraphicalDesign = sal_False;
@@ -981,20 +1016,30 @@ void OQueryController::impl_initialize()
try
{
getContainer()->initialize();
- impl_reset();
+ impl_reset( bForceInitialDesign );
- bool bAttemptedGraphicalDesign = m_bGraphicalDesign;
SQLExceptionInfo aError;
- impl_setViewMode( &aError );
+ const bool bAttemptedGraphicalDesign = m_bGraphicalDesign;
+
+ if ( bForceInitialDesign )
+ {
+ getContainer()->forceInitialView();
+ }
+ else
+ {
+ impl_setViewMode( &aError );
+ }
+
if ( aError.isValid() && bAttemptedGraphicalDesign && !m_bGraphicalDesign )
{
+ // we tried initializing the graphical view, this failed, and we were automatically switched to SQL
+ // view => tell this to the user
if ( !editingView() )
{
impl_showAutoSQLViewError( aError.get() );
}
}
-
getUndoMgr()->Clear();
if ( ( m_bGraphicalDesign )
@@ -1159,7 +1204,7 @@ void OQueryController::reconnect(sal_Bool _bUI)
}
// -----------------------------------------------------------------------------
-void OQueryController::saveViewSettings( ::comphelper::NamedValueCollection& o_rViewSettings, const bool i_includngCriteria ) const
+void OQueryController::saveViewSettings( ::comphelper::NamedValueCollection& o_rViewSettings, const bool i_includingCriteria ) const
{
saveTableWindows( o_rViewSettings );
@@ -1172,31 +1217,10 @@ void OQueryController::saveViewSettings( ::comphelper::NamedValueCollection& o_r
{
if ( !(*field)->IsEmpty() )
{
- const ::rtl::OUString sFieldSettingName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Field" ) ) + ::rtl::OUString::valueOf( i );
-
aFieldData.clear();
- (*field)->Save( aFieldData );
-
- if ( i_includngCriteria )
- {
- const ::std::vector< ::rtl::OUString >& rCriteria( (*field)->GetCriteria() );
- if ( !rCriteria.empty() )
- {
- sal_Int32 c = 0;
- ::comphelper::NamedValueCollection aCriteria;
- for ( ::std::vector< ::rtl::OUString >::const_iterator crit = rCriteria.begin();
- crit != rCriteria.end();
- ++crit, ++c
- )
- {
- const ::rtl::OUString sCritName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Criterion_" ) ) + ::rtl::OUString::valueOf( c );
- aCriteria.put( sCritName, *crit );
- }
-
- aFieldData.put( "Criteria", aCriteria.getPropertyValues() );
- }
- }
+ (*field)->Save( aFieldData, i_includingCriteria );
+ const ::rtl::OUString sFieldSettingName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Field" ) ) + ::rtl::OUString::valueOf( i );
aAllFieldsData.put( sFieldSettingName, aFieldData.getPropertyValues() );
}
}
@@ -1206,12 +1230,13 @@ void OQueryController::saveViewSettings( ::comphelper::NamedValueCollection& o_r
o_rViewSettings.put( "VisibleRows", m_nVisibleRows );
}
// -----------------------------------------------------------------------------
-void OQueryController::loadViewSettings( const Sequence< PropertyValue >& i_rViewData )
+void OQueryController::loadViewSettings( const ::comphelper::NamedValueCollection& o_rViewSettings )
{
- const ::comphelper::NamedValueCollection aViewData( i_rViewData );
- m_nSplitPos = aViewData.getOrDefault( "SplitterPosition", m_nSplitPos );
- m_nVisibleRows = aViewData.getOrDefault( "VisibleRows", m_nVisibleRows );
- m_aFieldInformation = aViewData.getOrDefault( "Fields", m_aFieldInformation );
+ loadTableWindows( o_rViewSettings );
+
+ m_nSplitPos = o_rViewSettings.getOrDefault( "SplitterPosition", m_nSplitPos );
+ m_nVisibleRows = o_rViewSettings.getOrDefault( "VisibleRows", m_nVisibleRows );
+ m_aFieldInformation = o_rViewSettings.getOrDefault( "Fields", m_aFieldInformation );
}
// -----------------------------------------------------------------------------
sal_Int32 OQueryController::getColWidth(sal_uInt16 _nColPos) const
@@ -1219,7 +1244,7 @@ sal_Int32 OQueryController::getColWidth(sal_uInt16 _nColPos) const
if ( _nColPos < m_aFieldInformation.getLength() )
{
::std::auto_ptr<OTableFieldDesc> pField( new OTableFieldDesc());
- pField->Load(m_aFieldInformation[_nColPos]);
+ pField->Load( m_aFieldInformation[ _nColPos ], false );
return pField->GetColWidth();
}
return 0;
@@ -1639,13 +1664,13 @@ short OQueryController::saveModified()
return nRet;
}
// -----------------------------------------------------------------------------
-void OQueryController::impl_reset()
+void OQueryController::impl_reset( const bool i_bIgnoreQuerySettings )
{
bool bValid = false;
Sequence< PropertyValue > aLayoutInformation;
// get command from the query if a query name was supplied
- if ( !editingCommand() )
+ if ( !i_bIgnoreQuerySettings && !editingCommand() )
{
if ( m_sName.getLength() )
{
@@ -1695,15 +1720,14 @@ void OQueryController::impl_reset()
{
try
{
- // load the layoutInformation
- loadTableWindows(aLayoutInformation);
- loadViewSettings(aLayoutInformation);
+ loadViewSettings( aLayoutInformation );
}
catch( const Exception& )
{
DBG_UNHANDLED_EXCEPTION();
}
}
+
if ( m_sStatement.getLength() )
{
setQueryComposer();