diff options
-rw-r--r-- | sw/inc/unoobj.hxx | 12 | ||||
-rw-r--r-- | sw/source/core/unocore/unoobj2.cxx | 100 | ||||
-rw-r--r-- | sw/source/core/unocore/unotbl.cxx | 63 |
3 files changed, 79 insertions, 96 deletions
diff --git a/sw/inc/unoobj.hxx b/sw/inc/unoobj.hxx index 2456d949b3f5..3fa496669ba5 100644 --- a/sw/inc/unoobj.hxx +++ b/sw/inc/unoobj.hxx @@ -2,9 +2,9 @@ * * $RCSfile: unoobj.hxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: dvo $ $Date: 2000-12-02 20:26:31 $ + * last change: $Author: os $ $Date: 2000-12-15 14:35:51 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -235,6 +235,7 @@ enum CursorType } while( (_pStartCrsr=(SwPaM *)_pStartCrsr->GetNext()) != __pStartCrsr ); \ } + /* -----------------26.06.98 16:18------------------- * * --------------------------------------------------*/ @@ -529,8 +530,13 @@ public: static void SelectPam(SwPaM& rCrsr, sal_Bool bExpand); static void SetString(SwUnoCrsr& rUnoCrsr, const rtl::OUString& rString); -}; + static ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > + createSortDescriptor(sal_Bool bFromTable); + static sal_Bool convertSortProperties( + const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rDescriptor, + SwSortOptions& rSortOpt); +}; /*-----------------20.03.98 07:47------------------- --------------------------------------------------*/ diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 7283790ee394..f1d8fab69563 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -2,9 +2,9 @@ * * $RCSfile: unoobj2.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: os $ $Date: 2000-12-15 12:27:01 $ + * last change: $Author: os $ $Date: 2000-12-15 14:35:14 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -400,24 +400,24 @@ void SwXTextCursor::insertDocumentFromURL(const OUString& rURL, else throw uno::RuntimeException(); } -/*-- 09.12.98 14:18:58--------------------------------------------------- +/* -----------------------------15.12.00 14:01-------------------------------- - -----------------------------------------------------------------------*/ -uno::Sequence< beans::PropertyValue > SwXTextCursor::createSortDescriptor(void) throw( uno::RuntimeException ) + ---------------------------------------------------------------------------*/ +uno::Sequence< beans::PropertyValue > SwXTextCursor::createSortDescriptor(sal_Bool bFromTable) { - vos::OGuard aGuard(Application::GetSolarMutex()); uno::Sequence< beans::PropertyValue > aRet(12); beans::PropertyValue* pArray = aRet.getArray(); uno::Any aVal; sal_Bool bFalse = sal_False; sal_Bool bTrue = sal_True; - aVal.setValue( &bFalse, ::getCppuBooleanType()); + aVal.setValue( &bFromTable, ::getCppuBooleanType()); pArray[0] = beans::PropertyValue(C2U("IsSortInTable"), -1, aVal, beans::PropertyState_DIRECT_VALUE); String sSpace(String::CreateFromAscii(" ")); sal_Unicode uSpace = sSpace.GetChar(0); - aVal.setValue( &uSpace, ::getCppuCharType()); + + aVal <<= uSpace; pArray[1] = beans::PropertyValue(C2U("Delimiter"), -1, aVal, beans::PropertyState_DIRECT_VALUE); aVal.setValue( &bTrue, ::getCppuBooleanType()); @@ -451,22 +451,29 @@ uno::Sequence< beans::PropertyValue > SwXTextCursor::createSortDescriptor(void) pArray[11] = beans::PropertyValue(C2U("IsSortAscending2"), -1, aVal, beans::PropertyState_DIRECT_VALUE); return aRet; } -/*-- 09.12.98 14:19:00--------------------------------------------------- + +/*-- 09.12.98 14:18:58--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextCursor::sort(const uno::Sequence< beans::PropertyValue >& rDescriptor) - throw( uno::RuntimeException ) +uno::Sequence< beans::PropertyValue > SwXTextCursor::createSortDescriptor(void) throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); + return SwXTextCursor::createSortDescriptor(sal_False); +} +/* -----------------------------15.12.00 14:06-------------------------------- + ---------------------------------------------------------------------------*/ +sal_Bool SwXTextCursor::convertSortProperties( + const uno::Sequence< beans::PropertyValue >& rDescriptor, SwSortOptions& rSortOpt) +{ + sal_Bool bRet = sal_True; const beans::PropertyValue* pProperties = rDescriptor.getConstArray(); - SwSortOptions aSortOpt; - aSortOpt.bTable = sal_False; - aSortOpt.nDeli = ' '; - aSortOpt.eDirection = SRT_COLUMNS; + rSortOpt.bTable = sal_False; + rSortOpt.cDeli = ' '; + rSortOpt.eDirection = SRT_COLUMNS; - aSortOpt.aKeys; + rSortOpt.aKeys; SwSortKey* pKey1 = new SwSortKey; pKey1->nColumnId = USHRT_MAX; pKey1->eSortKeyType = SRT_NUMERIC; @@ -491,33 +498,27 @@ void SwXTextCursor::sort(const uno::Sequence< beans::PropertyValue >& rDescripto if( COMPARE_EQUAL == rPropName.compareToAscii("IsSortInTable")) { if ( aValue.getValueType() == ::getBooleanCppuType() ) - { - aValue >>= aSortOpt.bTable; - } + rSortOpt.bTable = *(sal_Bool*)aValue.getValue(); else - throw uno::RuntimeException(); + bRet = sal_False; } else if(COMPARE_EQUAL == rPropName.compareToAscii("Delimiter")) { - if ( aValue.getValueType() == ::getCppuType((sal_Unicode*)0)) - { - sal_Unicode uChar; - aValue >>= uChar; - aSortOpt.nDeli = uChar; - } + sal_Unicode uChar; + if( aValue >>= uChar ) + rSortOpt.cDeli = uChar; else - throw uno::RuntimeException(); + bRet = sal_False; } else if(COMPARE_EQUAL == rPropName.compareToAscii("SortColumns")) { if ( aValue.getValueType() == ::getBooleanCppuType() ) { - sal_Bool bTemp; - aValue >>= bTemp; - aSortOpt.eDirection = bTemp ? SRT_COLUMNS : SRT_ROWS; + sal_Bool bTemp = *(sal_Bool*)aValue.getValue(); + rSortOpt.eDirection = bTemp ? SRT_COLUMNS : SRT_ROWS; } else - throw uno::RuntimeException(); + bRet = sal_False; } else if(COMPARE_EQUAL == rPropName.compareToAscii("SortRowOrColumnNo", 17) && rPropName.getLength() == 18 && @@ -529,11 +530,9 @@ void SwXTextCursor::sort(const uno::Sequence< beans::PropertyValue >& rDescripto if( aValue.getValueType() == ::getCppuType((const sal_Int16*)0) && nIndex < 3) aValue >>= nCol; if( nCol >= 0 ) - { aKeys[nIndex]->nColumnId = nCol; - } else - throw uno::RuntimeException(); + bRet = sal_False; } else if(0 == rPropName.search(C2U("IsSortNumeric")) && rPropName.getLength() == 14 && @@ -543,39 +542,50 @@ void SwXTextCursor::sort(const uno::Sequence< beans::PropertyValue >& rDescripto nIndex = nIndex - '0'; if ( aValue.getValueType() == ::getBooleanCppuType() && nIndex < 3 ) { - sal_Bool bTemp; - aValue >>= bTemp; + sal_Bool bTemp = *(sal_Bool*)aValue.getValue(); aKeys[nIndex]->eSortKeyType = bTemp ? SRT_NUMERIC : SRT_APLHANUM; } else - throw uno::RuntimeException(); + bRet = sal_False; } else if(0 == rPropName.search(C2U("IsSortAscending")) && rPropName.getLength() == 16 && lcl_IsNumeric(String(rPropName[(sal_uInt16)15]))) { - sal_uInt16 nIndex = rPropName.getStr()[13]; + sal_uInt16 nIndex = rPropName.getStr()[16]; if ( aValue.getValueType() == ::getBooleanCppuType() && nIndex < 3 ) { - sal_Bool bTemp; - aValue >>= bTemp; + sal_Bool bTemp = *(sal_Bool*)aValue.getValue(); aKeys[nIndex]->eSortOrder = bTemp ? SRT_ASCENDING : SRT_DESCENDING; } else - throw uno::RuntimeException(); + bRet = sal_False; } } if(pKey1->nColumnId != USHRT_MAX) - aSortOpt.aKeys.C40_INSERT(SwSortKey, pKey1, aSortOpt.aKeys.Count()); + rSortOpt.aKeys.C40_INSERT(SwSortKey, pKey1, rSortOpt.aKeys.Count()); if(pKey2->nColumnId != USHRT_MAX) - aSortOpt.aKeys.C40_INSERT(SwSortKey, pKey2, aSortOpt.aKeys.Count()); + rSortOpt.aKeys.C40_INSERT(SwSortKey, pKey2, rSortOpt.aKeys.Count()); if(pKey3->nColumnId != USHRT_MAX) - aSortOpt.aKeys.C40_INSERT(SwSortKey, pKey3, aSortOpt.aKeys.Count()); + rSortOpt.aKeys.C40_INSERT(SwSortKey, pKey3, rSortOpt.aKeys.Count()); + + return bRet && rSortOpt.aKeys.Count() > 0; +} +/*-- 09.12.98 14:19:00--------------------------------------------------- + -----------------------------------------------------------------------*/ +void SwXTextCursor::sort(const uno::Sequence< beans::PropertyValue >& rDescriptor) + throw( uno::RuntimeException ) +{ + vos::OGuard aGuard(Application::GetSolarMutex()); + SwSortOptions aSortOpt; SwUnoCrsr* pUnoCrsr = GetCrsr(); - if(pUnoCrsr && aSortOpt.aKeys.Count()) + + if(pUnoCrsr) { if(pUnoCrsr->HasMark()) { + if(!SwXTextCursor::convertSortProperties(rDescriptor, aSortOpt)) + throw uno::RuntimeException(); UnoActionContext aContext( pUnoCrsr->GetDoc() ); pUnoCrsr->GetDoc()->SortText(*pUnoCrsr, aSortOpt); } diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx index f6ef8087943a..30a9b4556eb6 100644 --- a/sw/source/core/unocore/unotbl.cxx +++ b/sw/source/core/unocore/unotbl.cxx @@ -2,9 +2,9 @@ * * $RCSfile: unotbl.cxx,v $ * - * $Revision: 1.13 $ + * $Revision: 1.14 $ * - * last change: $Author: dvo $ $Date: 2000-12-07 17:16:09 $ + * last change: $Author: os $ $Date: 2000-12-15 14:35:14 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -2117,7 +2117,6 @@ SwXTextTable::SwXTextTable() : aChartLstnrCntnr( (XTextTable*)this), bFirstRowAsLabel(sal_False), bFirstColumnAsLabel(sal_False), - pLastSortOptions(0), _pMap(aSwMapProvider.GetPropertyMap(PROPERTY_MAP_TEXT_TABLE)), bIsDescriptor(sal_True), nRows(2), @@ -2136,7 +2135,6 @@ SwXTextTable::SwXTextTable(SwFrmFmt& rFrmFmt) : bFirstRowAsLabel(sal_False), bFirstColumnAsLabel(sal_False), aPropSet(aSwMapProvider.GetPropertyMap(PROPERTY_MAP_TEXT_TABLE)), - pLastSortOptions(0), _pMap(aSwMapProvider.GetPropertyMap(PROPERTY_MAP_TEXT_TABLE)), bIsDescriptor(sal_False), nRows(0), @@ -2150,7 +2148,6 @@ SwXTextTable::SwXTextTable(SwFrmFmt& rFrmFmt) : -----------------------------------------------------------------------*/ SwXTextTable::~SwXTextTable() { - delete pLastSortOptions; delete pTableProps; } /*-- 11.12.98 12:42:44--------------------------------------------------- @@ -2799,33 +2796,20 @@ uno::Sequence< beans::PropertyValue > SwXTextTable::createSortDescriptor(void) throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - uno::Sequence< beans::PropertyValue > aRet; - //XTextSortDescriptor noch nicht wieder definiert - DBG_WARNING("not implemented") - return aRet; - /*SwXTextSortDescriptor* pDesc = new SwXTextSortDescriptor(sal_True); - uno::Reference< XSortDescriptor > xRet = pDesc; - if(!bEmpty && pLastSortOptions) - pDesc->SetSortOptions(*pLastSortOptions); - return xRet;*/ + return SwXTextCursor::createSortDescriptor(sal_False); } /*-- 11.12.98 12:42:49--------------------------------------------------- -----------------------------------------------------------------------*/ -void SwXTextTable::sort(const uno::Sequence< beans::PropertyValue >& xDescriptor) +void SwXTextTable::sort(const uno::Sequence< beans::PropertyValue >& rDescriptor) throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - DBG_WARNING("not implemented") -/* + SwSortOptions aSortOpt; SwFrmFmt* pFmt = GetFrmFmt(); - SwXTextSortDescriptor* pDesc = (SwXTextSortDescriptor*) - xDescriptor->getImplementation(::getCppuType((const SwXTextSortDescriptor*)0)); - - if(pFmt && pDesc && pDesc->GetSortOptions().aKeys.Count()) + if(pFmt && + SwXTextCursor::convertSortProperties(rDescriptor, aSortOpt)) { - delete pLastSortOptions; - pLastSortOptions = new SwSortOptions(pDesc->GetSortOptions()); SwTable* pTable = SwTable::FindTable( pFmt ); SwSelBoxes aBoxes; const SwTableSortBoxes& rTBoxes = pTable->GetTabSortBoxes(); @@ -2835,10 +2819,8 @@ void SwXTextTable::sort(const uno::Sequence< beans::PropertyValue >& xDescriptor aBoxes.Insert( pBox ); } UnoActionContext aContext( pFmt->GetDoc() ); - pFmt->GetDoc()->SortTbl(aBoxes, pDesc->GetSortOptions()); + pFmt->GetDoc()->SortTbl(aBoxes, aSortOpt); } - - * */ } /*-- 11.12.98 12:42:49--------------------------------------------------- @@ -3462,7 +3444,6 @@ SwXCellRange::SwXCellRange() : aCursorDepend(this, 0), aChartLstnrCntnr((cppu::OWeakObject*)this), pTblCrsr(0), - pLastSortOptions(0), aPropSet(0), bFirstRowAsLabel(sal_False), bFirstColumnAsLabel(sal_False), @@ -3483,7 +3464,6 @@ SwXCellRange::SwXCellRange(SwUnoCrsr* pCrsr, SwFrmFmt& rFrmFmt, aPropSet(aSwMapProvider.GetPropertyMap(PROPERTY_MAP_TABLE_RANGE)), bFirstRowAsLabel(sal_False), bFirstColumnAsLabel(sal_False), - pLastSortOptions(0), _pMap(aSwMapProvider.GetPropertyMap(PROPERTY_MAP_TABLE_RANGE)) { @@ -3493,7 +3473,6 @@ SwXCellRange::SwXCellRange(SwUnoCrsr* pCrsr, SwFrmFmt& rFrmFmt, -----------------------------------------------------------------------*/ SwXCellRange::~SwXCellRange() { - delete pLastSortOptions; delete pTblCrsr; } /*-- 11.12.98 14:27:34--------------------------------------------------- @@ -4026,37 +4005,25 @@ double SwXCellRange::getNotANumber(void) throw( uno::RuntimeException ) uno::Sequence< beans::PropertyValue > SwXCellRange::createSortDescriptor(void) throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - DBG_WARNING("not implemented") - uno::Sequence< beans::PropertyValue > aRet; - return aRet; - /*SwXTextSortDescriptor* pDesc = new SwXTextSortDescriptor(sal_True); - uno::Reference< XSortDescriptor > xRet = pDesc; - if(!bEmpty && pLastSortOptions) - pDesc->SetSortOptions(*pLastSortOptions); - return xRet;*/ + return SwXTextCursor::createSortDescriptor(sal_False); } /*-- 11.12.98 14:27:39--------------------------------------------------- -----------------------------------------------------------------------*/ -void SAL_CALL SwXCellRange::sort(const uno::Sequence< beans::PropertyValue >& xDescriptor) +void SAL_CALL SwXCellRange::sort(const uno::Sequence< beans::PropertyValue >& rDescriptor) throw( uno::RuntimeException ) { vos::OGuard aGuard(Application::GetSolarMutex()); - DBG_WARNING("not implemented") - /* + SwSortOptions aSortOpt; SwFrmFmt* pFmt = GetFrmFmt(); - SwXTextSortDescriptor* pDesc = (SwXTextSortDescriptor*) -// xDescriptor->getImplementation(::getCppuType((const SwXTextSortDescriptor*)0)); - - if(pFmt && pDesc && pDesc->GetSortOptions().aKeys.Count()) + if(pFmt && + SwXTextCursor::convertSortProperties(rDescriptor, aSortOpt)) { - delete pLastSortOptions; - pLastSortOptions = new SwSortOptions(pDesc->GetSortOptions()); SwUnoTableCrsr* pTableCrsr = *pTblCrsr; pTableCrsr->MakeBoxSels(); UnoActionContext aContext( pFmt->GetDoc() ); - pFmt->GetDoc()->SortTbl(pTableCrsr->GetBoxes(), pDesc->GetSortOptions()); - }*/ + pFmt->GetDoc()->SortTbl(pTableCrsr->GetBoxes(), aSortOpt); + } } /* -----------------27.04.98 16:54------------------- * |